do some refactoring, add fix for "java.util.NoSuchElementException: decoder" & improve logging

This commit is contained in:
Pyr 2023-04-19 19:44:55 +01:00
parent 3fa94b4f31
commit 8762d640f5
9 changed files with 108 additions and 233 deletions

@ -41,5 +41,9 @@ processResources {
expand("version": version)
}
runServer {
minecraftVersion "1.19.3"
}
tasks.assemble.dependsOn reobfJar
tasks.compileJava.dependsOn clean

@ -14,583 +14,482 @@ import java.util.UUID;
public final class CacheRegistry {
public static final Class<?> PACKET_PLAY_IN_USE_ENTITY_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayInUseEntity"))).load();
public static final Class<?> ENUM_PLAYER_INFO_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutPlayerInfo$EnumPlayerInfoAction")
.withClassName("ClientboundPlayerInfoUpdatePacket$a"))).load();
public static final Class<?> PACKET_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PROTOCOL)
.withClassName("Packet"))).load();
public static final Class<?> ENTITY_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withClassName("Entity"))).load();
public static final Class<?> ENTITY_LIVING = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withClassName("EntityLiving"))).load();
public static final Class<?> ENTITY_PLAYER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SERVER_LEVEL)
.withClassName("EntityPlayer"))).load();
public static final Class<?> ENTITY_ARMOR_STAND_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("decoration")
.withClassName("EntityArmorStand"))).load();
public static final Class<?> ENTITY_BAT_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("ambient")
.withClassName("EntityBat"))).load();
public static final Class<?> ENTITY_BLAZE_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityBlaze"))).load();
public static final Class<?> ENTITY_CAVE_SPIDER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityCaveSpider"))).load();
public static final Class<?> ENTITY_CHICKEN_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityChicken"))).load();
public static final Class<?> ENTITY_COW_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityCow"))).load();
public static final Class<?> ENTITY_CREEPER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityCreeper"))).load();
public static final Class<?> ENTITY_ENDER_DRAGON_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("boss.enderdragon")
.withClassName("EntityEnderDragon"))).load();
public static final Class<?> ENTITY_ENDERMAN_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityEnderman"))).load();
public static final Class<?> ENTITY_HUMAN_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("player")
.withClassName("EntityHuman"))).load();
public static final Class<?> ENTITY_ENDERMITE_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityEndermite"))).load();
public static final Class<?> ENTITY_GHAST_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityGhast"))).load();
public static final Class<?> ENTITY_IRON_GOLEM_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityIronGolem"))).load();
public static final Class<?> ENTITY_GIANT_ZOMBIE_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityGiantZombie"))).load();
public static final Class<?> ENTITY_GUARDIAN_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityGuardian"))).load();
public static final Class<?> ENTITY_HORSE_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal.horse")
.withClassName("EntityHorse"))).load();
public static final Class<?> ENTITY_LLAMA_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal.horse")
.withClassName("EntityLlama"))).load();
public static final Class<?> ENTITY_MAGMA_CUBE_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityMagmaCube"))).load();
public static final Class<?> ENTITY_MUSHROOM_COW_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityMushroomCow"))).load();
public static final Class<?> ENTITY_OCELOT_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityOcelot"))).load();
public static final Class<?> ENTITY_TURTLE = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityTurtle"))).load();
public static final Class<?> ENTITY_WARDEN = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster.warden")
.withClassName("EntityWarden")
.withClassName("Warden"))).load();
public static final Class<?> ENTITY_BEE_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityBee"))).load();
public static final Class<?> ENTITY_PARROT_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityParrot"))).load();
public static final Class<?> ENTITY_PIG_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityPig"))).load();
public static final Class<?> ENTITY_RABBIT_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityRabbit"))).load();
public static final Class<?> ENTITY_POLAR_BEAR_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityPolarBear"))).load();
public static final Class<?> ENTITY_PANDA_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityPanda"))).load();
public static final Class<?> ENTITY_SHEEP_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntitySheep"))).load();
public static final Class<?> ENTITY_SNOWMAN_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntitySnowman"))).load();
public static final Class<?> ENTITY_SHULKER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityShulker"))).load();
public static final Class<?> ENTITY_SILVERFISH_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntitySilverfish"))).load();
public static final Class<?> ENTITY_SKELETON_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntitySkeleton"))).load();
public static final Class<?> ENTITY_SLIME_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntitySlime"))).load();
public static final Class<?> ENTITY_SPIDER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntitySpider"))).load();
public static final Class<?> ENTITY_SQUID_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntitySquid"))).load();
public static final Class<?> ENTITY_VILLAGER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("npc")
.withClassName("EntityVillager"))).load();
public static final Class<?> ENTITY_WITCH_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityWitch"))).load();
public static final Class<?> ENTITY_WITHER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("boss.wither")
.withClassName("EntityWither"))).load();
public static final Class<?> ENTITY_ZOMBIE_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("monster")
.withClassName("EntityZombie"))).load();
public static final Class<?> ENTITY_WOLF_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityWolf"))).load();
public static final Class<?> ENTITY_AXOLOTL_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal.axolotl")
.withClassName("Axolotl"))).load();
public static final Class<?> ENTITY_GOAT_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal.goat")
.withClassName("Goat"))).load();
public static final Class<?> ENTITY_FOX_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withAdditionalData("animal")
.withClassName("EntityFox"))).load();
public static final Class<?> ENTITY_TYPES_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withClassName("EntityTypes"))).load();
public static final Class<?> ENUM_CHAT_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withClassName("EnumChatFormat"))).load();
public static final Class<?> ENUM_ITEM_SLOT = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withClassName("EnumItemSlot"))).load();
public static final Class<?> I_CHAT_BASE_COMPONENT = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.CHAT)
.withClassName("IChatBaseComponent"))).load();
public static final Class<?> ITEM_STACK_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ITEM)
.withClassName("ItemStack"))).load();
public static final Class<?> DATA_WATCHER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SYNCHER)
.withClassName("DataWatcher"))).load();
public static final Class<?> DATA_WATCHER_OBJECT = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SYNCHER)
.withClassName("DataWatcherObject"))).load();
public static final Class<?> DATA_WATCHER_REGISTRY = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SYNCHER)
.withClassName("DataWatcherRegistry"))).load();
public static final Class<?> DATA_WATCHER_SERIALIZER = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SYNCHER)
.withClassName("DataWatcherSerializer"))).load();
public static final Class<?> WORLD_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.WORLD_LEVEL)
.withClassName("World"))).load();
public static final Class<?> CRAFT_ITEM_STACK_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT))
.withClassName("inventory.CraftItemStack"))).load();
public static final Class<?> WORLD_SERVER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SERVER_LEVEL)
.withClassName("WorldServer"))).load();
public static final Class<?> MINECRAFT_SERVER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SERVER)
.withClassName("MinecraftServer"))).load();
public static final Class<?> PLAYER_INTERACT_MANAGER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SERVER_LEVEL)
.withClassName("PlayerInteractManager"))).load();
public static final Class<?> PLAYER_CONNECTION_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SERVER_NETWORK)
.withClassName("PlayerConnection"))).load();
public static final Class<?> NETWORK_MANAGER_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.NETWORK)
.withClassName("NetworkManager"))).load();
public static final Class<?> PACKET_PLAY_OUT_PLAYER_INFO_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutPlayerInfo")
.withClassName("ClientboundPlayerInfoUpdatePacket")))
.load();
public static final Class<?> PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("ClientboundPlayerInfoRemovePacket")))
.load();
public static final Class<?> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutScoreboardTeam"))).load();
public static final Class<?> PACKET_PLAY_OUT_ENTITY_DESTROY_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutEntityDestroy"))).load();
public static final Class<?> SCOREBOARD_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.WORLD_SCORES)
.withClassName("Scoreboard"))).load();
public static final Class<?> SCOREBOARD_TEAM_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.WORLD_SCORES)
.withClassName("ScoreboardTeam"))).load();
public static final Class<?> ENUM_TAG_VISIBILITY = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.WORLD_SCORES)
.withClassName("ScoreboardTeamBase$EnumNameTagVisibility"))).load();
public static final Class<?> CRAFT_CHAT_MESSAGE_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT))
.withClassName("util.CraftChatMessage"))).load();
public static final Class<?> PROFILE_PUBLIC_KEY_CLASS = (new TypeCache.BaseCache.ClazzLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.WORLD_ENTITY_PLAYER)
.withClassName("ProfilePublicKey"))).load();
public static final TypeCache.BaseCache<Constructor<?>> SCOREBOARD_TEAM_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(SCOREBOARD_TEAM_CLASS)
.withParameterTypes(SCOREBOARD_CLASS, String.class));
public static final TypeCache.BaseCache<Constructor<?>> PLAYER_CONSTRUCTOR_OLD = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_PLAYER_CLASS)
.withParameterTypes(MINECRAFT_SERVER_CLASS, WORLD_SERVER_CLASS, GameProfile.class, PLAYER_INTERACT_MANAGER_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PLAYER_CONSTRUCTOR_NEW = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_PLAYER_CLASS)
.withParameterTypes(MINECRAFT_SERVER_CLASS, WORLD_SERVER_CLASS, GameProfile.class));
public static final TypeCache.BaseCache<Constructor<?>> PLAYER_CONSTRUCTOR_NEW_1 = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_PLAYER_CLASS)
.withParameterTypes(MINECRAFT_SERVER_CLASS, WORLD_SERVER_CLASS, GameProfile.class, PROFILE_PUBLIC_KEY_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PLAYER_CONSTRUCTOR_NEW_2 = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_PLAYER_CLASS)
.withParameterTypes(MINECRAFT_SERVER_CLASS, WORLD_SERVER_CLASS, GameProfile.class));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.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.BaseCache<Constructor<?>> PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CLASS)
.withParameterTypes(List.class));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_ENTITY_LOOK_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutEntity$PacketPlayOutEntityLook")
.withParameterTypes(int.class, byte.class, byte.class, boolean.class));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_ENTITY_HEAD_ROTATION_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutEntityHeadRotation")
.withParameterTypes(ENTITY_CLASS, byte.class));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_ENTITY_TELEPORT_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutEntityTeleport")
.withParameterTypes(ENTITY_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutEntityMetadata")
.withParameterTypes(int.class, DATA_WATCHER_CLASS, boolean.class));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR_V1 = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutEntityMetadata")
.withParameterTypes(int.class, List.class));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_NAMED_ENTITY_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutNamedEntitySpawn")
.withParameterTypes(ENTITY_HUMAN_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(PACKET_PLAY_OUT_ENTITY_DESTROY_CLASS)
.withParameterTypes(int.class).withParameterTypes(int[].class));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_SPAWN_ENTITY_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutSpawnEntity")
.withClassName("PacketPlayOutSpawnEntityLiving")
.withParameterTypes(ENTITY_LIVING).withParameterTypes(ENTITY_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PLAYER_INTERACT_MANAGER_OLD_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PlayerInteractManager")
.withParameterTypes(WORLD_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PLAYER_INTERACT_MANAGER_NEW_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PlayerInteractManager")
.withParameterTypes(WORLD_SERVER_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CONSTRUCTOR_OLD = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(PACKET_PLAY_OUT_SCOREBOARD_TEAM_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutEntityEquipment")
.withParameterTypes(int.class, int.class, ITEM_STACK_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_NEWEST_OLD = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutEntityEquipment")
.withParameterTypes(int.class, ENUM_ITEM_SLOT, ITEM_STACK_CLASS));
public static final TypeCache.BaseCache<Constructor<?>> PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_V1 = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutEntityEquipment")
.withParameterTypes(int.class, List.class));
public static final TypeCache.BaseCache<Constructor<?>> I_CHAT_BASE_COMPONENT_A_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.CHAT)
.withClassName("ChatComponentText")
.withParameterTypes(String.class));
public static final TypeCache.BaseCache<Constructor<?>> ENTITY_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_ARMOR_STAND_CLASS)
.withParameterTypes(WORLD_CLASS, double.class, double.class, double.class));
public static final TypeCache.BaseCache<Constructor<?>> DATA_WATCHER_OBJECT_CONSTRUCTOR = new TypeCache.BaseCache.ConstructorLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(DATA_WATCHER_OBJECT)
.withParameterTypes(int.class, DATA_WATCHER_SERIALIZER));
public static final TypeCache.BaseCache<Method> AS_NMS_COPY_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT))
.withClassName("inventory.CraftItemStack")
.withMethodName("asNMSCopy")
.withParameterTypes(ItemStack.class));
public static final TypeCache.BaseCache<Method> GET_PROFILE_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withClassName(ENTITY_HUMAN_CLASS)
.withExpectResult(GameProfile.class));
public static final TypeCache.BaseCache<Method> GET_ENTITY_ID = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_CLASS)
.withMethodName("getId")
@ -599,36 +498,30 @@ public final class CacheRegistry {
.withExpectResult(int.class));
public static final TypeCache.BaseCache<Method> GET_HANDLE_PLAYER_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT))
.withClassName("entity.CraftPlayer").withClassName("entity.CraftHumanEntity")
.withMethodName("getHandle"));
public static final TypeCache.BaseCache<Method> GET_HANDLE_WORLD_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT))
.withClassName("CraftWorld")
.withMethodName("getHandle"));
public static final TypeCache.BaseCache<Method> GET_SERVER_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT))
.withClassName("CraftServer")
.withMethodName("getServer"));
public static final TypeCache.BaseCache<Method> SEND_PACKET_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(PLAYER_CONNECTION_CLASS)
.withMethodName("sendPacket").withMethodName("a")
.withParameterTypes(PACKET_CLASS));
public static final TypeCache.BaseCache<Method> SET_CUSTOM_NAME_OLD_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_CLASS)
.withMethodName("setCustomName")
.withParameterTypes(String.class));
public static final TypeCache.BaseCache<Method> SET_CUSTOM_NAME_NEW_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_CLASS)
.withMethodName("setCustomName")
@ -637,7 +530,6 @@ public final class CacheRegistry {
.withParameterTypes(I_CHAT_BASE_COMPONENT).withExpectResult(void.class));
public static final TypeCache.BaseCache<Method> SET_CUSTOM_NAME_VISIBLE_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_CLASS)
.withMethodName("setCustomNameVisible")
@ -645,14 +537,12 @@ public final class CacheRegistry {
.withParameterTypes(boolean.class));
public static final TypeCache.BaseCache<Method> SET_INVISIBLE_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_ARMOR_STAND_CLASS)
.withMethodName("setInvisible").withMethodName("j")
.withParameterTypes(boolean.class));
public static final TypeCache.BaseCache<Method> SET_LOCATION_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_CLASS)
.withMethodName("setPositionRotation")
@ -660,21 +550,18 @@ public final class CacheRegistry {
.withParameterTypes(double.class, double.class, double.class, float.class, float.class));
public static final TypeCache.BaseCache<Method> SET_DATA_WATCHER_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(DATA_WATCHER_CLASS)
.withMethodName("set").withMethodName("b")
.withParameterTypes(DATA_WATCHER_OBJECT, Object.class));
public static final TypeCache.BaseCache<Method> WATCH_DATA_WATCHER_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(DATA_WATCHER_CLASS)
.withMethodName("watch")
.withParameterTypes(int.class, Object.class));
public static final TypeCache.BaseCache<Method> GET_DATA_WATCHER_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_CLASS)
.withMethodName("getDataWatcher")
@ -683,131 +570,110 @@ public final class CacheRegistry {
.withExpectResult(DATA_WATCHER_CLASS));
public static final TypeCache.BaseCache<Method> GET_BUKKIT_ENTITY_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENTITY_CLASS)
.withMethodName("getBukkitEntity"));
public static final TypeCache.BaseCache<Method> GET_ENUM_CHAT_ID_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENUM_CHAT_CLASS)
.withMethodName("b"));
public static final TypeCache.BaseCache<Method> ENUM_CHAT_TO_STRING_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENUM_CHAT_CLASS)
.withExpectResult(String.class)
.withMethodName("toString"));
public static final TypeCache.BaseCache<Method> ENTITY_TYPES_A_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.ENTITY)
.withClassName(ENTITY_TYPES_CLASS)
.withMethodName("a")
.withParameterTypes(String.class));
public static final TypeCache.BaseCache<Method> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE_V1 = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(PACKET_PLAY_OUT_SCOREBOARD_TEAM_CLASS)
.withMethodName("a")
.withParameterTypes(SCOREBOARD_TEAM_CLASS));
public static final TypeCache.BaseCache<Method> PACKET_PLAY_OUT_SCOREBOARD_TEAM_CREATE = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(PACKET_PLAY_OUT_SCOREBOARD_TEAM_CLASS)
.withMethodName("a")
.withParameterTypes(SCOREBOARD_TEAM_CLASS, boolean.class));
public static final TypeCache.BaseCache<Method> SCOREBOARD_PLAYER_LIST = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(SCOREBOARD_TEAM_CLASS)
.withMethodName("getPlayerNameSet").withMethodName("g"));
public static final TypeCache.BaseCache<Method> ENUM_CHAT_FORMAT_FIND = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withClassName(ENUM_CHAT_CLASS)
.withParameterTypes(String.class).withExpectResult(ENUM_CHAT_CLASS));
public static final TypeCache.BaseCache<Method> CRAFT_CHAT_MESSAGE_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT))
.withClassName(CRAFT_CHAT_MESSAGE_CLASS)
.withMethodName("fromStringOrNull")
.withParameterTypes(String.class));
public static final TypeCache.BaseCache<Method> GET_UNIQUE_ID_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withClassName(ENTITY_CLASS)
.withExpectResult(UUID.class));
public static final TypeCache.BaseCache<Method> GET_DATAWATCHER_B_LIST = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withMethodName("c")
.withClassName(DATA_WATCHER_CLASS));
public static final TypeCache.BaseCache<Field> PLAYER_CONNECTION_FIELD = new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SERVER_LEVEL)
.withClassName(ENTITY_PLAYER_CLASS)
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "b" : "playerConnection"));
public static final TypeCache.BaseCache<Field> NETWORK_MANAGER_FIELD = new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(PLAYER_CONNECTION_CLASS)
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "a" : "networkManager")
.withExpectResult(NETWORK_MANAGER_CLASS));
public static final TypeCache.BaseCache<Field> CHANNEL_FIELD = new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.SERVER_NETWORK)
.withClassName(NETWORK_MANAGER_CLASS)
.withExpectResult(Channel.class));
public static final TypeCache.BaseCache<Field> PACKET_IN_USE_ENTITY_ID_FIELD = new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayInUseEntity")
.withFieldName("a"));
public static final TypeCache.BaseCache<Field> BUKKIT_COMMAND_MAP = new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT))
.withClassName("CraftServer")
.withFieldName("commandMap"));
public static final TypeCache.BaseCache<Object> ADD_PLAYER_FIELD = (new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutPlayerInfo$EnumPlayerInfoAction")
.withClassName("ClientboundPlayerInfoUpdatePacket$a")
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "a" : "ADD_PLAYER"))).asValueField();
public static final TypeCache.BaseCache<Object> UPDATE_LISTED_FIELD = (new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("ClientboundPlayerInfoUpdatePacket$a")
.withFieldName("d"))).asValueField();
public static final TypeCache.BaseCache<Object> REMOVE_PLAYER_FIELD = (new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName("PacketPlayOutPlayerInfo$EnumPlayerInfoAction")
.withClassName("ClientboundPlayerInfoUpdatePacket$a")
.withFieldName((Utils.BUKKIT_VERSION > 16) ? "e" : "REMOVE_PLAYER"))).asValueField();
public static final TypeCache.BaseCache<Object> DATA_WATCHER_REGISTER_FIELD = (new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(DATA_WATCHER_REGISTRY)
.withFieldName("a"))).asValueField();
public static final TypeCache.BaseCache<Object> ENUM_TAG_VISIBILITY_NEVER_FIELD = (new TypeCache.BaseCache.FieldLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))
.withCategory(CacheCategory.PACKET)
.withClassName(ENUM_TAG_VISIBILITY)
.withFieldName("b"))).asValueField();

@ -2,6 +2,7 @@ package io.github.znetworkw.znpcservers.cache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import lol.pyr.znpcsplus.ZNPCsPlus;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@ -11,8 +12,6 @@ import java.util.List;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import java.util.logging.Logger;
public interface TypeCache {
class ClassCache {
@ -37,10 +36,8 @@ public interface TypeCache {
}
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
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));
}
@ -69,9 +66,7 @@ public interface TypeCache {
private final Class<?> expectType;
public CacheBuilder(CachePackage cachePackage) {
this(cachePackage, CacheCategory.DEFAULT, new ArrayList<>(), "", new ArrayList<>(), "",
ImmutableList.of(), null);
this(cachePackage, CacheCategory.DEFAULT, new ArrayList<>(), "", new ArrayList<>(), "", ImmutableList.of(), null);
}
protected CacheBuilder(CachePackage cachePackage, CacheCategory cacheCategory, List<String> className, String fieldName, List<String> methods, String additionalData, ImmutableList<Class<?>[]> parameterTypes, Class<?> expectType) {
@ -90,19 +85,15 @@ public interface TypeCache {
}
public CacheBuilder withClassName(String className) {
return new CacheBuilder(this.cachePackage, this.cacheCategory,
new ImmutableList.Builder<String>().addAll(this.className)
.add(formatClass(className)).build(), this.fieldName, this.methods, this.additionalData, this.parameterTypes, this.expectType);
return new CacheBuilder(this.cachePackage, this.cacheCategory, new ImmutableList.Builder<String>().addAll(this.className).add(formatClass(className)).build(), this.fieldName, this.methods, this.additionalData, this.parameterTypes, this.expectType);
}
public CacheBuilder withClassName(Class<?> clazz) {
return new CacheBuilder(this.cachePackage, this.cacheCategory,
new ImmutableList.Builder<String>().addAll(this.className).add((clazz == null) ? "" : clazz.getName()).build(), this.fieldName, this.methods, this.additionalData, this.parameterTypes, this.expectType);
return new CacheBuilder(this.cachePackage, this.cacheCategory, new ImmutableList.Builder<String>().addAll(this.className).add((clazz == null) ? "" : clazz.getName()).build(), this.fieldName, this.methods, this.additionalData, this.parameterTypes, this.expectType);
}
public CacheBuilder withMethodName(String methodName) {
return new CacheBuilder(this.cachePackage, this.cacheCategory, this.className, this.fieldName,
new ImmutableList.Builder<String>().addAll(this.methods).add(methodName).build(), this.additionalData, this.parameterTypes, this.expectType);
return new CacheBuilder(this.cachePackage, this.cacheCategory, this.className, this.fieldName, new ImmutableList.Builder<String>().addAll(this.methods).add(methodName).build(), this.additionalData, this.parameterTypes, this.expectType);
}
public CacheBuilder withFieldName(String fieldName) {
@ -114,8 +105,7 @@ public interface TypeCache {
}
public CacheBuilder withParameterTypes(Class<?>... types) {
return new CacheBuilder(this.cachePackage, this.cacheCategory, this.className, this.fieldName, this.methods, this.additionalData,
ImmutableList.copyOf(Iterables.concat(this.parameterTypes, ImmutableList.of(types))), this.expectType);
return new CacheBuilder(this.cachePackage, this.cacheCategory, this.className, this.fieldName, this.methods, this.additionalData, ImmutableList.copyOf(Iterables.concat(this.parameterTypes, ImmutableList.of(types))), this.expectType);
}
public CacheBuilder withExpectResult(Class<?> expectType) {
@ -124,16 +114,13 @@ public interface TypeCache {
protected String formatClass(String className) {
return switch (this.cachePackage) {
case MINECRAFT_SERVER, CRAFT_BUKKIT -> String.format(((this.cachePackage == CachePackage.CRAFT_BUKKIT) ?
this.cachePackage.getFixedPackageName() : this.cachePackage.getForCategory(this.cacheCategory, this.additionalData)) + ".%s", className);
case MINECRAFT_SERVER, CRAFT_BUKKIT -> String.format(((this.cachePackage == CachePackage.CRAFT_BUKKIT) ? this.cachePackage.getFixedPackageName() : this.cachePackage.getForCategory(this.cacheCategory, this.additionalData)) + ".%s", className);
case DEFAULT -> className;
};
}
}
abstract class BaseCache<T> {
private static final Logger LOGGER = Logger.getLogger(BaseCache.class.getName());
protected final TypeCache.CacheBuilder cacheBuilder;
protected Class<?> BUILDER_CLASS;
@ -153,18 +140,14 @@ public interface TypeCache {
}
public T load() {
if (this.loaded)
return this.cached;
if (this.loaded) return this.cached;
try {
if (this.BUILDER_CLASS == null)
throw new IllegalStateException("can't find class for: " + this.cacheBuilder
.className);
if (this.BUILDER_CLASS == null) throw new IllegalStateException("can't find class for: " + this.cacheBuilder.className);
T eval = (this.cached != null) ? this.cached : (this.cached = onLoad());
if (eval == null)
throw new NullPointerException();
if (eval == null) throw new NullPointerException();
} catch (Throwable throwable) {
if (throwable instanceof IllegalStateException)
log("No cache found for: " + this.cacheBuilder.className);
throwable.printStackTrace();
if (throwable instanceof IllegalStateException) log("No cache found for: " + this.cacheBuilder.className);
log("No cache found for: " + this.cacheBuilder.className + " : " + this.cacheBuilder.methods.toString());
log("Skipping cache for " + this.cacheBuilder.className);
}
@ -173,7 +156,7 @@ public interface TypeCache {
}
private void log(String message) {
LOGGER.log(Level.WARNING, message);
ZNPCsPlus.LOGGER.warning("[BaseCache] " + message);
}
protected abstract T onLoad() throws Exception;
@ -197,26 +180,18 @@ public interface TypeCache {
Method methodThis = null;
List<String> methods = this.cacheBuilder.methods;
boolean hasExpectedType = (this.cacheBuilder.expectType != null);
if (methods.isEmpty() && hasExpectedType)
for (Method method : this.BUILDER_CLASS.getDeclaredMethods()) {
if (method.getReturnType() == this.cacheBuilder.expectType)
return method;
}
for (String methodName : this.cacheBuilder.methods) {
try {
Method maybeGet;
if (!Iterables.isEmpty(this.cacheBuilder.parameterTypes)) {
maybeGet = this.BUILDER_CLASS.getDeclaredMethod(methodName, Iterables.get(this.cacheBuilder.parameterTypes, 0));
} else {
maybeGet = this.BUILDER_CLASS.getDeclaredMethod(methodName);
}
if (this.cacheBuilder.expectType != null && this.cacheBuilder.expectType != maybeGet.getReturnType())
continue;
maybeGet.setAccessible(true);
methodThis = maybeGet;
} catch (NoSuchMethodException ignored) {
}
if (methods.isEmpty() && hasExpectedType) for (Method method : this.BUILDER_CLASS.getDeclaredMethods()) {
if (method.getReturnType() == this.cacheBuilder.expectType) return method;
}
for (String methodName : this.cacheBuilder.methods) try {
Method maybeGet;
if (!Iterables.isEmpty(this.cacheBuilder.parameterTypes))
maybeGet = this.BUILDER_CLASS.getDeclaredMethod(methodName, Iterables.get(this.cacheBuilder.parameterTypes, 0));
else maybeGet = this.BUILDER_CLASS.getDeclaredMethod(methodName);
if (this.cacheBuilder.expectType != null && this.cacheBuilder.expectType != maybeGet.getReturnType()) continue;
maybeGet.setAccessible(true);
methodThis = maybeGet;
} catch (NoSuchMethodException ignored) {}
return methodThis;
}
}
@ -266,17 +241,11 @@ public interface TypeCache {
protected Constructor<?> onLoad() throws NoSuchMethodException {
Constructor<?> constructor = null;
if (Iterables.size(this.cacheBuilder.parameterTypes) > 1) {
for (Class<?>[] keyParameters : this.cacheBuilder.parameterTypes) {
try {
constructor = this.BUILDER_CLASS.getDeclaredConstructor(keyParameters);
} catch (NoSuchMethodException ignored) {
}
}
} else {
constructor = (Iterables.size(this.cacheBuilder.parameterTypes) > 0) ? this.BUILDER_CLASS.getDeclaredConstructor(Iterables.get(this.cacheBuilder.parameterTypes, 0)) : this.BUILDER_CLASS.getDeclaredConstructor();
}
if (constructor != null)
constructor.setAccessible(true);
for (Class<?>[] keyParameters : this.cacheBuilder.parameterTypes) try {
constructor = this.BUILDER_CLASS.getDeclaredConstructor(keyParameters);
} catch (NoSuchMethodException ignored) {}
} else constructor = (Iterables.size(this.cacheBuilder.parameterTypes) > 0) ? this.BUILDER_CLASS.getDeclaredConstructor(Iterables.get(this.cacheBuilder.parameterTypes, 0)) : this.BUILDER_CLASS.getDeclaredConstructor();
if (constructor != null) constructor.setAccessible(true);
return constructor;
}
}
@ -288,8 +257,7 @@ public interface TypeCache {
protected Enum<?>[] onLoad() {
Enum<?>[] arrayOfEnum = (Enum<?>[]) this.BUILDER_CLASS.getEnumConstants();
for (Enum<?> enumConstant : arrayOfEnum)
TypeCache.ClassCache.register(enumConstant.name(), enumConstant, this.BUILDER_CLASS);
for (Enum<?> enumConstant : arrayOfEnum) TypeCache.ClassCache.register(enumConstant.name(), enumConstant, this.BUILDER_CLASS);
return arrayOfEnum;
}
}

@ -50,7 +50,6 @@ public class DefaultCommand extends Command {
sender.sendMessage("&b&lZNPCS &8» &7ZNetwork");
sender.sendMessage("&6https://www.spigotmc.org/resources/znpcs.80940");
Objects.requireNonNull(sender);
Objects.requireNonNull(sender);
getCommands().forEach(sender::sendMessage);
sender.sendMessage(ChatColor.DARK_GRAY + "Hover over the commands to see help for the command.");
sender.sendMessage("&6&m------------------------------------------");

@ -1,10 +1,10 @@
package io.github.znetworkw.znpcservers.npc;
import lol.pyr.znpcsplus.ZNPCsPlus;
import io.github.znetworkw.znpcservers.configuration.Configuration;
import io.github.znetworkw.znpcservers.configuration.ConfigurationValue;
import io.github.znetworkw.znpcservers.user.ZUser;
import io.github.znetworkw.znpcservers.utility.location.ZLocation;
import lol.pyr.znpcsplus.ZNPCsPlus;
import org.bukkit.Location;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
@ -16,8 +16,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@SuppressWarnings("ALL")
public interface NPCPath {
@ -89,8 +87,6 @@ public interface NPCPath {
}
abstract class AbstractTypeWriter implements NPCPath {
private static final Logger LOGGER = Logger.getLogger(AbstractTypeWriter.class.getName());
private static final ConcurrentMap<String, AbstractTypeWriter> PATH_TYPES = new ConcurrentHashMap<>();
private static final int PATH_DELAY = 1;
@ -153,7 +149,8 @@ public interface NPCPath {
throw throwable;
}
} catch (IOException e) {
LOGGER.log(Level.WARNING, String.format("The path %s could not be loaded", this.file.getName()));
ZNPCsPlus.LOGGER.warning("[AbstractTypeWriter] " + String.format("The path %s could not be loaded", this.file.getName()));
e.printStackTrace();
}
}
@ -174,7 +171,8 @@ public interface NPCPath {
throw throwable;
}
} catch (IOException e) {
LOGGER.log(Level.WARNING, String.format("Path %s could not be created", getName()), e);
ZNPCsPlus.LOGGER.warning("[AbstractTypeWriter] " + String.format("Path %s could not be created", getName()));
e.printStackTrace();
}
}

@ -11,11 +11,9 @@ public class PacketV19 extends PacketV18 {
public Object getPlayerPacket(Object nmsWorld, GameProfile gameProfile) throws ReflectiveOperationException {
try {
return CacheRegistry.PLAYER_CONSTRUCTOR_NEW_1.load().newInstance(CacheRegistry.GET_SERVER_METHOD
.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile, null);
return CacheRegistry.PLAYER_CONSTRUCTOR_NEW_1.load().newInstance(CacheRegistry.GET_SERVER_METHOD.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile, null);
} catch (Throwable e) {
return CacheRegistry.PLAYER_CONSTRUCTOR_NEW_2.load().newInstance(CacheRegistry.GET_SERVER_METHOD
.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile);
return CacheRegistry.PLAYER_CONSTRUCTOR_NEW_2.load().newInstance(CacheRegistry.GET_SERVER_METHOD.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile);
}
}
}

@ -20,9 +20,7 @@ public class PacketV8 implements Packet {
public Object getPlayerPacket(Object nmsWorld, GameProfile gameProfile) throws ReflectiveOperationException {
Constructor<?> constructor = (Utils.BUKKIT_VERSION > 13) ? CacheRegistry.PLAYER_INTERACT_MANAGER_NEW_CONSTRUCTOR.load() : CacheRegistry.PLAYER_INTERACT_MANAGER_OLD_CONSTRUCTOR.load();
return CacheRegistry.PLAYER_CONSTRUCTOR_OLD.load().newInstance(CacheRegistry.GET_SERVER_METHOD
.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile, constructor
.newInstance(nmsWorld));
.load().invoke(Bukkit.getServer()), nmsWorld, gameProfile, constructor.newInstance(nmsWorld));
}
public Object getSpawnPacket(Object nmsEntity, boolean isPlayer) throws ReflectiveOperationException {
@ -31,8 +29,7 @@ public class PacketV8 implements Packet {
public Object convertItemStack(int entityId, ItemSlot itemSlot, ItemStack itemStack) throws ReflectiveOperationException {
return CacheRegistry.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD.load().newInstance(entityId,
itemSlot.getSlotOld(), CacheRegistry.AS_NMS_COPY_METHOD
.load().invoke(CacheRegistry.CRAFT_ITEM_STACK_CLASS, itemStack));
itemSlot.getSlotOld(), CacheRegistry.AS_NMS_COPY_METHOD.load().invoke(CacheRegistry.CRAFT_ITEM_STACK_CLASS, itemStack));
}
public Object getClickType(Object interactPacket) throws ReflectiveOperationException {
@ -44,10 +41,7 @@ public class PacketV8 implements Packet {
try {
return CacheRegistry.PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR.load().newInstance(entityId, dataWatcher, true);
} catch (Exception e2) {
return CacheRegistry.PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR_V1
.load()
.newInstance(entityId, CacheRegistry.GET_DATAWATCHER_B_LIST
.load().invoke(dataWatcher));
return CacheRegistry.PACKET_PLAY_OUT_ENTITY_META_DATA_CONSTRUCTOR_V1.load().newInstance(entityId, CacheRegistry.GET_DATAWATCHER_B_LIST.load().invoke(dataWatcher));
}
}
@ -58,8 +52,7 @@ public class PacketV8 implements Packet {
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(CacheRegistry.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD.load().newInstance(npc.getEntityID(),
stackEntry.getKey().getSlotOld(),
builder.add(CacheRegistry.PACKET_PLAY_OUT_ENTITY_EQUIPMENT_CONSTRUCTOR_OLD.load().newInstance(npc.getEntityID(), stackEntry.getKey().getSlotOld(),
convertItemStack(npc.getEntityID(), stackEntry.getKey(), stackEntry.getValue())));
}
return builder.build();

@ -10,9 +10,13 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import lol.pyr.znpcsplus.ZNPCsPlus;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
public class ZUser {
@ -39,13 +43,48 @@ public class ZUser {
try {
Object playerHandle = CacheRegistry.GET_HANDLE_PLAYER_METHOD.load().invoke(toPlayer());
this.gameProfile = (GameProfile) CacheRegistry.GET_PROFILE_METHOD.load().invoke(playerHandle, new Object[0]);
Channel channel = (Channel) CacheRegistry.CHANNEL_FIELD.load().get(CacheRegistry.NETWORK_MANAGER_FIELD.load()
.get(this.playerConnection = CacheRegistry.PLAYER_CONNECTION_FIELD.load().get(playerHandle)));
if (channel.pipeline().names().contains("npc_interact"))
channel.pipeline().remove("npc_interact");
this.playerConnection = CacheRegistry.PLAYER_CONNECTION_FIELD.load().get(playerHandle);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("can't create user for player " + uuid.toString(), e.getCause());
}
if (!tryRegisterChannel()) ZNPCsPlus.SCHEDULER.runTaskTimer(new ChannelRegistrationFallbackTask(this), 3);
}
private static class ChannelRegistrationFallbackTask extends BukkitRunnable {
private final ZUser user;
private final Player player;
private int tries = 5;
private ChannelRegistrationFallbackTask(ZUser user) {
this.user = user;
this.player = user.toPlayer();
}
@Override
public void run() {
if (!player.isOnline() || user.tryRegisterChannel()) {
cancel();
return;
}
if (tries-- > 0) return;
cancel();
player.kick(Component.text("[ZNPCsPlus]", NamedTextColor.RED).appendNewline()
.append(Component.text("Couldn't inject interaction detector to channel", NamedTextColor.WHITE)).appendNewline()
.append(Component.text("Please report this at https://github.com/Pyrbu/ZNPCsPlus", NamedTextColor.WHITE)));
ZNPCsPlus.LOGGER.severe("Couldn't inject interaction detector to channel for player " + player.getName() + " (" + player.getUniqueId() + ")");
}
}
private boolean tryRegisterChannel() {
try {
Channel channel = (Channel) CacheRegistry.CHANNEL_FIELD.load().get(CacheRegistry.NETWORK_MANAGER_FIELD.load().get(this.playerConnection));
if (channel.pipeline().names().contains("npc_interact")) channel.pipeline().remove("npc_interact");
channel.pipeline().addAfter("decoder", "npc_interact", new ZNPCSocketDecoder());
} catch (IllegalAccessException | java.lang.reflect.InvocationTargetException e) {
throw new IllegalStateException("can't create player " + uuid.toString(), e.getCause());
return true;
} catch (IllegalAccessException e) {
throw new RuntimeException("illegal access exception while trying to register npc_interact channel");
} catch (NoSuchElementException e) {
return false;
}
}

@ -1,6 +1,5 @@
package lol.pyr.znpcsplus;
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.github.znetworkw.znpcservers.commands.list.DefaultCommand;
@ -27,10 +26,12 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.Collections;
import java.util.logging.Logger;
public class ZNPCsPlus extends JavaPlugin {
public static final File PLUGIN_FOLDER = new File("plugins/ServersNPC");
public static final File PATH_FOLDER = new File("plugins/ServersNPC/paths");
public static Logger LOGGER;
public static File PLUGIN_FOLDER;
public static File PATH_FOLDER;
public static final Gson GSON = new GsonBuilder()
.registerTypeAdapter(ZLocation.class, ZLocation.SERIALIZER)
.registerTypeHierarchyAdapter(ItemStack.class, new ItemStackSerializer())
@ -57,9 +58,17 @@ public class ZNPCsPlus extends JavaPlugin {
ConfigurationConstants.NPC_LIST.remove(npc.getNpcPojo());
}
@Override
public void onLoad() {
LOGGER = getLogger();
PLUGIN_FOLDER = getDataFolder();
PATH_FOLDER = new File(PLUGIN_FOLDER, "paths");
}
@Override
public void onEnable() {
ImmutableList<File> files = ImmutableList.of(PLUGIN_FOLDER, PATH_FOLDER);
for (File file : files) file.mkdirs();
PLUGIN_FOLDER.mkdirs();
PATH_FOLDER.mkdirs();
loadAllPaths();
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
@ -74,6 +83,7 @@ public class ZNPCsPlus extends JavaPlugin {
new InventoryListener(this);
}
@Override
public void onDisable() {
Configuration.SAVE_CONFIGURATIONS.forEach(Configuration::save);
Bukkit.getOnlinePlayers().forEach(ZUser::unregister);