Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
9969f9707b
Commit
d5a30708a8
@ -28,6 +28,7 @@ import de.steamwar.fightsystem.event.Meteor;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import de.steamwar.fightsystem.fight.HotbarKit;
|
||||
import de.steamwar.fightsystem.listener.Shutdown;
|
||||
import de.steamwar.fightsystem.listener.*;
|
||||
import de.steamwar.fightsystem.record.*;
|
||||
@ -89,6 +90,7 @@ public class FightSystem extends JavaPlugin {
|
||||
new ArrowPickup();
|
||||
new BlockFadeListener();
|
||||
new LeaveableArena();
|
||||
new HotbarKit.HotbarKitListener();
|
||||
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
|
||||
|
||||
new EnterHandler();
|
||||
|
@ -27,7 +27,6 @@ import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -38,7 +37,7 @@ import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class HotbarKit extends Kit implements Listener {
|
||||
public class HotbarKit extends Kit {
|
||||
|
||||
private static final int HOTBAR_SIZE = 9;
|
||||
|
||||
@ -49,7 +48,6 @@ public class HotbarKit extends Kit implements Listener {
|
||||
super(name, inventory, armor, effects);
|
||||
this.nameTags = nameTags;
|
||||
this.onClicks = onClicks;
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
|
||||
}
|
||||
|
||||
public HotbarKit() {
|
||||
@ -78,15 +76,22 @@ public class HotbarKit extends Kit implements Listener {
|
||||
super.loadToPlayer(player);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
Kit activeKit = activeKits.get(player);
|
||||
if(activeKit != this || PersonalKitCreator.inKitCreator(player) || getInventory()[slot] == null)
|
||||
return;
|
||||
public static class HotbarKitListener implements Listener {
|
||||
|
||||
event.setCancelled(true);
|
||||
onClicks[slot].accept(player);
|
||||
public HotbarKitListener() {
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
Kit activeKit = activeKits.get(player);
|
||||
if(!(activeKit instanceof HotbarKit) || PersonalKitCreator.inKitCreator(player) || activeKit.getInventory()[slot] == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
((HotbarKit)activeKit).onClicks[slot].accept(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren