aboutsummaryrefslogtreecommitdiff
path: root/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/brysonsteck/Resurrection/commands/CommandHowLong.java')
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandHowLong.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java b/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java
index 29314d7..32662a0 100644
--- a/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java
+++ b/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java
@@ -10,20 +10,38 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandHowLong implements CommandExecutor {
+ boolean DEBUG;
public CommandHowLong(String debug) {
+ this.DEBUG = Boolean.parseBoolean(debug);
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `/howlong` command was ran by " + commandSender.getName());
+ }
+
if (commandSender instanceof Player) {
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: CommandSender is a player.");
+ }
+
boolean self = false;
boolean valid = false;
if (strings.length == 0) {
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Valid; no arguments given. Assuming sender wants to check own time");
+ }
+
self = true;
valid = true;
} else if (strings.length == 1) {
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Valid; one argument given. Assuming sender wants to check another player's time");
+ }
+
valid = true;
}
@@ -37,6 +55,10 @@ public class CommandHowLong implements CommandExecutor {
commandSender.sendMessage(ChatColor.RED + "ERROR: That player is not online/doesn't exist!");
return false;
}
+
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Specified player " + p.getDisplayName() + " exists.");
+ }
}
PlayerData playerData = new PlayerData();
playerData.readData();
@@ -46,6 +68,10 @@ public class CommandHowLong implements CommandExecutor {
if (players.startsWith(p.getDisplayName())) {
String[] playerSplit = players.split(",");
if (Boolean.parseBoolean(playerSplit[1])) {
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player is dead according to file. Calculating time until resurrection");
+ }
+
long currentTime = System.currentTimeMillis();
long resurrectionTime = Long.parseLong(playerSplit[2]);
@@ -70,12 +96,20 @@ public class CommandHowLong implements CommandExecutor {
return false;
}
} else {
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: CommandSender is console.");
+ }
+
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.");
return false;
} else if (strings.length == 1) {
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Valid; console specified player to check.");
+ }
+
valid = true;
}
@@ -87,6 +121,10 @@ public class CommandHowLong implements CommandExecutor {
return false;
}
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Specified player " + p.getDisplayName() + " exists.");
+ }
+
PlayerData playerData = new PlayerData();
playerData.readData();
String rawData = playerData.getRawData();
@@ -95,6 +133,9 @@ public class CommandHowLong implements CommandExecutor {
if (players.startsWith(p.getDisplayName())) {
String[] playerSplit = players.split(",");
if (Boolean.parseBoolean(playerSplit[1])) {
+ if (DEBUG) {
+ Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player is dead according to file. Calculating time until resurrection");
+ }
long currentTime = System.currentTimeMillis();
long resurrectionTime = Long.parseLong(playerSplit[2]);