mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
feat: remove nms in HMCC, update to support Hibiscus Commons 0.1.8
This commit is contained in:
@@ -83,7 +83,7 @@ allprojects {
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||
compileOnly("org.projectlombok:lombok:1.18.2")
|
||||
compileOnly("me.lojosho:HibiscusCommons:0.1.7")
|
||||
compileOnly("me.lojosho:HibiscusCommons:0.1.8")
|
||||
|
||||
// Handled by Spigot Library Loader
|
||||
compileOnly("net.kyori:adventure-api:4.15.0")
|
||||
@@ -104,13 +104,6 @@ allprojects {
|
||||
|
||||
dependencies {
|
||||
implementation(project(path = ":common"))
|
||||
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R3", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_20_R1", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_20_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_20_R3", configuration = "reobf"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
@@ -134,13 +127,6 @@ tasks {
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependsOn(":v1_18_R2:reobfJar")
|
||||
dependsOn(":v1_19_R1:reobfJar")
|
||||
dependsOn(":v1_19_R2:reobfJar")
|
||||
dependsOn(":v1_19_R3:reobfJar")
|
||||
dependsOn(":v1_20_R1:reobfJar")
|
||||
dependsOn(":v1_20_R2:reobfJar")
|
||||
dependsOn(":v1_20_R3:reobfJar")
|
||||
mergeServiceFiles()
|
||||
|
||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.hibiscusmc.hmccosmetics;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticsAPI;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
||||
@@ -19,7 +20,6 @@ import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
|
||||
import com.hibiscusmc.hmccosmetics.listener.PaperPlayerGameListener;
|
||||
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
||||
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
@@ -31,7 +31,6 @@ import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.LocationSerializer;
|
||||
import me.lojosho.shaded.configupdater.common.config.CommentedConfiguration;
|
||||
import me.lojosho.shaded.configurate.ConfigurateException;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.ConfigurationOptions;
|
||||
import me.lojosho.shaded.configurate.yaml.NodeStyle;
|
||||
import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader;
|
||||
@@ -59,13 +58,6 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
||||
// Plugin startup logic
|
||||
instance = this;
|
||||
|
||||
// NMS version check
|
||||
if (!HMCCNMSHandlers.isVersionSupported()) {
|
||||
getLogger().severe("This version is not supported! Consider switching versions?");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
// File setup
|
||||
saveDefaultConfig();
|
||||
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
|
||||
@@ -78,7 +70,7 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
||||
if (!emoteFile.exists()) emoteFile.mkdir();
|
||||
|
||||
// Player Animator
|
||||
if (!HMCCNMSHandlers.getVersion().contains("v1_20_R2") && !HMCCNMSHandlers.getVersion().contains("v1_20_R3")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet
|
||||
if (!HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R2") && !HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R3")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet
|
||||
|
||||
// Configuration Sync
|
||||
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
||||
@@ -237,7 +229,7 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.isEmotesEnabled() && !HMCCNMSHandlers.getVersion().contains("v1_20_R2") && !HMCCNMSHandlers.getVersion().contains("v1_20_R3")) EmoteManager.loadEmotes(); // PlayerAnimator does not support 1.20.2 yet
|
||||
if (Settings.isEmotesEnabled() && !HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R2") && !HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R3")) EmoteManager.loadEmotes(); // PlayerAnimator does not support 1.20.2 yet
|
||||
|
||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||
|
||||
@@ -6,9 +6,9 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import org.bukkit.Color;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -103,7 +103,7 @@ public class HMCCosmeticsAPI {
|
||||
*/
|
||||
@Nullable
|
||||
public static String getNMSVersion() {
|
||||
return HMCCNMSHandlers.getVersion();
|
||||
return NMSHandlers.getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -35,7 +35,7 @@ public class CosmeticArmorType extends Cosmetic {
|
||||
&& ((user.getEntity() instanceof Player) && !user.getPlayer().getInventory().getItemInOffHand().getType().isAir())) return;
|
||||
ItemStack item = getItem(user);
|
||||
if (item == null) return;
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, item, HMCCPacketManager.getViewers(entity.getLocation()));
|
||||
PacketManager.equipmentSlotUpdate(entity.getEntityId(), equipSlot, item, HMCCPacketManager.getViewers(entity.getLocation()));
|
||||
}
|
||||
|
||||
public ItemStack getItem(@NotNull CosmeticUser user) {
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -57,7 +57,7 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
|
||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
||||
HMCCPacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
||||
// If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players
|
||||
if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), user.getUserBackpackManager().getEntityManager().getViewers());
|
||||
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
@@ -77,7 +77,7 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
if (!user.getHidden()) {
|
||||
//if (loc.getPitch() < -70) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, new ItemStack(Material.AIR), owner);
|
||||
//else NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
|
||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
@@ -28,6 +27,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
||||
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -272,7 +272,7 @@ public class PlayerGameListener implements Listener {
|
||||
List<Player> viewers = HMCCPacketManager.getViewers(user.getEntity().getLocation());
|
||||
if (viewers.isEmpty()) return;
|
||||
viewers.remove(user.getPlayer());
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getEntity().getEntityId(), EquipmentSlot.HAND, event.getPlayer().getInventory().getItemInMainHand(), viewers);
|
||||
PacketManager.equipmentSlotUpdate(user.getEntity().getEntityId(), EquipmentSlot.HAND, event.getPlayer().getInventory().getItemInMainHand(), viewers);
|
||||
}, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public interface HMCCNMSHandler {
|
||||
|
||||
void slotUpdate(
|
||||
Player player,
|
||||
int slot
|
||||
);
|
||||
|
||||
void equipmentSlotUpdate(
|
||||
int entityId,
|
||||
org.bukkit.inventory.EquipmentSlot slot,
|
||||
ItemStack item,
|
||||
List<Player> sendTo
|
||||
);
|
||||
|
||||
void equipmentSlotUpdate(
|
||||
int entityId,
|
||||
HashMap<EquipmentSlot, ItemStack> equipment,
|
||||
List<Player> sendTo
|
||||
);
|
||||
|
||||
void hideNPCName(
|
||||
Player player,
|
||||
String NPCName);
|
||||
|
||||
default boolean getSupported () {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class HMCCNMSHandlers {
|
||||
|
||||
private static final String[] SUPPORTED_VERSION = new String[]{"v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1", "v1_20_R2", "v1_20_R3"};
|
||||
private static HMCCNMSHandler handler;
|
||||
@Getter
|
||||
private static String version;
|
||||
|
||||
@Nullable
|
||||
public static HMCCNMSHandler getHandler() {
|
||||
if (handler != null) {
|
||||
return handler;
|
||||
} else {
|
||||
setup();
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
public static boolean isVersionSupported() {
|
||||
if (getHandler() == null) return false;
|
||||
return getHandler().getSupported();
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
if (handler != null) return;
|
||||
final String packageName = HMCCosmeticsPlugin.getInstance().getServer().getClass().getPackage().getName();
|
||||
String packageVersion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||
|
||||
for (String selectedVersion : SUPPORTED_VERSION) {
|
||||
if (!selectedVersion.contains(packageVersion)) {
|
||||
continue;
|
||||
}
|
||||
MessagesUtil.sendDebugMessages(packageVersion + " has been detected.", Level.INFO);
|
||||
version = packageVersion;
|
||||
try {
|
||||
handler = (HMCCNMSHandler) Class.forName("com.hibiscusmc.hmccosmetics.nms." + packageVersion + ".HMCCNMSHandler").getConstructor().newInstance();
|
||||
return;
|
||||
} catch (ClassNotFoundException | InvocationTargetException | InstantiationException |
|
||||
IllegalAccessException | NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
@@ -25,6 +24,7 @@ import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.InventoryUtils;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
@@ -204,7 +204,7 @@ public class CosmeticUser {
|
||||
updateCosmetic(cosmetic.getSlot());
|
||||
}
|
||||
if (items.isEmpty()) return;
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getEntity().getEntityId(), items, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), items, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
MessagesUtil.sendDebugMessages("updateCosmetic (All) - end - " + items.size());
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ public class CosmeticUser {
|
||||
EquipmentSlot equipmentSlot = HMCCInventoryUtils.getEquipmentSlot(slot);
|
||||
if (equipmentSlot == null) return;
|
||||
if (getPlayer() != null) {
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
} else {
|
||||
HMCCPacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
@@ -10,6 +9,7 @@ import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -85,9 +85,9 @@ public class UserBackpackManager {
|
||||
else HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||
}
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||
if (!user.getHidden()) HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
||||
if (!user.getHidden()) PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
||||
}
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), passengerIDs, outsideViewers);
|
||||
|
||||
// No one should be using ME because it barely works but some still use it, so it's here
|
||||
@@ -140,11 +140,11 @@ public class UserBackpackManager {
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
ItemStack item = new ItemStack(Material.AIR);
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
@@ -21,7 +20,6 @@ import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStopEvent;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -9,12 +9,13 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
@@ -124,7 +125,7 @@ public class UserWardrobeManager {
|
||||
HMCCPacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
||||
HMCCPacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
|
||||
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
|
||||
HMCCNMSHandlers.getHandler().hideNPCName(player, npcName);
|
||||
NMSHandlers.getHandler().hideNPCName(player, npcName);
|
||||
}, 4);
|
||||
|
||||
// Location
|
||||
@@ -136,7 +137,7 @@ public class UserWardrobeManager {
|
||||
// Maybe null as backpack maybe despawned before entering
|
||||
if (user.getUserBackpackManager() == null) user.respawnBackpack();
|
||||
user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0));
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
||||
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||
}
|
||||
|
||||
@@ -247,7 +248,7 @@ public class UserWardrobeManager {
|
||||
player.teleport(Objects.requireNonNullElseGet(exitLocation, () -> player.getWorld().getSpawnLocation()), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
|
||||
if (WardrobeSettings.isEquipPumpkin()) {
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, player.getInventory().getHelmet(), viewer);
|
||||
PacketManager.equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, player.getInventory().getHelmet(), viewer);
|
||||
}
|
||||
|
||||
if (WardrobeSettings.isEnabledBossbar()) {
|
||||
@@ -313,7 +314,7 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
if (WardrobeSettings.isEquipPumpkin()) {
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, new ItemStack(Material.CARVED_PUMPKIN), viewer);
|
||||
PacketManager.equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, new ItemStack(Material.CARVED_PUMPKIN), viewer);
|
||||
} else {
|
||||
HMCCPacketManager.equipmentSlotUpdate(user.getPlayer(), true, viewer); // Optifine dumbassery
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.*;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticsAPI;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
@@ -67,7 +67,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
if (empty) item = new ItemStack(Material.AIR);
|
||||
items.put(slot, item);
|
||||
}
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), items, sendTo);
|
||||
equipmentSlotUpdate(player.getEntityId(), items, sendTo);
|
||||
}
|
||||
public static void equipmentSlotUpdate(
|
||||
@NotNull Player player,
|
||||
@@ -93,7 +93,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
) {
|
||||
if (cosmeticSlot == CosmeticSlot.BACKPACK || cosmeticSlot == CosmeticSlot.BALLOON || cosmeticSlot == CosmeticSlot.EMOTE) return;
|
||||
|
||||
HMCCNMSHandlers.getHandler().equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
|
||||
equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
|
||||
}
|
||||
|
||||
public static void sendArmorstandMetadata(
|
||||
@@ -105,7 +105,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
packet.getIntegers().write(0, entityId);
|
||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||
|
||||
if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x10);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
@@ -127,7 +127,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
packet.getIntegers().write(0, entityId);
|
||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||
|
||||
if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
} else {
|
||||
@@ -147,7 +147,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
packet.getIntegers().write(0, entityId);
|
||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||
|
||||
if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(8, WrappedDataWatcher.Registry.get(Float.class)), 0f);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
@@ -266,7 +266,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
final int entityId,
|
||||
final @NotNull List<Player> sendTo
|
||||
) {
|
||||
if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1") || HMCCNMSHandlers.getVersion().contains("v1_19_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R3") || HMCCNMSHandlers.getVersion().contains("v1_20_R1")) {
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R3") || HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R1")) {
|
||||
WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
|
||||
wrapper.setEntityID(entityId);
|
||||
wrapper.setPlayerUUID(uuid);
|
||||
@@ -304,7 +304,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
||||
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
||||
// For sor some reason <1.19.2 handles it on the 0 field index, newer versions handles it on the 1
|
||||
if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||
info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(
|
||||
wrappedGameProfile,
|
||||
0,
|
||||
@@ -348,7 +348,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
packet.getIntegers().write(0, playerId);
|
||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||
|
||||
if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
} else {
|
||||
@@ -374,7 +374,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
final UUID uuid,
|
||||
final List<Player> sendTo
|
||||
) {
|
||||
if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
||||
// Remove player is deprecated on 1.19.3+, but we still need to support 1.18.2
|
||||
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||
import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticsAPI;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -26,7 +26,7 @@ public class WrapperPlayServerPlayerInfo extends AbstractPacket {
|
||||
}
|
||||
|
||||
public void setAction(PlayerInfoAction value) {
|
||||
if (HMCCNMSHandlers.getVersion().contains("v1_17_R1") || HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_17_R1") || HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||
handle.getPlayerInfoAction().write(0, value);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,12 +7,5 @@ pluginManagement {
|
||||
|
||||
rootProject.name = "HMCCosmetics"
|
||||
include(
|
||||
"common",
|
||||
"v1_18_R2",
|
||||
"v1_19_R1",
|
||||
"v1_19_R2",
|
||||
"v1_19_R3",
|
||||
"v1_20_R1",
|
||||
"v1_20_R2",
|
||||
"v1_20_R3"
|
||||
"common"
|
||||
)
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
plugins {
|
||||
id("java")
|
||||
id("io.papermc.paperweight.userdev") version "1.5.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
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,128 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.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.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.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 HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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.5.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperDevBundle("1.19.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,127 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
||||
|
||||
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.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_R1.CraftEquipmentSlot;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.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 HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler {
|
||||
@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);
|
||||
}
|
||||
|
||||
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.5.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
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,128 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.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.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.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 HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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.5.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperDevBundle("1.19.4-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,128 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
||||
|
||||
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.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_R3.CraftEquipmentSlot;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.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 HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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.5.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperDevBundle("1.20-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,128 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_20_R1;
|
||||
|
||||
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.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_20_R1.CraftEquipmentSlot;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.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 HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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.5.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperDevBundle("1.20.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,128 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_20_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.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_20_R2.CraftEquipmentSlot;
|
||||
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_20_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 HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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.5.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperDevBundle("1.20.4-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,128 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_20_R3;
|
||||
|
||||
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.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_20_R3.CraftEquipmentSlot;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.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 HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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