Major: Tracker system removal
This commit is contained in:
parent
d710683c9e
commit
1c1c6a479e
15 changed files with 31 additions and 315 deletions
|
@ -10,9 +10,7 @@ public final class APIConfig {
|
||||||
private boolean checkForUpdates = false;
|
private boolean checkForUpdates = false;
|
||||||
private boolean tickTickables = false;
|
private boolean tickTickables = false;
|
||||||
private boolean platformLogger = false;
|
private boolean platformLogger = false;
|
||||||
private boolean defaultCommands = false;
|
private boolean bstats = true;
|
||||||
private boolean platformTracking = false;
|
|
||||||
private boolean bstats = false;
|
|
||||||
|
|
||||||
public APIConfig(PacketEventsAPI<?> packetEvents) {
|
public APIConfig(PacketEventsAPI<?> packetEvents) {
|
||||||
this.packetEvents = packetEvents;
|
this.packetEvents = packetEvents;
|
||||||
|
@ -23,13 +21,13 @@ public final class APIConfig {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull APIConfig usePlatformLogger() {
|
public @NotNull APIConfig disableBStats() {
|
||||||
this.platformLogger = true;
|
this.bstats = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull APIConfig trackPlatformEntities() {
|
public @NotNull APIConfig usePlatformLogger() {
|
||||||
this.platformTracking = true;
|
this.platformLogger = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,15 +46,6 @@ public final class APIConfig {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull APIConfig registerDefaultCommands() {
|
|
||||||
this.defaultCommands = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldRegisterDefaultCommands() {
|
|
||||||
return defaultCommands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDebugMode() {
|
public boolean isDebugMode() {
|
||||||
return debugMode;
|
return debugMode;
|
||||||
}
|
}
|
||||||
|
@ -77,10 +66,6 @@ public final class APIConfig {
|
||||||
return platformLogger;
|
return platformLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldTrackPlatformEntities() {
|
|
||||||
return platformTracking;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldUseBstats() {
|
public boolean shouldUseBstats() {
|
||||||
return bstats;
|
return bstats;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,6 @@ import java.util.stream.Stream;
|
||||||
public interface Platform<P> {
|
public interface Platform<P> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Queries a stream of platform specific entities if the platform supports
|
|
||||||
* @throws UnsupportedOperationException if the platform does not support querying entities.
|
|
||||||
* @return a stream of platform specific entities. The stream is not guaranteed to be synchronized.
|
|
||||||
*/
|
|
||||||
@NotNull Stream<TrackedEntity> queryPlatformEntities();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds a platform specific entity by its entityId.
|
|
||||||
* @param entityId the entityId of the entity.
|
|
||||||
* @return a future that completes with the entity if found, or null if not found.
|
|
||||||
* @throws UnsupportedOperationException if the platform does not support querying entities.
|
|
||||||
*/
|
|
||||||
@Nullable TrackedEntity findPlatformEntity(int entityId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the entityId integer provider. This can be provided by a platform if needed.
|
* Gets the entityId integer provider. This can be provided by a platform if needed.
|
||||||
* @return the entityId integer provider.
|
* @return the entityId integer provider.
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package me.tofaa.entitylib;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface TrackedEntity {
|
|
||||||
|
|
||||||
int getEntityId();
|
|
||||||
|
|
||||||
@NotNull UUID getUuid();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package me.tofaa.entitylib.event.types;
|
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.player.User;
|
|
||||||
import me.tofaa.entitylib.TrackedEntity;
|
|
||||||
import me.tofaa.entitylib.event.EntityLibEvent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class GeneralTrackingEvent implements EntityLibEvent {
|
|
||||||
|
|
||||||
private final User user;
|
|
||||||
private final TrackedEntity entity;
|
|
||||||
|
|
||||||
public GeneralTrackingEvent(@NotNull User user, @NotNull TrackedEntity entity) {
|
|
||||||
this.user = user;
|
|
||||||
this.entity = entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TrackedEntity getEntity() {
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package me.tofaa.entitylib.event.types;
|
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.player.User;
|
|
||||||
import me.tofaa.entitylib.TrackedEntity;
|
|
||||||
|
|
||||||
import me.tofaa.entitylib.event.EntityLibEvent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class UserStopTrackingEntityEvent extends GeneralTrackingEvent implements EntityLibEvent {
|
|
||||||
|
|
||||||
|
|
||||||
public UserStopTrackingEntityEvent(@NotNull User user, @NotNull TrackedEntity entity) {
|
|
||||||
super(user, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package me.tofaa.entitylib.event.types;
|
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.player.User;
|
|
||||||
import me.tofaa.entitylib.TrackedEntity;
|
|
||||||
import me.tofaa.entitylib.event.EntityLibEvent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public final class UserTrackingEntityEvent extends GeneralTrackingEvent implements EntityLibEvent {
|
|
||||||
|
|
||||||
|
|
||||||
public UserTrackingEntityEvent(@NotNull User user, @NotNull TrackedEntity entity) {
|
|
||||||
super(user, entity);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@ package me.tofaa.entitylib.ve;
|
||||||
import com.github.retrooper.packetevents.protocol.player.User;
|
import com.github.retrooper.packetevents.protocol.player.User;
|
||||||
import me.tofaa.entitylib.EntityLib;
|
import me.tofaa.entitylib.EntityLib;
|
||||||
import me.tofaa.entitylib.wrapper.WrapperEntity;
|
import me.tofaa.entitylib.wrapper.WrapperEntity;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.UnmodifiableView;
|
import org.jetbrains.annotations.UnmodifiableView;
|
||||||
|
@ -13,6 +14,11 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A basic viewer manipulation engine.
|
||||||
|
* Allows for a set of rules to be applied as to show and hide an entity from viewers.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
public class ViewerEngine {
|
public class ViewerEngine {
|
||||||
|
|
||||||
private final List<ViewerRule> globalRules;
|
private final List<ViewerRule> globalRules;
|
||||||
|
@ -34,6 +40,16 @@ public class ViewerEngine {
|
||||||
EntityLib.getApi().getPacketEvents().getEventManager().unregisterListener(listener);
|
EntityLib.getApi().getPacketEvents().getEventManager().unregisterListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refresh() {
|
||||||
|
getTracked0().forEach(entity -> {
|
||||||
|
for (UUID viewer : entity.getViewers()) {
|
||||||
|
if (!canSpawnFor(viewer, entity)) {
|
||||||
|
entity.removeViewer(viewer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public Executor getExecutor() {
|
public Executor getExecutor() {
|
||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +71,14 @@ public class ViewerEngine {
|
||||||
return globalRules.stream().anyMatch(rule -> rule.shouldSee(user));
|
return globalRules.stream().anyMatch(rule -> rule.shouldSee(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canSpawnFor(UUID userId, WrapperEntity entity) {
|
||||||
|
User user = EntityLib.getApi().getPacketEvents().getProtocolManager().getUser(
|
||||||
|
EntityLib.getApi().getPacketEvents().getProtocolManager().getChannel(userId)
|
||||||
|
);
|
||||||
|
if (user == null) return false;
|
||||||
|
return canSpawnFor(user, entity);
|
||||||
|
}
|
||||||
|
|
||||||
public @UnmodifiableView Collection<WrapperEntity> getTracked() {
|
public @UnmodifiableView Collection<WrapperEntity> getTracked() {
|
||||||
return Collections.unmodifiableCollection(tracked);
|
return Collections.unmodifiableCollection(tracked);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.github.retrooper.packetevents.util.Vector3d;
|
||||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||||
import com.github.retrooper.packetevents.wrapper.play.server.*;
|
import com.github.retrooper.packetevents.wrapper.play.server.*;
|
||||||
import me.tofaa.entitylib.EntityLib;
|
import me.tofaa.entitylib.EntityLib;
|
||||||
import me.tofaa.entitylib.TrackedEntity;
|
|
||||||
import me.tofaa.entitylib.container.EntityContainer;
|
import me.tofaa.entitylib.container.EntityContainer;
|
||||||
import me.tofaa.entitylib.meta.EntityMeta;
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
import me.tofaa.entitylib.meta.types.ObjectData;
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
@ -23,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class WrapperEntity implements Tickable, TrackedEntity {
|
public class WrapperEntity implements Tickable {
|
||||||
|
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final int entityId;
|
private final int entityId;
|
||||||
|
|
|
@ -23,16 +23,6 @@ public abstract class AbstractPlatform<P> implements Platform<P> {
|
||||||
this.entityUuidProvider = new EntityUuidProvider.DefaultEntityUuidProvider();
|
this.entityUuidProvider = new EntityUuidProvider.DefaultEntityUuidProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Stream<TrackedEntity> queryPlatformEntities() {
|
|
||||||
throw new UnsupportedOperationException("Platform does not support querying entities.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable TrackedEntity findPlatformEntity(int entityId) {
|
|
||||||
throw new UnsupportedOperationException("Platform does not support querying entities.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupApi(@NotNull APIConfig settings) {
|
public void setupApi(@NotNull APIConfig settings) {
|
||||||
this.eventHandler = EventHandler.create();
|
this.eventHandler = EventHandler.create();
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package me.tofaa.entitylib.common;
|
|
||||||
|
|
||||||
import me.tofaa.entitylib.TrackedEntity;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public abstract class AbstractTrackedEntity<E> implements TrackedEntity {
|
|
||||||
|
|
||||||
private final E platformEntity;
|
|
||||||
|
|
||||||
protected AbstractTrackedEntity(@NotNull E platformEntity) {
|
|
||||||
this.platformEntity = platformEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public E getPlatformEntity() {
|
|
||||||
return platformEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,106 +0,0 @@
|
||||||
package me.tofaa.entitylib.spigot;
|
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
|
||||||
import com.github.retrooper.packetevents.event.PacketSendEvent;
|
|
||||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
|
||||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
|
||||||
import com.github.retrooper.packetevents.protocol.player.User;
|
|
||||||
import com.github.retrooper.packetevents.wrapper.play.server.*;
|
|
||||||
import me.tofaa.entitylib.TrackedEntity;
|
|
||||||
import me.tofaa.entitylib.event.types.UserStopTrackingEntityEvent;
|
|
||||||
import me.tofaa.entitylib.event.types.UserTrackingEntityEvent;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
|
||||||
|
|
||||||
final class InternalRegistryListener extends PacketListenerAbstract implements Listener {
|
|
||||||
|
|
||||||
private SpigotEntityLibPlatform platform;
|
|
||||||
|
|
||||||
InternalRegistryListener(SpigotEntityLibPlatform platform) {
|
|
||||||
this.platform = platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPacketSend(PacketSendEvent event) {
|
|
||||||
final User user = event.getUser();
|
|
||||||
final PacketTypeCommon type = event.getPacketType();
|
|
||||||
|
|
||||||
if (type == PacketType.Play.Server.DESTROY_ENTITIES) {
|
|
||||||
WrapperPlayServerDestroyEntities packet = new WrapperPlayServerDestroyEntities(event);
|
|
||||||
int[] ids = packet.getEntityIds();
|
|
||||||
Bukkit.getScheduler().runTaskLater(platform.getHandle(), () -> {
|
|
||||||
for (int id : ids) {
|
|
||||||
TrackedEntity tracked = findTracker(id);
|
|
||||||
if (tracked == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
platform.getEventHandler().callEvent(UserStopTrackingEntityEvent.class, new UserStopTrackingEntityEvent(user, tracked));
|
|
||||||
}
|
|
||||||
}, 2L);
|
|
||||||
}
|
|
||||||
else if (type == PacketType.Play.Server.SPAWN_ENTITY) {
|
|
||||||
WrapperPlayServerSpawnEntity packet = new WrapperPlayServerSpawnEntity(event);
|
|
||||||
int id = packet.getEntityId();
|
|
||||||
trackEntity(user, id);
|
|
||||||
}
|
|
||||||
else if (type == PacketType.Play.Server.SPAWN_EXPERIENCE_ORB) {
|
|
||||||
WrapperPlayServerSpawnExperienceOrb packet = new WrapperPlayServerSpawnExperienceOrb(event);
|
|
||||||
int id = packet.getEntityId();
|
|
||||||
trackEntity(user, id);
|
|
||||||
}
|
|
||||||
else if (type == PacketType.Play.Server.SPAWN_LIVING_ENTITY) {
|
|
||||||
WrapperPlayServerSpawnLivingEntity packet = new WrapperPlayServerSpawnLivingEntity(event);
|
|
||||||
int id = packet.getEntityId();
|
|
||||||
trackEntity(user, id);
|
|
||||||
}
|
|
||||||
else if (type == PacketType.Play.Server.SPAWN_PLAYER) {
|
|
||||||
WrapperPlayServerSpawnPlayer packet = new WrapperPlayServerSpawnPlayer(event);
|
|
||||||
int id = packet.getEntityId();
|
|
||||||
trackEntity(user, id);
|
|
||||||
}
|
|
||||||
else if (type == PacketType.Play.Server.SPAWN_WEATHER_ENTITY) {
|
|
||||||
WrapperPlayServerSpawnWeatherEntity packet = new WrapperPlayServerSpawnWeatherEntity(event);
|
|
||||||
int id = packet.getEntityId();
|
|
||||||
trackEntity(user, id);
|
|
||||||
}
|
|
||||||
else if (type == PacketType.Play.Server.SPAWN_PAINTING) {
|
|
||||||
WrapperPlayServerSpawnPainting packet = new WrapperPlayServerSpawnPainting(event);
|
|
||||||
int id = packet.getEntityId();
|
|
||||||
trackEntity(user, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void trackEntity(User user, int id) {
|
|
||||||
Bukkit.getScheduler().runTaskLater(platform.getHandle(), () -> {
|
|
||||||
TrackedEntity entity = findTracker(id);
|
|
||||||
if (entity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
platform.getEventHandler().callEvent(UserTrackingEntityEvent.class, new UserTrackingEntityEvent(user, entity));
|
|
||||||
}, 2L);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TrackedEntity findTracker(int id) {
|
|
||||||
TrackedEntity entity = platform.findPlatformEntity(id);
|
|
||||||
if (entity == null) {
|
|
||||||
entity = platform.getAPI().getEntity(id);
|
|
||||||
}
|
|
||||||
if (entity == null) {
|
|
||||||
if (platform.getAPI().getSettings().isDebugMode()) {
|
|
||||||
platform.getLogger().warning("Failed to find entity with id " + id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
|
||||||
Entity e = event.getEntity();
|
|
||||||
platform.getPlatformEntities().put(e.getEntityId(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package me.tofaa.entitylib.spigot;
|
|
||||||
|
|
||||||
import me.tofaa.entitylib.common.AbstractTrackedEntity;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class SpigotEntity extends AbstractTrackedEntity<Entity> {
|
|
||||||
|
|
||||||
public SpigotEntity(@NotNull Entity platformEntity) {
|
|
||||||
super(platformEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEntityId() {
|
|
||||||
return getPlatformEntity().getEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull UUID getUuid() {
|
|
||||||
return getPlatformEntity().getUniqueId();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,6 @@ import io.github.retrooper.packetevents.bstats.bukkit.Metrics;
|
||||||
import io.github.retrooper.packetevents.bstats.charts.SimplePie;
|
import io.github.retrooper.packetevents.bstats.charts.SimplePie;
|
||||||
import me.tofaa.entitylib.APIConfig;
|
import me.tofaa.entitylib.APIConfig;
|
||||||
import me.tofaa.entitylib.EntityLib;
|
import me.tofaa.entitylib.EntityLib;
|
||||||
import me.tofaa.entitylib.TrackedEntity;
|
|
||||||
import me.tofaa.entitylib.common.AbstractPlatform;
|
import me.tofaa.entitylib.common.AbstractPlatform;
|
||||||
import me.tofaa.entitylib.utils.ConcurrentWeakIdentityHashMap;
|
import me.tofaa.entitylib.utils.ConcurrentWeakIdentityHashMap;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -23,7 +22,6 @@ import java.util.stream.Stream;
|
||||||
public class SpigotEntityLibPlatform extends AbstractPlatform<JavaPlugin> {
|
public class SpigotEntityLibPlatform extends AbstractPlatform<JavaPlugin> {
|
||||||
|
|
||||||
private SpigotEntityLibAPI api;
|
private SpigotEntityLibAPI api;
|
||||||
private final Map<Integer, Entity> platformEntities = new ConcurrentWeakIdentityHashMap<>();
|
|
||||||
|
|
||||||
public SpigotEntityLibPlatform(@NotNull JavaPlugin plugin) {
|
public SpigotEntityLibPlatform(@NotNull JavaPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
@ -36,12 +34,6 @@ public class SpigotEntityLibPlatform extends AbstractPlatform<JavaPlugin> {
|
||||||
this.api = new SpigotEntityLibAPI(this, settings);
|
this.api = new SpigotEntityLibAPI(this, settings);
|
||||||
this.api.onLoad();
|
this.api.onLoad();
|
||||||
this.api.onEnable();
|
this.api.onEnable();
|
||||||
|
|
||||||
if (settings.shouldTrackPlatformEntities()) {
|
|
||||||
InternalRegistryListener listener = new InternalRegistryListener(this);
|
|
||||||
handle.getServer().getPluginManager().registerEvents(listener, handle);
|
|
||||||
api.getPacketEvents().getEventManager().registerListener(listener);
|
|
||||||
}
|
|
||||||
if (settings.shouldUseBstats()) {
|
if (settings.shouldUseBstats()) {
|
||||||
PacketEventsAPI<Plugin> pe = (PacketEventsAPI<Plugin>)api.getPacketEvents();
|
PacketEventsAPI<Plugin> pe = (PacketEventsAPI<Plugin>)api.getPacketEvents();
|
||||||
Metrics metrics = new Metrics(pe.getPlugin(), 21916);
|
Metrics metrics = new Metrics(pe.getPlugin(), 21916);
|
||||||
|
@ -50,33 +42,6 @@ public class SpigotEntityLibPlatform extends AbstractPlatform<JavaPlugin> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<Integer, Entity> getPlatformEntities() {
|
|
||||||
return platformEntities;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Stream<TrackedEntity> queryPlatformEntities() {
|
|
||||||
if (!api.getSettings().shouldTrackPlatformEntities()) return Stream.of();
|
|
||||||
return platformEntities.values().stream().map(SpigotEntity::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable TrackedEntity findPlatformEntity(final int entityId) {
|
|
||||||
if (!api.getSettings().shouldTrackPlatformEntities()) return null;
|
|
||||||
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
|
||||||
Entity e = world.getEntities().stream().filter(entity -> entity.getEntityId() == entityId).findFirst().orElse(null);
|
|
||||||
if (e != null) {
|
|
||||||
return new SpigotEntity(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
// Entity e = platformEntities.get(entityId);
|
|
||||||
// if (e == null) return null;
|
|
||||||
// return new SpigotEntity(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpigotEntityLibAPI getAPI() {
|
public SpigotEntityLibAPI getAPI() {
|
||||||
return api;
|
return api;
|
||||||
|
|
|
@ -29,7 +29,7 @@ tasks {
|
||||||
)
|
)
|
||||||
|
|
||||||
val sharedBukkitPlugins = runPaper.downloadPluginsSpec {
|
val sharedBukkitPlugins = runPaper.downloadPluginsSpec {
|
||||||
modrinth("packetevents", "MfD5eOYA")
|
modrinth("packetevents", "3Jr8ovul")
|
||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
|
|
|
@ -1,26 +1,14 @@
|
||||||
package me.tofaa.testentitylib;
|
package me.tofaa.testentitylib;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.PacketEvents;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
|
||||||
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
|
||||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
|
||||||
import me.tofaa.entitylib.APIConfig;
|
import me.tofaa.entitylib.APIConfig;
|
||||||
import me.tofaa.entitylib.EntityLib;
|
import me.tofaa.entitylib.EntityLib;
|
||||||
import me.tofaa.entitylib.event.types.UserTrackingEntityEvent;
|
|
||||||
import me.tofaa.entitylib.spigot.SpigotEntityLibAPI;
|
|
||||||
import me.tofaa.entitylib.spigot.SpigotEntityLibPlatform;
|
import me.tofaa.entitylib.spigot.SpigotEntityLibPlatform;
|
||||||
import me.tofaa.entitylib.wrapper.WrapperPlayer;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class TestEntityLibPlugin extends JavaPlugin {
|
public class TestEntityLibPlugin extends JavaPlugin {
|
||||||
|
|
||||||
|
@ -32,7 +20,6 @@ public class TestEntityLibPlugin extends JavaPlugin {
|
||||||
.debugMode()
|
.debugMode()
|
||||||
.checkForUpdates()
|
.checkForUpdates()
|
||||||
.tickTickables()
|
.tickTickables()
|
||||||
.trackPlatformEntities()
|
|
||||||
.useBstats()
|
.useBstats()
|
||||||
.usePlatformLogger();
|
.usePlatformLogger();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue