Formatting
This commit is contained in:
@@ -11,7 +11,7 @@ import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class CrashHandler {
|
||||
public class CrashHandler{
|
||||
|
||||
public static void handle(Throwable e){
|
||||
//TODO send full error report to server via HTTP
|
||||
@@ -24,7 +24,7 @@ public class CrashHandler {
|
||||
netActive = Net.active();
|
||||
netServer = Net.server();
|
||||
Net.dispose();
|
||||
}catch (Throwable p){
|
||||
}catch(Throwable p){
|
||||
p.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ public class CrashHandler {
|
||||
header += "Net Active: " + netActive + "\n";
|
||||
header += "Net Server: " + netServer + "\n";
|
||||
header += "OS: " + System.getProperty("os.name") + "\n";
|
||||
header += "Multithreading: " + Settings.getBool("multithread")+ "\n----\n";
|
||||
}catch (Throwable e4){
|
||||
header += "Multithreading: " + Settings.getBool("multithread") + "\n----\n";
|
||||
}catch(Throwable e4){
|
||||
header += "\n--error getting additional info--\n";
|
||||
e4.printStackTrace();
|
||||
}
|
||||
@@ -55,16 +55,16 @@ public class CrashHandler {
|
||||
try{
|
||||
filename = "crash-report-" + new SimpleDateFormat("dd-MM-yy h.mm.ss").format(new Date()) + ".txt";
|
||||
Files.write(Paths.get(System.getProperty("user.home"), "mindustry-crash-reports", filename), result.getBytes());
|
||||
}catch (Throwable i){
|
||||
}catch(Throwable i){
|
||||
i.printStackTrace();
|
||||
failed = true;
|
||||
}
|
||||
|
||||
try{
|
||||
javax.swing.JOptionPane.showMessageDialog(null, "An error has occured: \n" + result + "\n\n" +
|
||||
(!failed ? "A crash report has been written to " + new File(filename).getAbsolutePath() + ".\nPlease send this file to the developer!"
|
||||
: "Failed to generate crash report.\nPlease send an image of this crash log to the developer!"));
|
||||
}catch (Throwable i){
|
||||
(!failed ? "A crash report has been written to " + new File(filename).getAbsolutePath() + ".\nPlease send this file to the developer!"
|
||||
: "Failed to generate crash report.\nPlease send an image of this crash log to the developer!"));
|
||||
}catch(Throwable i){
|
||||
i.printStackTrace();
|
||||
//what now?
|
||||
}
|
||||
|
||||
@@ -30,20 +30,24 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class DesktopLauncher extends Lwjgl3Application{
|
||||
ObjectMap<String, Preferences> prefmap;
|
||||
|
||||
public static void main (String[] arg) {
|
||||
try {
|
||||
|
||||
public DesktopLauncher(ApplicationListener listener, Lwjgl3ApplicationConfiguration config){
|
||||
super(listener, config);
|
||||
}
|
||||
|
||||
public static void main(String[] arg){
|
||||
try{
|
||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
config.setTitle("Mindustry");
|
||||
config.setMaximized(true);
|
||||
config.setWindowedMode(960, 540);
|
||||
config.setWindowIcon("sprites/icon.png");
|
||||
|
||||
if(OS.isMac) {
|
||||
if(OS.isMac){
|
||||
Application.getApplication().setOpenFileHandler(e -> {
|
||||
List list = e.getFiles();
|
||||
|
||||
File target = (File)list.get(0);
|
||||
File target = (File) list.get(0);
|
||||
|
||||
Gdx.app.postRunnable(() -> {
|
||||
FileHandle file = OS.getAppDataDirectory("Mindustry").child("tmp").child(target.getName());
|
||||
@@ -56,7 +60,7 @@ public class DesktopLauncher extends Lwjgl3Application{
|
||||
try{
|
||||
SaveSlot slot = control.getSaves().importSave(file);
|
||||
ui.load.runLoadSave(slot);
|
||||
}catch (IOException e2){
|
||||
}catch(IOException e2){
|
||||
ui.showError(Bundles.format("text.save.import.fail", Strings.parseException(e2, false)));
|
||||
}
|
||||
}else{
|
||||
@@ -65,7 +69,7 @@ public class DesktopLauncher extends Lwjgl3Application{
|
||||
|
||||
}else if(file.extension().equalsIgnoreCase(mapExtension)){ //open map
|
||||
Gdx.app.postRunnable(() -> {
|
||||
if (!ui.editor.isShown()) {
|
||||
if(!ui.editor.isShown()){
|
||||
ui.editor.show();
|
||||
}
|
||||
|
||||
@@ -80,26 +84,22 @@ public class DesktopLauncher extends Lwjgl3Application{
|
||||
|
||||
Net.setClientProvider(new KryoClient());
|
||||
Net.setServerProvider(new KryoServer());
|
||||
new DesktopLauncher(new Mindustry(), config);
|
||||
}catch (Throwable e){
|
||||
CrashHandler.handle(e);
|
||||
}
|
||||
}
|
||||
|
||||
public DesktopLauncher(ApplicationListener listener, Lwjgl3ApplicationConfiguration config) {
|
||||
super(listener, config);
|
||||
new DesktopLauncher(new Mindustry(), config);
|
||||
}catch(Throwable e){
|
||||
CrashHandler.handle(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Preferences getPreferences(String name) {
|
||||
String prefsDirectory = OS.getAppDataDirectoryString("Mindustry");
|
||||
public Preferences getPreferences(String name){
|
||||
String prefsDirectory = OS.getAppDataDirectoryString("Mindustry");
|
||||
|
||||
if(prefmap == null){
|
||||
prefmap = new ObjectMap<>();
|
||||
if(prefmap == null){
|
||||
prefmap = new ObjectMap<>();
|
||||
}
|
||||
|
||||
if(prefmap.containsKey(name)){
|
||||
return prefmap.get(name);
|
||||
if(prefmap.containsKey(name)){
|
||||
return prefmap.get(name);
|
||||
}else{
|
||||
Preferences prefs = new BinaryPreferences(new Lwjgl3FileHandle(new File(prefsDirectory, name), FileType.Absolute));
|
||||
prefmap.put(name, prefs);
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.Locale;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class DesktopPlatform extends Platform {
|
||||
public class DesktopPlatform extends Platform{
|
||||
final static boolean useDiscord = OS.is64Bit;
|
||||
final static String applicationId = "398246104468291591";
|
||||
final static DateFormat format = SimpleDateFormat.getDateTimeInstance();
|
||||
@@ -38,14 +38,14 @@ public class DesktopPlatform extends Platform {
|
||||
|
||||
Vars.testMobile = isDebug() && Array.with(args).contains("-testMobile", false);
|
||||
|
||||
if(useDiscord) {
|
||||
if(useDiscord){
|
||||
DiscordEventHandlers handlers = new DiscordEventHandlers();
|
||||
DiscordRPC.INSTANCE.Discord_Initialize(applicationId, handlers, true, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, String filter) {
|
||||
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, String filter){
|
||||
new FileChooser(text, file -> file.extension().equalsIgnoreCase(filter), open, cons).show();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class DesktopPlatform extends Platform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRPC() {
|
||||
public void updateRPC(){
|
||||
|
||||
if(!useDiscord) return;
|
||||
|
||||
@@ -89,7 +89,7 @@ public class DesktopPlatform extends Platform {
|
||||
}else{
|
||||
if(ui.editor != null && ui.editor.isShown()){
|
||||
presence.state = "In Editor";
|
||||
}else {
|
||||
}else{
|
||||
presence.state = "In Menu";
|
||||
}
|
||||
}
|
||||
@@ -100,26 +100,27 @@ public class DesktopPlatform extends Platform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameExit() {
|
||||
public void onGameExit(){
|
||||
if(useDiscord) DiscordRPC.INSTANCE.Discord_Shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
public boolean isDebug(){
|
||||
return args.length > 0 && args[0].equalsIgnoreCase("-debug_" + getUUID().hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThreadProvider getThreadProvider() {
|
||||
public ThreadProvider getThreadProvider(){
|
||||
return new DefaultThreadImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUUID() {
|
||||
try {
|
||||
public String getUUID(){
|
||||
try{
|
||||
Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
|
||||
NetworkInterface out;
|
||||
for(out = e.nextElement(); out.getHardwareAddress() == null && e.hasMoreElements() && validAddress(out.getHardwareAddress()); out = e.nextElement());
|
||||
for(out = e.nextElement(); out.getHardwareAddress() == null && e.hasMoreElements() && validAddress(out.getHardwareAddress()); out = e.nextElement())
|
||||
;
|
||||
|
||||
byte[] bytes = out.getHardwareAddress();
|
||||
byte[] result = new byte[8];
|
||||
@@ -130,7 +131,7 @@ public class DesktopPlatform extends Platform {
|
||||
if(str.equals("AAAAAAAAAOA=")) throw new RuntimeException("Bad UUID.");
|
||||
|
||||
return str;
|
||||
}catch (Exception e){
|
||||
}catch(Exception e){
|
||||
return super.getUUID();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user