aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net/brysonsteck/Resurrection/Resurrection.java145
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandAbout.java31
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandBug.java14
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandDead.java100
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandHowLong.java15
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandResurrect.java14
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandSource.java17
-rw-r--r--src/net/brysonsteck/Resurrection/player/PlayerData.java12
-rw-r--r--src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java8
-rw-r--r--src/net/brysonsteck/Resurrection/startup/ParseSettings.java26
-rw-r--r--src/plugin.yml6
11 files changed, 226 insertions, 162 deletions
diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java
index a3ecf74..dabce44 100644
--- a/src/net/brysonsteck/Resurrection/Resurrection.java
+++ b/src/net/brysonsteck/Resurrection/Resurrection.java
@@ -5,13 +5,13 @@ import net.brysonsteck.Resurrection.player.PlayerListener;
import net.brysonsteck.Resurrection.startup.CheckForUpdate;
import net.brysonsteck.Resurrection.startup.ParseSettings;
import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
+import java.util.logging.Logger;
public class Resurrection extends JavaPlugin implements Listener {
@@ -19,180 +19,111 @@ public class Resurrection extends JavaPlugin implements Listener {
@Override
public void onDisable() {
super.onDisable();
- System.out.println("[Resurrection] Resurrection has completed shutdown.");
+ Logger log = this.getLogger();
+ log.info("Resurrection has completed shutdown.");
}
@Override
public void onEnable() {
+ Logger log = this.getLogger();
super.onEnable();
- System.out.println("[Resurrection] ---------------------------------------------------------");
+ log.info("---------------------------------------------------------");
- System.out.println("[Resurrection] Resurrection is starting!");
+ log.info("Resurrection is starting!");
PluginDescriptionFile pluginInfo = getDescription();
getServer().getPluginManager().registerEvents(this, this);
if (pluginInfo.getVersion().contains("beta")) {
// beta message
- System.out.println("[Resurrection] ---------------------------------------------------------");
- System.out.println("[Resurrection] WARNING!!!!");
- System.out.println("[Resurrection] You are running a beta version of Resurrection!");
- System.out.println("[Resurrection] ");
- System.out.println("[Resurrection] This means that this plugin is early in development and");
- System.out.println("[Resurrection] not completely finished, and as a result you may");
- System.out.println("[Resurrection] experience unexpected doodads. Make sure that the plugin");
- System.out.println("[Resurrection] is up-to-date for more features and bug fixes. The plugin");
- System.out.println("[Resurrection] will now check for updates.");
- System.out.println("[Resurrection] ---------------------------------------------------------");
+ log.warning("---------------------------------------------------------");
+ log.warning("WARNING!!!!");
+ log.warning("You are running a beta version of Resurrection!");
+ log.warning("");
+ log.warning("This means that this plugin is early in development and not completely finished, and as a result you may experience unexpected doodads. Make sure that the plugin is up-to-date for more features and bug fixes. The plugin will now check for updates.");
+ log.warning("---------------------------------------------------------");
} else {
- System.out.println("[Resurrection] ---------------------------------------------------------");
+ log.info("---------------------------------------------------------");
}
// check for updates
- System.out.println("[Resurrection] Checking for updates...");
+ log.info("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.");
+ log.info(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);
+ log.info("A new version of Resurrection is available! (current: " + pluginInfo.getVersion() + ", newest: " + newestVersion + ")");
+ log.info("You can download the latest release on GitHub here \\/");
+ log.info(newestVersionURL);
outdated = true;
}
}
- System.out.println("[Resurrection] ---------------------------------------------------------");
+ log.info("---------------------------------------------------------");
- System.out.println("[Resurrection] Locating player data and settings files...");
+ log.info("Locating player data and settings files...");
// check if playerData.resurrection exists
File playerFile = new File("plugins/playerData.resurrection");
File settingsFile = new File("plugins/settings.resurrection");
boolean fileFail = false;
if (!playerFile.exists()) {
- System.out.println("[Resurrection] Player data file does not exist. Creating now in the \"plugins\" directory...");
+ log.info("Player data file does not exist. Creating now in the \"plugins\" directory...");
try {
playerFile.createNewFile();
- System.out.println("[Resurrection] Player data file created successfully.");
+ log.info("Player data file created successfully.");
} catch (IOException e) {
- System.out.println("[Resurrection] An error has occurred creating the player data file!");
+ log.severe("An error has occurred creating the player data file!");
e.printStackTrace();
- System.out.println("[Resurrection] This file is crucial to Resurrection. Since the file could not be created, the plugin will now stop.");
+ log.severe("This file is crucial to Resurrection. Since the file could not be created, the plugin will now stop.");
Bukkit.getPluginManager().disablePlugin(this);
fileFail = true;
}
} else {
- System.out.println("[Resurrection] The player data file has been found!");
+ log.info("The player data file has been found!");
}
if (!settingsFile.exists()) {
- System.out.println("[Resurrection] Settings file does not exist. Creating now in the \"plugins\" directory...");
+ log.info("Settings file does not exist. Creating now in the \"plugins\" directory...");
new ParseSettings();
- System.out.println("[Resurrection] Settings file created successfully.");
+ log.info("Settings file created successfully.");
} else {
- System.out.println("[Resurrection] The settings file has also been found!");
+ log.info("The settings file has also been found!");
}
ParseSettings parseSettings = new ParseSettings();
- System.out.println("[Resurrection] ---------------------------------------------------------");
+ log.info("---------------------------------------------------------");
if (parseSettings.isSettingsComplete() && !fileFail) {
- boolean DEBUG = false;
if (Boolean.parseBoolean(parseSettings.getSetting("debug"))) {
- DEBUG = true;
- System.out.println("[Res. DEBUG]: ***** DEBUG MODE ENABLED *****");
- System.out.println("[Res. DEBUG]: Resurrection's debug mode has been enabled in the settings file.");
- System.out.println("[Res. DEBUG]: All debug messages after this disclaimer will be broadcasted (sent to everyone) prefaced with the tag \"[Res. DEBUG]\" and sent in bold yellow text.");
- System.out.println("[Res. DEBUG]: Several messages may be sent at a time. Therefore, debug mode should be disabled for anything other than, well, debugging.");
- System.out.println("[Resurrection] ---------------------------------------------------------");
+ log.warning("[Res. DEBUG]: DEBUG MODE ENABLED!");
+ log.warning("[Res. DEBUG]: Resurrection's debug mode has been enabled in the settings file. All debug messages after this disclaimer will be broadcasted (sent to everyone) prefaced with the tag \"[Res. DEBUG]\" and sent in bold yellow text. Several messages may be sent at a time. Therefore, debug mode should be disabled for anything other than, well, debugging.");
+ log.warning("---------------------------------------------------------");
}
- System.out.println("[Resurrection] Essential files found and valid. Registering listeners and adding commands...");
+ log.info("Essential files found and valid. Registering listeners and adding commands...");
// register listener
this.getServer().getPluginManager().registerEvents(new PlayerListener(parseSettings), this);
- if (DEBUG) {
- Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player listener registered.");
- }
// register commands
this.getCommand("about").setExecutor(new CommandAbout(parseSettings.getSetting("debug"), pluginInfo.getVersion(), outdated));
- if (DEBUG) {
- Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: `/about` registered.");
- }
this.getCommand("bug").setExecutor(new CommandBug(parseSettings.getSetting("debug")));
- if (DEBUG) {
- Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: `/bug` registered.");
- }
this.getCommand("resurrect").setExecutor(new CommandResurrect(parseSettings.getSetting("debug")));
- if (DEBUG) {
- Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: `/resurrect` registered.");
- }
this.getCommand("howlong").setExecutor(new CommandHowLong(parseSettings.getSetting("debug")));
- if (DEBUG) {
- Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: `/howlong` registered.");
- }
this.getCommand("source").setExecutor(new CommandSource(parseSettings.getSetting("debug")));
- if (DEBUG) {
- Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: `/source` registered.");
- }
+ this.getCommand("dead").setExecutor(new CommandDead(parseSettings.getSetting("debug")));
- System.out.println("[Resurrection] ---------------------------------------------------------");
- System.out.println("[Resurrection] Successfully Started!");
- System.out.println("[Resurrection] ---------------------------------------------------------");
+ log.info("---------------------------------------------------------");
+ log.info("Successfully Started!");
+ log.info("---------------------------------------------------------");
}
}
- public static void main(String[] args) {
-
-// String test = "fals";
-//
-// if (!test.toLowerCase().contains("true") && !test.toLowerCase().contains("false")) {
-// System.out.println("fail");
-// }
-
- // DO THIS
-// PlayerData playerData = new PlayerData();
-// System.out.println("--- Reading Player data file ---");
-// playerData.readData();
-// System.out.println(playerData.getPlayers());
-// System.out.println(playerData.getRawData());
-// System.out.println("--- Oh look! A new player joined. Adding them. ---");
-// String rawData = playerData.getRawData();
-// rawData = rawData + ";bryzinga,false,0";
-// playerData.saveData(rawData);
-// System.out.println(playerData.getPlayers());
-// System.out.println(playerData.getRawData());
-// System.out.println("--- A player has died! Update the data file! ---");
-// rawData = playerData.getRawData();
-// String[] rawPlayers = rawData.split(";");
-// String[] rawSinglePlayer = new String[3];
-// int index = 0;
-// for (String players : rawPlayers) {
-// if (players.startsWith("bryzinga")) {
-// String[] playerSplit = players.split(",");
-// playerSplit[1] = "true";
-// playerSplit[2] = "12345";
-//
-// rawPlayers[index] = String.join(",", playerSplit);
-// break;
-//
-// }
-// index++;
-// }
-// rawData = String.join(";", rawPlayers);
-// playerData.saveData(rawData);
-// System.out.println(rawData);
-// String[] array = ";bryzinga,false,0".split(";");
-// System.out.println(array.length);
-
-// TimeCheck timeCheck = new TimeCheck((System.currentTimeMillis() + 86212345) - System.currentTimeMillis());
-// System.out.println(timeCheck.formatTime());
-// System.out.println(System.currentTimeMillis());
- }
+ public static void main(String[] args) {}
}
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandAbout.java b/src/net/brysonsteck/Resurrection/commands/CommandAbout.java
index a820432..932c5c6 100644
--- a/src/net/brysonsteck/Resurrection/commands/CommandAbout.java
+++ b/src/net/brysonsteck/Resurrection/commands/CommandAbout.java
@@ -1,11 +1,16 @@
package net.brysonsteck.Resurrection.commands;
+import java.util.logging.Logger;
+
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import net.brysonsteck.Resurrection.Resurrection;
public class CommandAbout implements CommandExecutor {
boolean DEBUG;
@@ -20,6 +25,7 @@ public class CommandAbout implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
+ Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `/about` command was ran by " + commandSender.getName());
}
@@ -28,13 +34,15 @@ public class CommandAbout implements CommandExecutor {
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: CommandSender is a player.");
}
+
+ String outdatedText = "";
Player p = (Player) commandSender;
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "--- Resurrection ---" + ChatColor.RESET);
p.sendMessage(ChatColor.YELLOW + "Resurrection is a Spigot Minecraft plugin that forces players to wait a certain amount of time before respawning.");
- p.sendMessage(ChatColor.YELLOW + "This server is running version " + ChatColor.AQUA + currentVersion + ChatColor.YELLOW + " of Resurrection.");
if (outdated) {
- p.sendMessage(ChatColor.RED + "HOWEVER, A newer version of this plugin is available. Please notify a server admin to update this plugin for new features and/or stability improvements.");
+ outdatedText = " HOWEVER, A newer version of this plugin is available. Please notify a server admin to update this plugin for new features and/or stability improvements.";
}
+ p.sendMessage(ChatColor.YELLOW + "This server is running version " + ChatColor.AQUA + currentVersion + ChatColor.YELLOW + " of Resurrection." + ChatColor.RED + outdatedText);
p.sendMessage("---");
p.sendMessage(ChatColor.YELLOW + "This plugin is licensed under the GNU Affero General Public License v3.0. For more info, run " + ChatColor.AQUA + "/source");
p.sendMessage(ChatColor.YELLOW + "For more info on this plugin or to download it, visit the GitHub repository at " + ChatColor.AQUA + "https://github.com/brysonsteck/resurrection");
@@ -43,18 +51,17 @@ public class CommandAbout implements CommandExecutor {
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: CommandSender is console.");
}
- System.out.println("[Resurrection] --- Resurrection ---");
- System.out.println("[Resurrection]");
- System.out.println("[Resurrection] Resurrection is a Spigot Minecraft plugin that forces players to wait a certain amount of time before respawning.");
- System.out.println("[Resurrection] This server is running version " + currentVersion + " of Resurrection.");
+ String outdatedText = "";
+ log.info("--- Resurrection ---");
+ log.info("");
+ log.info("Resurrection is a Spigot Minecraft plugin that forces players to wait a certain amount of time before respawning.");
if (outdated) {
- System.out.println("[Resurrection] HOWEVER, a newer version of Resurrection is available. Please check the updater on startup for more information.");
+ outdatedText = " HOWEVER, a newer version of Resurrection is available. Please check the updater on startup for more information.";
}
- System.out.println("[Resurrection]");
- System.out.println("[Resurrection] This plugin is licensed under the GNU Affero General Public License v3.0. For more info, run /source");
- System.out.println("[Resurrection] Since you're the admin, you probably know where to download it lmao. Here's the link anyway: https://github.com/brysonsteck/resurrection");
- System.out.println("[Resurrection] Copyright 2021 Bryson Steck");
-
+ log.info("This server is running version " + currentVersion + " of Resurrection." + outdatedText);
+ log.info("");
+ log.info("This plugin is licensed under the GNU Affero General Public License v3.0. For more info, run \"/source\". Since you're the admin, you probably know where to download it lmao. Here's the link anyway: https://github.com/brysonsteck/resurrection");
+ log.info("Copyright 2021 Bryson Steck");
}
return true;
}
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandBug.java b/src/net/brysonsteck/Resurrection/commands/CommandBug.java
index c5c53a1..cd8c768 100644
--- a/src/net/brysonsteck/Resurrection/commands/CommandBug.java
+++ b/src/net/brysonsteck/Resurrection/commands/CommandBug.java
@@ -1,6 +1,9 @@
package net.brysonsteck.Resurrection.commands;
import net.brysonsteck.Resurrection.Resurrection;
+
+import java.util.logging.Logger;
+
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -19,6 +22,7 @@ public class CommandBug implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
+ Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `/bug` command was ran by " + commandSender.getName());
}
@@ -45,15 +49,13 @@ public class CommandBug implements CommandExecutor {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: CommandSender is console");
}
- System.out.println("[Resurrection] Did you find a bug? Well that sucks for you.");
+ log.info("Did you find a bug? Well that sucks for you.");
new BukkitRunnable() {
@Override
public void run() {
- System.out.println("[Resurrection] ");
- System.out.println("[Resurrection] Okay, fine. Maybe I'll tell you how to fix the problem. Hehe.");
- System.out.println("[Resurrection] You can either create an issue on GitHub here: https://github.com/brysonsteck/resurrection/issues");
- System.out.println("[Resurrection] OR you can fill out this Google Form if you don't know how to use GitHub: https://forms.gle/3gLmhMXowNyqKUGdA");
- System.out.println("[Resurrection] Please prepare to explain how the bug occurred regardless of how you report the bug to me.");
+ log.info("");
+ log.info("Okay, fine. Maybe I'll tell you how to fix the problem. Hehe.");
+ log.info("You can either create an issue on GitHub here: https://github.com/brysonsteck/resurrection/issues OR you can fill out this Google Form if you don't know how to use GitHub. Please prepare to explain how the bug occurred regardless of how you report the bug to me: https://forms.gle/3gLmhMXowNyqKUGdA ");
}
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), 60);
return true;
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandDead.java b/src/net/brysonsteck/Resurrection/commands/CommandDead.java
new file mode 100644
index 0000000..dd23174
--- /dev/null
+++ b/src/net/brysonsteck/Resurrection/commands/CommandDead.java
@@ -0,0 +1,100 @@
+package net.brysonsteck.Resurrection.commands;
+
+import java.util.logging.Logger;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import net.brysonsteck.Resurrection.Resurrection;
+import net.brysonsteck.Resurrection.player.PlayerData;
+import net.brysonsteck.Resurrection.player.TimeCheck;
+
+public class CommandDead implements CommandExecutor {
+ boolean DEBUG;
+
+ public CommandDead(String DEBUG) {
+ this.DEBUG = Boolean.parseBoolean(DEBUG);
+ }
+
+ @Override
+ public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
+ Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `/about` command was ran by " + commandSender.getName());
+ }
+
+ PlayerData playerData = new PlayerData();
+ playerData.readData();
+ String rawData = playerData.getRawData();
+ String[] rawPlayers = rawData.split(";");
+ int amountDead = 0;
+ for (String players : rawPlayers) {
+ String[] playerSplit = players.split(",");
+ if (playerSplit.length == 3) {
+ boolean dead = Boolean.parseBoolean(playerSplit[1]);
+ if (dead) {
+ amountDead++;
+ }
+ }
+ }
+ String[] responses = new String[amountDead];
+ int index = 0;
+ for (String players : rawPlayers) {
+ String[] playerSplit = players.split(",");
+ if (playerSplit.length == 3) {
+ String playerName = playerSplit[0];
+ boolean dead = Boolean.parseBoolean(playerSplit[1]);
+ long timeToResurrection = Long.parseLong(playerSplit[2]);
+
+ if (dead) {
+ TimeCheck timeCheck = new TimeCheck(timeToResurrection - System.currentTimeMillis());
+ if (System.currentTimeMillis() > timeToResurrection) {
+ responses[index] = playerName + " will resurrect when they rejoin.";
+ } else {
+ responses[index] = playerName + " will resurrect in " + timeCheck.formatTime('f');
+ }
+ index++;
+ }
+
+ }
+ }
+
+ if (commandSender instanceof Player) {
+ Player p = (Player) commandSender;
+ if (amountDead == 0) {
+ p.sendMessage(ChatColor.YELLOW + "There are currently no players awaiting resurrection.");
+ } else if (amountDead == 1) {
+ p.sendMessage(ChatColor.YELLOW + "There is currently 1 player awaiting resurrection:");
+ } else if (amountDead >= 2) {
+ p.sendMessage(ChatColor.YELLOW + "There are currently " + amountDead + " players awaiting resurrection:");
+ }
+ if (amountDead > 0) {
+ for (String response : responses) {
+ p.sendMessage(response);
+ }
+ }
+
+ } else {
+ if (amountDead == 0) {
+ log.info("There are currently no players awaiting resurrection.");
+ } else if (amountDead == 1) {
+ log.info("There is currently 1 player awaiting resurrection:");
+ } else if (amountDead >= 2) {
+ log.info("There are currently " + amountDead + " players awaiting resurrection:");
+ }
+ if (amountDead > 0) {
+ for (String response : responses) {
+ log.info(response);
+ }
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java b/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java
index 32662a0..1c1ae5f 100644
--- a/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java
+++ b/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java
@@ -1,13 +1,18 @@
package net.brysonsteck.Resurrection.commands;
+import net.brysonsteck.Resurrection.Resurrection;
import net.brysonsteck.Resurrection.player.PlayerData;
import net.brysonsteck.Resurrection.player.TimeCheck;
+
+import java.util.logging.Logger;
+
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.plugin.java.JavaPlugin;
public class CommandHowLong implements CommandExecutor {
boolean DEBUG;
@@ -18,6 +23,7 @@ public class CommandHowLong implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
+ Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `/howlong` command was ran by " + commandSender.getName());
}
@@ -103,7 +109,7 @@ public class CommandHowLong implements CommandExecutor {
boolean valid = false;
if (strings.length == 0) {
- System.out.println("[Resurrection] ERROR: The /howlong command requires the name of a player when ran through the console.");
+ log.warning("ERROR: The /howlong command requires the name of a player when ran through the console.");
return false;
} else if (strings.length == 1) {
if (DEBUG) {
@@ -117,7 +123,7 @@ public class CommandHowLong implements CommandExecutor {
Player p = Bukkit.getPlayer(strings[0]);
if (p == null) {
- System.out.println("[Resurrection] ERROR: That player is not online/doesn't exist!");
+ log.warning("ERROR: That player is not online/doesn't exist!");
return false;
}
@@ -141,16 +147,15 @@ public class CommandHowLong implements CommandExecutor {
TimeCheck timeCheck = new TimeCheck(resurrectionTime - currentTime);
- System.out.println("[Resurrection] " + p.getDisplayName() + " will respawn in " + timeCheck.formatTime('f'));
+ log.info(p.getDisplayName() + " will respawn in " + timeCheck.formatTime('f'));
return true;
} else {
- System.out.println("[Resurrection] ERROR: " + p.getDisplayName() + " is not dead!");
+ log.warning("ERROR: " + p.getDisplayName() + " is not dead!");
return false;
}
}
}
- System.out.println("[Resurrection] ERROR: An error has occurred while trying to get time information. This is a bug in the program and not your fault.");
return false;
}
}
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java
index 3d206c4..a2301b3 100644
--- a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java
+++ b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java
@@ -1,6 +1,10 @@
package net.brysonsteck.Resurrection.commands;
+import net.brysonsteck.Resurrection.Resurrection;
import net.brysonsteck.Resurrection.player.PlayerData;
+
+import java.util.logging.Logger;
+
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@@ -9,6 +13,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
public class CommandResurrect implements CommandExecutor {
@@ -20,6 +25,7 @@ public class CommandResurrect implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
+ Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `resurrect` command was ran by " + commandSender.getName());
}
@@ -72,7 +78,7 @@ public class CommandResurrect implements CommandExecutor {
return false;
}
} else {
- System.out.println(ChatColor.RED + "ERROR: Too few arguments!");
+ p.sendMessage(ChatColor.RED + "ERROR: Too few arguments!");
return false;
}
} else {
@@ -87,7 +93,7 @@ public class CommandResurrect implements CommandExecutor {
Player resurrectPlayer = Bukkit.getPlayer(strings[0]);
if (resurrectPlayer == null) {
- System.out.println("[Resurrection] ERROR: That player is not online/doesn't exist! Failed to resurrect.");
+ log.warning("ERROR: That player is not online/doesn't exist! Failed to resurrect.");
return false;
}
if (DEBUG) {
@@ -115,11 +121,11 @@ public class CommandResurrect implements CommandExecutor {
}
return true;
} else {
- System.out.println("[Resurrection] ERROR: " + strings[0] + " is not dead! Failed to resurrect.");
+ log.warning("ERROR: " + strings[0] + " is not dead! Failed to resurrect.");
return false;
}
} else {
- System.out.println("[Resurrection] ERROR: Too few arguments!");
+ log.warning("ERROR: Too few arguments!");
return false;
}
}
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandSource.java b/src/net/brysonsteck/Resurrection/commands/CommandSource.java
index 31481e8..c91e091 100644
--- a/src/net/brysonsteck/Resurrection/commands/CommandSource.java
+++ b/src/net/brysonsteck/Resurrection/commands/CommandSource.java
@@ -1,11 +1,16 @@
package net.brysonsteck.Resurrection.commands;
+import java.util.logging.Logger;
+
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import net.brysonsteck.Resurrection.Resurrection;
public class CommandSource implements CommandExecutor {
@@ -17,6 +22,7 @@ public class CommandSource implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
+ Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `/source` command was ran by " + commandSender.getName());
}
@@ -25,21 +31,14 @@ public class CommandSource implements CommandExecutor {
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: CommandSender is a player");
}
- commandSender.sendMessage(ChatColor.YELLOW + "Resurrection is FREE AND OPEN SOURCE under the");
- commandSender.sendMessage(ChatColor.YELLOW + "GNU Affero General Public License v3.0 via GitHub.");
- commandSender.sendMessage(ChatColor.YELLOW + "You can view the repository at " + ChatColor.AQUA + "https://github.com/brysonsteck/resurrection");
- commandSender.sendMessage(ChatColor.YELLOW + "and the license at " + ChatColor.AQUA + "https://github.com/brysonsteck/resurrection/blob/master/LICENSE");
+ commandSender.sendMessage(ChatColor.YELLOW + "Resurrection is FREE AND OPEN SOURCE under the GNU Affero General Public License v3.0 via GitHub. You can view the repository at " + ChatColor.AQUA + "https://github.com/brysonsteck/resurrection" + ChatColor.YELLOW + " and the license at " + ChatColor.AQUA + "https://github.com/brysonsteck/resurrection/blob/master/LICENSE");
return true;
} else {
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: CommandSender is console");
}
- System.out.println("[Resurrection] Resurrection is FREE AND OPEN SOURCE under the");
- System.out.println("[Resurrection] GNU Affero General Public License v3.0 via GitHub.");
- System.out.println("[Resurrection] You can view the repository at https://github.com/brysonsteck/resurrection");
- System.out.println("[Resurrection] and the license at https://github.com/brysonsteck/resurrection/blob/master/LICENSE");
-
+ log.info("Resurrection is FREE AND OPEN SOURCE under the GNU Affero General Public License v3.0 via GitHub. You can view the repository at https://github.com/brysonsteck/resurrection and the license at https://github.com/brysonsteck/resurrection/blob/master/LICENSE");
return true;
}
}
diff --git a/src/net/brysonsteck/Resurrection/player/PlayerData.java b/src/net/brysonsteck/Resurrection/player/PlayerData.java
index 89df20f..1ea7e29 100644
--- a/src/net/brysonsteck/Resurrection/player/PlayerData.java
+++ b/src/net/brysonsteck/Resurrection/player/PlayerData.java
@@ -9,12 +9,14 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
import java.util.Hashtable;
+import java.util.logging.Logger;
public class PlayerData {
Hashtable<String, Hashtable<String, String>> playerData = new Hashtable<>();
String rawData;
boolean DEBUG = Boolean.parseBoolean(new ParseSettings()
.getSetting("debug"));
+ Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
public void saveData(String write) {
try {
@@ -28,10 +30,10 @@ public class PlayerData {
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Error occurred while trying to save player data, avoid shutting down the server");
}
- System.out.println("[Resurrection] There was an issue saving the player data file.");
+ log.warning("There was an issue saving the player data file.");
e.printStackTrace();
- System.out.println("[Resurrection] Resurrection will continue to run despite this error, but avoid shutting down the server until a successful save occurs.");
- System.out.println("[Resurrection] In the mean time, check to make sure the playerData file exists and you have permissions to write to it.");
+ log.warning("Resurrection will continue to run despite this error, but avoid shutting down the server until a successful save occurs.");
+ log.warning("In the mean time, check to make sure the playerData file exists and you have permissions to write to it.");
}
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player data saved successfully, rereading data to ensure Resurrection is up to date");
@@ -70,9 +72,9 @@ public class PlayerData {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Error occurred while trying to read player data. Resurrection is shutting down");
}
- System.out.println("[Resurrection] There was an issue reading the player data file.");
+ log.severe("There was an issue reading the player data file.");
e.printStackTrace();
- System.out.println("[Resurrection] This file is crucial to Resurrection. Since the file could not be read, the plugin will now stop.");
+ log.severe("This file is crucial to Resurrection. Since the file could not be read, the plugin will now stop.");
Bukkit.getPluginManager().disablePlugin(JavaPlugin.getProvidingPlugin(Resurrection.class));
}
if (DEBUG) {
diff --git a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
index d926057..59c7b30 100644
--- a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
+++ b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
@@ -4,15 +4,21 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import net.brysonsteck.Resurrection.Resurrection;
+
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
+import java.util.logging.Logger;
public class CheckForUpdate {
boolean success;
String version;
String versionURL;
+ Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
public CheckForUpdate() {
try {
@@ -26,7 +32,7 @@ public class CheckForUpdate {
versionURL = softwareObj.get("github-release").toString();
success = true;
} catch (IOException e) {
- System.out.println("[Resurrection] An error has occurred while attempting to check for updates.");
+ log.warning("An error has occurred while attempting to check for updates.");
e.printStackTrace();
}
}
diff --git a/src/net/brysonsteck/Resurrection/startup/ParseSettings.java b/src/net/brysonsteck/Resurrection/startup/ParseSettings.java
index 75d24a6..c0c4830 100644
--- a/src/net/brysonsteck/Resurrection/startup/ParseSettings.java
+++ b/src/net/brysonsteck/Resurrection/startup/ParseSettings.java
@@ -6,6 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
import java.util.Hashtable;
+import java.util.logging.Logger;
public class ParseSettings {
Hashtable<String, String> settings = new Hashtable<>();
@@ -15,6 +16,7 @@ public class ParseSettings {
boolean valuesComplete;
public ParseSettings() {
+ Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger();
try {
File settingsFile = new File("plugins/settings.resurrection");
if (!settingsFile.exists()) {
@@ -43,25 +45,25 @@ public class ParseSettings {
}
reader.close();
if (!verifySettings()) {
- System.out.println("[Resurrection] There is a syntax issue inside the Settings file:");
+ log.severe("There is a syntax issue inside the Settings file:");
if (!settingsComplete) {
- System.out.println("[Resurrection] The setting \"" + failedSetting + "\" is not present in the settings file.\n" +
- "[Resurrection] Please double check the settings file to make sure the setting exists and a valid corresponding value is set.\n" +
- "[Resurrection] Example: \"resurrection_time=86400000\"\n" +
- "[Resurrection] Example: \"debug=false\"");
+ log.severe(" The setting \"" + failedSetting + "\" is not present in the settings file.");
+ log.severe(" Please double check the settings file to make sure the setting exists and a valid corresponding value is set.");
+ log.severe(" Example: \"resurrection_time=86400000\"");
+ log.severe(" Example: \"debug=false\"");
} else if (!valuesComplete) {
- System.out.println("[Resurrection] The setting \"" + failedSetting + "\" contains an invalid or empty value.\n" +
- "[Resurrection] Please double check the settings file to make sure that a valid value is set for this setting.\n" +
- "[Resurrection] Example: \"resurrection_time=86400000\"\n" +
- "[Resurrection] Example: \"debug=false\"");
+ log.severe("The setting \"" + failedSetting + "\" contains an invalid or empty value.");
+ log.severe(" Please double check the settings file to make sure that a valid value is set for this setting.");
+ log.severe(" Example: \"resurrection_time=86400000\"");
+ log.severe(" Example: \"debug=false\"");
}
- System.out.println("[Resurrection] This file is crucial to Resurrection. Since the file is not complete, the plugin will now stop.");
+ log.severe("This file is crucial to Resurrection. Since the file is not complete, the plugin will now stop.");
Bukkit.getPluginManager().disablePlugin(JavaPlugin.getProvidingPlugin(Resurrection.class));
}
} catch (IOException e) {
- System.out.println("[Resurrection] There was an issue reading the Settings file:");
+ log.severe("There was an issue reading the Settings file:");
e.printStackTrace();
- System.out.println("[Resurrection] This file is crucial to Resurrection. Since the file is not complete, the plugin will now stop.");
+ log.severe("This file is crucial to Resurrection. Since the file is not complete, the plugin will now stop.");
Bukkit.getPluginManager().disablePlugin(JavaPlugin.getProvidingPlugin(Resurrection.class));
}
}
diff --git a/src/plugin.yml b/src/plugin.yml
index bafa679..47b98a6 100644
--- a/src/plugin.yml
+++ b/src/plugin.yml
@@ -29,4 +29,8 @@ commands:
source:
description: Displays info about the source code of Resurrection.
- usage: /source \ No newline at end of file
+ usage: /source
+
+ dead:
+ description: Displays all players who are awaiting resurrection.
+ usage: /dead \ No newline at end of file