SteamWar/FightSystem
Archiviert
13
1

Fix HotbarKit
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-05-21 15:42:25 +02:00
Ursprung 9969f9707b
Commit d5a30708a8
2 geänderte Dateien mit 19 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -28,6 +28,7 @@ import de.steamwar.fightsystem.event.Meteor;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightWorld; import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.fight.HotbarKit;
import de.steamwar.fightsystem.listener.Shutdown; import de.steamwar.fightsystem.listener.Shutdown;
import de.steamwar.fightsystem.listener.*; import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.record.*; import de.steamwar.fightsystem.record.*;
@ -89,6 +90,7 @@ public class FightSystem extends JavaPlugin {
new ArrowPickup(); new ArrowPickup();
new BlockFadeListener(); new BlockFadeListener();
new LeaveableArena(); new LeaveableArena();
new HotbarKit.HotbarKitListener();
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f)); new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
new EnterHandler(); new EnterHandler();

Datei anzeigen

@ -27,7 +27,6 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -38,7 +37,7 @@ import java.util.Collection;
import java.util.Objects; import java.util.Objects;
import java.util.function.Consumer; import java.util.function.Consumer;
public class HotbarKit extends Kit implements Listener { public class HotbarKit extends Kit {
private static final int HOTBAR_SIZE = 9; private static final int HOTBAR_SIZE = 9;
@ -49,7 +48,6 @@ public class HotbarKit extends Kit implements Listener {
super(name, inventory, armor, effects); super(name, inventory, armor, effects);
this.nameTags = nameTags; this.nameTags = nameTags;
this.onClicks = onClicks; this.onClicks = onClicks;
new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
} }
public HotbarKit() { public HotbarKit() {
@ -78,15 +76,22 @@ public class HotbarKit extends Kit implements Listener {
super.loadToPlayer(player); super.loadToPlayer(player);
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public static class HotbarKitListener implements Listener {
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;
event.setCancelled(true); public HotbarKitListener() {
onClicks[slot].accept(player); 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);
}
} }
} }