SteamWar/FightSystem
Archiviert
13
1

Merge pull request 'Prevent schem selection DOS' (#381) from prevent-spam into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #381
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2023-02-17 10:29:56 +01:00
Commit 0d3a4f3894

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);
}
}