mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-29 11:59:21 +00:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f98614c4ee | ||
|
|
d28bb23f8c | ||
|
|
502cb533f8 | ||
|
|
b7fdc2087a | ||
|
|
10a42a3c96 | ||
|
|
51fc52e24b | ||
|
|
be632d8e8c | ||
|
|
a732a2b0a0 | ||
|
|
b14a0b5d16 | ||
|
|
50393c62b0 | ||
|
|
dbc4a07895 | ||
|
|
ab329e4fbf | ||
|
|
90ad700d0a | ||
|
|
56529d6111 | ||
|
|
b6a06007e8 | ||
|
|
edccc9ce4e | ||
|
|
e0b2f0f6b1 | ||
|
|
57f4d3703c | ||
|
|
8ef6692198 | ||
|
|
c48830f3ac | ||
|
|
734c04c1f4 | ||
|
|
b08b4019a9 | ||
|
|
cfb7876b6e | ||
|
|
6047d0e3c3 | ||
|
|
880c333df9 | ||
|
|
c4d7b657dd | ||
|
|
5be3ce8d21 | ||
|
|
33bba631fc | ||
|
|
775b9c299d | ||
|
|
6e02331c13 | ||
|
|
b7457cec9c | ||
|
|
e7288a1910 | ||
|
|
26b90bd8bb |
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.6.4"
|
version = "2.6.5"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -32,9 +32,6 @@ allprojects {
|
|||||||
// PlaceholderAPI
|
// PlaceholderAPI
|
||||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||||
|
|
||||||
//Hikari
|
|
||||||
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
|
|
||||||
|
|
||||||
// Citizens & Denizen
|
// Citizens & Denizen
|
||||||
maven("https://maven.citizensnpcs.co/repo")
|
maven("https://maven.citizensnpcs.co/repo")
|
||||||
|
|
||||||
@@ -73,12 +70,12 @@ allprojects {
|
|||||||
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.18.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2")
|
||||||
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")
|
||||||
compileOnly("com.mineinabyss:geary-papermc:0.24.1")
|
compileOnly("com.mineinabyss:geary-papermc:0.27.0")
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||||
@@ -97,18 +94,19 @@ dependencies {
|
|||||||
implementation(project(path = ":v1_19_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"))
|
||||||
|
|
||||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||||
implementation("net.kyori:adventure-api:4.11.0")
|
implementation("net.kyori:adventure-api:4.11.0")
|
||||||
implementation("net.kyori:adventure-text-minimessage:4.11.0")
|
implementation("net.kyori:adventure-text-minimessage:4.11.0")
|
||||||
implementation("net.kyori:adventure-platform-bukkit:4.1.2")
|
implementation("net.kyori:adventure-platform-bukkit:4.1.2")
|
||||||
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
||||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT")
|
||||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:bed3c46369")
|
||||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +127,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.20.1")
|
minecraftVersion("1.20.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
@@ -138,6 +136,7 @@ tasks {
|
|||||||
dependsOn(":v1_19_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")
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
|
||||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ dependencies {
|
|||||||
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.18.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2")
|
||||||
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")
|
||||||
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||||
@@ -34,7 +34,7 @@ dependencies {
|
|||||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:bed3c46369")
|
||||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
Metrics metrics = new Metrics(this, pluginId);
|
Metrics metrics = new Metrics(this, pluginId);
|
||||||
|
|
||||||
// NMS version check
|
// NMS version check
|
||||||
if (!NMSHandlers.getHandler().getSupported()) {
|
if (!NMSHandlers.isVersionSupported()) {
|
||||||
getLogger().severe("This version is not supported! Consider switching versions?");
|
getLogger().severe("This version is not supported! Consider switching versions?");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
@@ -98,7 +98,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
if (!emoteFile.exists()) emoteFile.mkdir();
|
if (!emoteFile.exists()) emoteFile.mkdir();
|
||||||
|
|
||||||
// Player Animator
|
// Player Animator
|
||||||
PlayerAnimatorImpl.initialize(this);
|
if (!NMSHandlers.getVersion().contains("v1_20_R2")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet
|
||||||
|
|
||||||
// Configuration Sync
|
// Configuration Sync
|
||||||
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
||||||
@@ -252,7 +252,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteManager.loadEmotes();
|
if (Settings.isEmotesEnabled() && !NMSHandlers.getVersion().contains("v1_20_R2")) EmoteManager.loadEmotes(); // PlayerAnimator does not support 1.20.2 yet
|
||||||
|
|
||||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package com.hibiscusmc.hmccosmetics.config;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
@@ -26,6 +29,8 @@ public class Settings {
|
|||||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
||||||
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||||
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
||||||
|
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
|
||||||
|
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
|
||||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
||||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||||
@@ -33,6 +38,7 @@ public class Settings {
|
|||||||
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||||
|
private static final String COSMETIC_EMOTE_ENABLE = "emote-enable";
|
||||||
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||||
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
||||||
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
||||||
@@ -107,6 +113,12 @@ public class Settings {
|
|||||||
@Getter
|
@Getter
|
||||||
private static boolean cosmeticForceOffhandCosmeticShow;
|
private static boolean cosmeticForceOffhandCosmeticShow;
|
||||||
@Getter
|
@Getter
|
||||||
|
private static boolean emotesEnabled;
|
||||||
|
@Getter
|
||||||
|
private static boolean disabledGamemodesEnabled;
|
||||||
|
@Getter
|
||||||
|
private static List<String> disabledGamemodes;
|
||||||
|
@Getter
|
||||||
private static int viewDistance;
|
private static int viewDistance;
|
||||||
@Getter
|
@Getter
|
||||||
private static int tickPeriod;
|
private static int tickPeriod;
|
||||||
@@ -161,9 +173,18 @@ public class Settings {
|
|||||||
|
|
||||||
ConfigurationNode cosmeticSettings = source.node(COSMETIC_SETTINGS_PATH);
|
ConfigurationNode cosmeticSettings = source.node(COSMETIC_SETTINGS_PATH);
|
||||||
|
|
||||||
|
ConfigurationNode disabledGamemodeSettings = cosmeticSettings.node(DISABLED_GAMEMODE_PATH);
|
||||||
|
disabledGamemodesEnabled = disabledGamemodeSettings.node(ENABLED_PATH).getBoolean(true);
|
||||||
|
try {
|
||||||
|
disabledGamemodes = disabledGamemodeSettings.node(DISABLED_GAMEMODE_GAMEMODES_PATH).getList(String.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
disabledGamemodes = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||||
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
||||||
|
emotesEnabled = cosmeticSettings.node(COSMETIC_EMOTE_ENABLE).getBoolean(true);
|
||||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||||
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -35,7 +36,10 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
if (Settings.getShouldAddEnchants(equipSlot)) {
|
if (Settings.getShouldAddEnchants(equipSlot)) {
|
||||||
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||||
}
|
}
|
||||||
|
// Basically, if force offhand is off AND there is no item in an offhand slot, then the equipment packet to add the cosmetic
|
||||||
|
if (!Settings.isCosmeticForceOffhandCosmeticShow()
|
||||||
|
&& equipSlot.equals(EquipmentSlot.OFF_HAND)
|
||||||
|
&& ((entity instanceof Player) && !user.getPlayer().getInventory().getItemInOffHand().getType().isAir())) return;
|
||||||
NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
|
NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,8 +91,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
if (!user.getHidden() && showLead) {
|
if (!user.getHidden() && showLead) {
|
||||||
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
||||||
if (sendTo.isEmpty()) return;
|
if (sendTo.isEmpty()) return;
|
||||||
PacketManager.sendEntitySpawnPacket(newLocation, userBalloonManager.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager.getPufferfishBalloonUniqueId(), sendTo);
|
user.getBalloonManager().getPufferfish().spawnPufferfish(newLocation, sendTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager.getPufferfishBalloonId(), sendTo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.bukkit.event.inventory.ClickType;
|
|||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
@@ -186,6 +187,12 @@ public class TypeCosmetic extends Type {
|
|||||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
|
if (skullMeta.hasOwner()) {
|
||||||
|
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||||
|
}
|
||||||
|
}
|
||||||
itemMeta.setLore(processedLore);
|
itemMeta.setLore(processedLore);
|
||||||
return itemMeta;
|
return itemMeta;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
@@ -72,6 +73,14 @@ public class TypeEmpty extends Type {
|
|||||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
|
if (skullMeta.hasOwner()) {
|
||||||
|
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itemMeta.setLore(processedLore);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import com.mineinabyss.geary.addons.GearyPhase;
|
|
||||||
import com.mineinabyss.geary.modules.GearyModuleKt;
|
|
||||||
import com.mineinabyss.geary.papermc.tracking.items.ItemTrackingKt;
|
import com.mineinabyss.geary.papermc.tracking.items.ItemTrackingKt;
|
||||||
import com.mineinabyss.geary.prefabs.PrefabKey;
|
import com.mineinabyss.geary.prefabs.PrefabKey;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -14,31 +10,19 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
|
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
|
||||||
*/
|
*/
|
||||||
public class HookGeary extends Hook {
|
public class HookGeary extends Hook {
|
||||||
private boolean enabled = false;
|
|
||||||
|
|
||||||
public HookGeary() {
|
public HookGeary() {
|
||||||
super("geary");
|
super("geary");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
if (!enabled) GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.INIT_ENTITIES, () -> {
|
|
||||||
enabled = true;
|
|
||||||
HMCCosmeticsPlugin.setup();
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary}
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(@NotNull String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
if (enabled) {
|
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
if (prefabKey == null) return null;
|
||||||
if (prefabKey == null) return null;
|
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
|
||||||
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
|
|
||||||
} else return new ItemStack(Material.AIR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,18 +54,15 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
||||||
if (!player.isOnline()) return null;
|
if (!player.isOnline()) return TranslationUtil.getTranslation("user-cosmetic", "offline");
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
|
||||||
if (user == null) return null;
|
if (user == null) return TranslationUtil.getTranslation("user-cosmetic", "invalid-user");
|
||||||
|
|
||||||
List<String> placeholderArgs = Arrays.asList(params.split("_", 3));
|
List<String> placeholderArgs = Arrays.asList(params.split("_", 3));
|
||||||
|
|
||||||
switch (placeholderArgs.get(0).toLowerCase()) {
|
switch (placeholderArgs.get(0).toLowerCase()) {
|
||||||
case "using":
|
case "using":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
if (cosmetic == null) return "INVALID_COSMETIC";
|
if (cosmetic == null) return "INVALID_COSMETIC";
|
||||||
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
||||||
@@ -74,13 +71,10 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
||||||
}
|
}
|
||||||
case "current":
|
case "current":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
CosmeticSlot slot = CosmeticSlot.valueOf(placeholderArgs.get(1).toUpperCase());
|
CosmeticSlot slot = CosmeticSlot.valueOf(placeholderArgs.get(1).toUpperCase());
|
||||||
if (slot == null) return null;
|
if (slot == null) return null;
|
||||||
if (user.getCosmetic(slot) == null) return null;
|
if (user.getCosmetic(slot) == null) return TranslationUtil.getTranslation("current-cosmetic", "no-cosmetic");
|
||||||
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
@@ -104,13 +98,11 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
output = user.getCosmetic(slot).getId();
|
output = user.getCosmetic(slot).getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TranslationUtil.getTranslation("current-cosmetic", String.valueOf(output));
|
if (output == null) output = "none";
|
||||||
|
return TranslationUtil.getTranslation("current-cosmetic", output);
|
||||||
}
|
}
|
||||||
case "unlocked":
|
case "unlocked":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
if (placeholderArgs.size() >= 3) {
|
if (placeholderArgs.size() >= 3) {
|
||||||
@@ -127,10 +119,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic, true)));
|
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic, true)));
|
||||||
}
|
}
|
||||||
case "equipped":
|
case "equipped":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
String args1 = placeholderArgs.get(1);
|
String args1 = placeholderArgs.get(1);
|
||||||
|
|
||||||
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||||
@@ -216,6 +205,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
if (itemMeta == null) return null;
|
if (itemMeta == null) return null;
|
||||||
|
if (!itemMeta.hasDisplayName()) return null;
|
||||||
return itemMeta.getDisplayName();
|
return itemMeta.getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onPlayerHit(EntityDamageByEntityEvent event) {
|
public void onPlayerHit(EntityDamageByEntityEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (event.getEntity().getEntityId() == event.getDamager().getEntityId()) event.setCancelled(true);
|
|
||||||
if (!entity.getPersistentDataContainer().has(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT))
|
if (!entity.getPersistentDataContainer().has(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT))
|
||||||
return;
|
return;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@@ -336,6 +335,16 @@ public class PlayerGameListener implements Listener {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
|
if (Settings.isDisabledGamemodesEnabled()) {
|
||||||
|
if (Settings.getDisabledGamemodes().contains(event.getNewGameMode().toString())) {
|
||||||
|
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||||
|
} else {
|
||||||
|
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.GAMEMODE)) {
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings.isDestroyLooseCosmetics()) {
|
if (Settings.isDestroyLooseCosmetics()) {
|
||||||
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
|
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
|
||||||
if (equippedArmor.length == 0) return;
|
if (equippedArmor.length == 0) return;
|
||||||
@@ -349,11 +358,14 @@ public class PlayerGameListener implements Listener {
|
|||||||
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
|
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
|
||||||
CosmeticUser user = event.getUser();
|
CosmeticUser user = event.getUser();
|
||||||
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
||||||
Location NPCLocation = user.getWardrobeManager().getNpcLocation();
|
|
||||||
CosmeticBalloonType cosmetic = (CosmeticBalloonType) event.getCosmetic();
|
CosmeticBalloonType cosmetic = (CosmeticBalloonType) event.getCosmetic();
|
||||||
|
Location npclocation = user.getWardrobeManager().getNpcLocation().clone().add(cosmetic.getBalloonOffset());
|
||||||
// We know that no other entity besides a regular player will be in the wardrobe
|
// We know that no other entity besides a regular player will be in the wardrobe
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(cosmetic.getBalloonOffset()), false, List.of(user.getPlayer()));
|
List<Player> viewer = List.of(user.getPlayer());
|
||||||
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(cosmetic.getBalloonOffset()));
|
user.getBalloonManager().getPufferfish().spawnPufferfish(npclocation.clone().add(cosmetic.getBalloonOffset()), viewer);
|
||||||
|
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), user.getWardrobeManager().getNPC_ID(), viewer);
|
||||||
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npclocation, false, viewer);
|
||||||
|
user.getBalloonManager().getModelEntity().teleport(npclocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,19 @@ package com.hibiscusmc.hmccosmetics.nms;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class NMSHandlers {
|
public class NMSHandlers {
|
||||||
|
|
||||||
private static final String[] SUPPORTED_VERSION = new String[]{"v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1"};
|
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"};
|
||||||
private static NMSHandler handler;
|
private static NMSHandler handler;
|
||||||
@Getter
|
@Getter
|
||||||
private static String version;
|
private static String version;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static NMSHandler getHandler() {
|
public static NMSHandler getHandler() {
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
return handler;
|
return handler;
|
||||||
@@ -23,6 +25,11 @@ public class NMSHandlers {
|
|||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isVersionSupported() {
|
||||||
|
if (getHandler() == null) return false;
|
||||||
|
return getHandler().getSupported();
|
||||||
|
}
|
||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
if (handler != null) return;
|
if (handler != null) return;
|
||||||
final String packageName = HMCCosmeticsPlugin.getInstance().getServer().getClass().getPackage().getName();
|
final String packageName = HMCCosmeticsPlugin.getInstance().getServer().getClass().getPackage().getName();
|
||||||
|
|||||||
@@ -527,6 +527,7 @@ public class CosmeticUser {
|
|||||||
POTION,
|
POTION,
|
||||||
ACTION,
|
ACTION,
|
||||||
COMMAND,
|
COMMAND,
|
||||||
EMOTE
|
EMOTE,
|
||||||
|
GAMEMODE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class UserBackpackManager {
|
|||||||
|
|
||||||
// No one should be using ME because it barely works but some still use it, so it's here
|
// No one should be using ME because it barely works but some still use it, so it's here
|
||||||
if (cosmeticBackpackType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) {
|
if (cosmeticBackpackType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) {
|
||||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
if (ModelEngineAPI.getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
||||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,15 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||||
|
import com.ticxo.modelengine.api.entity.BaseEntity;
|
||||||
|
import com.ticxo.modelengine.api.entity.BukkitEntity;
|
||||||
|
import com.ticxo.modelengine.api.entity.Dummy;
|
||||||
|
import com.ticxo.modelengine.api.entity.EntityDataTracker;
|
||||||
|
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -19,19 +25,23 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class UserBalloonManager {
|
public class UserBalloonManager {
|
||||||
|
|
||||||
|
private CosmeticUser user;
|
||||||
|
@Getter
|
||||||
private BalloonType balloonType;
|
private BalloonType balloonType;
|
||||||
private CosmeticBalloonType cosmeticBalloonType;
|
private CosmeticBalloonType cosmeticBalloonType;
|
||||||
@Getter
|
@Getter
|
||||||
private UserBalloonPufferfish pufferfish;
|
private UserBalloonPufferfish pufferfish;
|
||||||
private final ArmorStand modelEntity;
|
private final ArmorStand modelEntity;
|
||||||
|
|
||||||
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
|
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
|
||||||
|
this.user = user;
|
||||||
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
|
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
|
||||||
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
|
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
|
||||||
}
|
}
|
||||||
@@ -53,7 +63,7 @@ public class UserBalloonManager {
|
|||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
String id = cosmeticBalloonType.getModelName();
|
String id = cosmeticBalloonType.getModelName();
|
||||||
MessagesUtil.sendDebugMessages("Attempting Spawning for " + id);
|
MessagesUtil.sendDebugMessages("Attempting Spawning for " + id);
|
||||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(id) == null) {
|
if (ModelEngineAPI.getBlueprint(id) == null) {
|
||||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + id, Level.SEVERE);
|
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + id, Level.SEVERE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -61,14 +71,19 @@ public class UserBalloonManager {
|
|||||||
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(id));
|
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(id));
|
||||||
model.setCanHurt(false);
|
model.setCanHurt(false);
|
||||||
modeledEntity.addModel(model, false);
|
modeledEntity.addModel(model, false);
|
||||||
|
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
modeledEntity.getModels().forEach((d, singleModel) -> {
|
modeledEntity.getModels().forEach((d, singleModel) -> {
|
||||||
if (cosmeticBalloonType.isDyablePart(d)) {
|
if (cosmeticBalloonType.isDyablePart(d)) {
|
||||||
singleModel.getRendererHandler().setColor(color);
|
singleModel.setDefaultTint(color);
|
||||||
singleModel.getRendererHandler().update();
|
singleModel.getModelRenderer().sendToClient();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BukkitEntityData data = (BukkitEntityData) modeledEntity.getBase().getData();
|
||||||
|
data.setBlockedCullIgnoreRadius((double) Settings.getViewDistance());
|
||||||
|
data.getTracked().setPlayerPredicate(this::playerCheck);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (balloonType == BalloonType.ITEM) {
|
if (balloonType == BalloonType.ITEM) {
|
||||||
@@ -78,18 +93,19 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity entity = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
|
if (entity == null) {
|
||||||
if (entity == null) return;
|
MessagesUtil.sendDebugMessages("Balloon Removal Failed - Model Entity is Null");
|
||||||
|
return;
|
||||||
for (final Player player : entity.getRangeManager().getPlayerInRange()) {
|
|
||||||
entity.hideFromPlayer(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.destroy();
|
entity.destroy();
|
||||||
|
MessagesUtil.sendDebugMessages("Balloon Model Engine Removal");
|
||||||
}
|
}
|
||||||
|
|
||||||
modelEntity.remove();
|
modelEntity.remove();
|
||||||
cosmeticBalloonType = null;
|
cosmeticBalloonType = null;
|
||||||
|
MessagesUtil.sendDebugMessages("Balloon Entity Removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
||||||
@@ -98,14 +114,13 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType, Color color) {
|
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType, Color color) {
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
final ModeledEntity model = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
spawnModel(cosmeticBalloonType, color);
|
spawnModel(cosmeticBalloonType, color);
|
||||||
MessagesUtil.sendDebugMessages("model is null");
|
MessagesUtil.sendDebugMessages("model is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//if (model.getRangeManager().getPlayerInRange().contains(player)) return;
|
|
||||||
model.showToPlayer(user.getPlayer());
|
|
||||||
MessagesUtil.sendDebugMessages("Show to player");
|
MessagesUtil.sendDebugMessages("Show to player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -113,13 +128,11 @@ public class UserBalloonManager {
|
|||||||
modelEntity.getEquipment().setHelmet(user.getUserCosmeticItem(cosmeticBalloonType));
|
modelEntity.getEquipment().setHelmet(user.getUserCosmeticItem(cosmeticBalloonType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void removePlayerFromModel(final Player player) {
|
public void removePlayerFromModel(final Player viewer) {
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
final ModeledEntity model = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
|
|
||||||
if (model == null) return;
|
if (model == null) return;
|
||||||
|
|
||||||
model.hideFromPlayer(player);
|
|
||||||
MessagesUtil.sendDebugMessages("Hidden from player");
|
MessagesUtil.sendDebugMessages("Hidden from player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -170,7 +183,6 @@ public class UserBalloonManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendLeashPacket(int entityId) {
|
public void sendLeashPacket(int entityId) {
|
||||||
if (cosmeticBalloonType == null) return;
|
|
||||||
if (cosmeticBalloonType.isShowLead()) {
|
if (cosmeticBalloonType.isShowLead()) {
|
||||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||||
}
|
}
|
||||||
@@ -181,4 +193,21 @@ public class UserBalloonManager {
|
|||||||
ITEM,
|
ITEM,
|
||||||
NONE
|
NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean playerCheck(final Player player) {
|
||||||
|
MessagesUtil.sendDebugMessages("playerCheck");
|
||||||
|
CosmeticUser viewer = CosmeticUsers.getUser(player.getUniqueId());
|
||||||
|
|
||||||
|
if (user.getPlayer() == player) {
|
||||||
|
return (!user.getHidden());
|
||||||
|
} else {
|
||||||
|
if (user.isInWardrobe()) return false;
|
||||||
|
MessagesUtil.sendDebugMessages("playerCheck - Not Same Player");
|
||||||
|
if (viewer != null && viewer.isInWardrobe()) {
|
||||||
|
MessagesUtil.sendDebugMessages("playerCheck - Viewer in Wardrobe");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (!user.getHidden());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -35,6 +37,11 @@ public class UserBalloonPufferfish extends UserEntity {
|
|||||||
getViewers().clear();
|
getViewers().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void spawnPufferfish(Location location, List<Player> sendTo) {
|
||||||
|
PacketManager.sendEntitySpawnPacket(location, pufferFishEntityId, EntityType.PUFFERFISH, uuid, sendTo);
|
||||||
|
PacketManager.sendInvisibilityPacket(pufferFishEntityId, sendTo);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Player> refreshViewers(Location location) {
|
public List<Player> refreshViewers(Location location) {
|
||||||
if (System.currentTimeMillis() - getViewerLastUpdate() <= 1000) return List.of(); //Prevents mass refreshes
|
if (System.currentTimeMillis() - getViewerLastUpdate() <= 1000) return List.of(); //Prevents mass refreshes
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ public class UserWardrobeManager {
|
|||||||
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
||||||
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||||
|
user.getBalloonManager().setLocation(balloonLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WardrobeSettings.isEnabledBossbar()) {
|
if (WardrobeSettings.isEnabledBossbar()) {
|
||||||
@@ -234,7 +235,7 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
user.respawnBalloon();
|
//user.respawnBalloon();
|
||||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +301,9 @@ public class UserWardrobeManager {
|
|||||||
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
||||||
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
||||||
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
||||||
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
if (user.getBalloonManager().getBalloonType() != UserBalloonManager.BalloonType.MODELENGINE) {
|
||||||
|
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||||
|
}
|
||||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -337,13 +337,17 @@ public class PacketManager {
|
|||||||
final int entityId,
|
final int entityId,
|
||||||
final @NotNull List<Player> sendTo
|
final @NotNull List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
|
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1") || NMSHandlers.getVersion().contains("v1_19_R2") || NMSHandlers.getVersion().contains("v1_19_R3") || NMSHandlers.getVersion().contains("v1_20_R1")) {
|
||||||
wrapper.setEntityID(entityId);
|
WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
|
||||||
wrapper.setPlayerUUID(uuid);
|
wrapper.setEntityID(entityId);
|
||||||
wrapper.setPosition(location.toVector());
|
wrapper.setPlayerUUID(uuid);
|
||||||
wrapper.setPitch(location.getPitch());
|
wrapper.setPosition(location.toVector());
|
||||||
wrapper.setYaw(location.getYaw());
|
wrapper.setPitch(location.getPitch());
|
||||||
for (final Player p : sendTo) sendPacket(p, wrapper.getHandle());
|
wrapper.setYaw(location.getYaw());
|
||||||
|
for (final Player p : sendTo) sendPacket(p, wrapper.getHandle());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendEntitySpawnPacket(location, entityId, EntityType.PLAYER, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ cosmetic-settings:
|
|||||||
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
||||||
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
|
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
|
||||||
|
|
||||||
|
disabled-gamemode:
|
||||||
|
enabled: true
|
||||||
|
# Which gamemodes should cosmetics be disabled for. This is useful for servers that have a creative world. All options are here, https://hub.spigotmc.org/javadocs/spigot/org/bukkit/GameMode.html
|
||||||
|
gamemodes:
|
||||||
|
- "SPECTATOR"
|
||||||
|
|
||||||
|
# This disables the entire internal emote system within the plugin. This option requires a restart.
|
||||||
|
emote-enable: true
|
||||||
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
||||||
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
||||||
emote-air-check: true # Check if there is air under a player, if there is, don't play emote
|
emote-air-check: true # Check if there is air under a player, if there is, don't play emote
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jetpack:
|
|||||||
amount: 1
|
amount: 1
|
||||||
firstperson-item:
|
firstperson-item:
|
||||||
material: PAPER
|
material: PAPER
|
||||||
model-data: 14
|
model-data: 15
|
||||||
name: "<white>Jetpack"
|
name: "<white>Jetpack"
|
||||||
amount: 1
|
amount: 1
|
||||||
hammer:
|
hammer:
|
||||||
@@ -155,6 +155,6 @@ hibiscus_flower:
|
|||||||
permission: "hmccosmetics.hibiscus_flower"
|
permission: "hmccosmetics.hibiscus_flower"
|
||||||
item:
|
item:
|
||||||
material: PAPER
|
material: PAPER
|
||||||
model-data: 15
|
model-data: 16
|
||||||
name: "<#d24c9f>Hibiscus Flower"
|
name: "<#d24c9f>Hibiscus Flower"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
user-cosmetic:
|
||||||
|
offline: "Offline"
|
||||||
|
invalid-user: "Invalid User"
|
||||||
unlocked-cosmetic:
|
unlocked-cosmetic:
|
||||||
true: "true"
|
true: "true"
|
||||||
false: "false"
|
false: "false"
|
||||||
@@ -11,5 +14,5 @@ using-cosmetic:
|
|||||||
true: "true"
|
true: "true"
|
||||||
false: "false"
|
false: "false"
|
||||||
current-cosmetic:
|
current-cosmetic:
|
||||||
true: "true"
|
no-cosmetic: "No Cosmetic"
|
||||||
false: "false"
|
none: "none"
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ include(
|
|||||||
"v1_19_R2",
|
"v1_19_R2",
|
||||||
"v1_19_R3",
|
"v1_19_R3",
|
||||||
"v1_20_R1",
|
"v1_20_R1",
|
||||||
|
"v1_20_R2"
|
||||||
)
|
)
|
||||||
|
|||||||
27
v1_20_R2/build.gradle.kts
Normal file
27
v1_20_R2/build.gradle.kts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
public class MEGEntity extends ArmorStand {
|
||||||
|
public MEGEntity(Location loc) {
|
||||||
|
super(EntityType.ARMOR_STAND, ((CraftWorld) loc.getWorld()).getHandle());
|
||||||
|
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("Spawned MEGEntity at " + loc);
|
||||||
|
setInvisible(true);
|
||||||
|
setNoGravity(true);
|
||||||
|
setSilent(true);
|
||||||
|
setInvulnerable(true);
|
||||||
|
setSmall(true);
|
||||||
|
setMarker(true);
|
||||||
|
|
||||||
|
persist = false;
|
||||||
|
getBukkitEntity().getPersistentDataContainer().set(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT, Short.valueOf("1"));
|
||||||
|
|
||||||
|
((CraftWorld) loc.getWorld()).getHandle().addFreshEntity(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
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.Display;
|
||||||
|
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.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftEquipmentSlot;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
|
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.ArmorStand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NMSHandler implements com.hibiscusmc.hmccosmetics.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 ArmorStand getMEGEntity(Location loc) {
|
||||||
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
||||||
|
Display.TextDisplay entity = new Display.TextDisplay(net.minecraft.world.entity.EntityType.TEXT_DISPLAY, ((CraftWorld) location.getWorld()).getHandle());
|
||||||
|
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||||
|
entity.persist = false;
|
||||||
|
//entity.setText(net.minecraft.network.chat.Component.literal("TEST!"));
|
||||||
|
entity.setCustomNameVisible(true);
|
||||||
|
entity.setCustomName(Component.literal(text));
|
||||||
|
MessagesUtil.sendDebugMessages("spawnDisplayEntity - " + entity);
|
||||||
|
((CraftWorld) location.getWorld()).getHandle().addFreshEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
return entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
|
|
||||||
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user, entity.getLocation());
|
||||||
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(cosmeticBalloonType.getBalloonOffset()));
|
||||||
|
|
||||||
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
|
return userBalloonManager1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@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 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