Add ProtocolLib version of Player#sendBlockChange

This commit is contained in:
Mark Vainomaa 2016-09-22 16:32:11 +03:00
parent c4cf9d4f04
commit 21f3391a9d
1 changed files with 20 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.comphenix.packetwrapper.WrapperPlayClientUpdateSign;
import com.comphenix.packetwrapper.WrapperPlayServerBlockChange;
import com.comphenix.packetwrapper.WrapperPlayServerOpenSignEditor;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
@ -16,6 +17,7 @@ import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.WrappedBlockData;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -100,6 +102,14 @@ public class FakeSignFactory {
/* Send block change */
player.sendBlockChange(signLocation, Material.WALL_SIGN, (byte)0);
/*
TODO: those didn't seem to work
WrapperPlayServerBlockChange block = new WrapperPlayServerBlockChange();
block.setBlockData(WrappedBlockData.createData(Material.WALL_SIGN));
block.setLocation(new BlockPosition(signLocation.toVector()));
block.sendPacket(player);
*/
/* Set sign content */
player.sendSignChange(signLocation, defaultText);
}
@ -116,7 +126,17 @@ public class FakeSignFactory {
if (defaultText != null) {
/* Make sign disappear */
Location signLocation = new Location(player.getWorld(), (double)x, (double)y, (double)z);
/* Send block change */
player.sendBlockChange(signLocation, Material.AIR, (byte)0);
/*
TODO: those didn't seem to work
WrapperPlayServerBlockChange block = new WrapperPlayServerBlockChange();
block.setBlockData(WrappedBlockData.createData(Material.AIR));
block.setLocation(new BlockPosition(signLocation.toVector()));
block.sendPacket(player);
*/
}
signLocations.put(player.getName(), new Vector(x, y, z));
listeners.put(player.getName(), response);