Flush sign when finish first edit

Former-commit-id: d9abbbcaf3b40f6c756013f0f76e2a5dbd550261 [formerly 96cd1e800ec36e9c2af4884b1b435c82dd598a0b]
Former-commit-id: 266e007d364ea2d23c40063da8ba09a30b979669
This commit is contained in:
Ghost_chu committed 2018-11-22 12:05:27 +08:00
1 parent 3ff068689c
commit e2727fcd9e
9 files changed
+247 -161

No files matched your search

@@ -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 {
@@ -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;
@@ -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);
}
}
@@ -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;
@@ -0,0 +1,238 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* 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 <http://www.gnu.org/licenses/>.
*/
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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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);
}
}
@@ -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);
@@ -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;
@@ -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);
}
}
}
@@ -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.
* <p>
* 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);
}
}