SteamWar/FightSystem
Archiviert
13
1

Prevent schem selection DOS #381

Zusammengeführt
Lixfel hat 1 Commits von prevent-spam nach master 2023-02-17 10:29:56 +01:00 zusammengeführt
Nur Änderungen aus Commit 8ffa6296b1 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -37,7 +38,9 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
public class HotbarKit extends Kit {
@ -81,8 +84,11 @@ public class HotbarKit extends Kit {
public static class HotbarKitListener implements Listener {
private static final Set<Player> clicked = new HashSet<>();
public HotbarKitListener() {
new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
new StateDependentTask(ArenaMode.AntiReplay, FightState.Setup, clicked::clear, 1, 1);
}
@EventHandler
@ -93,11 +99,13 @@ public class HotbarKit extends Kit {
Player player = event.getPlayer();
int slot = player.getInventory().getHeldItemSlot();
Kit activeKit = activeKits.get(player);
System.out.println(event.getAction().name());
if(!(activeKit instanceof HotbarKit) || PersonalKitCreator.inKitCreator(player) || activeKit.getInventory()[slot] == null)
return;
event.setCancelled(true);
if(!clicked.add(player))
return;
((HotbarKit)activeKit).onClicks[slot].accept(player);
}
}