diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/net/brysonsteck/Resurrection/Resurrection.java | 7 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/commands/CommandResurrect.java | 2 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/player/PlayerData.java (renamed from src/net/brysonsteck/Resurrection/PlayerData.java) | 2 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/player/PlayerListener.java (renamed from src/net/brysonsteck/Resurrection/PlayerListener.java) | 38 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/player/ResurrectPlayer.java | 16 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/player/TimeCheck.java (renamed from src/net/brysonsteck/Resurrection/TimeCheck.java) | 4 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/plugin.yml | 2 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java | 9 |
8 files changed, 54 insertions, 26 deletions
diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java index cfd196d..7a7e949 100644 --- a/src/net/brysonsteck/Resurrection/Resurrection.java +++ b/src/net/brysonsteck/Resurrection/Resurrection.java @@ -2,15 +2,11 @@ package net.brysonsteck.Resurrection; import net.brysonsteck.Resurrection.commands.CommandAbout; import net.brysonsteck.Resurrection.commands.CommandResurrect; +import net.brysonsteck.Resurrection.player.PlayerListener; import net.brysonsteck.Resurrection.startup.CheckForUpdate; -import org.bukkit.command.CommandExecutor; import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; -import org.w3c.dom.stylesheets.LinkStyle; - -import static org.bukkit.Bukkit.getServer; public class Resurrection extends JavaPlugin implements Listener { // public Plugin plugin = getPlugin(Resurrection.class); @@ -52,6 +48,7 @@ public class Resurrection extends JavaPlugin implements Listener { // end of spigot things public static void main(String[] args) { + CheckForUpdate check = new CheckForUpdate(); // PlayerData playerData = new PlayerData(); // playerData.saveData("This is the first line\nthis is the second line"); // System.out.println(playerData.getPlayers()); diff --git a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java index 8d5c4b5..f05de5d 100644 --- a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java +++ b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java @@ -44,7 +44,7 @@ public class CommandResurrect implements CommandExecutor { System.out.println("That player does not exist! Failed to resurrect."); return false; } - if (resurrectPlayer.getGameMode() == GameMode.ADVENTURE) { + if (resurrectPlayer.getGameMode() == GameMode.SPECTATOR) { for (PotionEffect effect : resurrectPlayer.getActivePotionEffects()) resurrectPlayer.removePotionEffect(effect.getType()); resurrectPlayer.setGameMode(GameMode.SURVIVAL); diff --git a/src/net/brysonsteck/Resurrection/PlayerData.java b/src/net/brysonsteck/Resurrection/player/PlayerData.java index f63a359..a8a1192 100644 --- a/src/net/brysonsteck/Resurrection/PlayerData.java +++ b/src/net/brysonsteck/Resurrection/player/PlayerData.java @@ -1,4 +1,4 @@ -package net.brysonsteck.Resurrection; +package net.brysonsteck.Resurrection.player; import java.io.*; import java.util.Arrays; diff --git a/src/net/brysonsteck/Resurrection/PlayerListener.java b/src/net/brysonsteck/Resurrection/player/PlayerListener.java index e922a06..bec8abb 100644 --- a/src/net/brysonsteck/Resurrection/PlayerListener.java +++ b/src/net/brysonsteck/Resurrection/player/PlayerListener.java @@ -1,6 +1,7 @@ -package net.brysonsteck.Resurrection; +package net.brysonsteck.Resurrection.player; -import org.bukkit.Bukkit; +import net.brysonsteck.Resurrection.Resurrection; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -14,30 +15,41 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; -import static org.bukkit.Bukkit.getServer; - public class PlayerListener implements Listener { + Location spawn; + @EventHandler public void onDeath(PlayerDeathEvent e) { System.out.println("Resurrection: A player has died!"); Player p = e.getEntity(); Long timeOfDeath = System.currentTimeMillis(); Long resurrectionTime = timeOfDeath + 86400000; - - TimeCheck death = new TimeCheck(timeOfDeath); - TimeCheck resurrect = new TimeCheck((timeOfDeath + 86400000) - timeOfDeath); - - String deathFormatted = death.formatTime(); - String resurrectFormatted = resurrect.formatTime(); +// +// TimeCheck death = new TimeCheck(timeOfDeath); +// TimeCheck resurrect = new TimeCheck((timeOfDeath + 86400000) - timeOfDeath); +// +// String deathFormatted = death.formatTime(); +// String resurrectFormatted = resurrect.formatTime(); p.sendMessage("You have died!! You will be able to respawn in the next 24 hours."); + + new Thread (() -> { + try { + Thread.sleep(86400000); + } catch (InterruptedException interruptedException) { + interruptedException.printStackTrace(); + p.sendMessage("Failed to make the thread sleep!"); + } + ResurrectPlayer resurrectPlayer = new ResurrectPlayer(p); + }).start(); } @EventHandler public void onPlayerRespawn(PlayerRespawnEvent e) { final Player p = e.getPlayer(); - p.setGameMode(GameMode.ADVENTURE); + p.setGameMode(GameMode.SPECTATOR); + spawn = p.getLocation(); new BukkitRunnable() { @Override public void run() { @@ -57,8 +69,8 @@ public class PlayerListener implements Listener { public void onPlayerMove(PlayerMoveEvent e) { Player p = e.getPlayer(); Location location = p.getLocation(); - if (p.getGameMode() == GameMode.ADVENTURE) { - p.teleport(location); + if (p.getGameMode() == GameMode.SPECTATOR) { + p.teleport(spawn); } } } diff --git a/src/net/brysonsteck/Resurrection/player/ResurrectPlayer.java b/src/net/brysonsteck/Resurrection/player/ResurrectPlayer.java new file mode 100644 index 0000000..971ada3 --- /dev/null +++ b/src/net/brysonsteck/Resurrection/player/ResurrectPlayer.java @@ -0,0 +1,16 @@ +package net.brysonsteck.Resurrection.player; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; + +public class ResurrectPlayer { + + public ResurrectPlayer(Player p) { + for (PotionEffect effect : p.getActivePotionEffects()) + p.removePotionEffect(effect.getType()); + p.setGameMode(GameMode.SURVIVAL); + Bukkit.broadcastMessage(p.getDisplayName() + " has resurrected!"); + } +} diff --git a/src/net/brysonsteck/Resurrection/TimeCheck.java b/src/net/brysonsteck/Resurrection/player/TimeCheck.java index a7ea06c..f1cf004 100644 --- a/src/net/brysonsteck/Resurrection/TimeCheck.java +++ b/src/net/brysonsteck/Resurrection/player/TimeCheck.java @@ -1,8 +1,8 @@ -package net.brysonsteck.Resurrection; +package net.brysonsteck.Resurrection.player; import java.util.concurrent.TimeUnit; -class TimeCheck { +public class TimeCheck { long millis; public TimeCheck(long millis) { diff --git a/src/net/brysonsteck/Resurrection/plugin.yml b/src/net/brysonsteck/Resurrection/plugin.yml index 2a0f9a5..08a62bf 100644 --- a/src/net/brysonsteck/Resurrection/plugin.yml +++ b/src/net/brysonsteck/Resurrection/plugin.yml @@ -1,7 +1,7 @@ main: net.brysonsteck.Resurrection.Resurrection name: Resurrection author: 'Bryson Steck' -version: '0.0.1 alpha' +version: '0.1 beta' commands: about: description: Displays information about Resurrection. diff --git a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java index 1507480..be30844 100644 --- a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java +++ b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java @@ -20,8 +20,11 @@ public class CheckForUpdate { String json = urlReader(); JsonElement root = new JsonParser().parse(json); JsonObject rootobj = root.getAsJsonObject(); - version = rootobj.get("current-version").getAsString(); - versionURL = rootobj.get("release-url").getAsString(); + JsonElement softwareElement = rootobj.get("resurrection"); + JsonObject softwareObj = softwareElement.getAsJsonObject(); + version = softwareObj.get("current-release").toString(); +// version = rootobj.get("current-version").getAsString(); +// versionURL = rootobj.get("release-url").getAsString(); } catch (IOException e) { System.out.println("[Resurrection] An error has occurred while attempting to check for updates."); e.printStackTrace(); @@ -29,7 +32,7 @@ public class CheckForUpdate { } public String urlReader() throws IOException { - URL website = new URL("https://brysonsteck.net/resurrect.json"); + URL website = new URL("https://brysonsteck.net/updates.json"); URLConnection connection = website.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( |