diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2021-08-27 17:20:07 -0400 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2021-08-27 17:20:07 -0400 |
commit | 0154a34f1dc240652908810314167a44638c847e (patch) | |
tree | 4f4e4a7dac2581ee8b32644cb30c3f852a1b8e8d /src/main/java/net/tylermurphy/hideAndSeek/events | |
parent | 1.3.0 beta 2, bug fixes, added more block settings, added more config options (diff) | |
download | kenshinshideandseek-0154a34f1dc240652908810314167a44638c847e.tar.gz kenshinshideandseek-0154a34f1dc240652908810314167a44638c847e.tar.bz2 kenshinshideandseek-0154a34f1dc240652908810314167a44638c847e.zip |
add world rollback and other stuff
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/events')
-rw-r--r-- | src/main/java/net/tylermurphy/hideAndSeek/events/EventListener.java | 11 | ||||
-rw-r--r-- | src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java | 92 |
2 files changed, 68 insertions, 35 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/events/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/events/EventListener.java index 541dc68..0c70d8f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/events/EventListener.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/events/EventListener.java @@ -32,6 +32,7 @@ import org.bukkit.potion.PotionEffect; import net.md_5.bungee.api.ChatColor; import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.util.Functions; +import net.tylermurphy.hideAndSeek.util.Packet; public class EventListener implements Listener { @@ -45,9 +46,10 @@ public class EventListener implements Listener { for(PotionEffect effect : event.getPlayer().getActivePotionEffects()){ event.getPlayer().removePotionEffect(effect.getType()); } - event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); + event.getPlayer().teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); } else if(status.equals("Setup") || status.equals("Standby")) { Hider.addEntry(event.getPlayer().getName()); + event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); } playerList.put(event.getPlayer().getName(), event.getPlayer()); } @@ -72,8 +74,8 @@ public class EventListener implements Listener { if(spawnPosition == null) return; event.setCancelled(true); player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); - player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); - Functions.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1); + player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); + Packet.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1); if(Hider.hasEntry(event.getEntity().getName())) { Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE)); } @@ -82,6 +84,9 @@ public class EventListener implements Listener { } Seeker.addEntry(player.getName()); Functions.resetPlayer(player); + for(Player temp : playerList.values()) { + Packet.setGlow(player, temp, false); + } } } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java b/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java index 2198c05..042b0a3 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java @@ -3,6 +3,7 @@ package net.tylermurphy.hideAndSeek.events; import static net.tylermurphy.hideAndSeek.Store.*; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; @@ -13,11 +14,13 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; import org.bukkit.entity.Player; import org.bukkit.inventory.meta.FireworkMeta; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; +import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.ScoreboardManager; +import org.bukkit.scoreboard.Team.Option; +import org.bukkit.scoreboard.Team.OptionStatus; import net.tylermurphy.hideAndSeek.commands.Stop; -import net.tylermurphy.hideAndSeek.util.Functions; +import net.tylermurphy.hideAndSeek.util.Packet; public class EventTick { @@ -26,10 +29,53 @@ public class EventTick { public static void onTick() { if(board == null) { - Functions.loadScoreboard(); + ScoreboardManager manager = Bukkit.getScoreboardManager(); + Scoreboard mainBoard = manager.getMainScoreboard(); + + try { mainBoard.registerNewTeam("Seeker");} catch(Exception e) {} + Seeker = mainBoard.getTeam("Seeker"); + Seeker.setColor(ChatColor.RED); + if(nametagsVisible) + Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OTHER_TEAMS); + else + Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER); + Seeker.setAllowFriendlyFire(false); + + try { mainBoard.registerNewTeam("Hider");} catch(Exception e) {} + Hider = mainBoard.getTeam("Hider"); + Hider.setColor(ChatColor.GOLD); + if(nametagsVisible) + Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM); + else + Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER); + Hider.setAllowFriendlyFire(false); + + try { mainBoard.registerNewTeam("Spectator");} catch(Exception e) {} + Spectator = mainBoard.getTeam("Spectator"); + Spectator.setColor(ChatColor.GRAY); + Spectator.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER); + Spectator.setAllowFriendlyFire(false); + + board = mainBoard; } - Functions.emptyOfflinePlayers(); + for(String entry : Hider.getEntries()) { + if(!playerList.containsKey(entry)) { + Hider.removeEntry(entry); + } + } + + for(String entry : Seeker.getEntries()) { + if(!playerList.containsKey(entry)) { + Seeker.removeEntry(entry); + } + } + + for(String entry : Spectator.getEntries()) { + if(!playerList.containsKey(entry)) { + Spectator.removeEntry(entry); + } + } if(status.equals("Starting")) { onStarting(); @@ -53,7 +99,7 @@ public class EventTick { for(String playerName : Seeker.getEntries()) { Player player = playerList.get(playerName); if(player != null) { - player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); + player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); } } } @@ -86,26 +132,8 @@ public class EventTick { } tauntPlayer = ""; } - for(Player player : playerList.values()) { - player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 1000000, 1, false, false)); - } - for(String playerName : Seeker.getEntries()) { - Player player = playerList.get(playerName); - if(player != null) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 2, false, false)); - player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 1, false, false)); - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 1000000, 1, false, false)); - player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 10, false, false)); - } - for(Player temp : playerList.values()) { - Functions.setGlow(player, temp, false); - } - } for(String playerName : Hider.getEntries()) { Player player = playerList.get(playerName); - if(player != null) { - player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 1, false, false)); - } int distance = 100; for(String seekerName : Seeker.getEntries()) { Player seeker = playerList.get(seekerName); @@ -114,25 +142,25 @@ public class EventTick { distance = temp; } if(glowTime > 0) { - Functions.setGlow(player, seeker, true); + Packet.setGlow(player, seeker, true); } else { - Functions.setGlow(player, seeker, false); + Packet.setGlow(player, seeker, false); } } switch(tick%10) { case 0: - if(distance < 30) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f); - if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); + if(distance < 30) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f); + if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); break; case 3: - if(distance < 30) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f); - if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); + if(distance < 30) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f); + if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); break; case 6: - if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); + if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); break; case 9: - if(distance < 20) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); + if(distance < 20) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); break; } } |