From 219d7acbe2abb869f45b43c14f888bd527da248f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 1 May 2020 11:05:31 +0200 Subject: [PATCH] Preventing copying Signed-off-by: Lixfel --- .../fightsystem/listener/CheckListener.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/CheckListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/CheckListener.java index d890aff..cd52031 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/CheckListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/CheckListener.java @@ -5,10 +5,14 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.sql.Schematic; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import java.util.EnumSet; +import java.util.logging.Level; public class CheckListener extends BasicListener { @@ -16,6 +20,7 @@ public class CheckListener extends BasicListener { super(Config.check() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class)); } + @EventHandler public void onJoin(PlayerJoinEvent e){ Player player = e.getPlayer(); SteamwarUser user = SteamwarUser.get(player.getUniqueId()); @@ -31,6 +36,17 @@ public class CheckListener extends BasicListener { player.kickPlayer(""); } + @EventHandler + public void handlePlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { + Player player = event.getPlayer(); + if(!event.getMessage().contains("copy") && !event.getMessage().contains("cut")) + return; + + event.setCancelled(true); + player.sendMessage("§cDieser Befehl ist beim Prüfen gesperrt! Admin wird benachrichtigt."); + Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!"); + } + private static boolean allowedToCheck(SteamwarUser user) { return user.getUserGroup() == UserGroup.Supporter || user.getUserGroup() == UserGroup.Developer ||