summaryrefslogtreewikicommitdiff
path: root/src
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-04-19 20:00:53 -0400
committerTyler Murphy <tylermurphy534@gmail.com>2022-04-19 20:00:53 -0400
commit4278cf4472494d6f17bea33b8e54f7815a730ccf (patch)
tree5d1c175f93e1eb32bcd81198c646a6b88ed10372 /src
parent1.4.0 hotfix (diff)
downloadkenshinshideandseek-4278cf4472494d6f17bea33b8e54f7815a730ccf.tar.gz
kenshinshideandseek-4278cf4472494d6f17bea33b8e54f7815a730ccf.tar.bz2
kenshinshideandseek-4278cf4472494d6f17bea33b8e54f7815a730ccf.zip
1.4.1
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/About.java2
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java22
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java14
-rw-r--r--src/main/resources/config.yml11
-rw-r--r--src/main/resources/plugin.yml2
5 files changed, 44 insertions, 7 deletions
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<String>
+ blockedCommands,
+ blockedInteracts;
+
public static String
LOBBY_TITLE,
GAME_TITLE,
@@ -101,9 +109,6 @@ public class Config {
public static List<String>
LOBBY_CONTENTS,
GAME_CONTENTS;
-
- public static List<String>
- 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<String> tempInteracts = config.getStringList("blockedInteracts");
+ for(String id : tempInteracts){
+ Optional<XMaterial> 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