diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/commands/ancmd/Command.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/commands/ancmd/Command.java index ccecd12f..9d13c80c 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/commands/ancmd/Command.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/commands/ancmd/Command.java @@ -12,6 +12,7 @@ String display() default ""; boolean playerOnly() default false; boolean consoleOnly() default false; + boolean opOnly() default false; boolean async() default false; String[] permission() default {}; String[] tabCompletions() default {}; //Format label::result diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/commands/ancmd/CommandManager.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/commands/ancmd/CommandManager.java index 56464d04..264abce2 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/commands/ancmd/CommandManager.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/commands/ancmd/CommandManager.java @@ -156,7 +156,9 @@ public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd, S Command command = entry.getMethod().getMethod().getAnnotation(Command.class); Atlas.getInstance().getProfile().start("anCommand:" + cmd.getLabel()); Runnable runnable = () -> { - if(command.playerOnly() && !(sender instanceof Player)) { + if(command.opOnly() && !sender.isOp()) { + sender.sendMessage(Color.translate(command.noPermissionMessage())); + } else if(command.playerOnly() && !(sender instanceof Player)) { sender.sendMessage(Color.Red + "This command is for players only!"); } else if(command.consoleOnly() && !(sender instanceof ConsoleCommandSender)) { sender.sendMessage(Color.Red + "This command can only be run via terminal."); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/reflections/impl/CraftReflection.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/reflections/impl/CraftReflection.java index 57fbf30d..34ef7eeb 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/reflections/impl/CraftReflection.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/reflections/impl/CraftReflection.java @@ -5,7 +5,6 @@ import cc.funkemunky.api.reflections.types.WrappedMethod; import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -22,7 +21,6 @@ public class CraftReflection { public static WrappedClass craftWorld = Reflections.getCBClass("CraftWorld"); //1.7-1.14 public static WrappedClass craftInventoryPlayer = Reflections.getCBClass("inventory.CraftInventoryPlayer"); //1.7-1.14 public static WrappedClass craftServer = Reflections.getCBClass("CraftServer"); //1.7-1.14 - public static WrappedClass craftMagicNumbers = Reflections.getCBClass("util.CraftMagicNumbers"); //Vanilla Instances private static WrappedMethod itemStackInstance = craftItemStack.getMethod("asNMSCopy", ItemStack.class); //1.7-1.14 @@ -34,9 +32,6 @@ public class CraftReflection { private static WrappedMethod getInventory = craftInventoryPlayer.getMethod("getInventory"); //1.7-1.14 private static WrappedMethod mcServerInstance = craftServer.getMethod("getServer"); //1.7-1.14 private static WrappedMethod entityPlayerInstance = craftPlayer.getMethod("getHandle"); - private static WrappedMethod magicBlockFromMaterial = craftMagicNumbers.getMethod("getBlock", Material.class); - private static WrappedMethod magicMaterialBlock = craftMagicNumbers.getMethod("getMaterial", - MinecraftReflection.block.getParent()); public static T getVanillaItemStack(ItemStack stack) { return itemStackInstance.invoke(null, stack); @@ -60,10 +55,6 @@ public static T getVanillaBlock(Block block) { } else return blockInstance.invoke(block); } - public static T getVanillaBlock(Material material) { - return magicBlockFromMaterial.invoke(null, material); - } - public static T getVanillaWorld(World world) { return worldInstance.invoke(world); } @@ -80,9 +71,6 @@ public static T getMinecraftServer() { return mcServerInstance.invoke(Bukkit.getServer()); } - public static Material getTypeFromVanillaBlock(Object vanillaBlock) { - return magicMaterialBlock.invoke(null, vanillaBlock); - } static { } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/reflections/impl/MinecraftReflection.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/reflections/impl/MinecraftReflection.java index ae41ca7e..d54926a4 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/reflections/impl/MinecraftReflection.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/reflections/impl/MinecraftReflection.java @@ -78,7 +78,7 @@ public class MinecraftReflection { private static WrappedField pingField = entityPlayer.getFieldByName("ping"); //Blocks - private static WrappedMethod addCBoxes, bdGetBlock; + private static WrappedMethod addCBoxes; public static WrappedClass blockPos; private static WrappedConstructor blockPosConstructor; private static WrappedMethod getBlockData; @@ -302,10 +302,6 @@ public static T getPlayerConnection(Object player) { return connectionField.get(entityPlayer); } - public static T getBlockFromBlockData(Object blockData) { - return bdGetBlock.invoke(blockData); - } - //Can either use Player or EntityPlayer object. public static T getNetworkManager(Object player) { return connectionNetworkField.get(getPlayerConnection(player)); @@ -360,7 +356,6 @@ public static List getVanillaChunks(Object provider) { .getConstructor(double.class, double.class, double.class, double.class, double.class, double.class); iBlockData = Reflections.getNMSClass("IBlockData"); worldGetType = worldServer.getMethod("getType", blockPos.getParent()); - bdGetBlock = iBlockData.getMethodByType(block.getParent(), 0); } else { idioticOldStaticConstructorAABB = axisAlignedBB.getMethod("a", double.class, double.class, double.class, double.class, double.class, double.class); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/api/packets/channelhandler/TinyProtocol1_8.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/api/packets/channelhandler/TinyProtocol1_8.java index 38798989..6cb59530 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/api/packets/channelhandler/TinyProtocol1_8.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/api/packets/channelhandler/TinyProtocol1_8.java @@ -549,6 +549,7 @@ private final class PacketInterceptor extends ChannelDuplexHandler { public void channelRead(ChannelHandlerContext ctx, Object msg) { // Intercept channel final Channel channel = ctx.channel(); + if (PACKET_LOGIN_IN_START.isInstance(msg)) { GameProfile profile = getGameProfile.get(msg); channelLookup.put(profile.getName(), channel); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInAbilitiesPacket.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInAbilitiesPacket.java index 5e9452dc..780fa7c2 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInAbilitiesPacket.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInAbilitiesPacket.java @@ -40,11 +40,7 @@ public void process(Player player, ProtocolVersion version) { @Override public void updateObject() { - invulnerableField.set(getObject(), invulnerable); - flyingField.set(getObject(), flying); - allowedFlightField.set(getObject(), allowedFlight); - creativeModeField.set(getObject(), creativeMode); - flySpeedField.set(getObject(), flySpeed); - walkSpeedField.set(getObject(), walkSpeed); + setObject(NMSObject.construct(getObject(), + packet, invulnerable, flying, allowedFlight, creativeMode, flySpeed, walkSpeed)); } } \ No newline at end of file diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInArmAnimationPacket.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInArmAnimationPacket.java index 6f4a070f..06e459a2 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInArmAnimationPacket.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInArmAnimationPacket.java @@ -33,7 +33,7 @@ public void process(Player player, ProtocolVersion version) { @Override public void updateObject() { if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_9)) { - mainHandField.set(getObject(), enumHand.getEnum(mainHand ? "MAIN_HAND" : "OFF_HAND")); + setObject(NMSObject.construct(getObject(), packet, enumHand.getEnum(mainHand ? "MAIN_HAND" : "OFF_HAND"))); } } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInBlockDigPacket.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInBlockDigPacket.java index b13ddc60..c1e33aad 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInBlockDigPacket.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/in/WrappedInBlockDigPacket.java @@ -1,7 +1,5 @@ package cc.funkemunky.api.tinyprotocol.packet.in; -import cc.funkemunky.api.reflections.Reflections; -import cc.funkemunky.api.reflections.types.WrappedClass; import cc.funkemunky.api.tinyprotocol.api.NMSObject; import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; import cc.funkemunky.api.tinyprotocol.packet.types.BaseBlockPosition; @@ -37,17 +35,7 @@ public WrappedInBlockDigPacket(Object packet, Player player) { @Override public void updateObject() { - if(ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.V1_8)) { - fieldPosX.set(getObject(), position.getX()); - fieldPosY.set(getObject(), position.getY()); - fieldPosZ.set(getObject(), position.getZ()); - face.set(getObject(), direction.ordinal()); - intAction.set(getObject(), action.ordinal()); - } else { - fieldBlockPosition.set(getObject(), position.getAsBlockPosition()); - fieldDirection.set(getObject(), direction.toVanilla()); - fieldDigType.set(getObject(), action.toVanilla()); - } + } @Override @@ -79,21 +67,5 @@ public enum EnumPlayerDigType { DROP_ITEM, RELEASE_USE_ITEM, SWAP_HELD_ITEMS; - - static WrappedClass epdtClass = null; - - public T toVanilla() { - if(epdtClass == null ) return null; - return (T) epdtClass.getEnum(toString()); - } - - static { - if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_8)) { - epdtClass = Reflections.getNMSClass(ProtocolVersion.getGameVersion() - .isAbove(ProtocolVersion.V1_8) - ? "EnumPlayerDigType" - : "PacketPlayInBlockDig.EnumPlayerDigType"); - } - } } } \ No newline at end of file diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutAbilitiesPacket.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutAbilitiesPacket.java index 57586c9c..8afa9f00 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutAbilitiesPacket.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutAbilitiesPacket.java @@ -5,19 +5,29 @@ import cc.funkemunky.api.reflections.types.WrappedField; import cc.funkemunky.api.tinyprotocol.api.NMSObject; import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; +import cc.funkemunky.api.tinyprotocol.reflection.FieldAccessor; import lombok.Getter; import org.bukkit.entity.Player; public class WrappedOutAbilitiesPacket extends NMSObject { private static final String packet = Server.ABILITIES; - private static WrappedClass abilitiesClass = Reflections.getNMSClass(Server.ABILITIES); - private static WrappedField invulnerableField = abilitiesClass.getFieldByType(boolean.class, 0); - private static WrappedField flyingField = abilitiesClass.getFieldByType(boolean.class, 1); - private static WrappedField allowedFlightField = abilitiesClass.getFieldByType(boolean.class, 2); - private static WrappedField creativeModeField = abilitiesClass.getFieldByType(boolean.class, 3); - private static WrappedField flySpeedField = abilitiesClass.getFieldByType(float.class, 0); - private static WrappedField walkSpeedField = abilitiesClass.getFieldByType(float.class, 1); + private static FieldAccessor + invulnerableField = fetchField(packet, boolean.class, 0), + flyingField = fetchField(packet, boolean.class, 1), + allowedFlightField = fetchField(packet, boolean.class, 2), + creativeModeField = fetchField(packet, boolean.class, 3); + private static FieldAccessor + flySpeedField = fetchField(packet, float.class, 0), + walkSpeedField = fetchField(packet, float.class, 1); + + private static WrappedClass abilitiesClass = Reflections.getNMSClass("PlayerAbilities"); + private static WrappedField invulnerableAcc = abilitiesClass.getFieldByType(boolean.class, 0); + private static WrappedField flyingAcc = abilitiesClass.getFieldByType(boolean.class, 1); + private static WrappedField allowedFlightAcc = abilitiesClass.getFieldByType(boolean.class, 2); + private static WrappedField creativeModeAcc = abilitiesClass.getFieldByType(boolean.class, 3); + private static WrappedField flySpeedAcc = abilitiesClass.getFieldByType(float.class, 0); + private static WrappedField walkSpeedAcc = abilitiesClass.getFieldByType(float.class, 1); @Getter private boolean invulnerable, flying, allowedFlight, creativeMode; @Getter @@ -30,12 +40,12 @@ public WrappedOutAbilitiesPacket(Object object, Player player) { public WrappedOutAbilitiesPacket(boolean invulernable, boolean flying, boolean allowedFlight, boolean creativeMode, float flySpeed, float walkSpeed) { Object abilities = abilitiesClass.getConstructorAtIndex(0).newInstance(); - invulnerableField.set(abilities, invulernable); - flyingField.set(abilities, flying); - allowedFlightField.set(abilities, allowedFlight); - creativeModeField.set(abilities, creativeMode); - flySpeedField.set(abilities, flySpeed); - walkSpeedField.set(abilities, walkSpeed); + invulnerableAcc.set(abilities, invulernable); + flyingAcc.set(abilities, flying); + allowedFlightAcc.set(abilities, allowedFlight); + creativeModeAcc.set(abilities, creativeMode); + flySpeedAcc.set(abilities, flySpeed); + walkSpeedAcc.set(abilities, walkSpeed); setObject(Reflections.getNMSClass(packet).getConstructor(abilitiesClass.getParent()).newInstance(abilities)); } @@ -52,11 +62,6 @@ public void process(Player player, ProtocolVersion version) { @Override public void updateObject() { - invulnerableField.set(getObject(), invulnerable); - flyingField.set(getObject(), flying); - allowedFlightField.set(getObject(), allowedFlight); - creativeModeField.set(getObject(), creativeMode); - flySpeedField.set(getObject(), flySpeed); - walkSpeedField.set(getObject(), walkSpeed); + } } \ No newline at end of file diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutBlockChange.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutBlockChange.java index 1cc7632c..dfcf404d 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutBlockChange.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutBlockChange.java @@ -1,8 +1,6 @@ package cc.funkemunky.api.tinyprotocol.packet.out; import cc.funkemunky.api.reflections.Reflections; -import cc.funkemunky.api.reflections.impl.CraftReflection; -import cc.funkemunky.api.reflections.impl.MinecraftReflection; import cc.funkemunky.api.reflections.types.WrappedClass; import cc.funkemunky.api.reflections.types.WrappedField; import cc.funkemunky.api.reflections.types.WrappedMethod; @@ -13,7 +11,6 @@ import cc.funkemunky.api.tinyprotocol.reflection.FieldAccessor; import cc.funkemunky.api.utils.ReflectionsUtil; import lombok.Getter; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -25,19 +22,20 @@ public class WrappedOutBlockChange extends NMSObject { private static FieldAccessor legacyX; private static FieldAccessor legacyY; private static FieldAccessor legacyZ; + private static WrappedField blockChangeBlockField; private static WrappedField blockDataIntField; private static WrappedMethod getDataMethod; //1.8 and newer private static FieldAccessor blockPosAccessor; - - private static WrappedField blockField; + private static WrappedField iBlockDataField; private static WrappedClass blockChangeClass = Reflections.getNMSClass(packet); + private static WrappedClass nmsBlockClass = Reflections.getNMSClass("Block"); + private static WrappedClass craftBlockClass = Reflections.getCBClass("CraftBlock"); private BaseBlockPosition position; - private Material type; public WrappedOutBlockChange(Object packet) { super(packet); @@ -55,24 +53,14 @@ public WrappedOutBlockChange(Block block) { public void process(Player player, ProtocolVersion version) { if (ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.V1_8)) { position = new BaseBlockPosition(fetch(legacyX), fetch(legacyY), fetch(legacyZ)); - type = CraftReflection.getTypeFromVanillaBlock(fetch(blockField)); } else { position = new BaseBlockPosition(fetch(blockPosAccessor)); - type = CraftReflection.getTypeFromVanillaBlock(MinecraftReflection.getBlockFromBlockData(fetch(blockField))); } } @Override public void updateObject() { - if(ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.V1_8)) { - legacyX.set(getObject(), position.getX()); - legacyY.set(getObject(), position.getY()); - legacyZ.set(getObject(), position.getZ()); - blockField.set(getObject(), CraftReflection.getVanillaBlock(type)); - } else { - blockPosAccessor.set(getObject(), position.getAsBlockPosition()); - blockField.set(getObject(), MinecraftReflection.getBlockData(CraftReflection.getVanillaBlock(type))); - } + } static { @@ -81,12 +69,13 @@ public void updateObject() { legacyY = fetchField(packet, int.class, 1); legacyZ = fetchField(packet, int.class, 2); - blockField = blockChangeClass.getFirstFieldByType(MinecraftReflection.block.getParent()); + + blockChangeBlockField = blockChangeClass.getFirstFieldByType(nmsBlockClass.getParent()); blockDataIntField = blockChangeClass.getFieldByName("data"); getDataMethod = Reflections.getNMSClass("World").getMethod("getData", int.class, int.class, int.class); } else { blockPosAccessor = fetchField(packet, Object.class, 0); - blockField = blockChangeClass.getFieldByType(ReflectionsUtil.iBlockData, 0); + iBlockDataField = blockChangeClass.getFieldByType(ReflectionsUtil.iBlockData, 0); } } } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutChatPacket.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutChatPacket.java index 208f1971..1776ff68 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutChatPacket.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutChatPacket.java @@ -49,7 +49,7 @@ public void process(Player player, ProtocolVersion version) { @Override public void updateObject() { - + } static { diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutEntityEffectPacket.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutEntityEffectPacket.java index 7a12682e..c315b1a4 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutEntityEffectPacket.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutEntityEffectPacket.java @@ -16,11 +16,10 @@ public class WrappedOutEntityEffectPacket extends NMSObject { public byte flags; private static WrappedClass wrapped = Reflections.getNMSClass(Server.ENTITY_EFFECT); - private static WrappedField fieldEntityId = wrapped.getFieldByType(int.class, 0), - fieldEffectId = wrapped.getFieldByType(byte.class, 0), - fieldAmplifier = wrapped.getFieldByType(byte.class, 1), - fieldDuration = wrapped.getFieldByType(int.class, 1), - fieldFlags = wrapped.getFieldByType(byte.class, 2); + private static WrappedField fieldEntityId, + fieldEffectId, + fieldAmplifier, + fieldDuration, fieldFlags; public WrappedOutEntityEffectPacket(Object object, Player player) { super(object, player); @@ -32,15 +31,26 @@ public void updateObject() { fieldEffectId.set(getObject(), effectId); fieldAmplifier.set(getObject(), amplifier); fieldDuration.set(getObject(), duration); - fieldFlags.set(getObject(), flags); + if(ProtocolVersion.getGameVersion().isAbove(ProtocolVersion.V1_7_10)) fieldFlags.set(getObject(), flags); } @Override public void process(Player player, ProtocolVersion version) { entityId = fieldEntityId.get(getObject()); - effectId = fieldEntityId.get(getObject()); + effectId = fieldEffectId.get(getObject()); amplifier = fieldAmplifier.get(getObject()); - duration = fieldDuration.get(getObject()); - flags = fieldFlags.get(getObject()); + duration = ProtocolVersion.getGameVersion().isAbove(ProtocolVersion.V1_7_10) + ? fieldDuration.get(getObject()) : (short) fieldDuration.get(getObject()); + if(ProtocolVersion.getGameVersion().isAbove(ProtocolVersion.V1_7_10))flags = fieldFlags.get(getObject()); + } + + static { + fieldEntityId = wrapped.getFieldByType(int.class, 0); + fieldEffectId = wrapped.getFieldByType(byte.class, 0); + fieldAmplifier = wrapped.getFieldByType(byte.class, 1); + if(ProtocolVersion.getGameVersion().isAbove(ProtocolVersion.V1_7_10)) { + fieldDuration = wrapped.getFieldByType(int.class, 1); + fieldFlags = wrapped.getFieldByType(byte.class, 2); + } else fieldDuration = wrapped.getFieldByType(short.class, 0); } } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutOpenWindow.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutOpenWindow.java index 4b89bc85..07155c37 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutOpenWindow.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutOpenWindow.java @@ -36,8 +36,6 @@ public WrappedOutOpenWindow(int id, String name, WrappedChatMessage msg, int siz public void process(Player player, ProtocolVersion version) { id = fetch(idField); name = fetch(nameField); - if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_8)) - chatComponent = new WrappedChatComponent(fetch(chatCompField)); size = fetch(inventorySize); } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutRespawnPacket.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutRespawnPacket.java index 6b94d695..d261584f 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutRespawnPacket.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutRespawnPacket.java @@ -2,6 +2,7 @@ import cc.funkemunky.api.reflections.Reflections; import cc.funkemunky.api.reflections.types.WrappedClass; +import cc.funkemunky.api.reflections.types.WrappedConstructor; import cc.funkemunky.api.reflections.types.WrappedField; import cc.funkemunky.api.reflections.types.WrappedMethod; import cc.funkemunky.api.tinyprotocol.api.NMSObject; @@ -25,9 +26,10 @@ public WrappedOutRespawnPacket(Object object, Player player) { private static FieldAccessor difficultyAcessor; private static FieldAccessor gamemodeAccessor; private static FieldAccessor worldTypeAccessor; - private static WrappedClass worldTypeClass; + private static WrappedClass worldTypeClass, respawnClass = Reflections.getNMSClass(packet); private static WrappedField worldTypeNameField; private static WrappedMethod getTypeWorldType; + private static WrappedConstructor emptyConstructor = respawnClass.getConstructor(); //Before 1.13 private static FieldAccessor dimensionAccesor; @@ -43,6 +45,10 @@ public WrappedOutRespawnPacket(Object object, Player player) { private WrappedEnumDifficulty difficulty; private WorldType worldType; + public WrappedOutRespawnPacket() { + setObject(emptyConstructor.newInstance()); + } + public WrappedOutRespawnPacket(int dimension, WrappedEnumGameMode gamemode, WrappedEnumDifficulty difficulty, WorldType worldType) { this.dimension = dimension; @@ -68,10 +74,12 @@ public void process(Player player, ProtocolVersion version) { @Override public void updateObject() { - setPacket(packet, ProtocolVersion.getGameVersion().isAbove(ProtocolVersion.V1_13) - ? dimensionManagerFromId.invoke(dimension) : dimension, - difficulty.getObject(), gamemode.getObject(), - getTypeWorldType.invoke(null, worldType.getName())); + if(ProtocolVersion.getGameVersion().isAbove(ProtocolVersion.V1_13)) { + dimensionManagerAcceessor.set(getObject(), dimensionManagerFromId.invoke(dimension)); + } else dimensionAccesor.set(getObject(), dimension); + gamemodeAccessor.set(getObject(), gamemode.getObject()); + difficultyAcessor.set(getObject(), difficulty.getObject()); + worldTypeAccessor.set(getObject(), getTypeWorldType.invoke(null, worldType.getName())); } static { diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/updater/Updater.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/updater/Updater.java index 6f6cf1d9..dd9052c9 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/updater/Updater.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/updater/Updater.java @@ -13,7 +13,7 @@ @Getter public class Updater { - private int update = -1, currentUpdate = 60; + private int update = -1, currentUpdate = 61; private String version, downloadLink; private File pluginLocation; private boolean importantUpdate = true; diff --git a/AtlasParent/AtlasBungee/src/main/java/cc/funkemunky/bungee/listeners/AtlasMsgListener.java b/AtlasParent/AtlasBungee/src/main/java/cc/funkemunky/bungee/listeners/AtlasMsgListener.java index 575dd2b6..24bfa7ff 100644 --- a/AtlasParent/AtlasBungee/src/main/java/cc/funkemunky/bungee/listeners/AtlasMsgListener.java +++ b/AtlasParent/AtlasBungee/src/main/java/cc/funkemunky/bungee/listeners/AtlasMsgListener.java @@ -35,7 +35,7 @@ public void onEvent(PluginMessageEvent event) { ByteArrayInputStream bis = new ByteArrayInputStream(event.getData()); ObjectInputStream inputStream = new ObjectInputStream(bis); - System.out.println(event.getData().length); + //System.out.println(event.getData().length); String type = (String)inputStream.readObject(); switch(type) {