huge reflection refactor, major improvement to maintainability
This commit is contained in:
parent
8506aa99bc
commit
d9bde3d442
28 changed files with 715 additions and 827 deletions
|
@ -1,13 +1,11 @@
|
|||
package io.github.znetworkw.znpcservers.commands;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import io.github.znetworkw.znpcservers.reflection.ReflectionCache;
|
||||
import io.github.znetworkw.znpcservers.commands.exception.CommandException;
|
||||
import io.github.znetworkw.znpcservers.commands.exception.CommandExecuteException;
|
||||
import io.github.znetworkw.znpcservers.commands.exception.CommandPermissionException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
|
||||
|
@ -16,16 +14,6 @@ import java.util.*;
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Command extends BukkitCommand {
|
||||
private static final CommandMap COMMAND_MAP;
|
||||
|
||||
static {
|
||||
try {
|
||||
COMMAND_MAP = (CommandMap) ReflectionCache.BUKKIT_COMMAND_MAP.load().get(Bukkit.getServer());
|
||||
} catch (IllegalAccessException exception) {
|
||||
throw new IllegalStateException("Unable to register Bukkit command map.");
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<CommandInformation, CommandInvoker> subCommands;
|
||||
|
||||
public Command(String name) {
|
||||
|
@ -35,7 +23,7 @@ public class Command extends BukkitCommand {
|
|||
}
|
||||
|
||||
private void load() {
|
||||
COMMAND_MAP.register(getName(), this);
|
||||
Bukkit.getCommandMap().register(getName(), this);
|
||||
for (Method method : getClass().getMethods()) {
|
||||
if (method.isAnnotationPresent(CommandInformation.class)) {
|
||||
CommandInformation cmdInfo = method.getAnnotation(CommandInformation.class);
|
||||
|
@ -48,8 +36,7 @@ public class Command extends BukkitCommand {
|
|||
int size = Iterables.size(args);
|
||||
int subCommandsSize = (subCommand.arguments()).length;
|
||||
Map<String, String> argsMap = new HashMap<>();
|
||||
if (size > 1)
|
||||
if (subCommand.isMultiple()) {
|
||||
if (size > 1) if (subCommand.isMultiple()) {
|
||||
argsMap.put(Iterables.get(args, 1), String.join(" ", Iterables.skip(args, 2)));
|
||||
} else {
|
||||
for (int i = 0; i < Math.min(subCommandsSize, size); i++) {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package io.github.znetworkw.znpcservers.npc;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import io.github.znetworkw.znpcservers.reflection.ReflectionBasePackage;
|
||||
import io.github.znetworkw.znpcservers.reflection.TypeCache;
|
||||
import io.github.znetworkw.znpcservers.reflection.ReflectionBuilder;
|
||||
import io.github.znetworkw.znpcservers.reflection.ReflectionPackage;
|
||||
import io.github.znetworkw.znpcservers.reflection.types.EnumReflection;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
|
@ -32,8 +33,7 @@ public class CustomizationLoader {
|
|||
for (Class<?> parameter : method.getParameterTypes()) {
|
||||
TypeProperty typeProperty = TypeProperty.forType(parameter);
|
||||
if (typeProperty == null && parameter.isEnum())
|
||||
(new TypeCache.BaseReflection.EnumReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.DEFAULT))
|
||||
.withClassName(parameter.getTypeName()))).load();
|
||||
new EnumReflection(new ReflectionBuilder(ReflectionPackage.MINECRAFT).withClassName(parameter)).get();
|
||||
}
|
||||
builder.put(method.getName(), method);
|
||||
}
|
||||
|
|
|
@ -137,8 +137,8 @@ public class NPC {
|
|||
if (updateTime) this.lastMove = System.nanoTime();
|
||||
this.npcPojo.setLocation(new ZLocation(location = new Location(location.getWorld(), location.getBlockX() + 0.5D, location.getY(), location.getBlockZ() + 0.5D, location.getYaw(), location.getPitch())));
|
||||
}
|
||||
ReflectionCache.SET_LOCATION_METHOD.load().invoke(this.nmsEntity, location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
Object npcTeleportPacket = ReflectionCache.PACKET_PLAY_OUT_ENTITY_TELEPORT_CONSTRUCTOR.load().newInstance(this.nmsEntity);
|
||||
ReflectionCache.SET_LOCATION_METHOD.get().invoke(this.nmsEntity, location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
Object npcTeleportPacket = ReflectionCache.PACKET_PLAY_OUT_ENTITY_TELEPORT_CONSTRUCTOR.get().newInstance(this.nmsEntity);
|
||||
this.viewers.forEach(player -> Utils.sendPackets(player, npcTeleportPacket));
|
||||
this.hologram.setLocation(location, this.npcPojo.getNpcType().getHoloHeight());
|
||||
} catch (ReflectiveOperationException operationException) {
|
||||
|
@ -157,13 +157,13 @@ public class NPC {
|
|||
|
||||
public void setSecondLayerSkin() {
|
||||
try {
|
||||
Object dataWatcherObject = ReflectionCache.GET_DATA_WATCHER_METHOD.load().invoke(this.nmsEntity);
|
||||
Object dataWatcherObject = ReflectionCache.GET_DATA_WATCHER_METHOD.get().invoke(this.nmsEntity);
|
||||
if (Utils.versionNewer(9)) {
|
||||
ReflectionCache.SET_DATA_WATCHER_METHOD.load().invoke(dataWatcherObject,
|
||||
ReflectionCache.DATA_WATCHER_OBJECT_CONSTRUCTOR.load()
|
||||
.newInstance(this.npcSkin.getLayerIndex(), ReflectionCache.DATA_WATCHER_REGISTER_FIELD.load()), (byte) 127);
|
||||
ReflectionCache.SET_DATA_WATCHER_METHOD.get().invoke(dataWatcherObject,
|
||||
ReflectionCache.DATA_WATCHER_OBJECT_CONSTRUCTOR.get()
|
||||
.newInstance(this.npcSkin.getLayerIndex(), ReflectionCache.DATA_WATCHER_REGISTER_FIELD.get()), (byte) 127);
|
||||
} else {
|
||||
ReflectionCache.WATCH_DATA_WATCHER_METHOD.load().invoke(dataWatcherObject, 10, (byte) 127);
|
||||
ReflectionCache.WATCH_DATA_WATCHER_METHOD.get().invoke(dataWatcherObject, 10, (byte) 127);
|
||||
}
|
||||
} catch (ReflectiveOperationException operationException) {
|
||||
throw new UnexpectedCallException(operationException);
|
||||
|
@ -173,24 +173,24 @@ public class NPC {
|
|||
public synchronized void changeType(NPCType npcType) {
|
||||
deleteViewers();
|
||||
try {
|
||||
Object nmsWorld = ReflectionCache.GET_HANDLE_WORLD_METHOD.load().invoke(getLocation().getWorld());
|
||||
Object nmsWorld = ReflectionCache.GET_HANDLE_WORLD_METHOD.get().invoke(getLocation().getWorld());
|
||||
boolean isPlayer = (npcType == NPCType.PLAYER);
|
||||
this.nmsEntity = isPlayer ? this.packets.getProxyInstance().getPlayerPacket(nmsWorld, this.gameProfile) : (Utils.versionNewer(14) ? npcType.getConstructor().newInstance(npcType.getNmsEntityType(), nmsWorld) : npcType.getConstructor().newInstance(nmsWorld));
|
||||
this.bukkitEntity = ReflectionCache.GET_BUKKIT_ENTITY_METHOD.load().invoke(this.nmsEntity);
|
||||
this.uuid = (UUID) ReflectionCache.GET_UNIQUE_ID_METHOD.load().invoke(this.nmsEntity, new Object[0]);
|
||||
this.bukkitEntity = ReflectionCache.GET_BUKKIT_ENTITY_METHOD.get().invoke(this.nmsEntity);
|
||||
this.uuid = (UUID) ReflectionCache.GET_UNIQUE_ID_METHOD.get().invoke(this.nmsEntity, new Object[0]);
|
||||
if (isPlayer) {
|
||||
try {
|
||||
this.tabConstructor = ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.load().newInstance(ReflectionCache.ADD_PLAYER_FIELD.load(), Collections.singletonList(this.nmsEntity));
|
||||
this.tabConstructor = ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.get().newInstance(ReflectionCache.ADD_PLAYER_FIELD.get(), Collections.singletonList(this.nmsEntity));
|
||||
} catch (Throwable e) {
|
||||
this.tabConstructor = ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.load().newInstance(ReflectionCache.ADD_PLAYER_FIELD.load(), this.nmsEntity);
|
||||
this.updateTabConstructor = ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.load().newInstance(ReflectionCache.UPDATE_LISTED_FIELD.load(), this.nmsEntity);
|
||||
this.tabConstructor = ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.get().newInstance(ReflectionCache.ADD_PLAYER_FIELD.get(), this.nmsEntity);
|
||||
this.updateTabConstructor = ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.get().newInstance(ReflectionCache.UPDATE_LISTED_FIELD.get(), this.nmsEntity);
|
||||
}
|
||||
setSecondLayerSkin();
|
||||
}
|
||||
this.npcPojo.setNpcType(npcType);
|
||||
setLocation(getLocation(), false);
|
||||
this.packets.flushCache("spawnPacket", "removeTab");
|
||||
this.entityID = (Integer) ReflectionCache.GET_ENTITY_ID.load().invoke(this.nmsEntity, new Object[0]);
|
||||
this.entityID = (Integer) ReflectionCache.GET_ENTITY_ID.get().invoke(this.nmsEntity, new Object[0]);
|
||||
FunctionFactory.findFunctionsForNpc(this).forEach(function -> function.resolve(this));
|
||||
getPackets().getProxyInstance().update(this.packets);
|
||||
this.hologram.createHologram();
|
||||
|
@ -248,8 +248,8 @@ public class NPC {
|
|||
if (this.lastMove > 1L && lastMoveNanos < 1000000000L) return;
|
||||
Location direction = rotation ? location : this.npcPojo.getLocation().bukkitLocation().clone().setDirection(location.clone().subtract(this.npcPojo.getLocation().bukkitLocation().clone()).toVector());
|
||||
try {
|
||||
Object lookPacket = ReflectionCache.PACKET_PLAY_OUT_ENTITY_LOOK_CONSTRUCTOR.load().newInstance(this.entityID, (byte) (int) (direction.getYaw() * 256.0F / 360.0F), (byte) (int) (direction.getPitch() * 256.0F / 360.0F), true);
|
||||
Object headRotationPacket = ReflectionCache.PACKET_PLAY_OUT_ENTITY_HEAD_ROTATION_CONSTRUCTOR.load().newInstance(this.nmsEntity, (byte) (int) (direction.getYaw() * 256.0F / 360.0F));
|
||||
Object lookPacket = ReflectionCache.PACKET_PLAY_OUT_ENTITY_LOOK_CONSTRUCTOR.get().newInstance(this.entityID, (byte) (int) (direction.getYaw() * 256.0F / 360.0F), (byte) (int) (direction.getPitch() * 256.0F / 360.0F), true);
|
||||
Object headRotationPacket = ReflectionCache.PACKET_PLAY_OUT_ENTITY_HEAD_ROTATION_CONSTRUCTOR.get().newInstance(this.nmsEntity, (byte) (int) (direction.getYaw() * 256.0F / 360.0F));
|
||||
if (player != null) Utils.sendPackets(player, lookPacket, headRotationPacket);
|
||||
else this.viewers.forEach(players -> Utils.sendPackets(players, headRotationPacket));
|
||||
} catch (ReflectiveOperationException operationException) {
|
||||
|
@ -275,7 +275,7 @@ public class NPC {
|
|||
public void updateProfile(PropertyMap propertyMap) {
|
||||
if (this.npcPojo.getNpcType() != NPCType.PLAYER) return;
|
||||
try {
|
||||
Object gameProfileObj = ReflectionCache.GET_PROFILE_METHOD.load().invoke(this.nmsEntity);
|
||||
Object gameProfileObj = ReflectionCache.GET_PROFILE_METHOD.get().invoke(this.nmsEntity);
|
||||
Utils.setValue(gameProfileObj, "name", this.gameProfile.getName());
|
||||
Utils.setValue(gameProfileObj, "id", this.gameProfile.getId());
|
||||
Utils.setValue(gameProfileObj, "properties", propertyMap);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.github.znetworkw.znpcservers.npc;
|
||||
|
||||
import io.github.znetworkw.znpcservers.UnexpectedCallException;
|
||||
import io.github.znetworkw.znpcservers.reflection.TypeCache;
|
||||
import io.github.znetworkw.znpcservers.reflection.ClassCache;
|
||||
import io.github.znetworkw.znpcservers.utility.Utils;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
|
@ -81,7 +81,7 @@ public enum NPCType {
|
|||
}
|
||||
try {
|
||||
if (Utils.versionNewer(14)) {
|
||||
this.nmsEntityType = ((Optional<?>) ENTITY_TYPES_A_METHOD.load().invoke(null, this.bukkitEntityType.getKey().getKey().toLowerCase())).get();
|
||||
this.nmsEntityType = ((Optional<?>) ENTITY_TYPES_A_METHOD.get().invoke(null, this.bukkitEntityType.getKey().getKey().toLowerCase())).get();
|
||||
this.constructor = entityClass.getConstructor(ENTITY_TYPES_CLASS, WORLD_CLASS);
|
||||
} else {
|
||||
this.constructor = entityClass.getConstructor(WORLD_CLASS);
|
||||
|
@ -117,7 +117,7 @@ public enum NPCType {
|
|||
Object[] newArray = new Object[methodParameterTypes.length];
|
||||
for (int i = 0; i < methodParameterTypes.length; ++i) {
|
||||
TypeProperty typeProperty = TypeProperty.forType(methodParameterTypes[i]);
|
||||
newArray[i] = typeProperty != null ? typeProperty.getFunction().apply(strings[i]) : TypeCache.ClassCache.find(strings[i], methodParameterTypes[i]);
|
||||
newArray[i] = typeProperty != null ? typeProperty.getFunction().apply(strings[i]) : ClassCache.find(strings[i], methodParameterTypes[i]);
|
||||
}
|
||||
return newArray;
|
||||
}
|
||||
|
|
|
@ -16,16 +16,16 @@ public class GlowFunction extends NPCFunction {
|
|||
throw new IllegalStateException("invalid context type, " + functionContext.getClass().getSimpleName() + ", expected ContextWithValue.");
|
||||
String glowColorName = ((FunctionContext.ContextWithValue) functionContext).getValue();
|
||||
try {
|
||||
Object glowColor = ReflectionCache.ENUM_CHAT_FORMAT_FIND.load().invoke(null, (
|
||||
Object glowColor = ReflectionCache.ENUM_CHAT_FORMAT_FIND.get().invoke(null, (
|
||||
glowColorName == null || glowColorName.length() == 0) ? "WHITE" : glowColorName);
|
||||
if (glowColor == null)
|
||||
return NPCFunction.ResultType.FAIL;
|
||||
npc.getNpcPojo().setGlowName(glowColorName);
|
||||
npc.setGlowColor(glowColor);
|
||||
ReflectionCache.SET_DATA_WATCHER_METHOD.load().invoke(ReflectionCache.GET_DATA_WATCHER_METHOD
|
||||
.load().invoke(npc.getNmsEntity()), ReflectionCache.DATA_WATCHER_OBJECT_CONSTRUCTOR
|
||||
.load().newInstance(0, ReflectionCache.DATA_WATCHER_REGISTER_FIELD
|
||||
.load()), (byte) (!FunctionFactory.isTrue(npc, this) ? 64 : 0));
|
||||
ReflectionCache.SET_DATA_WATCHER_METHOD.get().invoke(ReflectionCache.GET_DATA_WATCHER_METHOD
|
||||
.get().invoke(npc.getNmsEntity()), ReflectionCache.DATA_WATCHER_OBJECT_CONSTRUCTOR
|
||||
.get().newInstance(0, ReflectionCache.DATA_WATCHER_REGISTER_FIELD
|
||||
.get()), (byte) (!FunctionFactory.isTrue(npc, this) ? 64 : 0));
|
||||
npc.getPackets().getProxyInstance().update(npc.getPackets());
|
||||
npc.deleteViewers();
|
||||
return NPCFunction.ResultType.SUCCESS;
|
||||
|
|
|
@ -37,15 +37,15 @@ public class Hologram {
|
|||
Location location = this.npc.getLocation();
|
||||
for (String line : this.npc.getNpcPojo().getHologramLines()) {
|
||||
boolean visible = !line.equalsIgnoreCase("%space%");
|
||||
Object armorStand = ReflectionCache.ENTITY_CONSTRUCTOR.load().newInstance(ReflectionCache.GET_HANDLE_WORLD_METHOD.load().invoke(location.getWorld()),
|
||||
Object armorStand = ReflectionCache.ENTITY_CONSTRUCTOR.get().newInstance(ReflectionCache.GET_HANDLE_WORLD_METHOD.get().invoke(location.getWorld()),
|
||||
location.getX(), location.getY() - 0.15D + y, location.getZ());
|
||||
if (visible) {
|
||||
ReflectionCache.SET_CUSTOM_NAME_VISIBLE_METHOD.load().invoke(armorStand, true);
|
||||
ReflectionCache.SET_CUSTOM_NAME_VISIBLE_METHOD.get().invoke(armorStand, true);
|
||||
updateLine(line, armorStand, null);
|
||||
}
|
||||
ReflectionCache.SET_INVISIBLE_METHOD.load().invoke(armorStand, true);
|
||||
ReflectionCache.SET_INVISIBLE_METHOD.get().invoke(armorStand, true);
|
||||
this.hologramLines.add(new HologramLine(line.replace(ConfigurationConstants.SPACE_SYMBOL, " "), armorStand, (Integer) ReflectionCache.GET_ENTITY_ID
|
||||
.load().invoke(armorStand)));
|
||||
.get().invoke(armorStand)));
|
||||
y += LINE_SPACING;
|
||||
}
|
||||
setLocation(location, 0.0D);
|
||||
|
@ -92,7 +92,7 @@ public class Hologram {
|
|||
public void updateLocation() {
|
||||
this.hologramLines.forEach(hologramLine -> {
|
||||
try {
|
||||
Object packet = ReflectionCache.PACKET_PLAY_OUT_ENTITY_TELEPORT_CONSTRUCTOR.load().newInstance(hologramLine.armorStand);
|
||||
Object packet = ReflectionCache.PACKET_PLAY_OUT_ENTITY_TELEPORT_CONSTRUCTOR.get().newInstance(hologramLine.armorStand);
|
||||
this.npc.getViewers().forEach(player -> Utils.sendPackets(player, packet));
|
||||
}
|
||||
catch (ReflectiveOperationException operationException) {
|
||||
|
@ -106,7 +106,7 @@ public class Hologram {
|
|||
try {
|
||||
double y = this.npc.getNpcPojo().getHologramHeight();
|
||||
for (HologramLine hologramLine : this.hologramLines) {
|
||||
ReflectionCache.SET_LOCATION_METHOD.load().invoke(hologramLine.armorStand, location.getX(), location.getY() - 0.15 + y, location.getZ(), location.getYaw(), location.getPitch());
|
||||
ReflectionCache.SET_LOCATION_METHOD.get().invoke(hologramLine.armorStand, location.getX(), location.getY() - 0.15 + y, location.getZ(), location.getYaw(), location.getPitch());
|
||||
y += LINE_SPACING;
|
||||
}
|
||||
this.updateLocation();
|
||||
|
@ -118,9 +118,9 @@ public class Hologram {
|
|||
|
||||
private void updateLine(String line, Object armorStand, @Nullable ZUser user) throws InvocationTargetException, IllegalAccessException {
|
||||
if (NEW_METHOD) {
|
||||
ReflectionCache.SET_CUSTOM_NAME_NEW_METHOD.load().invoke(armorStand, ReflectionCache.CRAFT_CHAT_MESSAGE_METHOD.load().invoke(null, LineReplacer.makeAll(user, line)));
|
||||
ReflectionCache.SET_CUSTOM_NAME_NEW_METHOD.get().invoke(armorStand, ReflectionCache.CRAFT_CHAT_MESSAGE_METHOD.get().invoke(null, LineReplacer.makeAll(user, line)));
|
||||
} else {
|
||||
ReflectionCache.SET_CUSTOM_NAME_OLD_METHOD.load().invoke(armorStand, LineReplacer.makeAll(user, line));
|
||||
ReflectionCache.SET_CUSTOM_NAME_OLD_METHOD.get().invoke(armorStand, LineReplacer.makeAll(user, line));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public interface Packet {
|
|||
@SuppressWarnings("SuspiciousTernaryOperatorInVarargsCall")
|
||||
@PacketValue(keyName = "destroyPacket", valueType = ValueType.ARGUMENTS)
|
||||
default Object getDestroyPacket(int entityId) throws ReflectiveOperationException {
|
||||
return ReflectionCache.PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR.load().newInstance(ReflectionCache.PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR.load().getParameterTypes()[0].isArray() ? new int[] {entityId} : entityId);
|
||||
return ReflectionCache.PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR.get().newInstance(ReflectionCache.PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR.get().getParameterTypes()[0].isArray() ? new int[] {entityId} : entityId);
|
||||
}
|
||||
|
||||
@PacketValue(keyName = "enumSlot", valueType = ValueType.ARGUMENTS)
|
||||
|
@ -46,11 +46,11 @@ public interface Packet {
|
|||
@PacketValue(keyName = "removeTab")
|
||||
default Object getTabRemovePacket(Object nmsEntity) throws ReflectiveOperationException {
|
||||
try {
|
||||
return ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.load().newInstance(ReflectionCache.REMOVE_PLAYER_FIELD.load(), Collections.singletonList(nmsEntity));
|
||||
return ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.get().newInstance(ReflectionCache.REMOVE_PLAYER_FIELD.get(), Collections.singletonList(nmsEntity));
|
||||
} catch (Throwable throwable) {
|
||||
boolean useOldMethod = (ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CLASS != null);
|
||||
if (useOldMethod) return ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CONSTRUCTOR.load().newInstance(Collections.singletonList(ReflectionCache.GET_UNIQUE_ID_METHOD.load().invoke(nmsEntity)));
|
||||
return ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.load().newInstance(ReflectionCache.REMOVE_PLAYER_FIELD.load(), nmsEntity);
|
||||
if (useOldMethod) return ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CONSTRUCTOR.get().newInstance(Collections.singletonList(ReflectionCache.GET_UNIQUE_ID_METHOD.get().invoke(nmsEntity)));
|
||||
return ReflectionCache.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.get().newInstance(ReflectionCache.REMOVE_PLAYER_FIELD.get(), nmsEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,29 +63,29 @@ public interface Packet {
|
|||
ImmutableList.Builder<Object> builder = ImmutableList.builder();
|
||||
boolean isVersion17 = (Utils.BUKKIT_VERSION > 16);
|
||||
boolean isVersion9 = (Utils.BUKKIT_VERSION > 8);
|
||||
Object scoreboardTeamPacket = isVersion17 ? ReflectionCache.SCOREBOARD_TEAM_CONSTRUCTOR.load().newInstance(null, npc.getGameProfile().getName()) : ReflectionCache.PACKET_PLAY_OUT_SCOREBOARD_TEAM_CONSTRUCTOR_OLD.load().newInstance();
|
||||
Object scoreboardTeamPacket = isVersion17 ? ReflectionCache.SCOREBOARD_TEAM_CONSTRUCTOR.get().newInstance(null, npc.getGameProfile().getName()) : ReflectionCache.PACKET_PLAY_OUT_SCOREBOARD_TEAM_CONSTRUCTOR_OLD.get().newInstance();
|
||||
if (!isVersion17) {
|
||||
Utils.setValue(scoreboardTeamPacket, "a", npc.getGameProfile().getName());
|
||||
Utils.setValue(scoreboardTeamPacket, isVersion9 ? "i" : "h", 1);
|
||||
}
|
||||
builder.add(isVersion17 ? ReflectionCache.PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE_V1.load().invoke(null, scoreboardTeamPacket) : scoreboardTeamPacket);
|
||||
builder.add(isVersion17 ? ReflectionCache.PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE_V1.get().invoke(null, scoreboardTeamPacket) : scoreboardTeamPacket);
|
||||
if (isVersion17) {
|
||||
scoreboardTeamPacket = ReflectionCache.SCOREBOARD_TEAM_CONSTRUCTOR.load().newInstance(null, npc.getGameProfile().getName());
|
||||
scoreboardTeamPacket = ReflectionCache.SCOREBOARD_TEAM_CONSTRUCTOR.get().newInstance(null, npc.getGameProfile().getName());
|
||||
if (Utils.BUKKIT_VERSION > 17) {
|
||||
Utils.setValue(scoreboardTeamPacket, "d", npc.getGameProfile().getName());
|
||||
ReflectionUtils.findFieldForClassAndSet(scoreboardTeamPacket, ReflectionCache.ENUM_TAG_VISIBILITY, ReflectionCache.ENUM_TAG_VISIBILITY_NEVER_FIELD.load());
|
||||
Utils.setValue(scoreboardTeamPacket, "m", ReflectionCache.ENUM_CHAT_FORMAT_FIND.load().invoke(null, "DARK_GRAY"));
|
||||
ReflectionUtils.findFieldForClassAndSet(scoreboardTeamPacket, ReflectionCache.ENUM_TAG_VISIBILITY, ReflectionCache.ENUM_TAG_VISIBILITY_NEVER_FIELD.get());
|
||||
Utils.setValue(scoreboardTeamPacket, "m", ReflectionCache.ENUM_CHAT_FORMAT_FIND.get().invoke(null, "DARK_GRAY"));
|
||||
} else {
|
||||
Utils.setValue(scoreboardTeamPacket, "e", npc.getGameProfile().getName());
|
||||
Utils.setValue(scoreboardTeamPacket, "l", ReflectionCache.ENUM_TAG_VISIBILITY_NEVER_FIELD.load());
|
||||
Utils.setValue(scoreboardTeamPacket, "l", ReflectionCache.ENUM_TAG_VISIBILITY_NEVER_FIELD.get());
|
||||
}
|
||||
} else {
|
||||
scoreboardTeamPacket = ReflectionCache.PACKET_PLAY_OUT_SCOREBOARD_TEAM_CONSTRUCTOR_OLD.load().newInstance();
|
||||
scoreboardTeamPacket = ReflectionCache.PACKET_PLAY_OUT_SCOREBOARD_TEAM_CONSTRUCTOR_OLD.get().newInstance();
|
||||
Utils.setValue(scoreboardTeamPacket, "a", npc.getGameProfile().getName());
|
||||
Utils.setValue(scoreboardTeamPacket, "e", "never");
|
||||
Utils.setValue(scoreboardTeamPacket, isVersion9 ? "i" : "h", 0);
|
||||
}
|
||||
Collection<String> collection = isVersion17 ? (Collection<String>) ReflectionCache.SCOREBOARD_PLAYER_LIST.load().invoke(scoreboardTeamPacket) : (Collection<String>) Utils.getValue(scoreboardTeamPacket, isVersion9 ? "h" : "g");
|
||||
Collection<String> collection = isVersion17 ? (Collection<String>) ReflectionCache.SCOREBOARD_PLAYER_LIST.get().invoke(scoreboardTeamPacket) : (Collection<String>) Utils.getValue(scoreboardTeamPacket, isVersion9 ? "h" : "g");
|
||||
if (npc.getNpcPojo().getNpcType() == NPCType.PLAYER) {
|
||||
collection.add(npc.getGameProfile().getName());
|
||||
} else {
|
||||
|
@ -93,7 +93,7 @@ public interface Packet {
|
|||
}
|
||||
if (allowGlowColor() && FunctionFactory.isTrue(npc, "glow"))
|
||||
updateGlowPacket(npc, scoreboardTeamPacket);
|
||||
builder.add(isVersion17 ? ReflectionCache.PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE.load().invoke(null, scoreboardTeamPacket, Boolean.TRUE) : scoreboardTeamPacket);
|
||||
builder.add(isVersion17 ? ReflectionCache.PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE.get().invoke(null, scoreboardTeamPacket, Boolean.TRUE) : scoreboardTeamPacket);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,6 @@ public class PacketV16 extends PacketV9 {
|
|||
pairs.add(new Pair<>(getItemSlot(entry
|
||||
.getKey().getSlot()),
|
||||
convertItemStack(npc.getEntityID(), entry.getKey(), entry.getValue())));
|
||||
return ImmutableList.of(ReflectionCache.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_V1.load().newInstance(npc.getEntityID(), pairs));
|
||||
return ImmutableList.of(ReflectionCache.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_V1.get().newInstance(npc.getEntityID(), pairs));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ public class PacketV17 extends PacketV16 {
|
|||
}
|
||||
|
||||
public Object getPlayerPacket(Object nmsWorld, GameProfile gameProfile) throws ReflectiveOperationException {
|
||||
return ReflectionCache.PLAYER_CONSTRUCTOR_NEW.load().newInstance(ReflectionCache.GET_SERVER_METHOD.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile);
|
||||
return ReflectionCache.PLAYER_CONSTRUCTOR_NEW.get().newInstance(ReflectionCache.GET_SERVER_METHOD.get().invoke(Bukkit.getServer()), nmsWorld, gameProfile);
|
||||
}
|
||||
|
||||
public void updateGlowPacket(NPC npc, Object packet) throws ReflectiveOperationException {
|
||||
Utils.setValue(packet, "n", ReflectionCache.ENUM_CHAT_FORMAT_FIND.load().invoke(null, npc.getNpcPojo().getGlowName()));
|
||||
Utils.setValue(packet, "n", ReflectionCache.ENUM_CHAT_FORMAT_FIND.get().invoke(null, npc.getNpcPojo().getGlowName()));
|
||||
}
|
||||
|
||||
public Object getClickType(Object interactPacket) {
|
||||
|
|
|
@ -10,6 +10,6 @@ public class PacketV18 extends PacketV17 {
|
|||
}
|
||||
|
||||
public void updateGlowPacket(NPC npc, Object packet) throws ReflectiveOperationException {
|
||||
Utils.setValue(packet, "m", ReflectionCache.ENUM_CHAT_FORMAT_FIND.load().invoke(null, npc.getNpcPojo().getGlowName()));
|
||||
Utils.setValue(packet, "m", ReflectionCache.ENUM_CHAT_FORMAT_FIND.get().invoke(null, npc.getNpcPojo().getGlowName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ public class PacketV19 extends PacketV18 {
|
|||
|
||||
public Object getPlayerPacket(Object nmsWorld, GameProfile gameProfile) throws ReflectiveOperationException {
|
||||
try {
|
||||
return ReflectionCache.PLAYER_CONSTRUCTOR_NEW_1.load(true).newInstance(ReflectionCache.GET_SERVER_METHOD.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile, null);
|
||||
return ReflectionCache.PLAYER_CONSTRUCTOR_NEW_1.get(true).newInstance(ReflectionCache.GET_SERVER_METHOD.get().invoke(Bukkit.getServer()), nmsWorld, gameProfile, null);
|
||||
} catch (Throwable e) {
|
||||
return ReflectionCache.PLAYER_CONSTRUCTOR_NEW_2.load().newInstance(ReflectionCache.GET_SERVER_METHOD.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile);
|
||||
return ReflectionCache.PLAYER_CONSTRUCTOR_NEW_2.get().newInstance(ReflectionCache.GET_SERVER_METHOD.get().invoke(Bukkit.getServer()), nmsWorld, gameProfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,18 +18,18 @@ public class PacketV8 implements Packet {
|
|||
}
|
||||
|
||||
public Object getPlayerPacket(Object nmsWorld, GameProfile gameProfile) throws ReflectiveOperationException {
|
||||
Constructor<?> constructor = (Utils.BUKKIT_VERSION > 13) ? ReflectionCache.PLAYER_INTERACT_MANAGER_NEW_CONSTRUCTOR.load() : ReflectionCache.PLAYER_INTERACT_MANAGER_OLD_CONSTRUCTOR.load();
|
||||
return ReflectionCache.PLAYER_CONSTRUCTOR_OLD.load().newInstance(ReflectionCache.GET_SERVER_METHOD
|
||||
.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile, constructor.newInstance(nmsWorld));
|
||||
Constructor<?> constructor = (Utils.BUKKIT_VERSION > 13) ? ReflectionCache.PLAYER_INTERACT_MANAGER_NEW_CONSTRUCTOR.get() : ReflectionCache.PLAYER_INTERACT_MANAGER_OLD_CONSTRUCTOR.get();
|
||||
return ReflectionCache.PLAYER_CONSTRUCTOR_OLD.get().newInstance(ReflectionCache.GET_SERVER_METHOD
|
||||
.get().invoke(Bukkit.getServer()), nmsWorld, gameProfile, constructor.newInstance(nmsWorld));
|
||||
}
|
||||
|
||||
public Object getSpawnPacket(Object nmsEntity, boolean isPlayer) throws ReflectiveOperationException {
|
||||
return isPlayer ? ReflectionCache.PACKET_PLAY_OUT_NAMED_ENTITY_CONSTRUCTOR.load().newInstance(nmsEntity) : ReflectionCache.PACKET_PLAY_OUT_SPAWN_ENTITY_CONSTRUCTOR.load().newInstance(nmsEntity);
|
||||
return isPlayer ? ReflectionCache.PACKET_PLAY_OUT_NAMED_ENTITY_CONSTRUCTOR.get().newInstance(nmsEntity) : ReflectionCache.PACKET_PLAY_OUT_SPAWN_ENTITY_CONSTRUCTOR.get().newInstance(nmsEntity);
|
||||
}
|
||||
|
||||
public Object convertItemStack(int entityId, ItemSlot itemSlot, ItemStack itemStack) throws ReflectiveOperationException {
|
||||
return ReflectionCache.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD.load().newInstance(entityId,
|
||||
itemSlot.getSlotOld(), ReflectionCache.AS_NMS_COPY_METHOD.load().invoke(ReflectionCache.CRAFT_ITEM_STACK_CLASS, itemStack));
|
||||
return ReflectionCache.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD.get().newInstance(entityId,
|
||||
itemSlot.getSlotOld(), ReflectionCache.AS_NMS_COPY_METHOD.get().invoke(ReflectionCache.CRAFT_ITEM_STACK_CLASS, itemStack));
|
||||
}
|
||||
|
||||
public Object getClickType(Object interactPacket) throws ReflectiveOperationException {
|
||||
|
@ -37,22 +37,22 @@ public class PacketV8 implements Packet {
|
|||
}
|
||||
|
||||
public Object getMetadataPacket(int entityId, Object nmsEntity) throws ReflectiveOperationException {
|
||||
Object dataWatcher = ReflectionCache.GET_DATA_WATCHER_METHOD.load().invoke(nmsEntity);
|
||||
Object dataWatcher = ReflectionCache.GET_DATA_WATCHER_METHOD.get().invoke(nmsEntity);
|
||||
try {
|
||||
return ReflectionCache.PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR.load(true).newInstance(entityId, dataWatcher, true);
|
||||
return ReflectionCache.PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR.get(true).newInstance(entityId, dataWatcher, true);
|
||||
} catch (Exception e2) {
|
||||
return ReflectionCache.PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR_V1.load().newInstance(entityId, ReflectionCache.GET_DATAWATCHER_B_LIST.load().invoke(dataWatcher));
|
||||
return ReflectionCache.PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR_V1.get().newInstance(entityId, ReflectionCache.GET_DATAWATCHER_B_LIST.get().invoke(dataWatcher));
|
||||
}
|
||||
}
|
||||
|
||||
public Object getHologramSpawnPacket(Object armorStand) throws ReflectiveOperationException {
|
||||
return ReflectionCache.PACKET_PLAY_OUT_SPAWN_ENTITY_CONSTRUCTOR.load().newInstance(armorStand);
|
||||
return ReflectionCache.PACKET_PLAY_OUT_SPAWN_ENTITY_CONSTRUCTOR.get().newInstance(armorStand);
|
||||
}
|
||||
|
||||
public ImmutableList<Object> getEquipPackets(NPC npc) throws ReflectiveOperationException {
|
||||
ImmutableList.Builder<Object> builder = ImmutableList.builder();
|
||||
for (Map.Entry<ItemSlot, ItemStack> stackEntry : npc.getNpcPojo().getNpcEquip().entrySet()) {
|
||||
builder.add(ReflectionCache.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD.load().newInstance(npc.getEntityID(), stackEntry.getKey().getSlotOld(),
|
||||
builder.add(ReflectionCache.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD.get().newInstance(npc.getEntityID(), stackEntry.getKey().getSlotOld(),
|
||||
convertItemStack(npc.getEntityID(), stackEntry.getKey(), stackEntry.getValue())));
|
||||
}
|
||||
return builder.build();
|
||||
|
|
|
@ -15,13 +15,13 @@ public class PacketV9 extends PacketV8 {
|
|||
}
|
||||
|
||||
public Object convertItemStack(int entityId, ItemSlot itemSlot, ItemStack itemStack) throws ReflectiveOperationException {
|
||||
return ReflectionCache.AS_NMS_COPY_METHOD.load().invoke(ReflectionCache.CRAFT_ITEM_STACK_CLASS, itemStack);
|
||||
return ReflectionCache.AS_NMS_COPY_METHOD.get().invoke(ReflectionCache.CRAFT_ITEM_STACK_CLASS, itemStack);
|
||||
}
|
||||
|
||||
public ImmutableList<Object> getEquipPackets(NPC npc) throws ReflectiveOperationException {
|
||||
ImmutableList.Builder<Object> builder = ImmutableList.builder();
|
||||
for (Map.Entry<ItemSlot, ItemStack> stackEntry : npc.getNpcPojo().getNpcEquip().entrySet()) {
|
||||
builder.add(ReflectionCache.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_NEWEST_OLD.load().newInstance(npc.getEntityID(),
|
||||
builder.add(ReflectionCache.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_NEWEST_OLD.get().newInstance(npc.getEntityID(),
|
||||
getItemSlot(stackEntry.getKey().getSlot()),
|
||||
convertItemStack(npc.getEntityID(), stackEntry.getKey(), stackEntry.getValue())));
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ public class PacketV9 extends PacketV8 {
|
|||
}
|
||||
|
||||
public void updateGlowPacket(NPC npc, Object packet) throws ReflectiveOperationException {
|
||||
Object enumChatString = ReflectionCache.ENUM_CHAT_TO_STRING_METHOD.load().invoke(npc.getGlowColor());
|
||||
Object enumChatString = ReflectionCache.ENUM_CHAT_TO_STRING_METHOD.get().invoke(npc.getGlowColor());
|
||||
if (Utils.BUKKIT_VERSION > 12) {
|
||||
Utils.setValue(packet, npc.getGlowColor(), ReflectionCache.ENUM_CHAT_CLASS);
|
||||
Utils.setValue(packet, "c", ReflectionCache.I_CHAT_BASE_COMPONENT_A_CONSTRUCTOR.load().newInstance(enumChatString));
|
||||
Utils.setValue(packet, "c", ReflectionCache.I_CHAT_BASE_COMPONENT_A_CONSTRUCTOR.get().newInstance(enumChatString));
|
||||
} else {
|
||||
Utils.setValue(packet, "g", ReflectionCache.GET_ENUM_CHAT_ID_METHOD.load().invoke(npc.getGlowColor()));
|
||||
Utils.setValue(packet, "g", ReflectionCache.GET_ENUM_CHAT_ID_METHOD.get().invoke(npc.getGlowColor()));
|
||||
Utils.setValue(packet, "c", enumChatString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package io.github.znetworkw.znpcservers.reflection;
|
||||
|
||||
import io.github.znetworkw.znpcservers.utility.Utils;
|
||||
import lol.pyr.znpcsplus.ZNPCsPlus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BaseReflection <T> {
|
||||
protected final List<String> className;
|
||||
|
||||
protected Class<?> BUILDER_CLASS;
|
||||
|
||||
private T cached;
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
protected BaseReflection(ReflectionBuilder builder) {
|
||||
this(builder.getClassName());
|
||||
}
|
||||
|
||||
protected BaseReflection(List<String> className) {
|
||||
this.className = className;
|
||||
for (String classes : className) {
|
||||
try {
|
||||
this.BUILDER_CLASS = Class.forName(classes);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return get(false);
|
||||
}
|
||||
|
||||
public T get(boolean missAllowed) {
|
||||
if (this.loaded) return this.cached;
|
||||
try {
|
||||
if (this.BUILDER_CLASS == null) throw new ClassNotFoundException("No class found: " + className);
|
||||
T eval = (this.cached != null) ? this.cached : (this.cached = load());
|
||||
if (eval == null) throw new NullPointerException();
|
||||
} catch (Throwable throwable) {
|
||||
if (!missAllowed) {
|
||||
warn(getClass().getSimpleName() + " get failed!");
|
||||
warn("Class Names: " + className);
|
||||
warn("Loader Type: " + getClass().getCanonicalName());
|
||||
warn("Bukkit Version: " + Utils.BUKKIT_VERSION + " (" + Utils.getBukkitPackage() + ")");
|
||||
warn("Exception:");
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.loaded = true;
|
||||
return this.cached;
|
||||
}
|
||||
|
||||
private void warn(String message) {
|
||||
ZNPCsPlus.LOGGER.warning("[Reflection] " + message);
|
||||
}
|
||||
|
||||
protected abstract T load() throws Exception;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package io.github.znetworkw.znpcservers.reflection;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class ClassCache {
|
||||
protected static final ConcurrentMap<CacheKey, Object> CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
public static Object find(String name, Class<?> objectClass) {
|
||||
return CACHE.get(new CacheKey(name, objectClass));
|
||||
}
|
||||
|
||||
public static void register(String name, Object object, Class<?> objectClass) {
|
||||
CACHE.putIfAbsent(new CacheKey(name, objectClass), object);
|
||||
}
|
||||
|
||||
private static class CacheKey {
|
||||
private final Class<?> type;
|
||||
private final String value;
|
||||
|
||||
public CacheKey(String value, Class<?> type) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CacheKey classKey = (CacheKey) o;
|
||||
return (Objects.equals(this.type, classKey.type) && Objects.equals(this.value, classKey.value));
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package io.github.znetworkw.znpcservers.reflection;
|
||||
|
||||
import io.github.znetworkw.znpcservers.utility.Utils;
|
||||
|
||||
public enum ReflectionBasePackage {
|
||||
DEFAULT,
|
||||
CRAFT_BUKKIT("org.bukkit.craftbukkit." + Utils.getBukkitPackage()),
|
||||
MINECRAFT_SERVER("net.minecraft");
|
||||
|
||||
private final String fixedPackageName;
|
||||
|
||||
ReflectionBasePackage(String packageName) {
|
||||
this.fixedPackageName = Utils.versionNewer(17) ? packageName : (packageName + (packageName.contains("minecraft") ? (".server." + Utils.getBukkitPackage()) : ""));
|
||||
}
|
||||
|
||||
ReflectionBasePackage() {
|
||||
this.fixedPackageName = "";
|
||||
}
|
||||
|
||||
public String getForCategory(ReflectionTopPackage packetCategory, String extra) {
|
||||
return Utils.versionNewer(17) ? (packetCategory
|
||||
.getPackageName() + ((extra.length() > 0) ? ("." + extra) : "")) :
|
||||
this.fixedPackageName;
|
||||
}
|
||||
|
||||
public String getFixedPackageName() {
|
||||
return this.fixedPackageName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package io.github.znetworkw.znpcservers.reflection;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ReflectionBuilder {
|
||||
private final String reflectionPackage;
|
||||
private String fieldName;
|
||||
private String additionalData;
|
||||
private final ArrayList<String> className = new ArrayList<>();
|
||||
private final ArrayList<String> methods = new ArrayList<>();
|
||||
private final ArrayList<Class<?>[]> parameterTypes = new ArrayList<>();
|
||||
private Class<?> expectType;
|
||||
|
||||
public ReflectionBuilder(String reflectionPackage) {
|
||||
this(reflectionPackage, "", "", null);
|
||||
}
|
||||
|
||||
protected ReflectionBuilder(String reflectionPackage, String fieldName, String additionalData, Class<?> expectType) {
|
||||
this.reflectionPackage = reflectionPackage;
|
||||
this.fieldName = fieldName;
|
||||
this.additionalData = additionalData;
|
||||
this.expectType = expectType;
|
||||
}
|
||||
|
||||
public ReflectionBuilder withClassName(String className) {
|
||||
this.className.add(ReflectionPackage.join(reflectionPackage, additionalData, className));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReflectionBuilder withClassName(Class<?> clazz) {
|
||||
className.add(clazz.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReflectionBuilder withMethodName(String methodName) {
|
||||
this.methods.add(methodName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReflectionBuilder withFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReflectionBuilder withSubClass(String additionalData) {
|
||||
this.additionalData = additionalData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReflectionBuilder withParameterTypes(Class<?>... types) {
|
||||
this.parameterTypes.add(types);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReflectionBuilder withExpectResult(Class<?> expectType) {
|
||||
this.expectType = expectType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Class<?> getExpectType() {
|
||||
return expectType;
|
||||
}
|
||||
|
||||
public ImmutableList<Class<?>[]> getParameterTypes() {
|
||||
return ImmutableList.copyOf(this.parameterTypes);
|
||||
}
|
||||
|
||||
public ImmutableList<String> getClassName() {
|
||||
return ImmutableList.copyOf(this.className);
|
||||
}
|
||||
|
||||
public ImmutableList<String> getMethods() {
|
||||
return ImmutableList.copyOf(this.methods);
|
||||
}
|
||||
|
||||
public String getPackage() {
|
||||
return reflectionPackage;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package io.github.znetworkw.znpcservers.reflection;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.github.znetworkw.znpcservers.reflection.types.*;
|
||||
import io.github.znetworkw.znpcservers.utility.Utils;
|
||||
import io.netty.channel.Channel;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -13,484 +14,386 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
public final class ReflectionCache {
|
||||
public static final Class<?> PACKET_PLAY_IN_USE_ENTITY_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
.withClassName("PacketPlayInUseEntity"))).load();
|
||||
public static final Class<?> PACKET_PLAY_IN_USE_ENTITY_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayInUseEntity")).get();
|
||||
|
||||
public static final Class<?> ENUM_PLAYER_INFO_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final Class<?> ENUM_PLAYER_INFO_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutPlayerInfo$EnumPlayerInfoAction")
|
||||
.withClassName("ClientboundPlayerInfoUpdatePacket$a"))).load();
|
||||
.withClassName("ClientboundPlayerInfoUpdatePacket$a")).get();
|
||||
|
||||
public static final Class<?> PACKET_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PROTOCOL)
|
||||
.withClassName("Packet"))).load();
|
||||
public static final Class<?> PACKET_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.PROTOCOL)
|
||||
.withClassName("Packet")).get();
|
||||
|
||||
public static final Class<?> ENTITY_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withClassName("Entity"))).load();
|
||||
public static final Class<?> ENTITY_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withClassName("Entity")).get();
|
||||
|
||||
public static final Class<?> ENTITY_LIVING = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withClassName("EntityLiving"))).load();
|
||||
public static final Class<?> ENTITY_LIVING = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withClassName("EntityLiving")).get();
|
||||
|
||||
public static final Class<?> ENTITY_PLAYER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SERVER_LEVEL)
|
||||
.withClassName("EntityPlayer"))).load();
|
||||
public static final Class<?> ENTITY_PLAYER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.SERVER_LEVEL)
|
||||
.withClassName("EntityPlayer")).get();
|
||||
|
||||
public static final Class<?> ENTITY_ARMOR_STAND_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("decoration")
|
||||
.withClassName("EntityArmorStand"))).load();
|
||||
public static final Class<?> ENTITY_ARMOR_STAND_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("decoration")
|
||||
.withClassName("EntityArmorStand")).get();
|
||||
|
||||
public static final Class<?> ENTITY_BAT_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("ambient")
|
||||
.withClassName("EntityBat"))).load();
|
||||
public static final Class<?> ENTITY_BAT_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("ambient")
|
||||
.withClassName("EntityBat")).get();
|
||||
|
||||
public static final Class<?> ENTITY_BLAZE_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityBlaze"))).load();
|
||||
public static final Class<?> ENTITY_BLAZE_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityBlaze")).get();
|
||||
|
||||
public static final Class<?> ENTITY_CAVE_SPIDER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityCaveSpider"))).load();
|
||||
public static final Class<?> ENTITY_CAVE_SPIDER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityCaveSpider")).get();
|
||||
|
||||
public static final Class<?> ENTITY_CHICKEN_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityChicken"))).load();
|
||||
public static final Class<?> ENTITY_CHICKEN_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityChicken")).get();
|
||||
|
||||
public static final Class<?> ENTITY_COW_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityCow"))).load();
|
||||
public static final Class<?> ENTITY_COW_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityCow")).get();
|
||||
|
||||
public static final Class<?> ENTITY_CREEPER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityCreeper"))).load();
|
||||
public static final Class<?> ENTITY_CREEPER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityCreeper")).get();
|
||||
|
||||
public static final Class<?> ENTITY_ENDER_DRAGON_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("boss.enderdragon")
|
||||
.withClassName("EntityEnderDragon"))).load();
|
||||
public static final Class<?> ENTITY_ENDER_DRAGON_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("boss.enderdragon")
|
||||
.withClassName("EntityEnderDragon")).get();
|
||||
|
||||
public static final Class<?> ENTITY_ENDERMAN_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityEnderman"))).load();
|
||||
public static final Class<?> ENTITY_ENDERMAN_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityEnderman")).get();
|
||||
|
||||
public static final Class<?> ENTITY_HUMAN_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("player")
|
||||
.withClassName("EntityHuman"))).load();
|
||||
public static final Class<?> ENTITY_HUMAN_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("player")
|
||||
.withClassName("EntityHuman")).get();
|
||||
|
||||
public static final Class<?> ENTITY_ENDERMITE_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityEndermite"))).load();
|
||||
public static final Class<?> ENTITY_ENDERMITE_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityEndermite")).get();
|
||||
|
||||
public static final Class<?> ENTITY_GHAST_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityGhast"))).load();
|
||||
public static final Class<?> ENTITY_GHAST_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityGhast")).get();
|
||||
|
||||
public static final Class<?> ENTITY_IRON_GOLEM_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityIronGolem"))).load();
|
||||
public static final Class<?> ENTITY_IRON_GOLEM_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityIronGolem")).get();
|
||||
|
||||
public static final Class<?> ENTITY_GIANT_ZOMBIE_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityGiantZombie"))).load();
|
||||
public static final Class<?> ENTITY_GIANT_ZOMBIE_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityGiantZombie")).get();
|
||||
|
||||
public static final Class<?> ENTITY_GUARDIAN_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityGuardian"))).load();
|
||||
public static final Class<?> ENTITY_GUARDIAN_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityGuardian")).get();
|
||||
|
||||
public static final Class<?> ENTITY_HORSE_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal.horse")
|
||||
.withClassName("EntityHorse"))).load();
|
||||
public static final Class<?> ENTITY_HORSE_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal.horse")
|
||||
.withClassName("EntityHorse")).get();
|
||||
|
||||
public static final Class<?> ENTITY_LLAMA_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal.horse")
|
||||
.withClassName("EntityLlama"))).load(!Utils.versionNewer(11));
|
||||
public static final Class<?> ENTITY_LLAMA_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal.horse")
|
||||
.withClassName("EntityLlama")).get(!Utils.versionNewer(11));
|
||||
|
||||
public static final Class<?> ENTITY_MAGMA_CUBE_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityMagmaCube"))).load();
|
||||
public static final Class<?> ENTITY_MAGMA_CUBE_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityMagmaCube")).get();
|
||||
|
||||
public static final Class<?> ENTITY_MUSHROOM_COW_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityMushroomCow"))).load();
|
||||
public static final Class<?> ENTITY_MUSHROOM_COW_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityMushroomCow")).get();
|
||||
|
||||
public static final Class<?> ENTITY_OCELOT_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityOcelot"))).load();
|
||||
public static final Class<?> ENTITY_OCELOT_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityOcelot")).get();
|
||||
|
||||
public static final Class<?> ENTITY_TURTLE = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityTurtle"))).load(!Utils.versionNewer(13));
|
||||
public static final Class<?> ENTITY_TURTLE = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityTurtle")).get(!Utils.versionNewer(13));
|
||||
|
||||
public static final Class<?> ENTITY_WARDEN = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster.warden")
|
||||
public static final Class<?> ENTITY_WARDEN = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster.warden")
|
||||
.withClassName("EntityWarden")
|
||||
.withClassName("Warden"))).load(!Utils.versionNewer(19));
|
||||
.withClassName("Warden")).get(!Utils.versionNewer(19));
|
||||
|
||||
public static final Class<?> ENTITY_BEE_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityBee"))).load(!Utils.versionNewer(15));
|
||||
public static final Class<?> ENTITY_BEE_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityBee")).get(!Utils.versionNewer(15));
|
||||
|
||||
public static final Class<?> ENTITY_PARROT_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityParrot"))).load(!Utils.versionNewer(12));
|
||||
public static final Class<?> ENTITY_PARROT_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityParrot")).get(!Utils.versionNewer(12));
|
||||
|
||||
public static final Class<?> ENTITY_PIG_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityPig"))).load();
|
||||
public static final Class<?> ENTITY_PIG_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityPig")).get();
|
||||
|
||||
public static final Class<?> ENTITY_RABBIT_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityRabbit"))).load();
|
||||
public static final Class<?> ENTITY_RABBIT_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityRabbit")).get();
|
||||
|
||||
public static final Class<?> ENTITY_POLAR_BEAR_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityPolarBear"))).load(!Utils.versionNewer(10));
|
||||
public static final Class<?> ENTITY_POLAR_BEAR_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityPolarBear")).get(!Utils.versionNewer(10));
|
||||
|
||||
public static final Class<?> ENTITY_PANDA_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityPanda"))).load(!Utils.versionNewer(14));
|
||||
public static final Class<?> ENTITY_PANDA_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityPanda")).get(!Utils.versionNewer(14));
|
||||
|
||||
public static final Class<?> ENTITY_SHEEP_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntitySheep"))).load();
|
||||
public static final Class<?> ENTITY_SHEEP_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntitySheep")).get();
|
||||
|
||||
public static final Class<?> ENTITY_SNOWMAN_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntitySnowman"))).load();
|
||||
public static final Class<?> ENTITY_SNOWMAN_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntitySnowman")).get();
|
||||
|
||||
public static final Class<?> ENTITY_SHULKER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityShulker"))).load(!Utils.versionNewer(9));
|
||||
public static final Class<?> ENTITY_SHULKER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityShulker")).get(!Utils.versionNewer(9));
|
||||
|
||||
public static final Class<?> ENTITY_SILVERFISH_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntitySilverfish"))).load();
|
||||
public static final Class<?> ENTITY_SILVERFISH_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntitySilverfish")).get();
|
||||
|
||||
public static final Class<?> ENTITY_SKELETON_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntitySkeleton"))).load();
|
||||
public static final Class<?> ENTITY_SKELETON_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntitySkeleton")).get();
|
||||
|
||||
public static final Class<?> ENTITY_SLIME_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntitySlime"))).load();
|
||||
public static final Class<?> ENTITY_SLIME_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntitySlime")).get();
|
||||
|
||||
public static final Class<?> ENTITY_SPIDER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntitySpider"))).load();
|
||||
public static final Class<?> ENTITY_SPIDER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntitySpider")).get();
|
||||
|
||||
public static final Class<?> ENTITY_SQUID_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntitySquid"))).load();
|
||||
public static final Class<?> ENTITY_SQUID_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntitySquid")).get();
|
||||
|
||||
public static final Class<?> ENTITY_VILLAGER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("npc")
|
||||
.withClassName("EntityVillager"))).load();
|
||||
public static final Class<?> ENTITY_VILLAGER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("npc")
|
||||
.withClassName("EntityVillager")).get();
|
||||
|
||||
public static final Class<?> ENTITY_WITCH_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityWitch"))).load();
|
||||
public static final Class<?> ENTITY_WITCH_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityWitch")).get();
|
||||
|
||||
public static final Class<?> ENTITY_WITHER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("boss.wither")
|
||||
.withClassName("EntityWither"))).load();
|
||||
public static final Class<?> ENTITY_WITHER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("boss.wither")
|
||||
.withClassName("EntityWither")).get();
|
||||
|
||||
public static final Class<?> ENTITY_ZOMBIE_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("monster")
|
||||
.withClassName("EntityZombie"))).load();
|
||||
public static final Class<?> ENTITY_ZOMBIE_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("monster")
|
||||
.withClassName("EntityZombie")).get();
|
||||
|
||||
public static final Class<?> ENTITY_WOLF_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityWolf"))).load();
|
||||
public static final Class<?> ENTITY_WOLF_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityWolf")).get();
|
||||
|
||||
public static final Class<?> ENTITY_AXOLOTL_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal.axolotl")
|
||||
.withClassName("Axolotl"))).load(!Utils.versionNewer(17));
|
||||
public static final Class<?> ENTITY_AXOLOTL_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal.axolotl")
|
||||
.withClassName("Axolotl")).get(!Utils.versionNewer(17));
|
||||
|
||||
public static final Class<?> ENTITY_GOAT_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal.goat")
|
||||
.withClassName("Goat"))).load(!Utils.versionNewer(17));
|
||||
public static final Class<?> ENTITY_GOAT_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal.goat")
|
||||
.withClassName("Goat")).get(!Utils.versionNewer(17));
|
||||
|
||||
public static final Class<?> ENTITY_FOX_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withAdditionalData("animal")
|
||||
.withClassName("EntityFox"))).load(!Utils.versionNewer(14));
|
||||
public static final Class<?> ENTITY_FOX_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withSubClass("animal")
|
||||
.withClassName("EntityFox")).get(!Utils.versionNewer(14));
|
||||
|
||||
public static final Class<?> ENTITY_TYPES_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withClassName("EntityTypes"))).load();
|
||||
public static final Class<?> ENTITY_TYPES_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withClassName("EntityTypes")).get();
|
||||
|
||||
public static final Class<?> ENUM_CHAT_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withClassName("EnumChatFormat"))).load();
|
||||
public static final Class<?> ENUM_CHAT_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.MINECRAFT)
|
||||
.withClassName("EnumChatFormat")).get();
|
||||
|
||||
public static final Class<?> ENUM_ITEM_SLOT = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
.withClassName("EnumItemSlot"))).load(!Utils.versionNewer(9));
|
||||
public static final Class<?> ENUM_ITEM_SLOT = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withClassName("EnumItemSlot")).get(!Utils.versionNewer(9));
|
||||
|
||||
public static final Class<?> I_CHAT_BASE_COMPONENT = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.CHAT)
|
||||
.withClassName("IChatBaseComponent"))).load();
|
||||
public static final Class<?> I_CHAT_BASE_COMPONENT = new ClassReflection(new ReflectionBuilder(ReflectionPackage.CHAT)
|
||||
.withClassName("IChatBaseComponent")).get();
|
||||
|
||||
public static final Class<?> ITEM_STACK_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ITEM)
|
||||
.withClassName("ItemStack"))).load();
|
||||
public static final Class<?> ITEM_STACK_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.ITEM)
|
||||
.withClassName("ItemStack")).get();
|
||||
|
||||
public static final Class<?> DATA_WATCHER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SYNCHER)
|
||||
.withClassName("DataWatcher"))).load(!Utils.versionNewer(9));
|
||||
public static final Class<?> DATA_WATCHER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.SYNCHER)
|
||||
.withClassName("DataWatcher")).get(!Utils.versionNewer(9));
|
||||
|
||||
public static final Class<?> DATA_WATCHER_OBJECT = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SYNCHER)
|
||||
.withClassName("DataWatcherObject"))).load(!Utils.versionNewer(9));
|
||||
public static final Class<?> DATA_WATCHER_OBJECT = new ClassReflection(new ReflectionBuilder(ReflectionPackage.SYNCHER)
|
||||
.withClassName("DataWatcherObject")).get(!Utils.versionNewer(9));
|
||||
|
||||
public static final Class<?> DATA_WATCHER_REGISTRY = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SYNCHER)
|
||||
.withClassName("DataWatcherRegistry"))).load(!Utils.versionNewer(9));
|
||||
public static final Class<?> DATA_WATCHER_REGISTRY = new ClassReflection(new ReflectionBuilder(ReflectionPackage.SYNCHER)
|
||||
.withClassName("DataWatcherRegistry")).get(!Utils.versionNewer(9));
|
||||
|
||||
public static final Class<?> DATA_WATCHER_SERIALIZER = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SYNCHER)
|
||||
.withClassName("DataWatcherSerializer"))).load(!Utils.versionNewer(9));
|
||||
public static final Class<?> DATA_WATCHER_SERIALIZER = new ClassReflection(new ReflectionBuilder(ReflectionPackage.SYNCHER)
|
||||
.withClassName("DataWatcherSerializer")).get(!Utils.versionNewer(9));
|
||||
|
||||
public static final Class<?> WORLD_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.WORLD_LEVEL)
|
||||
.withClassName("World"))).load();
|
||||
public static final Class<?> WORLD_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.WORLD_LEVEL)
|
||||
.withClassName("World")).get();
|
||||
|
||||
public static final Class<?> CRAFT_ITEM_STACK_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.CRAFT_BUKKIT))
|
||||
.withClassName("inventory.CraftItemStack"))).load();
|
||||
public static final Class<?> CRAFT_ITEM_STACK_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.BUKKIT)
|
||||
.withClassName("inventory.CraftItemStack")).get();
|
||||
|
||||
public static final Class<?> WORLD_SERVER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SERVER_LEVEL)
|
||||
.withClassName("WorldServer"))).load();
|
||||
public static final Class<?> WORLD_SERVER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.SERVER_LEVEL)
|
||||
.withClassName("WorldServer")).get();
|
||||
|
||||
public static final Class<?> MINECRAFT_SERVER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SERVER)
|
||||
.withClassName("MinecraftServer"))).load();
|
||||
public static final Class<?> MINECRAFT_SERVER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.SERVER)
|
||||
.withClassName("MinecraftServer")).get();
|
||||
|
||||
public static final Class<?> PLAYER_INTERACT_MANAGER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SERVER_LEVEL)
|
||||
.withClassName("PlayerInteractManager"))).load();
|
||||
public static final Class<?> PLAYER_INTERACT_MANAGER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.SERVER_LEVEL)
|
||||
.withClassName("PlayerInteractManager")).get();
|
||||
|
||||
public static final Class<?> PLAYER_CONNECTION_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SERVER_NETWORK)
|
||||
.withClassName("PlayerConnection"))).load();
|
||||
public static final Class<?> PLAYER_CONNECTION_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.SERVER_NETWORK)
|
||||
.withClassName("PlayerConnection")).get();
|
||||
|
||||
public static final Class<?> NETWORK_MANAGER_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.NETWORK)
|
||||
.withClassName("NetworkManager"))).load();
|
||||
public static final Class<?> NETWORK_MANAGER_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.NETWORK)
|
||||
.withClassName("NetworkManager")).get();
|
||||
|
||||
public static final Class<?> PACKET_PLAY_OUT_PLAYER_INFO_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final Class<?> PACKET_PLAY_OUT_PLAYER_INFO_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutPlayerInfo")
|
||||
.withClassName("ClientboundPlayerInfoUpdatePacket")))
|
||||
.load();
|
||||
.withClassName("ClientboundPlayerInfoUpdatePacket"))
|
||||
.get();
|
||||
|
||||
public static final Class<?> PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
.withClassName("ClientboundPlayerInfoRemovePacket")))
|
||||
.load(true);
|
||||
public static final Class<?> PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("ClientboundPlayerInfoRemovePacket"))
|
||||
.get(true);
|
||||
|
||||
public static final Class<?> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
.withClassName("PacketPlayOutScoreboardTeam"))).load();
|
||||
public static final Class<?> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutScoreboardTeam")).get();
|
||||
|
||||
public static final Class<?> PACKET_PLAY_OUT_ENTITY_DESTROY_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntityDestroy"))).load();
|
||||
public static final Class<?> PACKET_PLAY_OUT_ENTITY_DESTROY_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntityDestroy")).get();
|
||||
|
||||
public static final Class<?> SCOREBOARD_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.WORLD_SCORES)
|
||||
.withClassName("Scoreboard"))).load();
|
||||
public static final Class<?> SCOREBOARD_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.WORLD_SCORES)
|
||||
.withClassName("Scoreboard")).get();
|
||||
|
||||
public static final Class<?> SCOREBOARD_TEAM_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.WORLD_SCORES)
|
||||
.withClassName("ScoreboardTeam"))).load();
|
||||
public static final Class<?> SCOREBOARD_TEAM_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.WORLD_SCORES)
|
||||
.withClassName("ScoreboardTeam")).get();
|
||||
|
||||
public static final Class<?> ENUM_TAG_VISIBILITY = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.WORLD_SCORES)
|
||||
.withClassName("ScoreboardTeamBase$EnumNameTagVisibility"))).load();
|
||||
public static final Class<?> ENUM_TAG_VISIBILITY = new ClassReflection(new ReflectionBuilder(ReflectionPackage.WORLD_SCORES)
|
||||
.withClassName("ScoreboardTeamBase$EnumNameTagVisibility")).get();
|
||||
|
||||
public static final Class<?> CRAFT_CHAT_MESSAGE_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.CRAFT_BUKKIT))
|
||||
.withClassName("util.CraftChatMessage"))).load();
|
||||
public static final Class<?> CRAFT_CHAT_MESSAGE_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.BUKKIT)
|
||||
.withClassName("util.CraftChatMessage")).get();
|
||||
|
||||
public static final Class<?> PROFILE_PUBLIC_KEY_CLASS = (new TypeCache.BaseReflection.ClassReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.WORLD_ENTITY_PLAYER)
|
||||
.withClassName("ProfilePublicKey"))).load(!Utils.versionNewer(19));
|
||||
public static final Class<?> PROFILE_PUBLIC_KEY_CLASS = new ClassReflection(new ReflectionBuilder(ReflectionPackage.WORLD_ENTITY_PLAYER)
|
||||
.withClassName("ProfilePublicKey")).get(!Utils.versionNewer(19));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> SCOREBOARD_TEAM_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> SCOREBOARD_TEAM_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(SCOREBOARD_TEAM_CLASS)
|
||||
.withParameterTypes(SCOREBOARD_CLASS, String.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PLAYER_CONSTRUCTOR_OLD = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PLAYER_CONSTRUCTOR_OLD = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_PLAYER_CLASS)
|
||||
.withParameterTypes(MINECRAFT_SERVER_CLASS, WORLD_SERVER_CLASS, GameProfile.class, PLAYER_INTERACT_MANAGER_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PLAYER_CONSTRUCTOR_NEW = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PLAYER_CONSTRUCTOR_NEW = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_PLAYER_CLASS)
|
||||
.withParameterTypes(MINECRAFT_SERVER_CLASS, WORLD_SERVER_CLASS, GameProfile.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PLAYER_CONSTRUCTOR_NEW_1 = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PLAYER_CONSTRUCTOR_NEW_1 = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_PLAYER_CLASS)
|
||||
.withParameterTypes(MINECRAFT_SERVER_CLASS, WORLD_SERVER_CLASS, GameProfile.class, PROFILE_PUBLIC_KEY_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PLAYER_CONSTRUCTOR_NEW_2 = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PLAYER_CONSTRUCTOR_NEW_2 = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_PLAYER_CLASS)
|
||||
.withParameterTypes(MINECRAFT_SERVER_CLASS, WORLD_SERVER_CLASS, GameProfile.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(PACKET_PLAY_OUT_PLAYER_INFO_CLASS)
|
||||
.withParameterTypes(ENUM_PLAYER_INFO_CLASS, (Utils.BUKKIT_VERSION > 16) ? Collection.class : Iterable.class).withParameterTypes(ENUM_PLAYER_INFO_CLASS, ENTITY_PLAYER_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CLASS)
|
||||
.withParameterTypes(List.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_LOOK_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_LOOK_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntity$PacketPlayOutEntityLook")
|
||||
.withParameterTypes(int.class, byte.class, byte.class, boolean.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_HEAD_ROTATION_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_HEAD_ROTATION_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntityHeadRotation")
|
||||
.withParameterTypes(ENTITY_CLASS, byte.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_TELEPORT_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_TELEPORT_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntityTeleport")
|
||||
.withParameterTypes(ENTITY_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntityMetadata")
|
||||
.withParameterTypes(int.class, DATA_WATCHER_CLASS, boolean.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR_V1 = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR_V1 = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntityMetadata")
|
||||
.withParameterTypes(int.class, List.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_NAMED_ENTITY_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_NAMED_ENTITY_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutNamedEntitySpawn")
|
||||
.withParameterTypes(ENTITY_HUMAN_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(PACKET_PLAY_OUT_ENTITY_DESTROY_CLASS)
|
||||
.withParameterTypes(int.class).withParameterTypes(int[].class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_SPAWN_ENTITY_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_SPAWN_ENTITY_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutSpawnEntity")
|
||||
.withClassName("PacketPlayOutSpawnEntityLiving")
|
||||
.withParameterTypes(ENTITY_LIVING).withParameterTypes(ENTITY_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PLAYER_INTERACT_MANAGER_OLD_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PLAYER_INTERACT_MANAGER_OLD_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PlayerInteractManager")
|
||||
.withParameterTypes(WORLD_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PLAYER_INTERACT_MANAGER_NEW_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PLAYER_INTERACT_MANAGER_NEW_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PlayerInteractManager")
|
||||
.withParameterTypes(WORLD_SERVER_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CONSTRUCTOR_OLD = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CONSTRUCTOR_OLD = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(PACKET_PLAY_OUT_SCOREBOARD_TEAM_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntityEquipment")
|
||||
.withParameterTypes(int.class, int.class, ITEM_STACK_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_NEWEST_OLD = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_NEWEST_OLD = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntityEquipment")
|
||||
.withParameterTypes(int.class, ENUM_ITEM_SLOT, ITEM_STACK_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_V1 = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_V1 = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutEntityEquipment")
|
||||
.withParameterTypes(int.class, List.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> I_CHAT_BASE_COMPONENT_A_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.CHAT)
|
||||
public static final BaseReflection<Constructor<?>> I_CHAT_BASE_COMPONENT_A_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.CHAT)
|
||||
.withClassName("ChatComponentText")
|
||||
.withParameterTypes(String.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> ENTITY_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> ENTITY_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_ARMOR_STAND_CLASS)
|
||||
.withParameterTypes(WORLD_CLASS, double.class, double.class, double.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Constructor<?>> DATA_WATCHER_OBJECT_CONSTRUCTOR = new TypeCache.BaseReflection.ConstructorReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Constructor<?>> DATA_WATCHER_OBJECT_CONSTRUCTOR = new ConstructorReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(DATA_WATCHER_OBJECT)
|
||||
.withParameterTypes(int.class, DATA_WATCHER_SERIALIZER));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> AS_NMS_COPY_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.CRAFT_BUKKIT))
|
||||
public static final BaseReflection<Method> AS_NMS_COPY_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.BUKKIT)
|
||||
.withClassName("inventory.CraftItemStack")
|
||||
.withMethodName("asNMSCopy")
|
||||
.withParameterTypes(ItemStack.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_PROFILE_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
public static final BaseReflection<Method> GET_PROFILE_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withClassName(ENTITY_HUMAN_CLASS)
|
||||
.withExpectResult(GameProfile.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_ENTITY_ID = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> GET_ENTITY_ID = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_CLASS)
|
||||
.withMethodName("getId")
|
||||
.withMethodName("ae")
|
||||
|
@ -498,72 +401,63 @@ public final class ReflectionCache {
|
|||
.withMethodName("af")
|
||||
.withExpectResult(int.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_HANDLE_PLAYER_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.CRAFT_BUKKIT))
|
||||
public static final BaseReflection<Method> GET_HANDLE_PLAYER_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.BUKKIT)
|
||||
.withClassName("entity.CraftPlayer").withClassName("entity.CraftHumanEntity")
|
||||
.withMethodName("getHandle"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_HANDLE_WORLD_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.CRAFT_BUKKIT))
|
||||
public static final BaseReflection<Method> GET_HANDLE_WORLD_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.BUKKIT)
|
||||
.withClassName("CraftWorld")
|
||||
.withMethodName("getHandle"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_SERVER_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.CRAFT_BUKKIT))
|
||||
public static final BaseReflection<Method> GET_SERVER_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.BUKKIT)
|
||||
.withClassName("CraftServer")
|
||||
.withMethodName("getServer"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> SEND_PACKET_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> SEND_PACKET_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(PLAYER_CONNECTION_CLASS)
|
||||
.withMethodName("sendPacket").withMethodName("a")
|
||||
.withParameterTypes(PACKET_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> SET_CUSTOM_NAME_OLD_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> SET_CUSTOM_NAME_OLD_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_CLASS)
|
||||
.withMethodName("setCustomName")
|
||||
.withParameterTypes(String.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> SET_CUSTOM_NAME_NEW_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> SET_CUSTOM_NAME_NEW_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_CLASS)
|
||||
.withMethodName("setCustomName")
|
||||
.withMethodName("a")
|
||||
.withMethodName("b")
|
||||
.withParameterTypes(I_CHAT_BASE_COMPONENT).withExpectResult(void.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> SET_CUSTOM_NAME_VISIBLE_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> SET_CUSTOM_NAME_VISIBLE_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_CLASS)
|
||||
.withMethodName("setCustomNameVisible")
|
||||
.withMethodName("n")
|
||||
.withParameterTypes(boolean.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> SET_INVISIBLE_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> SET_INVISIBLE_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_ARMOR_STAND_CLASS)
|
||||
.withMethodName("setInvisible").withMethodName("j")
|
||||
.withParameterTypes(boolean.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> SET_LOCATION_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> SET_LOCATION_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_CLASS)
|
||||
.withMethodName("setPositionRotation")
|
||||
.withMethodName("a")
|
||||
.withParameterTypes(double.class, double.class, double.class, float.class, float.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> SET_DATA_WATCHER_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> SET_DATA_WATCHER_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(DATA_WATCHER_CLASS)
|
||||
.withMethodName("set").withMethodName("b")
|
||||
.withParameterTypes(DATA_WATCHER_OBJECT, Object.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> WATCH_DATA_WATCHER_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> WATCH_DATA_WATCHER_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(DATA_WATCHER_CLASS)
|
||||
.withMethodName("watch")
|
||||
.withParameterTypes(int.class, Object.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_DATA_WATCHER_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> GET_DATA_WATCHER_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_CLASS)
|
||||
.withMethodName("getDataWatcher")
|
||||
.withMethodName("ai")
|
||||
|
@ -571,112 +465,91 @@ public final class ReflectionCache {
|
|||
.withMethodName("aj")
|
||||
.withExpectResult(DATA_WATCHER_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_BUKKIT_ENTITY_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> GET_BUKKIT_ENTITY_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENTITY_CLASS)
|
||||
.withMethodName("getBukkitEntity"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_ENUM_CHAT_ID_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> GET_ENUM_CHAT_ID_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENUM_CHAT_CLASS)
|
||||
.withMethodName("b"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> ENUM_CHAT_TO_STRING_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> ENUM_CHAT_TO_STRING_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENUM_CHAT_CLASS)
|
||||
.withExpectResult(String.class)
|
||||
.withMethodName("toString"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> ENTITY_TYPES_A_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.ENTITY)
|
||||
public static final BaseReflection<Method> ENTITY_TYPES_A_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.ENTITY)
|
||||
.withClassName(ENTITY_TYPES_CLASS)
|
||||
.withMethodName("a")
|
||||
.withParameterTypes(String.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE_V1 = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE_V1 = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(PACKET_PLAY_OUT_SCOREBOARD_TEAM_CLASS)
|
||||
.withMethodName("a")
|
||||
.withParameterTypes(SCOREBOARD_TEAM_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(PACKET_PLAY_OUT_SCOREBOARD_TEAM_CLASS)
|
||||
.withMethodName("a")
|
||||
.withParameterTypes(SCOREBOARD_TEAM_CLASS, boolean.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> SCOREBOARD_PLAYER_LIST = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> SCOREBOARD_PLAYER_LIST = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(SCOREBOARD_TEAM_CLASS)
|
||||
.withMethodName("getPlayerNameSet").withMethodName("g"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> ENUM_CHAT_FORMAT_FIND = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
public static final BaseReflection<Method> ENUM_CHAT_FORMAT_FIND = new MethodReflection(new ReflectionBuilder(ReflectionPackage.MINECRAFT)
|
||||
.withClassName(ENUM_CHAT_CLASS)
|
||||
.withParameterTypes(String.class).withExpectResult(ENUM_CHAT_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> CRAFT_CHAT_MESSAGE_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.CRAFT_BUKKIT))
|
||||
public static final BaseReflection<Method> CRAFT_CHAT_MESSAGE_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.BUKKIT)
|
||||
.withClassName(CRAFT_CHAT_MESSAGE_CLASS)
|
||||
.withMethodName("fromStringOrNull")
|
||||
.withParameterTypes(String.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_UNIQUE_ID_METHOD = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
public static final BaseReflection<Method> GET_UNIQUE_ID_METHOD = new MethodReflection(new ReflectionBuilder(ReflectionPackage.MINECRAFT)
|
||||
.withClassName(ENTITY_CLASS)
|
||||
.withExpectResult(UUID.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Method> GET_DATAWATCHER_B_LIST = new TypeCache.BaseReflection.MethodReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Method> GET_DATAWATCHER_B_LIST = new MethodReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withMethodName("c")
|
||||
.withClassName(DATA_WATCHER_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Field> PLAYER_CONNECTION_FIELD = new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SERVER_LEVEL)
|
||||
public static final BaseReflection<Field> PLAYER_CONNECTION_FIELD = new FieldReflection(new ReflectionBuilder(ReflectionPackage.SERVER_LEVEL)
|
||||
.withClassName(ENTITY_PLAYER_CLASS)
|
||||
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "b" : "playerConnection"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Field> NETWORK_MANAGER_FIELD = new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Field> NETWORK_MANAGER_FIELD = new FieldReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(PLAYER_CONNECTION_CLASS)
|
||||
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "a" : "networkManager")
|
||||
.withExpectResult(NETWORK_MANAGER_CLASS));
|
||||
|
||||
public static final TypeCache.BaseReflection<Field> CHANNEL_FIELD = new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.SERVER_NETWORK)
|
||||
public static final BaseReflection<Field> CHANNEL_FIELD = new FieldReflection(new ReflectionBuilder(ReflectionPackage.SERVER_NETWORK)
|
||||
.withClassName(NETWORK_MANAGER_CLASS)
|
||||
.withExpectResult(Channel.class));
|
||||
|
||||
public static final TypeCache.BaseReflection<Field> PACKET_IN_USE_ENTITY_ID_FIELD = new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Field> PACKET_IN_USE_ENTITY_ID_FIELD = new FieldReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayInUseEntity")
|
||||
.withFieldName("a"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Field> BUKKIT_COMMAND_MAP = new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.CRAFT_BUKKIT))
|
||||
.withClassName("CraftServer")
|
||||
.withFieldName("commandMap"));
|
||||
|
||||
public static final TypeCache.BaseReflection<Object> ADD_PLAYER_FIELD = (new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Object> ADD_PLAYER_FIELD = new FieldReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutPlayerInfo$EnumPlayerInfoAction")
|
||||
.withClassName("ClientboundPlayerInfoUpdatePacket$a")
|
||||
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "a" : "ADD_PLAYER"))).asValueField();
|
||||
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "a" : "ADD_PLAYER")).asValueField();
|
||||
|
||||
public static final TypeCache.BaseReflection<Object> UPDATE_LISTED_FIELD = (new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Object> UPDATE_LISTED_FIELD = new FieldReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("ClientboundPlayerInfoUpdatePacket$a")
|
||||
.withFieldName("d"))).asValueField();
|
||||
.withFieldName("d")).asValueField();
|
||||
|
||||
public static final TypeCache.BaseReflection<Object> REMOVE_PLAYER_FIELD = (new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Object> REMOVE_PLAYER_FIELD = new FieldReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName("PacketPlayOutPlayerInfo$EnumPlayerInfoAction")
|
||||
.withClassName("ClientboundPlayerInfoUpdatePacket$a")
|
||||
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "e" : "REMOVE_PLAYER"))).asValueField();
|
||||
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "e" : "REMOVE_PLAYER")).asValueField();
|
||||
|
||||
public static final TypeCache.BaseReflection<Object> DATA_WATCHER_REGISTER_FIELD = (new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Object> DATA_WATCHER_REGISTER_FIELD = new FieldReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(DATA_WATCHER_REGISTRY)
|
||||
.withFieldName("a"))).asValueField();
|
||||
.withFieldName("a")).asValueField();
|
||||
|
||||
public static final TypeCache.BaseReflection<Object> ENUM_TAG_VISIBILITY_NEVER_FIELD = (new TypeCache.BaseReflection.FieldReflection((new TypeCache.ReflectionBuilder(ReflectionBasePackage.MINECRAFT_SERVER))
|
||||
.withCategory(ReflectionTopPackage.PACKET)
|
||||
public static final BaseReflection<Object> ENUM_TAG_VISIBILITY_NEVER_FIELD = new FieldReflection(new ReflectionBuilder(ReflectionPackage.PACKET)
|
||||
.withClassName(ENUM_TAG_VISIBILITY)
|
||||
.withFieldName("b"))).asValueField();
|
||||
.withFieldName("b")).asValueField();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package io.github.znetworkw.znpcservers.reflection;
|
||||
|
||||
import io.github.znetworkw.znpcservers.utility.Utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ReflectionPackage {
|
||||
public static final String BUKKIT = fixBasePackage("org.bukkit.craftbukkit." + Utils.getBukkitPackage());
|
||||
public static final String MINECRAFT = fixBasePackage("net.minecraft");
|
||||
|
||||
public static final String NETWORK = join(MINECRAFT, "network");
|
||||
public static final String PROTOCOL = join(MINECRAFT, "network.protocol");
|
||||
public static final String CHAT = join(MINECRAFT, "network.chat");
|
||||
public static final String PACKET = join(MINECRAFT, "network.protocol.game");
|
||||
public static final String SYNCHER = join(MINECRAFT, "network.syncher");
|
||||
public static final String ENTITY = join(MINECRAFT, "world.entity");
|
||||
public static final String WORLD_ENTITY_PLAYER = join(MINECRAFT, "world.entity.player");
|
||||
public static final String ITEM = join(MINECRAFT, "world.item");
|
||||
public static final String WORLD_LEVEL = join(MINECRAFT, "world.level");
|
||||
public static final String WORLD_SCORES = join(MINECRAFT, "world.scores");
|
||||
public static final String SERVER_LEVEL = join(MINECRAFT, "server.level");
|
||||
public static final String SERVER_NETWORK = join(MINECRAFT, "server.network");
|
||||
public static final String SERVER = join(MINECRAFT, "server");
|
||||
|
||||
public static String join(String... parts) {
|
||||
return Arrays.stream(parts)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> p.length() != 0)
|
||||
.collect(Collectors.joining("."));
|
||||
}
|
||||
|
||||
private static String fixBasePackage(String packageName) {
|
||||
return Utils.versionNewer(17) ? packageName : (packageName + (packageName.contains("minecraft") ? (".server." + Utils.getBukkitPackage()) : ""));
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package io.github.znetworkw.znpcservers.reflection;
|
||||
|
||||
public enum ReflectionTopPackage {
|
||||
DEFAULT(""),
|
||||
NETWORK("network"),
|
||||
PROTOCOL("network.protocol"),
|
||||
CHAT("network.chat"),
|
||||
PACKET("network.protocol.game"),
|
||||
SYNCHER("network.syncher"),
|
||||
ENTITY("world.entity"),
|
||||
WORLD_ENTITY_PLAYER("world.entity.player"),
|
||||
ITEM("world.item"),
|
||||
WORLD_LEVEL("world.level"),
|
||||
WORLD_SCORES("world.scores"),
|
||||
SERVER_LEVEL("server.level"),
|
||||
SERVER_NETWORK("server.network"),
|
||||
SERVER("server");
|
||||
|
||||
private final String packageName;
|
||||
|
||||
ReflectionTopPackage(String subPackageName) {
|
||||
StringBuilder stringBuilder = new StringBuilder(ReflectionBasePackage.MINECRAFT_SERVER.getFixedPackageName());
|
||||
if (subPackageName.length() > 0) {
|
||||
stringBuilder.append(".");
|
||||
stringBuilder.append(subPackageName);
|
||||
}
|
||||
this.packageName = stringBuilder.toString();
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return this.packageName;
|
||||
}
|
||||
}
|
|
@ -1,274 +0,0 @@
|
|||
package io.github.znetworkw.znpcservers.reflection;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import io.github.znetworkw.znpcservers.utility.Utils;
|
||||
import lol.pyr.znpcsplus.ZNPCsPlus;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public interface TypeCache {
|
||||
class ClassCache {
|
||||
protected static final ConcurrentMap<CacheKey, Object> CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
public static Object find(String name, Class<?> objectClass) {
|
||||
return CACHE.get(new CacheKey(name, objectClass));
|
||||
}
|
||||
|
||||
public static void register(String name, Object object, Class<?> objectClass) {
|
||||
CACHE.putIfAbsent(new CacheKey(name, objectClass), object);
|
||||
}
|
||||
|
||||
private static class CacheKey {
|
||||
private final Class<?> type;
|
||||
|
||||
private final String value;
|
||||
|
||||
public CacheKey(String value, Class<?> type) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CacheKey classKey = (CacheKey) o;
|
||||
return (Objects.equals(this.type, classKey.type) && Objects.equals(this.value, classKey.value));
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ReflectionBuilder {
|
||||
private final ReflectionBasePackage reflectionBasePackage;
|
||||
|
||||
private final ReflectionTopPackage reflectionTopPackage;
|
||||
|
||||
private final String fieldName;
|
||||
|
||||
private final List<String> className;
|
||||
|
||||
private final List<String> methods;
|
||||
|
||||
private final String additionalData;
|
||||
|
||||
private final ImmutableList<Class<?>[]> parameterTypes;
|
||||
|
||||
private final Class<?> expectType;
|
||||
|
||||
public ReflectionBuilder(ReflectionBasePackage reflectionBasePackage) {
|
||||
this(reflectionBasePackage, ReflectionTopPackage.DEFAULT, new ArrayList<>(), "", new ArrayList<>(), "", ImmutableList.of(), null);
|
||||
}
|
||||
|
||||
protected ReflectionBuilder(ReflectionBasePackage reflectionBasePackage, ReflectionTopPackage reflectionTopPackage, List<String> className, String fieldName, List<String> methods, String additionalData, ImmutableList<Class<?>[]> parameterTypes, Class<?> expectType) {
|
||||
this.reflectionBasePackage = reflectionBasePackage;
|
||||
this.reflectionTopPackage = reflectionTopPackage;
|
||||
this.className = className;
|
||||
this.methods = methods;
|
||||
this.fieldName = fieldName;
|
||||
this.additionalData = additionalData;
|
||||
this.parameterTypes = parameterTypes;
|
||||
this.expectType = expectType;
|
||||
}
|
||||
|
||||
public ReflectionBuilder withCategory(ReflectionTopPackage reflectionTopPackage) {
|
||||
return new ReflectionBuilder(this.reflectionBasePackage, reflectionTopPackage, this.className, this.fieldName, this.methods, this.additionalData, this.parameterTypes, this.expectType);
|
||||
}
|
||||
|
||||
public ReflectionBuilder withClassName(String className) {
|
||||
return new ReflectionBuilder(this.reflectionBasePackage, this.reflectionTopPackage, new ImmutableList.Builder<String>().addAll(this.className).add(formatClass(className)).build(), this.fieldName, this.methods, this.additionalData, this.parameterTypes, this.expectType);
|
||||
}
|
||||
|
||||
public ReflectionBuilder withClassName(Class<?> clazz) {
|
||||
return new ReflectionBuilder(this.reflectionBasePackage, this.reflectionTopPackage, new ImmutableList.Builder<String>().addAll(this.className).add((clazz == null) ? "" : clazz.getName()).build(), this.fieldName, this.methods, this.additionalData, this.parameterTypes, this.expectType);
|
||||
}
|
||||
|
||||
public ReflectionBuilder withMethodName(String methodName) {
|
||||
return new ReflectionBuilder(this.reflectionBasePackage, this.reflectionTopPackage, this.className, this.fieldName, new ImmutableList.Builder<String>().addAll(this.methods).add(methodName).build(), this.additionalData, this.parameterTypes, this.expectType);
|
||||
}
|
||||
|
||||
public ReflectionBuilder withFieldName(String fieldName) {
|
||||
return new ReflectionBuilder(this.reflectionBasePackage, this.reflectionTopPackage, this.className, fieldName, this.methods, this.additionalData, this.parameterTypes, this.expectType);
|
||||
}
|
||||
|
||||
public ReflectionBuilder withAdditionalData(String additionalData) {
|
||||
return new ReflectionBuilder(this.reflectionBasePackage, this.reflectionTopPackage, this.className, this.fieldName, this.methods, additionalData, this.parameterTypes, this.expectType);
|
||||
}
|
||||
|
||||
public ReflectionBuilder withParameterTypes(Class<?>... types) {
|
||||
return new ReflectionBuilder(this.reflectionBasePackage, this.reflectionTopPackage, this.className, this.fieldName, this.methods, this.additionalData, ImmutableList.copyOf(Iterables.concat(this.parameterTypes, ImmutableList.of(types))), this.expectType);
|
||||
}
|
||||
|
||||
public ReflectionBuilder withExpectResult(Class<?> expectType) {
|
||||
return new ReflectionBuilder(this.reflectionBasePackage, this.reflectionTopPackage, this.className, this.fieldName, this.methods, this.additionalData, this.parameterTypes, expectType);
|
||||
}
|
||||
|
||||
protected String formatClass(String className) {
|
||||
return switch (this.reflectionBasePackage) {
|
||||
case MINECRAFT_SERVER, CRAFT_BUKKIT -> String.format(((this.reflectionBasePackage == ReflectionBasePackage.CRAFT_BUKKIT) ? this.reflectionBasePackage.getFixedPackageName() : this.reflectionBasePackage.getForCategory(this.reflectionTopPackage, this.additionalData)) + ".%s", className);
|
||||
case DEFAULT -> className;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BaseReflection<T> {
|
||||
protected final ReflectionBuilder reflectionBuilder;
|
||||
|
||||
protected Class<?> BUILDER_CLASS;
|
||||
|
||||
private T cached;
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
protected BaseReflection(ReflectionBuilder reflectionBuilder) {
|
||||
this.reflectionBuilder = reflectionBuilder;
|
||||
for (String classes : reflectionBuilder.className) {
|
||||
try {
|
||||
this.BUILDER_CLASS = Class.forName(classes);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T load() {
|
||||
return load(false);
|
||||
}
|
||||
|
||||
public T load(boolean missAllowed) {
|
||||
if (this.loaded) return this.cached;
|
||||
try {
|
||||
if (this.BUILDER_CLASS == null) throw new ClassNotFoundException("No class found: " + this.reflectionBuilder.className.toString());
|
||||
T eval = (this.cached != null) ? this.cached : (this.cached = onLoad());
|
||||
if (eval == null) throw new NullPointerException();
|
||||
} catch (Throwable throwable) {
|
||||
if (!missAllowed) {
|
||||
log("Cache load failed!");
|
||||
log("Class Names: " + this.reflectionBuilder.className.toString());
|
||||
log("Loader Type: " + getClass().getCanonicalName());
|
||||
log("Bukkit Version: " + Utils.BUKKIT_VERSION + " (" + Utils.getBukkitPackage() + ")");
|
||||
log("Exception:");
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.loaded = true;
|
||||
return this.cached;
|
||||
}
|
||||
|
||||
private void log(String message) {
|
||||
ZNPCsPlus.LOGGER.warning("[ReflectionCache] " + message);
|
||||
}
|
||||
|
||||
protected abstract T onLoad() throws Exception;
|
||||
|
||||
public static class ClassReflection extends BaseReflection<Class<?>> {
|
||||
public ClassReflection(ReflectionBuilder reflectionBuilder) {
|
||||
super(reflectionBuilder);
|
||||
}
|
||||
|
||||
protected Class<?> onLoad() {
|
||||
return this.BUILDER_CLASS;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MethodReflection extends BaseReflection<Method> {
|
||||
public MethodReflection(ReflectionBuilder builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
protected Method onLoad() {
|
||||
Method methodThis = null;
|
||||
List<String> methods = this.reflectionBuilder.methods;
|
||||
boolean hasExpectedType = (this.reflectionBuilder.expectType != null);
|
||||
if (methods.isEmpty() && hasExpectedType) for (Method method : this.BUILDER_CLASS.getDeclaredMethods()) {
|
||||
if (method.getReturnType() == this.reflectionBuilder.expectType) return method;
|
||||
}
|
||||
for (String methodName : this.reflectionBuilder.methods) try {
|
||||
Method maybeGet;
|
||||
if (!Iterables.isEmpty(this.reflectionBuilder.parameterTypes))
|
||||
maybeGet = this.BUILDER_CLASS.getDeclaredMethod(methodName, Iterables.get(this.reflectionBuilder.parameterTypes, 0));
|
||||
else maybeGet = this.BUILDER_CLASS.getDeclaredMethod(methodName);
|
||||
if (this.reflectionBuilder.expectType != null && this.reflectionBuilder.expectType != maybeGet.getReturnType()) continue;
|
||||
maybeGet.setAccessible(true);
|
||||
methodThis = maybeGet;
|
||||
} catch (NoSuchMethodException ignored) {}
|
||||
return methodThis;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FieldReflection extends BaseReflection<Field> {
|
||||
public FieldReflection(ReflectionBuilder reflectionBuilder) {
|
||||
super(reflectionBuilder);
|
||||
}
|
||||
|
||||
protected Field onLoad() throws NoSuchFieldException {
|
||||
if (this.reflectionBuilder.expectType != null)
|
||||
for (Field field1 : this.BUILDER_CLASS.getDeclaredFields()) {
|
||||
if (field1.getType() == this.reflectionBuilder.expectType) {
|
||||
field1.setAccessible(true);
|
||||
return field1;
|
||||
}
|
||||
}
|
||||
Field field = this.BUILDER_CLASS.getDeclaredField(this.reflectionBuilder.fieldName);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
}
|
||||
|
||||
public AsValueField asValueField() {
|
||||
return new AsValueField(this);
|
||||
}
|
||||
|
||||
private static class AsValueField extends BaseReflection<Object> {
|
||||
private final FieldReflection fieldReflection;
|
||||
|
||||
public AsValueField(FieldReflection fieldReflection) {
|
||||
super(fieldReflection.reflectionBuilder);
|
||||
this.fieldReflection = fieldReflection;
|
||||
}
|
||||
|
||||
protected Object onLoad() throws IllegalAccessException, NoSuchFieldException {
|
||||
Field field = this.fieldReflection.onLoad();
|
||||
return field.get(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConstructorReflection extends BaseReflection<Constructor<?>> {
|
||||
public ConstructorReflection(ReflectionBuilder reflectionBuilder) {
|
||||
super(reflectionBuilder);
|
||||
}
|
||||
|
||||
protected Constructor<?> onLoad() throws NoSuchMethodException {
|
||||
Constructor<?> constructor = null;
|
||||
if (Iterables.size(this.reflectionBuilder.parameterTypes) > 1) {
|
||||
for (Class<?>[] keyParameters : this.reflectionBuilder.parameterTypes) try {
|
||||
constructor = this.BUILDER_CLASS.getDeclaredConstructor(keyParameters);
|
||||
} catch (NoSuchMethodException ignored) {}
|
||||
} else constructor = (Iterables.size(this.reflectionBuilder.parameterTypes) > 0) ? this.BUILDER_CLASS.getDeclaredConstructor(Iterables.get(this.reflectionBuilder.parameterTypes, 0)) : this.BUILDER_CLASS.getDeclaredConstructor();
|
||||
if (constructor != null) constructor.setAccessible(true);
|
||||
return constructor;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EnumReflection extends BaseReflection<Enum<?>[]> {
|
||||
public EnumReflection(ReflectionBuilder reflectionBuilder) {
|
||||
super(reflectionBuilder);
|
||||
}
|
||||
|
||||
protected Enum<?>[] onLoad() {
|
||||
Enum<?>[] arrayOfEnum = (Enum<?>[]) this.BUILDER_CLASS.getEnumConstants();
|
||||
for (Enum<?> enumConstant : arrayOfEnum) TypeCache.ClassCache.register(enumConstant.name(), enumConstant, this.BUILDER_CLASS);
|
||||
return arrayOfEnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package io.github.znetworkw.znpcservers.reflection.types;
|
||||
|
||||
import io.github.znetworkw.znpcservers.reflection.BaseReflection;
|
||||
import io.github.znetworkw.znpcservers.reflection.ReflectionBuilder;
|
||||
|
||||
public class ClassReflection extends BaseReflection<Class<?>> {
|
||||
public ClassReflection(ReflectionBuilder reflectionBuilder) {
|
||||
super(reflectionBuilder);
|
||||
}
|
||||
|
||||
protected Class<?> load() {
|
||||
return this.BUILDER_CLASS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package io.github.znetworkw.znpcservers.reflection.types;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import io.github.znetworkw.znpcservers.reflection.BaseReflection;
|
||||
import io.github.znetworkw.znpcservers.reflection.ReflectionBuilder;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
public class ConstructorReflection extends BaseReflection<Constructor<?>> {
|
||||
private final ImmutableList<Class<?>[]> parameterTypes;
|
||||
|
||||
public ConstructorReflection(ReflectionBuilder reflectionBuilder) {
|
||||
super(reflectionBuilder);
|
||||
this.parameterTypes = reflectionBuilder.getParameterTypes();
|
||||
}
|
||||
|
||||
protected Constructor<?> load() throws NoSuchMethodException {
|
||||
Constructor<?> constructor = null;
|
||||
if (Iterables.size(parameterTypes) > 1) {
|
||||
for (Class<?>[] keyParameters : parameterTypes) try {
|
||||
constructor = this.BUILDER_CLASS.getDeclaredConstructor(keyParameters);
|
||||
} catch (NoSuchMethodException ignored) {}
|
||||
} else constructor = (Iterables.size(parameterTypes) > 0) ? this.BUILDER_CLASS.getDeclaredConstructor(Iterables.get(parameterTypes, 0)) : this.BUILDER_CLASS.getDeclaredConstructor();
|
||||
if (constructor != null) constructor.setAccessible(true);
|
||||
return constructor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package io.github.znetworkw.znpcservers.reflection.types;
|
||||
|
||||
import io.github.znetworkw.znpcservers.reflection.BaseReflection;
|
||||
import io.github.znetworkw.znpcservers.reflection.ClassCache;
|
||||
import io.github.znetworkw.znpcservers.reflection.ReflectionBuilder;
|
||||
|
||||
public class EnumReflection extends BaseReflection<Enum<?>[]> {
|
||||
public EnumReflection(ReflectionBuilder reflectionBuilder) {
|
||||
super(reflectionBuilder);
|
||||
}
|
||||
|
||||
protected Enum<?>[] load() {
|
||||
Enum<?>[] arrayOfEnum = (Enum<?>[]) this.BUILDER_CLASS.getEnumConstants();
|
||||
for (Enum<?> enumConstant : arrayOfEnum) ClassCache.register(enumConstant.name(), enumConstant, this.BUILDER_CLASS);
|
||||
return arrayOfEnum;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package io.github.znetworkw.znpcservers.reflection.types;
|
||||
|
||||
import io.github.znetworkw.znpcservers.reflection.BaseReflection;
|
||||
import io.github.znetworkw.znpcservers.reflection.ReflectionBuilder;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
public class FieldReflection extends BaseReflection<Field> {
|
||||
private final String fieldName;
|
||||
private final Class<?> expectType;
|
||||
|
||||
public FieldReflection(ReflectionBuilder reflectionBuilder) {
|
||||
super(reflectionBuilder);
|
||||
this.fieldName = reflectionBuilder.getFieldName();
|
||||
this.expectType = reflectionBuilder.getExpectType();
|
||||
}
|
||||
|
||||
protected Field load() throws NoSuchFieldException {
|
||||
if (expectType != null)
|
||||
for (Field field1 : this.BUILDER_CLASS.getDeclaredFields()) {
|
||||
if (field1.getType() == expectType) {
|
||||
field1.setAccessible(true);
|
||||
return field1;
|
||||
}
|
||||
}
|
||||
Field field = this.BUILDER_CLASS.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
}
|
||||
|
||||
public AsValueField asValueField() {
|
||||
return new AsValueField(this, className);
|
||||
}
|
||||
|
||||
private static class AsValueField extends BaseReflection<Object> {
|
||||
private final FieldReflection fieldReflection;
|
||||
|
||||
public AsValueField(FieldReflection fieldReflection, List<String> className) {
|
||||
super(className);
|
||||
this.fieldReflection = fieldReflection;
|
||||
}
|
||||
|
||||
protected Object load() throws IllegalAccessException, NoSuchFieldException {
|
||||
Field field = this.fieldReflection.load();
|
||||
return field.get(null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package io.github.znetworkw.znpcservers.reflection.types;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import io.github.znetworkw.znpcservers.reflection.BaseReflection;
|
||||
import io.github.znetworkw.znpcservers.reflection.ReflectionBuilder;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class MethodReflection extends BaseReflection<Method> {
|
||||
private final ImmutableList<String> methods;
|
||||
private final ImmutableList<Class<?>[]> parameterTypes;
|
||||
private final Class<?> expectType;
|
||||
|
||||
public MethodReflection(ReflectionBuilder builder) {
|
||||
super(builder);
|
||||
this.methods = builder.getMethods();
|
||||
this.expectType = builder.getExpectType();
|
||||
this.parameterTypes = builder.getParameterTypes();
|
||||
}
|
||||
|
||||
protected Method load() {
|
||||
Method methodThis = null;
|
||||
boolean hasExpectedType = (expectType != null);
|
||||
if (methods.isEmpty() && hasExpectedType) for (Method method : this.BUILDER_CLASS.getDeclaredMethods()) if (method.getReturnType() == expectType) return method;
|
||||
for (String methodName : methods) try {
|
||||
Method maybeGet;
|
||||
if (!Iterables.isEmpty(parameterTypes)) maybeGet = this.BUILDER_CLASS.getDeclaredMethod(methodName, Iterables.get(parameterTypes, 0));
|
||||
else maybeGet = this.BUILDER_CLASS.getDeclaredMethod(methodName);
|
||||
if (expectType != null && expectType != maybeGet.getReturnType()) continue;
|
||||
maybeGet.setAccessible(true);
|
||||
methodThis = maybeGet;
|
||||
} catch (NoSuchMethodException ignored) {}
|
||||
return methodThis;
|
||||
}
|
||||
}
|
|
@ -41,9 +41,9 @@ public class ZUser {
|
|||
this.lastClicked = new HashMap<>();
|
||||
this.eventServices = new ArrayList<>();
|
||||
try {
|
||||
Object playerHandle = ReflectionCache.GET_HANDLE_PLAYER_METHOD.load().invoke(toPlayer());
|
||||
this.gameProfile = (GameProfile) ReflectionCache.GET_PROFILE_METHOD.load().invoke(playerHandle, new Object[0]);
|
||||
this.playerConnection = ReflectionCache.PLAYER_CONNECTION_FIELD.load().get(playerHandle);
|
||||
Object playerHandle = ReflectionCache.GET_HANDLE_PLAYER_METHOD.get().invoke(toPlayer());
|
||||
this.gameProfile = (GameProfile) ReflectionCache.GET_PROFILE_METHOD.get().invoke(playerHandle, new Object[0]);
|
||||
this.playerConnection = ReflectionCache.PLAYER_CONNECTION_FIELD.get().get(playerHandle);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new IllegalStateException("can't create user for player " + uuid.toString(), e.getCause());
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class ZUser {
|
|||
|
||||
private boolean tryRegisterChannel() {
|
||||
try {
|
||||
Channel channel = (Channel) ReflectionCache.CHANNEL_FIELD.load().get(ReflectionCache.NETWORK_MANAGER_FIELD.load().get(this.playerConnection));
|
||||
Channel channel = (Channel) ReflectionCache.CHANNEL_FIELD.get().get(ReflectionCache.NETWORK_MANAGER_FIELD.get().get(this.playerConnection));
|
||||
if (channel.pipeline().names().contains("npc_interact")) channel.pipeline().remove("npc_interact");
|
||||
channel.pipeline().addAfter("decoder", "npc_interact", new ZNPCSocketDecoder());
|
||||
return true;
|
||||
|
@ -141,7 +141,7 @@ public class ZUser {
|
|||
long lastInteractNanos = System.nanoTime() - ZUser.this.lastInteract;
|
||||
if (ZUser.this.lastInteract != 0L && lastInteractNanos < 1000000000L)
|
||||
return;
|
||||
int entityId = ReflectionCache.PACKET_IN_USE_ENTITY_ID_FIELD.load().getInt(packet);
|
||||
int entityId = ReflectionCache.PACKET_IN_USE_ENTITY_ID_FIELD.get().getInt(packet);
|
||||
NPC npc = NPC.all().stream().filter(npc1 -> (npc1.getEntityID() == entityId)).findFirst().orElse(null);
|
||||
if (npc == null)
|
||||
return;
|
||||
|
|
|
@ -76,7 +76,7 @@ public final class Utils {
|
|||
try {
|
||||
for (Object packet : packets) {
|
||||
if (packet != null)
|
||||
ReflectionCache.SEND_PACKET_METHOD.load().invoke(user.getPlayerConnection(), packet);
|
||||
ReflectionCache.SEND_PACKET_METHOD.get().invoke(user.getPlayerConnection(), packet);
|
||||
}
|
||||
} catch (IllegalAccessException | java.lang.reflect.InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in a new issue