SteamWar/SpigotCore
Archiviert
13
0

Merge pull request 'Fix double and tripple click of REntityServer' (#233) from FixMultiClick into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #233
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2023-02-24 20:44:05 +01:00
Commit fa68eb7060

Datei anzeigen

@ -33,6 +33,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@ -69,14 +70,22 @@ public class REntityServer implements Listener {
private final HashMap<Player, Integer> viewDistance = new HashMap<>();
private EntityActionListener callback = null;
private final Set<Player> playersThatClicked = Collections.synchronizedSet(new HashSet<>());
private final BiFunction<Player, Object, Object> filter = (player, packet) -> {
REntity entity = entityMap.get(useEntityTarget.get(packet));
if (entity == null)
return packet;
if (playersThatClicked.contains(player))
return null;
playersThatClicked.add(player);
EntityAction action = getEntityAction.apply(useEntityAction.get(packet)) == 1 ? EntityAction.ATTACK : EntityAction.INTERACT;
Bukkit.getScheduler().runTask(Core.getInstance(), () -> callback.onAction(player, entity, action));
Bukkit.getScheduler().runTask(Core.getInstance(), () -> {
playersThatClicked.remove(player);
callback.onAction(player, entity, action);
});
return null;
};