From 4278cf4472494d6f17bea33b8e54f7815a730ccf Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Tue, 19 Apr 2022 20:00:53 -0400 Subject: [PATCH] 1.4.1 --- pom.xml | 14 ++++++++++-- .../hideAndSeek/command/About.java | 2 +- .../hideAndSeek/configuration/Config.java | 22 ++++++++++++++++--- .../hideAndSeek/game/EventListener.java | 14 ++++++++++++ src/main/resources/config.yml | 11 ++++++++-- src/main/resources/plugin.yml | 2 +- 6 files changed, 56 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 1d77b2c..a5b94b8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 net.tylermurphy HideAndSeek - 1.4.0 + 1.4.1 Hide and Seek Plugin UTF-8 @@ -26,7 +26,15 @@ com.cryptomorin.xseries - net.tylermurphy.xseries + net.tylermurphy.dependencies.xseries + + + org.sqlite + net.tylermurphy.dependencies.sqlite + + + org.ibex + net.tylermurphy.dependencies.ibex @@ -42,6 +50,7 @@ *:* META-INF/*.MF + META-INF sqlite-jdbc.properties @@ -51,6 +60,7 @@ META-INF/services/java.sql.Driver + true diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java index bfc6c85..f19cb09 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java @@ -26,7 +26,7 @@ public class About implements ICommand { public void execute(CommandSender sender, String[] args) { sender.sendMessage( - String.format("%s%sHide and Seek %s(%s1.4.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + + String.format("%s%sHide and Seek %s(%s1.4.1%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/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java index f18ec5f..4b13e1c 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java @@ -19,11 +19,15 @@ package net.tylermurphy.hideAndSeek.configuration; +import com.cryptomorin.xseries.XMaterial; import net.tylermurphy.hideAndSeek.util.Version; +import org.bukkit.Material; import org.bukkit.util.Vector; +import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Optional; public class Config { @@ -84,6 +88,10 @@ public class Config { seekerPingLevel2, seekerPingLevel3; + public static List + blockedCommands, + blockedInteracts; + public static String LOBBY_TITLE, GAME_TITLE, @@ -101,9 +109,6 @@ public class Config { public static List LOBBY_CONTENTS, GAME_CONTENTS; - - public static List - blockedCommands; public static void loadConfig() { @@ -198,6 +203,17 @@ public class Config { teleportToExit = config.getBoolean("teleportToExit"); locale = config.getString("locale", "local"); blockedCommands = config.getStringList("blockedCommands"); + blockedInteracts = new ArrayList<>(); + List tempInteracts = config.getStringList("blockedInteracts"); + for(String id : tempInteracts){ + Optional optional_mat = XMaterial.matchXMaterial(id); + if(optional_mat.isPresent()){ + Material mat = optional_mat.get().parseMaterial(); + if(mat != null){ + blockedInteracts.add(mat.name()); + } + } + } //Leaderboard LOBBY_TITLE = leaderboard.getString("lobby.title"); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java index 0c84058..a8418e2 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java @@ -36,6 +36,7 @@ import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; import org.bukkit.event.entity.*; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.player.*; @@ -159,6 +160,7 @@ public class EventListener implements Listener { } } } + return; } if (Game.status != Status.PLAYING) { event.setCancelled(true); @@ -169,17 +171,20 @@ public class EventListener implements Listener { Entity damager = ((EntityDamageByEntityEvent) event).getDamager(); if (damager instanceof Player) { attacker = (Player) damager; + if (!Board.isPlayer(attacker)) event.setCancelled(true); if (Board.onSameTeam(player, attacker)) event.setCancelled(true); if (Board.isSpectator(player)) event.setCancelled(true); } else if(damager instanceof Arrow){ ProjectileSource source = ((Arrow) damager).getShooter(); if(source instanceof Player){ attacker = (Player) source; + if (!Board.isPlayer(attacker)) event.setCancelled(true); if (Board.onSameTeam(player, attacker)) event.setCancelled(true); if (Board.isSpectator(player)) event.setCancelled(true); } } } + if(event.isCancelled()) return; if (player.getHealth() - event.getFinalDamage() < 0.5 || !pvpEnabled) { if (spawnPosition == null) return; event.setCancelled(true); @@ -269,4 +274,13 @@ public class EventListener implements Listener { } } } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerInteract(PlayerInteractEvent event) { + if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { + if(Board.isPlayer(event.getPlayer()) && blockedInteracts.contains(event.getClickedBlock().getType().name())){ + event.setCancelled(true); + } + } + } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 8482cf8..5f3e2b8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -114,14 +114,21 @@ seekerPing: # de-DE (German - Germany) locale: "en-US" -# Block's commands being run by any user while playing the game. -# Can be usefully If you aren't using a permission plugin and want +# Stop commands being run by any user while playing the game. +# Can be usefull If you aren't using a permission plugin and want # to op people, but still want to block certain commands. # Not really usefully if using permission plugins. # You can add /kill for any use, but it's already blocked on those # playing the game. blockedCommands: [msg, tp, gamemode, kill, give, effect] +# Stop interactions with any block by any user while playing the game. +# If your map has things such as chests for aesthetic only, you can +# block the use of clicking them. It shouldn't matter what version of +# the block ID you enter, as the plugin will automatically switch to the +# block ID of your current Minecraft server version. +blockedInteracts: [FURNACE, CRAFTING_TABLE, ANVIL, CHEST, BARREL] + # ---------------------------------------------------------- # # ONLY EDIT BEYOND THIS POINT IF YOU KNOW WHAT YOU ARE DOING # # ---------------------------------------------------------- # diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c03205c..9fe2c54 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.4.0 +version: 1.4.1 author: KenshinEto load: STARTUP api-version: 1.13