mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 02:25:57 +01:00
Trial removing Player NPCs from the paper per-player mob limits
This commit is contained in:
parent
ec4ba73ada
commit
708bf13afd
@ -282,6 +282,11 @@ public class CitizensNPC extends AbstractNPC {
|
||||
getOrAddTrait(SneakTrait.class).setSneaking(sneaking);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRemoveFromPlayerList() {
|
||||
return data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST, Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRemoveFromTabList() {
|
||||
return data().get(NPC.Metadata.REMOVE_FROM_TABLIST, Setting.DISABLE_TABLIST.asBoolean());
|
||||
|
@ -375,6 +375,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
if (!npc.hasTrait(EntityPoseTrait.class) || npc.getTraitNullable(EntityPoseTrait.class).getPose() == null) {
|
||||
eu();
|
||||
}
|
||||
if (NMSImpl.PAPER_PLAYER_MOB_COUNTS != null && npc.shouldRemoveFromPlayerList()) {
|
||||
int[] counts;
|
||||
try {
|
||||
counts = (int[]) NMSImpl.PAPER_PLAYER_MOB_COUNTS.invoke(this);
|
||||
for (int i = 0; i < counts.length; i++) {
|
||||
counts[i] = 0;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePackets(boolean navigating) {
|
||||
|
@ -2367,6 +2367,7 @@ public class NMSImpl implements NMSBridge {
|
||||
private static final MethodHandle NAVIGATION_S = NMS.getFinalSetter(NavigationAbstract.class, "s");
|
||||
private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getSetter(NavigationAbstract.class, "b");
|
||||
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
|
||||
public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(EntityPlayer.class, "mobCounts");
|
||||
private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_GETTER = NMS.getGetter(PlayerChunkMap.class,
|
||||
"viewDistance");
|
||||
private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_SETTER = NMS.getSetter(PlayerChunkMap.class,
|
||||
|
@ -366,6 +366,17 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
Bukkit.getServer().getPluginManager().unsubscribeFromPermission("bukkit.broadcast.user", getBukkitEntity());
|
||||
updatePackets(npc.getNavigator().isNavigating());
|
||||
npc.update();
|
||||
if (NMSImpl.PAPER_PLAYER_MOB_COUNTS != null && npc.shouldRemoveFromPlayerList()) {
|
||||
int[] counts;
|
||||
try {
|
||||
counts = (int[]) NMSImpl.PAPER_PLAYER_MOB_COUNTS.invoke(this);
|
||||
for (int i = 0; i < counts.length; i++) {
|
||||
counts[i] = 0;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2345,6 +2345,7 @@ public class NMSImpl implements NMSBridge {
|
||||
private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFinalSetter(PathNavigation.class, "t");
|
||||
private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class);
|
||||
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
|
||||
public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts");
|
||||
private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_GETTER = NMS.getGetter(ChunkMap.class, "J");
|
||||
private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_SETTER = NMS.getSetter(ChunkMap.class, "J");
|
||||
private static final MethodHandle PUFFERFISH_C = NMS.getSetter(Pufferfish.class, "bU");
|
||||
|
@ -363,6 +363,17 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
Bukkit.getServer().getPluginManager().unsubscribeFromPermission("bukkit.broadcast.user", getBukkitEntity());
|
||||
updatePackets(npc.getNavigator().isNavigating());
|
||||
npc.update();
|
||||
if (NMSImpl.PAPER_PLAYER_MOB_COUNTS != null && npc.shouldRemoveFromPlayerList()) {
|
||||
int[] counts;
|
||||
try {
|
||||
counts = (int[]) NMSImpl.PAPER_PLAYER_MOB_COUNTS.invoke(this);
|
||||
for (int i = 0; i < counts.length; i++) {
|
||||
counts[i] = 0;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,9 +48,7 @@ public class HumanController extends AbstractEntityController {
|
||||
if (getBukkitEntity() == null || !getBukkitEntity().isValid()
|
||||
|| getBukkitEntity() != handle.getBukkitEntity())
|
||||
return;
|
||||
boolean removeFromPlayerList = npc.data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST,
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), npc.shouldRemoveFromPlayerList());
|
||||
}, 20);
|
||||
handle.getBukkitEntity().setSleepingIgnored(true);
|
||||
return handle.getBukkitEntity();
|
||||
|
@ -2394,6 +2394,7 @@ public class NMSImpl implements NMSBridge {
|
||||
private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFinalSetter(PathNavigation.class, "t");
|
||||
private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class);
|
||||
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
|
||||
public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts");
|
||||
private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_GETTER = NMS.getGetter(ChunkMap.class, "N");
|
||||
private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_SETTER = NMS.getSetter(ChunkMap.class, "N");
|
||||
private static MethodHandle PORTAL_ENTRANCE_POS_GETTER = NMS.getGetter(Entity.class, "ai");
|
||||
|
@ -372,6 +372,17 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
Bukkit.getServer().getPluginManager().unsubscribeFromPermission("bukkit.broadcast.user", getBukkitEntity());
|
||||
updatePackets(npc.getNavigator().isNavigating());
|
||||
npc.update();
|
||||
if (NMSImpl.PAPER_PLAYER_MOB_COUNTS != null && npc.shouldRemoveFromPlayerList()) {
|
||||
int[] counts;
|
||||
try {
|
||||
counts = (int[]) NMSImpl.PAPER_PLAYER_MOB_COUNTS.invoke(this);
|
||||
for (int i = 0; i < counts.length; i++) {
|
||||
counts[i] = 0;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,9 +48,7 @@ public class HumanController extends AbstractEntityController {
|
||||
if (getBukkitEntity() == null || !getBukkitEntity().isValid()
|
||||
|| getBukkitEntity() != handle.getBukkitEntity())
|
||||
return;
|
||||
boolean removeFromPlayerList = npc.data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST,
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), npc.shouldRemoveFromPlayerList());
|
||||
}, 20);
|
||||
handle.getBukkitEntity().setSleepingIgnored(true);
|
||||
return handle.getBukkitEntity();
|
||||
|
@ -2632,6 +2632,7 @@ public class NMSImpl implements NMSBridge {
|
||||
private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFirstFinalSetter(PathNavigation.class,
|
||||
PathFinder.class);
|
||||
private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class);
|
||||
public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts");
|
||||
private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_GETTER = NMS.getFirstGetter(ChunkMap.class,
|
||||
int.class);
|
||||
private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_SETTER = NMS.getFirstSetter(ChunkMap.class,
|
||||
|
@ -377,6 +377,17 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
Bukkit.getServer().getPluginManager().unsubscribeFromPermission("bukkit.broadcast.user", getBukkitEntity());
|
||||
updatePackets(npc.getNavigator().isNavigating());
|
||||
npc.update();
|
||||
if (NMSImpl.PAPER_PLAYER_MOB_COUNTS != null && npc.shouldRemoveFromPlayerList()) {
|
||||
int[] counts;
|
||||
try {
|
||||
counts = (int[]) NMSImpl.PAPER_PLAYER_MOB_COUNTS.invoke(this);
|
||||
for (int i = 0; i < counts.length; i++) {
|
||||
counts[i] = 0;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,9 +50,7 @@ public class HumanController extends AbstractEntityController {
|
||||
if (getBukkitEntity() == null || !getBukkitEntity().isValid()
|
||||
|| getBukkitEntity() != handle.getBukkitEntity())
|
||||
return;
|
||||
boolean removeFromPlayerList = npc.data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST,
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), npc.shouldRemoveFromPlayerList());
|
||||
}, 20);
|
||||
handle.getBukkitEntity().setSleepingIgnored(true);
|
||||
return handle.getBukkitEntity();
|
||||
|
@ -2723,9 +2723,10 @@ public class NMSImpl implements NMSBridge {
|
||||
private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFirstFinalSetter(PathNavigation.class,
|
||||
PathFinder.class);
|
||||
private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class);
|
||||
public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts");
|
||||
|
||||
private static final MethodHandle PLAYER_INFO_ENTRIES_LIST = NMS
|
||||
.getFirstFinalSetter(ClientboundPlayerInfoUpdatePacket.class, List.class);
|
||||
|
||||
private static final MethodHandle PLAYERINFO_ENTRIES = PLAYER_INFO_ENTRIES_LIST;
|
||||
private static final MethodHandle PORTAL_ENTRANCE_POS_GETTER = NMS.getGetter(Entity.class, "ay");
|
||||
private static final MethodHandle PORTAL_ENTRANCE_POS_SETTER = NMS.getSetter(Entity.class, "ay");
|
||||
|
@ -376,6 +376,17 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
Bukkit.getServer().getPluginManager().unsubscribeFromPermission("bukkit.broadcast.user", getBukkitEntity());
|
||||
updatePackets(npc.getNavigator().isNavigating());
|
||||
npc.update();
|
||||
if (NMSImpl.PAPER_PLAYER_MOB_COUNTS != null && npc.shouldRemoveFromPlayerList()) {
|
||||
int[] counts;
|
||||
try {
|
||||
counts = (int[]) NMSImpl.PAPER_PLAYER_MOB_COUNTS.invoke(this);
|
||||
for (int i = 0; i < counts.length; i++) {
|
||||
counts[i] = 0;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,9 +50,7 @@ public class HumanController extends AbstractEntityController {
|
||||
if (getBukkitEntity() == null || !getBukkitEntity().isValid()
|
||||
|| getBukkitEntity() != handle.getBukkitEntity())
|
||||
return;
|
||||
boolean removeFromPlayerList = npc.data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST,
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), npc.shouldRemoveFromPlayerList());
|
||||
}, 20);
|
||||
handle.getBukkitEntity().setSleepingIgnored(true);
|
||||
return handle.getBukkitEntity();
|
||||
|
@ -612,6 +612,12 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSBoundingBox.wrap(getHandle(handle).getBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(Object data) {
|
||||
return NMSBoundingBox.wrap(((CraftBlockData) data).getState()
|
||||
.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty()).bounds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
|
||||
ServerLevel world = ((CraftWorld) block.getWorld()).getHandle();
|
||||
@ -619,12 +625,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return shape.isEmpty() ? BoundingBox.EMPTY : NMSBoundingBox.wrap(shape.bounds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(Object data) {
|
||||
return NMSBoundingBox.wrap(((CraftBlockData) data).getState()
|
||||
.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty()).bounds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getComponentMap(org.bukkit.inventory.ItemStack item) {
|
||||
if (META_COMPOUND_TAG == null) {
|
||||
@ -2651,6 +2651,7 @@ public class NMSImpl implements NMSBridge {
|
||||
|
||||
private static final MethodHandle ATTRIBUTE_SUPPLIER = NMS.getFirstGetter(AttributeMap.class,
|
||||
AttributeSupplier.class);
|
||||
|
||||
private static final MethodHandle AVAILABLE_BEHAVIORS_BY_PRIORITY = NMS.getGetter(Brain.class, "f");
|
||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.BEE,
|
||||
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
|
||||
@ -2704,6 +2705,7 @@ public class NMSImpl implements NMSBridge {
|
||||
private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFirstFinalSetter(PathNavigation.class,
|
||||
PathFinder.class);
|
||||
private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class);
|
||||
public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts");
|
||||
private static final MethodHandle PLAYER_INFO_ENTRIES_LIST = NMS
|
||||
.getFirstFinalSetter(ClientboundPlayerInfoUpdatePacket.class, List.class);
|
||||
private static final MethodHandle PLAYERINFO_ENTRIES = PLAYER_INFO_ENTRIES_LIST;
|
||||
|
Loading…
Reference in New Issue
Block a user