From ffa54954b14f06fc0ed944d2b33f4cfb0aff4fbb Mon Sep 17 00:00:00 2001 From: TheDutchMC Date: Sat, 7 Nov 2020 18:10:15 +0100 Subject: [PATCH] Added support for 1.16.4 --- Spigot_1_16_R3/build.gradle | 4 ++ .../torchSubCmds/Highlight_1_16_r3.java | 65 +++++++++++++++++++ build.gradle | 1 + gradle.properties | 2 +- settings.gradle | 1 + .../torchSubCmds/HighlightExecutor.java | 4 +- 6 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 Spigot_1_16_R3/build.gradle create mode 100644 Spigot_1_16_R3/src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/Highlight_1_16_r3.java diff --git a/Spigot_1_16_R3/build.gradle b/Spigot_1_16_R3/build.gradle new file mode 100644 index 0000000..17ba6c9 --- /dev/null +++ b/Spigot_1_16_R3/build.gradle @@ -0,0 +1,4 @@ +apply plugin: 'java' +dependencies { + compileOnly 'org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT' +} diff --git a/Spigot_1_16_R3/src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/Highlight_1_16_r3.java b/Spigot_1_16_R3/src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/Highlight_1_16_r3.java new file mode 100644 index 0000000..e1fad7a --- /dev/null +++ b/Spigot_1_16_R3/src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/Highlight_1_16_r3.java @@ -0,0 +1,65 @@ +package nl.thedutchmc.harotorch.commands.torchSubCmds; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; + +import net.minecraft.server.v1_16_R3.EntityMagmaCube; +import net.minecraft.server.v1_16_R3.EntityPlayer; +import net.minecraft.server.v1_16_R3.EntityTypes; +import net.minecraft.server.v1_16_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_16_R3.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_16_R3.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_16_R3.PlayerConnection; +import net.minecraft.server.v1_16_R3.World; + +public class Highlight_1_16_r3 { + + public static List spawnHighlight(Player p, List locations) { + + List result = new ArrayList<>(); + + EntityPlayer ep = ((CraftPlayer) p).getHandle(); + PlayerConnection conn = ep.playerConnection; + + for(Location loc : locations) { + + World nmsWorld = ((CraftWorld) loc.getWorld()).getHandle(); + + EntityMagmaCube nmsEntity = new EntityMagmaCube(EntityTypes.MAGMA_CUBE, nmsWorld); + + nmsEntity.setInvisible(false); + nmsEntity.collides = false; //Colllision + nmsEntity.setFlag(6, true); //Glowing + nmsEntity.setFlag(5, true); //Invisibility + nmsEntity.setSize(2, true); //Set the size of the magma cube to be a full block + nmsEntity.setLocation(loc.getBlockX() + 0.5D, loc.getBlockY(), loc.getBlockZ() + 0.5D, 0f, 0f); + + PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(nmsEntity); + PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata(nmsEntity.getId(), nmsEntity.getDataWatcher(), true); + + conn.sendPacket(spawnPacket); + conn.sendPacket(metaPacket); + + result.add(nmsEntity.getId()); + } + + return result; + } + + public static void killHighlighted(List ids, Player p) { + + EntityPlayer ep = ((CraftPlayer) p).getHandle(); + PlayerConnection conn = ep.playerConnection; + + for(int id : ids) { + PacketPlayOutEntityDestroy killPacket = new PacketPlayOutEntityDestroy(id); + + conn.sendPacket(killPacket); + } + } +} diff --git a/build.gradle b/build.gradle index d1ad6bc..2efad91 100644 --- a/build.gradle +++ b/build.gradle @@ -44,6 +44,7 @@ dependencies { compile group: 'commons-io', name: 'commons-io', version: '2.6' compile project('Spigot_1_16_R2') + compile project('Spigot_1_16_R3') } diff --git a/gradle.properties b/gradle.properties index 9238c7d..6d93001 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -pluginVersion = 2.1.3 +pluginVersion = 2.1.4 pluginGroup = nl.thedutchmc.harotorch pluginName = HaroTorch \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 75442f2..bc9fadf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,3 +9,4 @@ rootProject.name = 'HaroTorch' include ':Spigot_1_16_R2' +include ':Spigot_1_16_R3' diff --git a/src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/HighlightExecutor.java b/src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/HighlightExecutor.java index eed9db9..9c0e2c1 100644 --- a/src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/HighlightExecutor.java +++ b/src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/HighlightExecutor.java @@ -23,6 +23,7 @@ public static boolean highlight(CommandSender sender, String[] args, HaroTorch p switch(HaroTorch.NMS_VERSION) { case "v1_16_R2": returnedIds = Highlight_1_16_r2.spawnHighlight(p, nearbyTorches); break; + case "v1_16_R3": returnedIds = Highlight_1_16_r3.spawnHighlight(p, nearbyTorches); break; default: String msg = LangHandler.activeLang.getLangMessages().get("highlightVersionNotSupported").replaceAll("%NMS_VERSION%", HaroTorch.NMS_VERSION); p.sendMessage(HaroTorch.getMessagePrefix() + ChatColor.GOLD + msg); @@ -39,7 +40,8 @@ public void run() { switch(HaroTorch.NMS_VERSION) { case "v1_16_R2": Highlight_1_16_r2.killHighlighted(returnedIds, p); break; - + case "v1_16_R3": Highlight_1_16_r3.killHighlighted(returnedIds, p); break; + } p.sendMessage(HaroTorch.getMessagePrefix() + ChatColor.GOLD + LangHandler.activeLang.getLangMessages().get("endingHighlight"));