From f5b1f23b63f95c582363dacc467791cb2dc116e3 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Mon, 15 Apr 2019 18:40:47 +0200 Subject: [PATCH] bow can now only be used after fight begin Signed-off-by: Yaruma3341 --- src/me/yaruma/fightsystem/FightSystem.java | 1 + .../listener/ProjectileLaunchListener.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/me/yaruma/fightsystem/listener/ProjectileLaunchListener.java diff --git a/src/me/yaruma/fightsystem/FightSystem.java b/src/me/yaruma/fightsystem/FightSystem.java index 88135ac..bf690a2 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 EntityDamageListener(), plugin); pm.registerEvents(new EntityExplodeListener(), plugin); pm.registerEvents(new PlayerTeleportListener(), plugin); + pm.registerEvents(new ProjectileLaunchListener(), plugin); //WinConditions if(Config.AllDead) pm.registerEvents(new WinconditionAllDead(), plugin); diff --git a/src/me/yaruma/fightsystem/listener/ProjectileLaunchListener.java b/src/me/yaruma/fightsystem/listener/ProjectileLaunchListener.java new file mode 100644 index 0000000..b1ef744 --- /dev/null +++ b/src/me/yaruma/fightsystem/listener/ProjectileLaunchListener.java @@ -0,0 +1,24 @@ +package me.yaruma.fightsystem.listener; + +import me.yaruma.fightsystem.FightSystem; +import me.yaruma.fightsystem.fight.FightState; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileLaunchEvent; + +public class ProjectileLaunchListener implements Listener { + + FightSystem instance = FightSystem.getPlugin(); + + @EventHandler + public void handleProjectileLaunch(ProjectileLaunchEvent event) { + Player player = (Player) event.getEntity().getShooter(); + if(instance.getFightState() != FightState.RUNNING) { + event.setCancelled(true); + player.sendMessage(FightSystem.PREFIX + "§cDu kannst den Bogen erst nach Fightbeginn nutzen!"); + } + } + + +}