From d8da188f024aa705ff285dfbf35d8c5e4b917af9 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Sat, 25 Dec 2021 08:23:19 -0600 Subject: [PATCH] Rebase pom.xml --- pom.xml | 8 +++-- .../hideAndSeek/command/About.java | 2 +- .../hideAndSeek/configuration/Items.java | 1 + .../hideAndSeek/game/EventListener.java | 32 +++++++++++++------ .../hideAndSeek/util/CommandHandler.java | 8 ++--- .../tylermurphy/hideAndSeek/util/Util.java | 10 ++++++ 6 files changed, 43 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index be5659b..5d49f1f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,10 @@ -4.0.0 +4.0.0 net.tylermurphy +<<<<<<< HEAD KenshinsHideAndSeek +======= + HideAndSeek +>>>>>>> 06b31297d3d83a0c7b76230be1b089bdfd8e4afa 1.3.3 Hide and Seek Plugin @@ -46,4 +50,4 @@ compile - \ No newline at end of file + diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java index c341666..6256f69 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java @@ -7,7 +7,7 @@ public class About implements ICommand { public void execute(CommandSender sender, String[] args) { sender.sendMessage( - String.format("%s%sHide and Seek %s(1.3.2%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + + String.format("%s%sHide and Seek %s(1.3.3%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) + String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE) ); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java index e5470af..3651a41 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java @@ -78,6 +78,7 @@ public class Items { if(material == Material.POTION || material == Material.SPLASH_POTION || material == Material.LINGERING_POTION){ PotionMeta meta = getPotionMeta(stack, item); stack.setItemMeta(meta); + } else { ConfigurationSection enchantments = item.getConfigurationSection("enchantments"); if (enchantments != null) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java index d7bb89b..60c7132 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java @@ -3,11 +3,7 @@ package net.tylermurphy.hideAndSeek.game; import static net.tylermurphy.hideAndSeek.configuration.Config.*; import net.tylermurphy.hideAndSeek.command.Join; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.attribute.Attribute; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -21,9 +17,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerKickEvent; -import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.*; import net.tylermurphy.hideAndSeek.util.Packet; import net.tylermurphy.hideAndSeek.util.Util; @@ -36,8 +30,8 @@ public class EventListener implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - event.getPlayer().setLevel(0); Main.plugin.board.remove(event.getPlayer()); + Util.removeItems(event.getPlayer()); if(!Util.isSetup()) return; if(autoJoin){ Join.join(event.getPlayer()); @@ -65,6 +59,7 @@ public class EventListener implements Listener { for(PotionEffect effect : event.getPlayer().getActivePotionEffects()){ event.getPlayer().removePotionEffect(effect.getType()); } + Util.removeItems(event.getPlayer()); } @EventHandler @@ -78,6 +73,25 @@ public class EventListener implements Listener { for(PotionEffect effect : event.getPlayer().getActivePotionEffects()){ event.getPlayer().removePotionEffect(effect.getType()); } + Util.removeItems(event.getPlayer()); + } + + @EventHandler + public void onChat(AsyncPlayerChatEvent event){ + if(Main.plugin.board.isSeeker(event.getPlayer())){ + event.setCancelled(true); + Main.plugin.board.getSpectators().forEach(spectator -> spectator.sendMessage(ChatColor.GRAY + "[SPECTATOR] " + event.getPlayer().getName() + ": " + event.getMessage())); + } + } + + @EventHandler + public void onMove(PlayerMoveEvent event){ + if(!event.getPlayer().getWorld().equals("hideandseek_" + spawnWorld)) return; + if(event.getPlayer().hasPermission("hideandseek.leavebounds")) return; + if(!event.getTo().getWorld().getName().equals("hideandseek_" + spawnWorld)) return; + if(event.getTo().getBlockX() < saveMinX || event.getTo().getBlockX() > saveMinX || event.getTo().getBlockZ() < saveMinZ || event.getTo().getBlockZ() > saveMaxZ){ + event.setCancelled(true); + } } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/CommandHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/util/CommandHandler.java index 56084dd..18a2c8c 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/CommandHandler.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/CommandHandler.java @@ -41,7 +41,7 @@ public class CommandHandler { } public static boolean handleCommand(CommandSender sender, Command cmd, String label, String[] args) { - if(sender instanceof Player == false) { + if(!(sender instanceof Player)) { sender.sendMessage(errorPrefix + message("COMMAND_PLAYER_ONLY")); } else if(args.length < 1 || !COMMAND_REGISTER.containsKey(args[0].toLowerCase()) ) { if(permissionsRequired && !sender.hasPermission("hideandseek.about")) { @@ -50,7 +50,7 @@ public class CommandHandler { COMMAND_REGISTER.get("about").execute(sender, null); } } else { - if(!args[0].toLowerCase().equals("about") && !args[0].toLowerCase().equals("help") && SaveMap.runningBackup) { + if(!args[0].equalsIgnoreCase("about") && !args[0].equalsIgnoreCase("help") && SaveMap.runningBackup) { sender.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS")); } else if(permissionsRequired && !sender.hasPermission("hideandseek."+args[0].toLowerCase())) { sender.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED")); @@ -65,9 +65,5 @@ public class CommandHandler { } return true; } - - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - return CommandHandler.handleCommand(sender, command, label, args); - } } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java index f3bee71..513ac16 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java @@ -4,6 +4,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*; import java.io.*; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import net.md_5.bungee.api.ChatColor; @@ -82,4 +83,13 @@ public class Util { } } } + + public static void removeItems(Player player){ + for(ItemStack si : Items.SEEKER_ITEMS) + for(ItemStack i : player.getInventory().getContents()) + if(si.isSimilar(i)) player.getInventory().remove(i); + for(ItemStack hi : Items.HIDER_ITEMS) + for(ItemStack i : player.getInventory().getContents()) + if(hi.isSimilar(i)) player.getInventory().remove(i); + } } \ No newline at end of file