fix double arrow formatting issue, add 1.19.4 support, fix entity destroy issue

This commit is contained in:
Pyr 2023-04-19 21:40:58 +01:00
parent 4f6048c058
commit b95c5ab3f3
5 changed files with 13 additions and 18 deletions

@ -495,6 +495,7 @@ public final class CacheRegistry {
.withMethodName("getId") .withMethodName("getId")
.withMethodName("ae") .withMethodName("ae")
.withMethodName("ah") .withMethodName("ah")
.withMethodName("af")
.withExpectResult(int.class)); .withExpectResult(int.class));
public static final TypeCache.BaseCache<Method> GET_HANDLE_PLAYER_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT)) public static final TypeCache.BaseCache<Method> GET_HANDLE_PLAYER_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.CRAFT_BUKKIT))
@ -567,6 +568,7 @@ public final class CacheRegistry {
.withMethodName("getDataWatcher") .withMethodName("getDataWatcher")
.withMethodName("ai") .withMethodName("ai")
.withMethodName("al") .withMethodName("al")
.withMethodName("aj")
.withExpectResult(DATA_WATCHER_CLASS)); .withExpectResult(DATA_WATCHER_CLASS));
public static final TypeCache.BaseCache<Method> GET_BUKKIT_ENTITY_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER)) public static final TypeCache.BaseCache<Method> GET_BUKKIT_ENTITY_METHOD = new TypeCache.BaseCache.MethodLoader((new TypeCache.CacheBuilder(CachePackage.MINECRAFT_SERVER))

@ -151,7 +151,10 @@ public interface TypeCache {
if (eval == null) throw new NullPointerException(); if (eval == null) throw new NullPointerException();
} catch (Throwable throwable) { } catch (Throwable throwable) {
if (!missAllowed) { if (!missAllowed) {
log("Cache for class failed to load due to the following exception: " + this.cacheBuilder.className); log("Cache load failed!");
log("Class Names: " + this.cacheBuilder.className.toString());
log("Loader Type: " + getClass().getCanonicalName());
log("Exception:");
throwable.printStackTrace(); throwable.printStackTrace();
} }
} }

@ -32,7 +32,7 @@ public class CommandSender {
} }
public void sendMessage(CommandInformation subCommand) { public void sendMessage(CommandInformation subCommand) {
sendMessage(" &7» &6/&eznpcs " + subCommand.name() + " " + sendMessage(" &7\u00BB &6/&eznpcs " + subCommand.name() + " " +
Arrays.stream(subCommand.arguments()) Arrays.stream(subCommand.arguments())
.map(s -> "<" + s + ">") .map(s -> "<" + s + ">")
.collect(Collectors.joining(" ")), .collect(Collectors.joining(" ")),

@ -47,7 +47,7 @@ public class DefaultCommand extends Command {
@CommandInformation(arguments = {}, name = "", permission = "") @CommandInformation(arguments = {}, name = "", permission = "")
public void defaultCommand(CommandSender sender, Map<String, String> args) { public void defaultCommand(CommandSender sender, Map<String, String> args) {
sender.sendMessage("&6&m------------------------------------------"); sender.sendMessage("&6&m------------------------------------------");
sender.sendMessage("&b&lZNPCS &8» &7ZNetwork"); sender.sendMessage("&b&lZNPCS &8\u00BB &7ZNetwork");
sender.sendMessage("&6https://www.spigotmc.org/resources/znpcs.80940"); sender.sendMessage("&6https://www.spigotmc.org/resources/znpcs.80940");
Objects.requireNonNull(sender); Objects.requireNonNull(sender);
getCommands().forEach(sender::sendMessage); getCommands().forEach(sender::sendMessage);
@ -77,12 +77,8 @@ public class DefaultCommand extends Command {
return; return;
} }
NPCType npcType = NPCType.valueOf(args.get("type").toUpperCase()); NPCType npcType = NPCType.valueOf(args.get("type").toUpperCase());
NPC npc = ZNPCsPlus.createNPC(id, npcType, sender.getPlayer().getLocation(), name); ZNPCsPlus.createNPC(id, npcType, sender.getPlayer().getLocation(), name);
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.SUCCESS); Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.SUCCESS);
if (npcType == NPCType.PLAYER) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.FETCHING_SKIN, name);
DO_APPLY_SKIN.apply(sender.getPlayer(), npc, name);
}
} }
@CommandInformation(arguments = {"id"}, name = "delete", permission = "znpcs.cmd.delete", help = {" &f&l* &e/znpcs delete <npc_id>"}) @CommandInformation(arguments = {"id"}, name = "delete", permission = "znpcs.cmd.delete", help = {" &f&l* &e/znpcs delete <npc_id>"})

@ -35,8 +35,7 @@ public interface Packet {
@SuppressWarnings("SuspiciousTernaryOperatorInVarargsCall") @SuppressWarnings("SuspiciousTernaryOperatorInVarargsCall")
@PacketValue(keyName = "destroyPacket", valueType = ValueType.ARGUMENTS) @PacketValue(keyName = "destroyPacket", valueType = ValueType.ARGUMENTS)
default Object getDestroyPacket(int entityId) throws ReflectiveOperationException { default Object getDestroyPacket(int entityId) throws ReflectiveOperationException {
(new int[1])[0] = entityId; return CacheRegistry.PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR.load().newInstance(CacheRegistry.PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR.load().getParameterTypes()[0].isArray() ? new int[] {entityId} : entityId);
return CacheRegistry.PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR.load().newInstance(CacheRegistry.PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR.load().getParameterTypes()[0].isArray() ? new int[1] : entityId);
} }
@PacketValue(keyName = "enumSlot", valueType = ValueType.ARGUMENTS) @PacketValue(keyName = "enumSlot", valueType = ValueType.ARGUMENTS)
@ -47,16 +46,11 @@ public interface Packet {
@PacketValue(keyName = "removeTab") @PacketValue(keyName = "removeTab")
default Object getTabRemovePacket(Object nmsEntity) throws ReflectiveOperationException { default Object getTabRemovePacket(Object nmsEntity) throws ReflectiveOperationException {
try { try {
return CacheRegistry.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.load().newInstance(CacheRegistry.REMOVE_PLAYER_FIELD return CacheRegistry.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.load().newInstance(CacheRegistry.REMOVE_PLAYER_FIELD.load(), Collections.singletonList(nmsEntity));
.load(),
Collections.singletonList(nmsEntity));
} catch (Throwable throwable) { } catch (Throwable throwable) {
boolean useOldMethod = (CacheRegistry.PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CLASS != null); boolean useOldMethod = (CacheRegistry.PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CLASS != null);
if (useOldMethod) if (useOldMethod) return CacheRegistry.PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CONSTRUCTOR.load().newInstance(Collections.singletonList(CacheRegistry.GET_UNIQUE_ID_METHOD.load().invoke(nmsEntity)));
return CacheRegistry.PACKET_PLAY_OUT_PLAYER_INFO_REMOVE_CONSTRUCTOR.load() return CacheRegistry.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.load().newInstance(CacheRegistry.REMOVE_PLAYER_FIELD.load(), nmsEntity);
.newInstance(Collections.singletonList(CacheRegistry.GET_UNIQUE_ID_METHOD.load().invoke(nmsEntity)));
return CacheRegistry.PACKET_PLAY_OUT_PLAYER_INFO_CONSTRUCTOR.load().newInstance(CacheRegistry.REMOVE_PLAYER_FIELD
.load(), nmsEntity);
} }
} }