aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--out/artifacts/Resurrection_jar/Resurrection.jarbin1344911 -> 1347919 bytes
-rw-r--r--out/production/DeadForADay/net/brysonsteck/DeadForADay.classbin1840 -> 0 bytes
-rw-r--r--out/production/DeadForADay/net/brysonsteck/PlayerData.classbin1749 -> 0 bytes
-rw-r--r--out/production/DeadForADay/net/brysonsteck/plugin.yml0
-rw-r--r--out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.classbin4914 -> 0 bytes
-rw-r--r--out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandAbout.classbin1161 -> 0 bytes
-rw-r--r--out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.classbin5046 -> 0 bytes
-rw-r--r--out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerData.classbin2649 -> 0 bytes
-rw-r--r--out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener$1.classbin1424 -> 0 bytes
-rw-r--r--out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener.classbin6279 -> 0 bytes
-rw-r--r--out/production/Resurrection/net/brysonsteck/Resurrection/player/TimeCheck.classbin1005 -> 0 bytes
-rw-r--r--out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.classbin2700 -> 0 bytes
-rw-r--r--src/net/brysonsteck/Resurrection/Resurrection.java24
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandAbout.java16
-rw-r--r--src/net/brysonsteck/Resurrection/commands/CommandHowLong.java105
-rw-r--r--src/net/brysonsteck/Resurrection/plugin.yml4
-rw-r--r--src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java4
18 files changed, 140 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index e938891..ed3a310 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
.idea/
-
+.out/production/
Resurrection.iml
diff --git a/out/artifacts/Resurrection_jar/Resurrection.jar b/out/artifacts/Resurrection_jar/Resurrection.jar
index 10875bd..e5527d8 100644
--- a/out/artifacts/Resurrection_jar/Resurrection.jar
+++ b/out/artifacts/Resurrection_jar/Resurrection.jar
Binary files differ
diff --git a/out/production/DeadForADay/net/brysonsteck/DeadForADay.class b/out/production/DeadForADay/net/brysonsteck/DeadForADay.class
deleted file mode 100644
index 6fe8bca..0000000
--- a/out/production/DeadForADay/net/brysonsteck/DeadForADay.class
+++ /dev/null
Binary files differ
diff --git a/out/production/DeadForADay/net/brysonsteck/PlayerData.class b/out/production/DeadForADay/net/brysonsteck/PlayerData.class
deleted file mode 100644
index 978e898..0000000
--- a/out/production/DeadForADay/net/brysonsteck/PlayerData.class
+++ /dev/null
Binary files differ
diff --git a/out/production/DeadForADay/net/brysonsteck/plugin.yml b/out/production/DeadForADay/net/brysonsteck/plugin.yml
deleted file mode 100644
index e69de29..0000000
--- a/out/production/DeadForADay/net/brysonsteck/plugin.yml
+++ /dev/null
diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class
deleted file mode 100644
index b092eae..0000000
--- a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class
+++ /dev/null
Binary files differ
diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandAbout.class b/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandAbout.class
deleted file mode 100644
index b1dc48d..0000000
--- a/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandAbout.class
+++ /dev/null
Binary files differ
diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class b/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class
deleted file mode 100644
index 9e71d9b..0000000
--- a/out/production/Resurrection/net/brysonsteck/Resurrection/commands/CommandResurrect.class
+++ /dev/null
Binary files differ
diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerData.class b/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerData.class
deleted file mode 100644
index 31ee8f8..0000000
--- a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerData.class
+++ /dev/null
Binary files differ
diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener$1.class b/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener$1.class
deleted file mode 100644
index 2b652ed..0000000
--- a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener$1.class
+++ /dev/null
Binary files differ
diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener.class b/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener.class
deleted file mode 100644
index 19c7b12..0000000
--- a/out/production/Resurrection/net/brysonsteck/Resurrection/player/PlayerListener.class
+++ /dev/null
Binary files differ
diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/player/TimeCheck.class b/out/production/Resurrection/net/brysonsteck/Resurrection/player/TimeCheck.class
deleted file mode 100644
index 506321e..0000000
--- a/out/production/Resurrection/net/brysonsteck/Resurrection/player/TimeCheck.class
+++ /dev/null
Binary files differ
diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class b/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class
deleted file mode 100644
index 2dc9d07..0000000
--- a/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class
+++ /dev/null
Binary files differ
diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java
index 4692a7f..49a328b 100644
--- a/src/net/brysonsteck/Resurrection/Resurrection.java
+++ b/src/net/brysonsteck/Resurrection/Resurrection.java
@@ -1,8 +1,8 @@
package net.brysonsteck.Resurrection;
import net.brysonsteck.Resurrection.commands.CommandAbout;
+import net.brysonsteck.Resurrection.commands.CommandHowLong;
import net.brysonsteck.Resurrection.commands.CommandResurrect;
-import net.brysonsteck.Resurrection.player.PlayerData;
import net.brysonsteck.Resurrection.player.PlayerListener;
import net.brysonsteck.Resurrection.startup.CheckForUpdate;
import org.bukkit.event.Listener;
@@ -11,7 +11,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
-import java.util.Hashtable;
public class Resurrection extends JavaPlugin implements Listener {
@@ -69,14 +68,16 @@ public class Resurrection extends JavaPlugin implements Listener {
// check for updates
System.out.println("[Resurrection] Checking for updates...");
CheckForUpdate check = new CheckForUpdate();
- 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);
+ 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);
+ }
}
System.out.println("[Resurrection] ---------------------------------------------------------");
@@ -86,8 +87,9 @@ public class Resurrection extends JavaPlugin implements Listener {
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
// register commands
- this.getCommand("about").setExecutor(new CommandAbout());
+ this.getCommand("about").setExecutor(new CommandAbout(pluginInfo.getVersion()));
this.getCommand("resurrect").setExecutor(new CommandResurrect());
+ this.getCommand("howlong").setExecutor(new CommandHowLong());
System.out.println("[Resurrection] ---------------------------------------------------------");
System.out.println("[Resurrection] Successfully Started!");
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandAbout.java b/src/net/brysonsteck/Resurrection/commands/CommandAbout.java
index ac95f20..40ea0a8 100644
--- a/src/net/brysonsteck/Resurrection/commands/CommandAbout.java
+++ b/src/net/brysonsteck/Resurrection/commands/CommandAbout.java
@@ -1,14 +1,28 @@
package net.brysonsteck.Resurrection.commands;
+import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandAbout implements CommandExecutor {
+ String currentVersion;
+ boolean checked = false;
+
+ public CommandAbout(String currentVersion) {
+ this.currentVersion = currentVersion;
+ }
+
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
- String aboutMessage = "This is the about message for Resurrection.";
+ String aboutMessage = ChatColor.GREEN + "" + ChatColor.BOLD + "Resurrection\n\n" + ChatColor.RESET +
+ "Resurrection is a Spigot Minecraft plugin that forces players to wait 24 hours before respawning.\n" +
+ "The current version of this plugin is " + currentVersion + ".\n\n" +
+ "This plugin is licensed under the GNU Affero General Public License v3.0. Read more here: " +
+ "For more information on this plugin or to download it for yourself, visit the GitHub repository at https://github.com/brysonsteck/resurrection" +
+ "\u00a9 2021 Bryson Steck.";
+
if (commandSender instanceof Player) {
Player p = (Player) commandSender;
p.sendMessage(aboutMessage);
diff --git a/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java b/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java
new file mode 100644
index 0000000..72daf30
--- /dev/null
+++ b/src/net/brysonsteck/Resurrection/commands/CommandHowLong.java
@@ -0,0 +1,105 @@
+package net.brysonsteck.Resurrection.commands;
+
+import net.brysonsteck.Resurrection.player.PlayerData;
+import net.brysonsteck.Resurrection.player.TimeCheck;
+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;
+
+public class CommandHowLong implements CommandExecutor {
+
+ @Override
+ public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
+ if (commandSender instanceof Player) {
+ boolean self = false;
+ boolean valid = false;
+
+ if (strings.length == 0) {
+ self = true;
+ valid = true;
+ } else if (strings.length == 1) {
+ valid = true;
+ }
+
+ if (valid) {
+ Player p;
+ if (self) {
+ p = (Player) commandSender;
+ } else {
+ p = Bukkit.getPlayer(strings[0]);
+ if (p == null) {
+ commandSender.sendMessage(ChatColor.RED + "ERROR: Player does not exist or is offline!");
+ return false;
+ }
+ }
+ PlayerData playerData = new PlayerData();
+ playerData.readData();
+ String rawData = playerData.getRawData();
+ String[] rawPlayers = rawData.split(";");
+ for (String players : rawPlayers) {
+ if (players.startsWith(p.getDisplayName())) {
+ String[] playerSplit = players.split(",");
+ if (Boolean.parseBoolean(playerSplit[1])) {
+ long currentTime = System.currentTimeMillis();
+ long resurrectionTime = Long.parseLong(playerSplit[2]);
+
+ TimeCheck timeCheck = new TimeCheck(resurrectionTime - currentTime);
+ if (self) {
+ commandSender.sendMessage("You will respawn in " + timeCheck.formatTime());
+ } else {
+ commandSender.sendMessage(p.getDisplayName() + " will respawn in " + timeCheck.formatTime());
+ }
+ return true;
+ }
+ }
+ }
+ commandSender.sendMessage("ERROR: An error has occurred while trying to get time information. This is a bug in the program and not your fault.");
+ return false;
+ }
+ } else {
+ 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) {
+ valid = true;
+ }
+
+ if (valid) {
+
+ Player p = Bukkit.getPlayer(strings[0]);
+ if (p == null) {
+ commandSender.sendMessage(ChatColor.RED + "ERROR: Player does not exist or is offline!");
+ return false;
+ }
+
+ PlayerData playerData = new PlayerData();
+ playerData.readData();
+ String rawData = playerData.getRawData();
+ String[] rawPlayers = rawData.split(";");
+ for (String players : rawPlayers) {
+ if (players.startsWith(p.getDisplayName())) {
+ String[] playerSplit = players.split(",");
+ if (Boolean.parseBoolean(playerSplit[1])) {
+ long currentTime = System.currentTimeMillis();
+ long resurrectionTime = Long.parseLong(playerSplit[2]);
+
+ TimeCheck timeCheck = new TimeCheck(resurrectionTime - currentTime);
+
+ commandSender.sendMessage(p.getDisplayName() + " will respawn in " + timeCheck.formatTime());
+
+ return true;
+ }
+ }
+ }
+ commandSender.sendMessage("ERROR: An error has occurred while trying to get time information. This is a bug in the program and not your fault.");
+ return false;
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/net/brysonsteck/Resurrection/plugin.yml b/src/net/brysonsteck/Resurrection/plugin.yml
index 08a62bf..9eca574 100644
--- a/src/net/brysonsteck/Resurrection/plugin.yml
+++ b/src/net/brysonsteck/Resurrection/plugin.yml
@@ -8,9 +8,9 @@ commands:
permission: op
usage: /about
- timecheck:
+ howlong:
description: Displays the remaining time before the player (or specified player) is resurrected.
- usage: /timecheck [PLAYER NAME]
+ usage: /howlong [PLAYER_NAME]
resurrect:
description: Manually resurrects a player.
diff --git a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
index 2a46aa5..d926057 100644
--- a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
+++ b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
@@ -10,6 +10,7 @@ import java.net.URLConnection;
public class CheckForUpdate {
+ boolean success;
String version;
String versionURL;
@@ -23,6 +24,7 @@ public class CheckForUpdate {
version = softwareObj.get("current-release").toString();
version = version.replace("\"", "");
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.");
e.printStackTrace();
@@ -47,6 +49,8 @@ public class CheckForUpdate {
return response.toString();
}
+ public boolean isSuccess() { return success; }
+
public String getVersionURL() {
return versionURL;
}