From 06b31297d3d83a0c7b76230be1b089bdfd8e4afa Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Fri, 24 Dec 2021 22:40:21 -0500 Subject: [PATCH] 1.3.3 beta 1 --- pom.xml | 2 +- .../hideAndSeek/bukkit/CommandHandler.java | 8 ++--- .../hideAndSeek/bukkit/EventListener.java | 32 +++++++++++++------ .../hideAndSeek/command/About.java | 2 +- .../hideAndSeek/configuration/Items.java | 1 + .../tylermurphy/hideAndSeek/util/Util.java | 10 ++++++ src/main/resources/plugin.yml | 6 +++- 7 files changed, 43 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 544d3bb..de10b5b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 net.tylermurphy HideAndSeek - 1.3.2 + 1.3.3 Hide and Seek Plugin diff --git a/src/main/java/net/tylermurphy/hideAndSeek/bukkit/CommandHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/CommandHandler.java index 1efb505..5d4fc76 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/bukkit/CommandHandler.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/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/bukkit/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java index ffad241..a425f99 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java @@ -3,11 +3,7 @@ package net.tylermurphy.hideAndSeek.bukkit; 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/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/util/Util.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java index c24936b..a1ae4e0 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 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ce62925..bd391c9 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: HideAndSeek main: net.tylermurphy.hideAndSeek.Main -version: 1.3.2 +version: 1.3.3 author: KenshinEto load: STARTUP api-version: 1.14 @@ -28,6 +28,7 @@ permissions: hideandseek.savemap: true hideandseek.join: true hideandseek.leave: true + hideandseek.leavebounds: true hideandseek.about: description: Allows you to run the about command default: true @@ -70,3 +71,6 @@ permissions: hideandseek.leave: description: Allows you to leave the game manual lobby default: true + hideandseek.leavebounds: + description: Allows players to leave specified game bounderies + default: op