From 908cd6297c2be25db181ff47ad27549882636af4 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Wed, 5 Jan 2022 14:17:01 -0700 Subject: figuring out api stuff for recent minecraft releases --- .../Resurrection/commands/CommandResurrect.java | 14 ++++++++++++-- .../Resurrection/player/PlayerListener.java | 20 +++++++++++++++++--- src/plugin.yml | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java index a2301b3..a026d31 100644 --- a/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java +++ b/src/net/brysonsteck/Resurrection/commands/CommandResurrect.java @@ -61,7 +61,12 @@ public class CommandResurrect implements CommandExecutor { resurrectPlayer.removePotionEffect(effect.getType()); resurrectPlayer.setGameMode(GameMode.SURVIVAL); for(Player player : Bukkit.getOnlinePlayers()){ - player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); + try { + player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); + } catch (NoSuchFieldError e) { + log.warning("NoSuchFieldError encountered, playing Wither noise instead."); + player.playSound(player.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0); + } } Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + strings[0] + " has been resurrected manually by an admin!"); removeDeath(resurrectPlayer); @@ -108,7 +113,12 @@ public class CommandResurrect implements CommandExecutor { resurrectPlayer.removePotionEffect(effect.getType()); resurrectPlayer.setGameMode(GameMode.SURVIVAL); for(Player player : Bukkit.getOnlinePlayers()){ - player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); + try { + player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); + } catch (NoSuchFieldError e) { + log.warning("NoSuchFieldError encountered, playing Wither noise instead."); + player.playSound(player.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0); + } } Bukkit.broadcastMessage(strings[0] + " has been resurrected manually by an admin!"); removeDeath(resurrectPlayer); diff --git a/src/net/brysonsteck/Resurrection/player/PlayerListener.java b/src/net/brysonsteck/Resurrection/player/PlayerListener.java index 9a445e4..99d41b1 100644 --- a/src/net/brysonsteck/Resurrection/player/PlayerListener.java +++ b/src/net/brysonsteck/Resurrection/player/PlayerListener.java @@ -2,6 +2,9 @@ package net.brysonsteck.Resurrection.player; import net.brysonsteck.Resurrection.startup.ParseSettings; import net.brysonsteck.Resurrection.Resurrection; + +import java.util.logging.Logger; + import org.bukkit.*; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -24,6 +27,7 @@ public class PlayerListener implements Listener { //Hashtable playerSpawns = new Hashtable<>(); ParseSettings parseSettings; boolean DEBUG; + Logger log = JavaPlugin.getProvidingPlugin(Resurrection.class).getLogger(); public PlayerListener(ParseSettings parseSettings) { this.parseSettings = parseSettings; @@ -55,7 +59,7 @@ public class PlayerListener implements Listener { boolean dead = Boolean.parseBoolean(playerSplit[1]); timeToResurrection = Long.parseLong(playerSplit[2]); - if (timeToResurrection < System.currentTimeMillis()) { + if (timeToResurrection < System.currentTimeMillis() && timeToResurrection != 0) { dead = false; playerSplit[1] = String.valueOf(dead); timeToResurrection = 0; @@ -144,7 +148,12 @@ public class PlayerListener implements Listener { p.teleport(spawn); } for(Player p : Bukkit.getOnlinePlayers()){ - p.playSound(p.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); + try { + p.playSound(p.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); + } catch (NoSuchFieldError e) { + log.warning("NoSuchFieldError encountered, playing Wither noise instead."); + p.playSound(p.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0); + } } } }.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), timeToResurrection); @@ -235,7 +244,12 @@ public class PlayerListener implements Listener { p.teleport(spawn); } for(Player p : Bukkit.getOnlinePlayers()){ - p.playSound(p.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); + try { + p.playSound(p.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1, 0); + } catch (NoSuchFieldError e) { + log.warning("NoSuchFieldError encountered, playing Wither noise instead."); + p.playSound(p.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 0); + } } } }.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), timeToResurrection); diff --git a/src/plugin.yml b/src/plugin.yml index 47b98a6..ff48360 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,7 +1,7 @@ main: net.brysonsteck.Resurrection.Resurrection name: Resurrection author: 'Bryson Steck' -version: '1.2' +version: '1.3' website: https://brysonsteck.net/resurrection.html description: Makes players wait large amounts of time before respawning! database: false -- cgit v1.2.3