mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
feat: drop 1.18.2 -> 1.19.3 support, version bump (0.4.0), add run-paper gradle plugin
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,3 +16,4 @@
|
|||||||
/output/
|
/output/
|
||||||
.gradle
|
.gradle
|
||||||
build
|
build
|
||||||
|
/run/
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ plugins {
|
|||||||
//id("com.github.johnrengelman.shadow") version "8.1.1"
|
//id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||||
//id("io.papermc.hangar-publish-plugin") version "0.1.1"
|
//id("io.papermc.hangar-publish-plugin") version "0.1.1"
|
||||||
|
id("xyz.jpenilla.run-paper") version "2.0.0"
|
||||||
id("io.papermc.paperweight.userdev") version "1.7.1" apply false
|
id("io.papermc.paperweight.userdev") version "1.7.1" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "me.lojosho"
|
group = "me.lojosho"
|
||||||
version = "0.3.3"
|
version = "0.4.0"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -65,7 +66,7 @@ allprojects {
|
|||||||
|
|
||||||
// Included externally
|
// Included externally
|
||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
@@ -105,8 +106,6 @@ allprojects {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(path = ":common"))
|
implementation(project(path = ":common"))
|
||||||
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
|
||||||
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
|
||||||
implementation(project(path = ":v1_19_R3", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R3", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_20_R1", configuration = "reobf"))
|
implementation(project(path = ":v1_20_R1", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_20_R2", configuration = "reobf"))
|
implementation(project(path = ":v1_20_R2", configuration = "reobf"))
|
||||||
@@ -120,6 +119,11 @@ tasks {
|
|||||||
//options.release.set(17)
|
//options.release.set(17)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runServer {
|
||||||
|
dependsOn(shadowJar)
|
||||||
|
minecraftVersion("1.20.6")
|
||||||
|
}
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
options.encoding = Charsets.UTF_8.name()
|
options.encoding = Charsets.UTF_8.name()
|
||||||
}
|
}
|
||||||
@@ -130,8 +134,6 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
dependsOn(":v1_18_R2:reobfJar")
|
|
||||||
dependsOn(":v1_19_R2:reobfJar")
|
|
||||||
dependsOn(":v1_19_R3:reobfJar")
|
dependsOn(":v1_19_R3:reobfJar")
|
||||||
dependsOn(":v1_20_R1:reobfJar")
|
dependsOn(":v1_20_R1:reobfJar")
|
||||||
dependsOn(":v1_20_R2:reobfJar")
|
dependsOn(":v1_20_R2:reobfJar")
|
||||||
@@ -158,10 +160,6 @@ tasks {
|
|||||||
build {
|
build {
|
||||||
dependsOn(shadowJar)
|
dependsOn(shadowJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles generating the plugin yml
|
// Handles generating the plugin yml
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ pluginManagement {
|
|||||||
rootProject.name = "HibiscusCommons"
|
rootProject.name = "HibiscusCommons"
|
||||||
include(
|
include(
|
||||||
"common",
|
"common",
|
||||||
"v1_18_R2",
|
|
||||||
"v1_19_R2",
|
|
||||||
"v1_19_R3",
|
"v1_19_R3",
|
||||||
"v1_20_R1",
|
"v1_20_R1",
|
||||||
"v1_20_R2",
|
"v1_20_R2",
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
id("io.papermc.paperweight.userdev") version "1.7.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
paperweight.paperDevBundle("1.18.2-R0.1-SNAPSHOT")
|
|
||||||
implementation(project(":common"))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
|
|
||||||
build {
|
|
||||||
dependsOn(reobfJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
compileJava {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
options.release.set(17)
|
|
||||||
}
|
|
||||||
javadoc {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
processResources {
|
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,153 +0,0 @@
|
|||||||
package me.lojosho.hibiscuscommons.nms.v1_18_R2;
|
|
||||||
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
|
||||||
import net.minecraft.world.scores.Team;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftEquipmentSlot;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NMSHandler implements me.lojosho.hibiscuscommons.nms.NMSHandler {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNextEntityId() {
|
|
||||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getEntity(int entityId) {
|
|
||||||
net.minecraft.world.entity.Entity entity = getNMSEntity(entityId);
|
|
||||||
if (entity == null) return null;
|
|
||||||
return entity.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
|
||||||
if (entity == null) continue;
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
org.bukkit.inventory.EquipmentSlot slot,
|
|
||||||
ItemStack item,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
EquipmentSlot nmsSlot = null;
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = null;
|
|
||||||
|
|
||||||
// Converting EquipmentSlot and ItemStack to NMS ones.
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(item);
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
HashMap<org.bukkit.inventory.EquipmentSlot, ItemStack> equipment,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = new ArrayList<>();
|
|
||||||
|
|
||||||
for (org.bukkit.inventory.EquipmentSlot slot : equipment.keySet()) {
|
|
||||||
EquipmentSlot nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(equipment.get(slot));
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
pairs.add(pair);
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void slotUpdate(
|
|
||||||
Player player,
|
|
||||||
int slot
|
|
||||||
) {
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
ServerPlayer player1 = ((CraftPlayer) player).getHandle();
|
|
||||||
|
|
||||||
if (index < Inventory.getSelectionSize()) {
|
|
||||||
index += 36;
|
|
||||||
} else if (index > 39) {
|
|
||||||
index += 5; // Off hand
|
|
||||||
} else if (index > 35) {
|
|
||||||
index = 8 - (index - 36);
|
|
||||||
}
|
|
||||||
ItemStack item = player.getInventory().getItem(slot);
|
|
||||||
|
|
||||||
Packet packet = new ClientboundContainerSetSlotPacket(player1.inventoryMenu.containerId, player1.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item));
|
|
||||||
sendPacket(player, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hideNPCName(Player player, String NPCName) {
|
|
||||||
//Creating the team
|
|
||||||
PlayerTeam team = new PlayerTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), NPCName);
|
|
||||||
|
|
||||||
//Setting name visibility
|
|
||||||
team.setNameTagVisibility(Team.Visibility.NEVER);
|
|
||||||
|
|
||||||
//Remove the Team (i assume so if it exists)
|
|
||||||
ClientboundSetPlayerTeamPacket removeTeamPacket = ClientboundSetPlayerTeamPacket.createRemovePacket(team);
|
|
||||||
sendPacket(player, removeTeamPacket);
|
|
||||||
//Creating the Team
|
|
||||||
ClientboundSetPlayerTeamPacket createTeamPacket = ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true);
|
|
||||||
sendPacket(player, createTeamPacket);
|
|
||||||
//Adding players to the team (You have to use the NPC's name, and add it to a list)
|
|
||||||
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, new ArrayList<String>() {{
|
|
||||||
add(NPCName);
|
|
||||||
}}, ClientboundSetPlayerTeamPacket.Action.ADD);
|
|
||||||
sendPacket(player, createPlayerTeamPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
|
||||||
connection.send(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getSupported() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
id("io.papermc.paperweight.userdev") version "1.7.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
paperweight.paperDevBundle("1.19.3-R0.1-SNAPSHOT")
|
|
||||||
implementation(project(":common"))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
|
|
||||||
build {
|
|
||||||
dependsOn(reobfJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
compileJava {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
options.release.set(17)
|
|
||||||
}
|
|
||||||
javadoc {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
processResources {
|
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,153 +0,0 @@
|
|||||||
package me.lojosho.hibiscuscommons.nms.v1_19_R2;
|
|
||||||
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
|
||||||
import net.minecraft.world.scores.Team;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftEquipmentSlot;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NMSHandler implements me.lojosho.hibiscuscommons.nms.NMSHandler {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNextEntityId() {
|
|
||||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getEntity(int entityId) {
|
|
||||||
net.minecraft.world.entity.Entity entity = getNMSEntity(entityId);
|
|
||||||
if (entity == null) return null;
|
|
||||||
return entity.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
|
||||||
if (entity == null) continue;
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
org.bukkit.inventory.EquipmentSlot slot,
|
|
||||||
ItemStack item,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
EquipmentSlot nmsSlot = null;
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = null;
|
|
||||||
|
|
||||||
// Converting EquipmentSlot and ItemStack to NMS ones.
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(item);
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
HashMap<org.bukkit.inventory.EquipmentSlot, ItemStack> equipment,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = new ArrayList<>();
|
|
||||||
|
|
||||||
for (org.bukkit.inventory.EquipmentSlot slot : equipment.keySet()) {
|
|
||||||
EquipmentSlot nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(equipment.get(slot));
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
pairs.add(pair);
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void slotUpdate(
|
|
||||||
Player player,
|
|
||||||
int slot
|
|
||||||
) {
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
ServerPlayer player1 = ((CraftPlayer) player).getHandle();
|
|
||||||
|
|
||||||
if (index < Inventory.getSelectionSize()) {
|
|
||||||
index += 36;
|
|
||||||
} else if (index > 39) {
|
|
||||||
index += 5; // Off hand
|
|
||||||
} else if (index > 35) {
|
|
||||||
index = 8 - (index - 36);
|
|
||||||
}
|
|
||||||
ItemStack item = player.getInventory().getItem(slot);
|
|
||||||
|
|
||||||
Packet packet = new ClientboundContainerSetSlotPacket(player1.inventoryMenu.containerId, player1.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item));
|
|
||||||
sendPacket(player, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hideNPCName(Player player, String NPCName) {
|
|
||||||
//Creating the team
|
|
||||||
PlayerTeam team = new PlayerTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), NPCName);
|
|
||||||
|
|
||||||
//Setting name visibility
|
|
||||||
team.setNameTagVisibility(Team.Visibility.NEVER);
|
|
||||||
|
|
||||||
//Remove the Team (i assume so if it exists)
|
|
||||||
ClientboundSetPlayerTeamPacket removeTeamPacket = ClientboundSetPlayerTeamPacket.createRemovePacket(team);
|
|
||||||
sendPacket(player, removeTeamPacket);
|
|
||||||
//Creating the Team
|
|
||||||
ClientboundSetPlayerTeamPacket createTeamPacket = ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true);
|
|
||||||
sendPacket(player, createTeamPacket);
|
|
||||||
//Adding players to the team (You have to use the NPC's name, and add it to a list)
|
|
||||||
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, new ArrayList<String>() {{
|
|
||||||
add(NPCName);
|
|
||||||
}}, ClientboundSetPlayerTeamPacket.Action.ADD);
|
|
||||||
sendPacket(player, createPlayerTeamPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
|
||||||
connection.send(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getSupported() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user