SteamWar/SpigotCore
Archiviert
13
0

Fix pr stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-02-04 20:24:24 +01:00
Ursprung b5a9b3d068
Commit c02d7c2c7d

Datei anzeigen

@ -35,6 +35,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
@ -49,7 +50,7 @@ public class REntityServer implements Listener {
private static final Reflection.FieldAccessor<Integer> useEntityTarget = Reflection.getField(useEntity, int.class, 0);
private static final Reflection.FieldAccessor<Integer> useEntityAction = Reflection.getField(useEntity, int.class, 1);
private final HashMap<Integer, REntity> entityMap = new HashMap<>();
private final ConcurrentHashMap<Integer, REntity> entityMap = new ConcurrentHashMap<>();
private final HashMap<Long, HashSet<REntity>> entities = new HashMap<>();
private final HashMap<Long, Set<Player>> players = new HashMap<>();
private final HashMap<Player, Location> lastLocation = new HashMap<>();
@ -60,26 +61,23 @@ public class REntityServer implements Listener {
private BiFunction<Player, Object, Object> filter = (player, packet) -> {
if (callback == null) return packet;
int target = useEntityTarget.get(packet);
if (!entityMap.containsKey(target)) return packet;
REntity entity = entityMap.get(target);
int action = useEntityAction.get(packet);
if (action == 2) action = 0;
int finalAction = action;
if (entity == null) return packet;
EntityAction action = useEntityAction.get(packet) == 1 ? EntityAction.ATTACK : EntityAction.INTERACT;
Bukkit.getScheduler().runTask(Core.getInstance(), () -> {
callback.onAction(player, entity, finalAction == 0 ? EntityAction.INTERACT : EntityAction.ATTACK);
callback.onAction(player, entity, action);
});
return null;
};
public REntityServer() {
Core.getInstance().getServer().getPluginManager().registerEvents(this, Core.getInstance());
TinyProtocol.instance.addFilter(useEntity, filter);
}
public void setCallback(EntityActionListener callback) {
this.callback = callback;
TinyProtocol.instance.addFilter(useEntity, filter);
}
public void addPlayer(Player player) {