aboutsummaryrefslogtreecommitdiff
path: root/src/net/brysonsteck/Resurrection/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/brysonsteck/Resurrection/commands')
-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
6 files changed, 155 insertions, 36 deletions
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;
}
}