diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientStructureBlock.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientStructureBlock.java index bc660f276..68eb80272 100644 --- a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientStructureBlock.java +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientStructureBlock.java @@ -20,6 +20,7 @@ package com.comphenix.packetwrapper; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; public class WrapperPlayClientStructureBlock extends AbstractPacket { diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTabComplete.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTabComplete.java index ebb0f29e8..171578623 100644 --- a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTabComplete.java +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTabComplete.java @@ -20,6 +20,8 @@ package com.comphenix.packetwrapper; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; +import com.mojang.brigadier.suggestion.Suggestions; public class WrapperPlayClientTabComplete extends AbstractPacket { public static final PacketType TYPE = PacketType.Play.Client.TAB_COMPLETE; diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCommands.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCommands.java index 96d1cf6d0..317cb0767 100644 --- a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCommands.java +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCommands.java @@ -39,11 +39,11 @@ public class WrapperPlayServerCommands extends AbstractPacket { * Mojang's brigadier library isn't versioned inside craftbukkit, * so it should be safe to use here. */ - public RootCommandNode getRoot() { - return (RootCommandNode) handle.getModifier().read(0); + public RootCommandNode getRoot() { + return (RootCommandNode) handle.getModifier().read(0); } - public void setRoot(RootCommandNode node) { + public void setRoot(RootCommandNode node) { handle.getModifier().write(0, node); } } diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMapChunk.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMapChunk.java index 4912a7cd8..091ba8659 100644 --- a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMapChunk.java +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMapChunk.java @@ -23,6 +23,7 @@ import java.util.List; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.wrappers.nbt.NbtBase; +import com.comphenix.protocol.wrappers.nbt.NbtCompound; public class WrapperPlayServerMapChunk extends AbstractPacket { public static final PacketType TYPE = PacketType.Play.Server.MAP_CHUNK; diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldParticles-DESKTOP-9AN38QR.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldParticles-DESKTOP-9AN38QR.java new file mode 100644 index 000000000..3232c8bbb --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldParticles-DESKTOP-9AN38QR.java @@ -0,0 +1,238 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedParticle; + +public class WrapperPlayServerWorldParticles extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.WORLD_PARTICLES; + + public WrapperPlayServerWorldParticles() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerWorldParticles(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve the particle. + * + * @return The current particle + */ + public WrappedParticle getParticle() { + return handle.getNewParticles().read(0); + } + + /** + * Set the particle. + * + * @param value - new value. + */ + public void setParticleType(WrappedParticle value) { + handle.getNewParticles().write(0, value); + } + + /** + * Retrieve X. + *

+ * Notes: x position of the particle + * + * @return The current X + */ + public float getX() { + return handle.getFloat().read(0); + } + + /** + * Set X. + * + * @param value - new value. + */ + public void setX(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Y. + *

+ * Notes: y position of the particle + * + * @return The current Y + */ + public float getY() { + return handle.getFloat().read(1); + } + + /** + * Set Y. + * + * @param value - new value. + */ + public void setY(float value) { + handle.getFloat().write(1, value); + } + + /** + * Retrieve Z. + *

+ * Notes: z position of the particle + * + * @return The current Z + */ + public float getZ() { + return handle.getFloat().read(2); + } + + /** + * Set Z. + * + * @param value - new value. + */ + public void setZ(float value) { + handle.getFloat().write(2, value); + } + + /** + * Retrieve Offset X. + *

+ * Notes: this is added to the X position after being multiplied by + * random.nextGaussian() + * + * @return The current Offset X + */ + public float getOffsetX() { + return handle.getFloat().read(3); + } + + /** + * Set Offset X. + * + * @param value - new value. + */ + public void setOffsetX(float value) { + handle.getFloat().write(3, value); + } + + /** + * Retrieve Offset Y. + *

+ * Notes: this is added to the Y position after being multiplied by + * random.nextGaussian() + * + * @return The current Offset Y + */ + public float getOffsetY() { + return handle.getFloat().read(4); + } + + /** + * Set Offset Y. + * + * @param value - new value. + */ + public void setOffsetY(float value) { + handle.getFloat().write(4, value); + } + + /** + * Retrieve Offset Z. + *

+ * Notes: this is added to the Z position after being multiplied by + * random.nextGaussian() + * + * @return The current Offset Z + */ + public float getOffsetZ() { + return handle.getFloat().read(5); + } + + /** + * Set Offset Z. + * + * @param value - new value. + */ + public void setOffsetZ(float value) { + handle.getFloat().write(5, value); + } + + /** + * Retrieve Particle data. + *

+ * Notes: the data of each particle + * + * @return The current Particle data + */ + public float getParticleData() { + return handle.getFloat().read(6); + } + + /** + * Set Particle data. + * + * @param value - new value. + */ + public void setParticleData(float value) { + handle.getFloat().write(6, value); + } + + /** + * Retrieve Number of particles. + *

+ * Notes: the number of particles to create + * + * @return The current Number of particles + */ + public int getNumberOfParticles() { + return handle.getIntegers().read(0); + } + + /** + * Set Number of particles. + * + * @param value - new value. + */ + public void setNumberOfParticles(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Long Distance. + *

+ * Notes: if true, particle distance increases from 256 to 65536. + * + * @return The current Long Distance + */ + public boolean getLongDistance() { + return handle.getBooleans().read(0); + } + + /** + * Set Long Distance. + * + * @param value - new value. + */ + public void setLongDistance(boolean value) { + handle.getBooleans().write(0, value); + } +} diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index d79d88243..811c276ec 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -188,6 +188,7 @@ public class QuickShop extends JavaPlugin { @Override public void run() { QuickShop.instance.commandExecutor.signGUIApi(data, wrapper.getLines()[0]); + event.getPlayer().sendBlockChange(new Location(event.getPlayer().getWorld(),event.getPlayer().getLocation().getBlockX(), SignMenuFactory.POSITION_HEIGHT, event.getPlayer().getLocation().getBlockZ()), Material.AIR.createBlockData()); } }.runTask(QuickShop.instance); diff --git a/src/main/java/org/maxgamer/quickshop/Util/SignMenuFactory.java b/src/main/java/org/maxgamer/quickshop/Util/SignMenuFactory.java index 39e2093b6..0aa9eee03 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/SignMenuFactory.java +++ b/src/main/java/org/maxgamer/quickshop/Util/SignMenuFactory.java @@ -21,7 +21,7 @@ import org.bukkit.plugin.Plugin; public final class SignMenuFactory { - private static final int POSITION_HEIGHT = 255; + public static final int POSITION_HEIGHT = 255; private static final int ACTION_INDEX = 9; private static final int SIGN_LINES = 4; diff --git a/src/main/java/org/maxgamer/quickshop/Wrapper/AbstractPacket.java b/src/main/java/org/maxgamer/quickshop/Wrapper/AbstractPacket.java deleted file mode 100644 index 9fce1e23f..000000000 --- a/src/main/java/org/maxgamer/quickshop/Wrapper/AbstractPacket.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.maxgamer.quickshop.Wrapper; - -import java.lang.reflect.InvocationTargetException; - -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.PacketContainer; -import com.google.common.base.Objects; - -public abstract class AbstractPacket { - // The packet we will be modifying - protected PacketContainer handle; - - /** - * Constructs a new strongly typed wrapper for the given packet. - * - * @param handle - handle to the raw packet data. - * @param type - the packet type. - */ - protected AbstractPacket(PacketContainer handle, PacketType type) { - // Make sure we're given a valid packet - if (handle == null) - throw new IllegalArgumentException("Packet handle cannot be NULL."); - if (!Objects.equal(handle.getType(), type)) - throw new IllegalArgumentException(handle.getHandle() - + " is not a packet of type " + type); - - this.handle = handle; - } - - /** - * Retrieve a handle to the raw packet data. - * - * @return Raw packet data. - */ - public PacketContainer getHandle() { - return handle; - } - - /** - * Send the current packet to the given receiver. - * - * @param receiver - the receiver. - * @throws RuntimeException If the packet cannot be sent. - */ - public void sendPacket(Player receiver) { - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(receiver, - getHandle()); - } catch (InvocationTargetException e) { - throw new RuntimeException("Cannot send packet.", e); - } - } - - /** - * Send the current packet to all online players. - */ - public void broadcastPacket() { - ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHandle()); - } - - /** - * Simulate receiving the current packet from the given sender. - * - * @param sender - the sender. - * @throws RuntimeException If the packet cannot be received. - * @deprecated Misspelled. recieve to receive - * @see #receivePacket(Player) - */ - @Deprecated - public void recievePacket(Player sender) { - try { - ProtocolLibrary.getProtocolManager().recieveClientPacket(sender, - getHandle()); - } catch (Exception e) { - throw new RuntimeException("Cannot recieve packet.", e); - } - } - - /** - * Simulate receiving the current packet from the given sender. - * - * @param sender - the sender. - * @throws RuntimeException if the packet cannot be received. - */ - public void receivePacket(Player sender) { - try { - ProtocolLibrary.getProtocolManager().recieveClientPacket(sender, - getHandle()); - } catch (Exception e) { - throw new RuntimeException("Cannot receive packet.", e); - } - } -} \ No newline at end of file diff --git a/src/main/java/org/maxgamer/quickshop/Wrapper/WrapperPlayClientUpdateSign.java b/src/main/java/org/maxgamer/quickshop/Wrapper/WrapperPlayClientUpdateSign.java deleted file mode 100644 index 9eddb4e92..000000000 --- a/src/main/java/org/maxgamer/quickshop/Wrapper/WrapperPlayClientUpdateSign.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.maxgamer.quickshop.Wrapper; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.BlockPosition; - -public class WrapperPlayClientUpdateSign extends AbstractPacket { - public static final PacketType TYPE = PacketType.Play.Client.UPDATE_SIGN; - - public WrapperPlayClientUpdateSign() { - super(new PacketContainer(TYPE), TYPE); - handle.getModifier().writeDefaults(); - } - - public WrapperPlayClientUpdateSign(PacketContainer packet) { - super(packet, TYPE); - } - - /** - * Retrieve Location. - *

- * Notes: block Coordinates - * - * @return The current Location - */ - public BlockPosition getLocation() { - return handle.getBlockPositionModifier().read(0); - } - - /** - * Set Location. - * - * @param value - new value. - */ - public void setLocation(BlockPosition value) { - handle.getBlockPositionModifier().write(0, value); - } - - /** - * Retrieve this sign's lines of text. - * - * @return The current lines - */ - public String[] getLines() { - return handle.getStringArrays().read(0); - } - - /** - * Set this sign's lines of text. - * - * @param value - Lines, must be 4 elements long - */ - public void setLines(String[] value) { - if (value == null) - throw new IllegalArgumentException("value cannot be null!"); - if (value.length != 4) - throw new IllegalArgumentException("value must have 4 elements!"); - - handle.getStringArrays().write(0, value); - } -} \ No newline at end of file