program exits if playerdata file creation fails
This commit is contained in:
parent
9715546f29
commit
2be09b6fbc
2 changed files with 27 additions and 19 deletions
|
@ -48,6 +48,25 @@ public class Resurrection extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for updates
|
||||||
|
System.out.println("[Resurrection] Checking for updates...");
|
||||||
|
CheckForUpdate check = new CheckForUpdate();
|
||||||
|
boolean outdated = false;
|
||||||
|
if (check.isSuccess()) {
|
||||||
|
String newestVersion = check.getVersion();
|
||||||
|
String newestVersionURL = check.getVersionURL();
|
||||||
|
if (pluginInfo.getVersion().equals(newestVersion)) {
|
||||||
|
System.out.println("[Resurrection] " + newestVersion + " is the latest version of Resurrection.");
|
||||||
|
} else {
|
||||||
|
System.out.println("[Resurrection] A new version of Resurrection is available! (current: " + pluginInfo.getVersion() + ", newest: " + newestVersion + ")");
|
||||||
|
System.out.println("[Resurrection] You can download the latest release on GitHub here \\/");
|
||||||
|
System.out.println("[Resurrection] " + newestVersionURL);
|
||||||
|
outdated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("[Resurrection] ---------------------------------------------------------");
|
||||||
|
|
||||||
System.out.println("[Resurrection] Locating the file \"playerData.resurrection\"...");
|
System.out.println("[Resurrection] Locating the file \"playerData.resurrection\"...");
|
||||||
// check if playerData.resurrection exists
|
// check if playerData.resurrection exists
|
||||||
File playerFile = new File("plugins/playerData.resurrection");
|
File playerFile = new File("plugins/playerData.resurrection");
|
||||||
|
@ -59,6 +78,8 @@ public class Resurrection extends JavaPlugin implements Listener {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("[Resurrection] An error has occurred creating the player data file!");
|
System.out.println("[Resurrection] An error has occurred creating the player data file!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
System.out.println("[Resurrection] This file is crucial to Resurrection. Since the file could not be created, the plugin will now stop.");
|
||||||
|
System.exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("[Resurrection] The player data file has been found!");
|
System.out.println("[Resurrection] The player data file has been found!");
|
||||||
|
@ -66,25 +87,6 @@ public class Resurrection extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
System.out.println("[Resurrection] ---------------------------------------------------------");
|
System.out.println("[Resurrection] ---------------------------------------------------------");
|
||||||
|
|
||||||
// check for updates
|
|
||||||
System.out.println("[Resurrection] Checking for updates...");
|
|
||||||
CheckForUpdate check = new CheckForUpdate();
|
|
||||||
boolean outdated = false;
|
|
||||||
if (check.isSuccess()) {
|
|
||||||
String newestVersion = check.getVersion();
|
|
||||||
String newestVersionURL = check.getVersionURL();
|
|
||||||
if (pluginInfo.getVersion().equals(newestVersion)) {
|
|
||||||
System.out.println("[Resurrection] " + newestVersion + " is the latest version of Resurrection.");
|
|
||||||
} else {
|
|
||||||
System.out.println("[Resurrection] A new version of Resurrection is available! (current: " + pluginInfo.getVersion() + ", newest: " + newestVersion);
|
|
||||||
System.out.println("[Resurrection] You can download the latest release on GitHub here \\/");
|
|
||||||
System.out.println("[Resurrection] " + newestVersionURL);
|
|
||||||
outdated = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("[Resurrection] ---------------------------------------------------------");
|
|
||||||
|
|
||||||
System.out.println("[Resurrection] Registering listeners and adding commands...");
|
System.out.println("[Resurrection] Registering listeners and adding commands...");
|
||||||
// register listener
|
// register listener
|
||||||
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
|
|
|
@ -53,6 +53,12 @@ public class CommandHowLong implements CommandExecutor {
|
||||||
commandSender.sendMessage(p.getDisplayName() + " will respawn in " + timeCheck.formatTime());
|
commandSender.sendMessage(p.getDisplayName() + " will respawn in " + timeCheck.formatTime());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
if (self) {
|
||||||
|
commandSender.sendMessage("You aren't dead, dummy.");
|
||||||
|
} else {
|
||||||
|
commandSender.sendMessage("ERROR: " + p.getDisplayName() + " is not dead!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue