diff options
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/game/Game.java')
-rw-r--r-- | src/main/java/net/tylermurphy/hideAndSeek/game/Game.java | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java index 225eab0..3b1a0dd 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java @@ -21,14 +21,19 @@ package net.tylermurphy.hideAndSeek.game; import static net.tylermurphy.hideAndSeek.configuration.Config.*; +import com.cryptomorin.xseries.XMaterial; +import com.cryptomorin.xseries.XSound; +import com.cryptomorin.xseries.messages.Titles; import net.md_5.bungee.api.ChatColor; import net.tylermurphy.hideAndSeek.configuration.Items; import net.tylermurphy.hideAndSeek.database.Database; import net.tylermurphy.hideAndSeek.util.Status; +import net.tylermurphy.hideAndSeek.util.Version; import net.tylermurphy.hideAndSeek.util.WinType; import net.tylermurphy.hideAndSeek.world.WorldLoader; import org.bukkit.*; import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeInstance; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; @@ -42,7 +47,6 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import java.beans.EventHandler; import java.io.File; import java.util.*; import java.util.stream.Collectors; @@ -92,11 +96,11 @@ public class Game { for(Player player : Board.getSeekers()) { player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,1000000,127,false,false)); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000,127,false,false)); - player.sendTitle(ChatColor.RED + "" + ChatColor.BOLD + "SEEKER", ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString(), 10, 70, 20); + Titles.sendTitle(player, 10, 70, 20, ChatColor.RED + "" + ChatColor.BOLD + "SEEKER", ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString()); } for(Player player : Board.getHiders()) { player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false)); - player.sendTitle(ChatColor.GOLD + "" + ChatColor.BOLD + "HIDER", ChatColor.WHITE + message("HIDERS_SUBTITLE").toString(), 10, 70, 20); + Titles.sendTitle(player, 10, 70, 20, ChatColor.GOLD + "" + ChatColor.BOLD + "HIDER", ChatColor.WHITE + message("HIDERS_SUBTITLE").toString()); } if(tauntEnabled) taunt = new Taunt(); @@ -153,8 +157,10 @@ public class Game { player.removePotionEffect(effect.getType()); } player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100)); - for(Player temp : Board.getPlayers()) { - Packet.setGlow(player, temp, false); + if(Version.atLeast("1.9")){ + for(Player temp : Board.getPlayers()) { + Packet.setGlow(player, temp, false); + } } } EventListener.temp_loc.clear(); @@ -207,7 +213,8 @@ public class Game { for(PotionEffect effect : Items.HIDER_EFFECTS) player.addPotionEffect(effect); if(glowEnabled) { - ItemStack snowball = new ItemStack(Material.SNOWBALL, 1); + assert XMaterial.SNOWBALL.parseMaterial() != null; + ItemStack snowball = new ItemStack(XMaterial.SNOWBALL.parseMaterial(), 1); ItemMeta snowballMeta = snowball.getItemMeta(); assert snowballMeta != null; snowballMeta.setDisplayName("Glow Powerup"); @@ -238,11 +245,16 @@ public class Game { player.setGameMode(GameMode.SPECTATOR); Board.createGameBoard(player); player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); - player.sendTitle(ChatColor.GRAY + "" + ChatColor.BOLD + "SPECTATING", ChatColor.WHITE + message("SPECTATOR_SUBTITLE").toString(), 10, 70, 20); + Titles.sendTitle(player, 10, 70, 20, ChatColor.GRAY + "" + ChatColor.BOLD + "SPECTATING", ChatColor.WHITE + message("SPECTATOR_SUBTITLE").toString()); } player.setFoodLevel(20); - player.setHealth(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getBaseValue()); + if(Version.atLeast("1.9")) { + AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH); + if (attribute != null) player.setHealth(attribute.getValue()); + } else { + player.setHealth(player.getMaxHealth()); + } } public static void removeItems(Player player){ @@ -296,20 +308,36 @@ public class Game { distance = temp; } } - switch(tick%10) { +// if(seekerPing) switch(tick%10) { +// case 0: +// if(distance < seekerPingLevel1) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_BASEDRUM.parseSound(), .5f, 1f); +// if(distance < seekerPingLevel3) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_PLING.parseSound(), .3f, 1f); +// break; +// case 3: +// if(distance < seekerPingLevel1) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_BASEDRUM.parseSound(), .3f, 1f); +// if(distance < seekerPingLevel3) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_PLING.parseSound(), .3f, 1f); +// break; +// case 6: +// if(distance < seekerPingLevel3) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_PLING.parseSound(), .3f, 1f); +// break; +// case 9: +// if(distance < seekerPingLevel2) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_PLING.parseSound(), .3f, 1f); +// break; +// } + if(seekerPing) switch(tick%10) { case 0: - if(distance < 30) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f); - if(distance < 10) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); + if(distance < seekerPingLevel1) XSound.BLOCK_NOTE_BLOCK_BASEDRUM.play(hider, .5f, 1f); + if(distance < seekerPingLevel3) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f); break; case 3: - if(distance < 30) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f); - if(distance < 10) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); + if(distance < seekerPingLevel1) XSound.BLOCK_NOTE_BLOCK_BASEDRUM.play(hider, .3f, 1f); + if(distance < seekerPingLevel3) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f); break; case 6: - if(distance < 10) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); + if(distance < seekerPingLevel3) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f); break; case 9: - if(distance < 20) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f); + if(distance < seekerPingLevel2) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f); break; } } |