diff options
Diffstat (limited to '')
4 files changed, 85 insertions, 0 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java b/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java index 032deca..8e4078e 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java @@ -36,6 +36,7 @@ public class PAPIExpansion extends PlaceholderExpansion { return true; } + @SuppressWarnings("ConstantConditions") @Override public String onRequest(OfflinePlayer player, @NotNull String params) { Database database = Main.getInstance().getDatabase(); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java new file mode 100644 index 0000000..9293beb --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java @@ -0,0 +1,31 @@ +package net.tylermurphy.hideAndSeek.util.packet; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.ProtocolManager; +import com.comphenix.protocol.events.PacketContainer; +import org.bukkit.entity.Player; + +import java.lang.reflect.InvocationTargetException; + +public class AbstractPacket { + + private static final ProtocolManager protocolManager; + static { + protocolManager = ProtocolLibrary.getProtocolManager(); + } + + protected final PacketContainer packet; + + protected AbstractPacket(PacketType type){ + packet = protocolManager.createPacket(type); + packet.getModifier().writeDefaults(); + } + + public void send(Player player){ + try { + protocolManager.sendServerPacket(player, packet); + } catch (InvocationTargetException ignored) {} + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/packet/BlockChangePacket.java b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/BlockChangePacket.java new file mode 100644 index 0000000..53f3f9c --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/BlockChangePacket.java @@ -0,0 +1,24 @@ +package net.tylermurphy.hideAndSeek.util.packet; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.wrappers.BlockPosition; +import com.comphenix.protocol.wrappers.WrappedBlockData; +import org.bukkit.Location; +import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; + +public class BlockChangePacket extends AbstractPacket { + + public BlockChangePacket(){ + super(PacketType.Play.Server.BLOCK_CHANGE); + } + + public void setBlockPosition(@NotNull Location location){ + super.packet.getBlockPositionModifier().write(0, new BlockPosition(location.toVector())); + } + + public void setMaterial(Material material){ + super.packet.getBlockData().write(0, WrappedBlockData.createData(material)); + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/packet/EntityTeleportPacket.java b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/EntityTeleportPacket.java new file mode 100644 index 0000000..b3c7734 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/EntityTeleportPacket.java @@ -0,0 +1,29 @@ +package net.tylermurphy.hideAndSeek.util.packet; + +import com.comphenix.protocol.PacketType; +import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class EntityTeleportPacket extends AbstractPacket { + + public EntityTeleportPacket(){ + super(PacketType.Play.Server.ENTITY_TELEPORT); + } + + public void setEntity(@NotNull Entity entity){ + super.packet.getIntegers().write(0, entity.getEntityId()); + } + + public void setX(double x){ + super.packet.getDoubles().write(0, x); + } + + public void setY(double y){ + super.packet.getDoubles().write(1, y); + } + + public void setZ(double z){ + super.packet.getDoubles().write(2, z); + } + +} |