Skip to content

Commit

Permalink
Add PaintballHandler for 1.11
Browse files Browse the repository at this point in the history
I haven't tested it yet but, I've added the PainballHandler class for Spigot 1.11.
  • Loading branch information
TGRHavoc committed Mar 4, 2017
1 parent 2d016c1 commit b4a3c73
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ovh.tgrhavoc.mvpgadgets.gadgets.paintballgun.nms.v1_11_R1;

import java.util.Collection;

import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.util.CraftMagicNumbers;
import org.bukkit.entity.Player;

import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.PacketPlayOutBlockChange;
import ovh.tgrhavoc.mvpgadgets.gadgets.paintballgun.nms.AbstractPaintHandler;

public class PaintballHandler extends AbstractPaintHandler{

@Override
public void sendChangeBlock(Player player, Block newBlock, Material material, byte data) {
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(
((CraftWorld)newBlock.getWorld()).getHandle(), new BlockPosition(
newBlock.getLocation().getX(), newBlock.getLocation().getY(), newBlock.getLocation().getZ()));
packet.block = CraftMagicNumbers.getBlock(material).fromLegacyData(data);
CraftPlayer cP = (CraftPlayer)player;
cP.getHandle().playerConnection.sendPacket(packet);
}

@Override
public void updateBlock(Collection<? extends Player> players, Block block, Material material, byte data) {
for (Player player : players) {
sendChangeBlock(player, block, material, data);
}
}

}

0 comments on commit b4a3c73

Please sign in to comment.