From 42cf7ecd1330316c7bcc59d16c598e88a1fa2d70 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sun, 14 Apr 2019 00:02:33 +0200 Subject: [PATCH] closed security leak (gm3 teleport) Signed-off-by: Yaruma3341 --- src/me/yaruma/fightsystem/FightSystem.java | 1 + .../listener/PlayerTeleportListener.java | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/me/yaruma/fightsystem/listener/PlayerTeleportListener.java diff --git a/src/me/yaruma/fightsystem/FightSystem.java b/src/me/yaruma/fightsystem/FightSystem.java index acf6b7f..1c5790c 100644 --- a/src/me/yaruma/fightsystem/FightSystem.java +++ b/src/me/yaruma/fightsystem/FightSystem.java @@ -87,6 +87,7 @@ public class FightSystem extends JavaPlugin { pm.registerEvents(new PlayerRespawnListener(), plugin); pm.registerEvents(new EntityDamageListener(), plugin); pm.registerEvents(new EntityExplodeListener(), plugin); + pm.registerEvents(new PlayerTeleportListener(), plugin); //WinConditions if(Config.AllDead) pm.registerEvents(new WinconditionAllDead(), plugin); diff --git a/src/me/yaruma/fightsystem/listener/PlayerTeleportListener.java b/src/me/yaruma/fightsystem/listener/PlayerTeleportListener.java new file mode 100644 index 0000000..344ffc7 --- /dev/null +++ b/src/me/yaruma/fightsystem/listener/PlayerTeleportListener.java @@ -0,0 +1,22 @@ +package me.yaruma.fightsystem.listener; + +import me.yaruma.fightsystem.FightSystem; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerTeleportEvent; + +public class PlayerTeleportListener implements Listener { + + @EventHandler + public void onTpGM3(PlayerTeleportEvent e) { + if (e.getPlayer().hasPermission("bukkit.command.teleport")) { + return; + } + if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) { + e.setCancelled(true); + e.getPlayer().sendMessage(FightSystem.PREFIX + "§cDu darfst die GM3 Teleportfunktion nicht benutzen!"); + } + } + + +}