mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-23 17:09:24 +00:00
Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8453a8b20d | ||
|
|
e59ee03ac7 | ||
|
|
01155f40dd | ||
|
|
fa9f81e5e2 | ||
|
|
54bcef1a45 | ||
|
|
8e14899397 | ||
|
|
061718a3b6 | ||
|
|
2eea426460 | ||
|
|
b0136d6076 | ||
|
|
d0b45b951c | ||
|
|
e42f5c8c7d | ||
|
|
5d4fb85fec | ||
|
|
04b11a0830 | ||
|
|
353086b9c1 | ||
|
|
4e40a7cc96 | ||
|
|
e2715fe631 | ||
|
|
c7deb756db | ||
|
|
11f26f8f0a | ||
|
|
6d814d86b3 | ||
|
|
12f8b05469 | ||
|
|
b5322bc10b | ||
|
|
7a4fd9a98b | ||
|
|
239e13fab2 | ||
|
|
94b5a1bb3b | ||
|
|
71ed820917 | ||
|
|
20532fbaf2 | ||
|
|
4068af98d2 | ||
|
|
95e83992de | ||
|
|
96817d7279 | ||
|
|
ba7a99247a | ||
|
|
f1da6105c0 | ||
|
|
c06a4fcede | ||
|
|
afb20ea0bb | ||
|
|
774caf8d91 | ||
|
|
a0c2c8a9aa | ||
|
|
5b7f75f7a0 | ||
|
|
3f7d010dfa | ||
|
|
4d84bd681d | ||
|
|
0daff3044d | ||
|
|
ee87338cd4 | ||
|
|
2b467e63ce | ||
|
|
6000cf9c1b | ||
|
|
f2b0fb29d3 | ||
|
|
d2962ba5ed | ||
|
|
b37083a298 | ||
|
|
e35a29a13b | ||
|
|
344aaf32e0 | ||
|
|
6498cb43ea |
@@ -2,13 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
id("xyz.jpenilla.run-paper") version "2.0.0"
|
id("xyz.jpenilla.run-paper") version "2.0.0"
|
||||||
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
|
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.4.8"
|
version = "2.5.0"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -71,14 +71,14 @@ allprojects {
|
|||||||
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.0.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||||
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")
|
||||||
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.6-4")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.19.4")
|
minecraftVersion("1.20.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
@@ -172,6 +172,9 @@ bukkit {
|
|||||||
depend = listOf("ProtocolLib")
|
depend = listOf("ProtocolLib")
|
||||||
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen")
|
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen")
|
||||||
version = "${project.version}"
|
version = "${project.version}"
|
||||||
|
loadBefore = listOf(
|
||||||
|
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
||||||
|
)
|
||||||
|
|
||||||
commands {
|
commands {
|
||||||
register("cosmetic") {
|
register("cosmetic") {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ dependencies {
|
|||||||
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.0.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
@@ -18,7 +18,7 @@ dependencies {
|
|||||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||||
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
||||||
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
|
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||||
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
|
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
|
||||||
exclude("org.spigotmc", "spigot")
|
exclude("org.spigotmc", "spigot")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
private static boolean disable = false;
|
private static boolean disable = false;
|
||||||
private static YamlConfigurationLoader configLoader;
|
private static YamlConfigurationLoader configLoader;
|
||||||
private static final int pluginId = 13873;
|
private static final int pluginId = 13873;
|
||||||
private static boolean hasModelEngine = false;
|
|
||||||
private static boolean onLatestVersion = true;
|
private static boolean onLatestVersion = true;
|
||||||
private static String latestVersion = "";
|
private static String latestVersion = "";
|
||||||
|
|
||||||
@@ -128,11 +127,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
// Database
|
// Database
|
||||||
new Database();
|
new Database();
|
||||||
|
|
||||||
// ModelEngine
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("ModelEngine") != null) {
|
|
||||||
hasModelEngine = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// WorldGuard
|
// WorldGuard
|
||||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
|
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
|
||||||
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
||||||
@@ -286,9 +280,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasModelEngine() {
|
|
||||||
return hasModelEngine;
|
|
||||||
}
|
|
||||||
public static boolean isOnLatestVersion() {
|
public static boolean isOnLatestVersion() {
|
||||||
return onLatestVersion;
|
return onLatestVersion;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
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 org.bukkit.Color;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -46,4 +49,32 @@ public class HMCCosmeticsAPI {
|
|||||||
public static Menu getMenu(String id) {
|
public static Menu getMenu(String id) {
|
||||||
return Menus.getMenu(id);
|
return Menus.getMenu(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equips a cosmetic to a player. You can use getUser and getCosmetic to get the CosmeticUser and Cosmetic to equip.
|
||||||
|
* @param user CosmeticUser to equip cosmetic to
|
||||||
|
* @param cosmetic Cosmetic to equip
|
||||||
|
*/
|
||||||
|
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic) {
|
||||||
|
equipCosmetic(user, cosmetic, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equips a cosmetic to a player with a color. You can use getUser and getCosmetic to get the CosmeticUser and Cosmetic to equip.
|
||||||
|
* @param user CosmeticUser to equip cosmetic to
|
||||||
|
* @param cosmetic Cosmetic to equip
|
||||||
|
* @param color Color to apply to cosmetic
|
||||||
|
*/
|
||||||
|
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic, @Nullable Color color) {
|
||||||
|
user.addPlayerCosmetic(cosmetic, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a cosmetic in cosmeticslot.
|
||||||
|
* @param user The user to remove the cosmetic from
|
||||||
|
* @param slot The slot to remove the cosmetic from
|
||||||
|
*/
|
||||||
|
public static void unequipCosmetic(CosmeticUser user, CosmeticSlot slot) {
|
||||||
|
user.removeCosmeticSlot(slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class WardrobeSettings {
|
public class WardrobeSettings {
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|||||||
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.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
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;
|
||||||
|
|||||||
@@ -1,29 +1,39 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||||
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 org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.AreaEffectCloud;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
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 CosmeticBackpackType extends Cosmetic {
|
public class CosmeticBackpackType extends Cosmetic {
|
||||||
|
|
||||||
private final String modelName;
|
private final String modelName;
|
||||||
private UserBackpackManager.BackpackType backpackType;
|
private ItemStack firstPersonBackpack;
|
||||||
|
|
||||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
modelName = config.node("model").getString();
|
modelName = config.node("model").getString();
|
||||||
backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
|
|
||||||
|
if (!config.node("firstperson-item").virtual()) {
|
||||||
|
this.firstPersonBackpack = generateItemStack(config.node("firstperson-item"));
|
||||||
|
}
|
||||||
|
//backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -44,16 +54,26 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
||||||
|
|
||||||
if (user.getUserBackpackManager().getBackpackType().equals(UserBackpackManager.BackpackType.FIRST_PERSON)) {
|
|
||||||
user.getUserBackpackManager().teleportEffectEntity(loc);
|
|
||||||
PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getAreaEffectEntityId(), loc);
|
|
||||||
PacketManager.sendRidingPacket(user.getUserBackpackManager().getAreaEffectEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
|
|
||||||
} else {
|
|
||||||
PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());
|
user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());
|
||||||
|
|
||||||
|
List<Player> outsideViewers = user.getUserBackpackManager().getCloudManager().refreshViewers(loc);
|
||||||
|
if (!user.isInWardrobe() && isFirstPersonCompadible()) {
|
||||||
|
List<Player> owner = List.of(user.getPlayer());
|
||||||
|
|
||||||
|
ArrayList<Integer> particleCloud = user.getUserBackpackManager().getAreaEffectEntityId();
|
||||||
|
for (int i = 0; i < particleCloud.size(); i++) {
|
||||||
|
if (i == 0) {
|
||||||
|
PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||||
|
} else {
|
||||||
|
PacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||||
|
if (!user.getHidden()) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
||||||
|
MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
|
||||||
|
}
|
||||||
|
PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
|
|
||||||
user.getUserBackpackManager().showBackpack();
|
user.getUserBackpackManager().showBackpack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +81,7 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
return modelName;
|
return modelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserBackpackManager.BackpackType getBackpackType() {
|
public boolean isFirstPersonCompadible() {
|
||||||
return backpackType;
|
return firstPersonBackpack != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -73,6 +73,10 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
|
|
||||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
||||||
|
if (user.getHidden()) {
|
||||||
|
userBalloonManager.getPufferfish().hidePufferfish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
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;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.hibiscusmc.hmccosmetics.database;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.Data;
|
import com.hibiscusmc.hmccosmetics.database.types.Data;
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.InternalData;
|
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.MySQLData;
|
import com.hibiscusmc.hmccosmetics.database.types.MySQLData;
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
|
import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
@@ -16,9 +15,6 @@ public class Database {
|
|||||||
|
|
||||||
private static Data data;
|
private static Data data;
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static InternalData INTERNAL_DATA = new InternalData();
|
|
||||||
|
|
||||||
private static final MySQLData MYSQL_DATA = new MySQLData();
|
private static final MySQLData MYSQL_DATA = new MySQLData();
|
||||||
private static final SQLiteData SQLITE_DATA = new SQLiteData();
|
private static final SQLiteData SQLITE_DATA = new SQLiteData();
|
||||||
|
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.database.types;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class InternalData extends Data {
|
|
||||||
|
|
||||||
NamespacedKey key = new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetics");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setup() {
|
|
||||||
// Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save(CosmeticUser user) {
|
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
|
||||||
|
|
||||||
player.getPersistentDataContainer().set(key, PersistentDataType.STRING, serializeData(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
|
||||||
Player player = Bukkit.getPlayer(uniqueId);
|
|
||||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
|
||||||
|
|
||||||
if (!player.getPersistentDataContainer().has(key, PersistentDataType.STRING)) return user;
|
|
||||||
String rawData = player.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
|
||||||
|
|
||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> a = deserializeData(user, rawData);
|
|
||||||
for (Map<Cosmetic, Color> cosmeticColors : a.values()) {
|
|
||||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
// This can not be async.
|
|
||||||
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(UUID uniqueId) {
|
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(uniqueId);
|
|
||||||
|
|
||||||
if (player.isOnline()) {
|
|
||||||
Player onlinePlayer = player.getPlayer();
|
|
||||||
if (onlinePlayer.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
|
|
||||||
onlinePlayer.getPersistentDataContainer().remove(key);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,10 @@ import org.bukkit.Bukkit;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public abstract class SQLData extends Data {
|
public abstract class SQLData extends Data {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({"Duplicates", "resource"}) // Duplicate is from deprecated InternalData
|
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
public CosmeticUser get(UUID uniqueId) {
|
||||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
CosmeticUser user = new CosmeticUser(uniqueId);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
public class EmoteManager {
|
public class EmoteManager {
|
||||||
private static final @NotNull Map<@NotNull String, @NotNull String> emotes = new HashMap<>();
|
private static final @NotNull Map<String, String> emotes = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all BlockBench animations from the emotes folder and puts it into the animation manager registry and local registry
|
* Loads all BlockBench animations from the emotes folder and puts it into the animation manager registry and local registry
|
||||||
|
|||||||
@@ -5,15 +5,16 @@ import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Types;
|
import com.hibiscusmc.hmccosmetics.gui.type.Types;
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
|
||||||
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
||||||
import dev.triumphteam.gui.guis.Gui;
|
import dev.triumphteam.gui.guis.Gui;
|
||||||
import dev.triumphteam.gui.guis.GuiItem;
|
import dev.triumphteam.gui.guis.GuiItem;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -23,7 +24,9 @@ import org.spongepowered.configurate.ConfigurationNode;
|
|||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class Menu {
|
public class Menu {
|
||||||
|
|
||||||
@@ -32,6 +35,8 @@ public class Menu {
|
|||||||
private final int rows;
|
private final int rows;
|
||||||
private final ConfigurationNode config;
|
private final ConfigurationNode config;
|
||||||
private final String permissionNode;
|
private final String permissionNode;
|
||||||
|
private final ArrayList<MenuItem> items;
|
||||||
|
private final int refreshRate;
|
||||||
|
|
||||||
public Menu(String id, @NotNull ConfigurationNode config) {
|
public Menu(String id, @NotNull ConfigurationNode config) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -40,64 +45,15 @@ public class Menu {
|
|||||||
title = config.node("title").getString("chest");
|
title = config.node("title").getString("chest");
|
||||||
rows = config.node("rows").getInt(1);
|
rows = config.node("rows").getInt(1);
|
||||||
permissionNode = config.node("permission").getString("");
|
permissionNode = config.node("permission").getString("");
|
||||||
|
refreshRate = config.node("refresh-rate").getInt(-1);
|
||||||
|
|
||||||
|
items = new ArrayList<>();
|
||||||
|
setupItems();
|
||||||
|
|
||||||
Menus.addMenu(this);
|
Menus.addMenu(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
private void setupItems() {
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return this.title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRows() {
|
|
||||||
return this.getRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openMenu(CosmeticUser user) {
|
|
||||||
openMenu(user, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openMenu(@NotNull CosmeticUser user, boolean ignorePermission) {
|
|
||||||
Player player = user.getPlayer();
|
|
||||||
if (player == null) return;
|
|
||||||
if (!ignorePermission && !permissionNode.isEmpty()) {
|
|
||||||
if (!player.hasPermission(permissionNode) && !player.isOp()) {
|
|
||||||
MessagesUtil.sendMessage(player, "no-permission");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final Component component = Adventure.MINI_MESSAGE.deserialize(Placeholder.applyPapiPlaceholders(player, this.title));
|
|
||||||
Gui gui = Gui.gui().
|
|
||||||
title(component).
|
|
||||||
rows(this.rows).
|
|
||||||
create();
|
|
||||||
|
|
||||||
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
|
||||||
|
|
||||||
// TODO: Redo this whole gui creation process to allow for all items, possibly implement caching
|
|
||||||
gui = getItems(user, gui);
|
|
||||||
final Gui finalGui = gui; // Need to make it final for the runtask
|
|
||||||
|
|
||||||
// API
|
|
||||||
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
|
||||||
});
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
// Internal
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
finalGui.open(player);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Contract("_, _ -> param2")
|
|
||||||
private Gui getItems(@NotNull CosmeticUser user, Gui gui) {
|
|
||||||
Player player = user.getPlayer();
|
|
||||||
|
|
||||||
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
||||||
|
|
||||||
List<String> slotString;
|
List<String> slotString;
|
||||||
@@ -137,27 +93,97 @@ public class Menu {
|
|||||||
if (Types.isType(typeId)) type = Types.getType(typeId);
|
if (Types.isType(typeId)) type = Types.getType(typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int slot : slots) {
|
items.add(new MenuItem(slots, item, type, config));
|
||||||
ItemStack modifiedItem = getMenuItem(user, type, config, item.clone(), slot).clone();
|
}
|
||||||
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
|
}
|
||||||
|
|
||||||
Type finalType = type;
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRows() {
|
||||||
|
return this.getRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openMenu(CosmeticUser user) {
|
||||||
|
openMenu(user, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openMenu(@NotNull CosmeticUser user, boolean ignorePermission) {
|
||||||
|
Player player = user.getPlayer();
|
||||||
|
if (player == null) return;
|
||||||
|
if (!ignorePermission && !permissionNode.isEmpty()) {
|
||||||
|
if (!player.hasPermission(permissionNode) && !player.isOp()) {
|
||||||
|
MessagesUtil.sendMessage(player, "no-permission");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final Component component = Adventure.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(player, this.title));
|
||||||
|
Gui gui = Gui.gui().
|
||||||
|
title(component).
|
||||||
|
rows(this.rows).
|
||||||
|
create();
|
||||||
|
|
||||||
|
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||||
|
|
||||||
|
AtomicInteger taskid = new AtomicInteger(-1);
|
||||||
|
gui.setOpenGuiAction(event -> {
|
||||||
|
Runnable run = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (gui.getInventory().getViewers().size() == 0 && taskid.get() != -1) {
|
||||||
|
Bukkit.getScheduler().cancelTask(taskid.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateMenu(user, gui);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (refreshRate != -1) {
|
||||||
|
taskid.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(HMCCosmeticsPlugin.getInstance(), run, 0, refreshRate));
|
||||||
|
} else {
|
||||||
|
run.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gui.setCloseGuiAction(event -> {
|
||||||
|
if (taskid.get() != -1) Bukkit.getScheduler().cancelTask(taskid.get());
|
||||||
|
});
|
||||||
|
|
||||||
|
// API
|
||||||
|
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
||||||
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
});
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
// Internal
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
gui.open(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMenu(CosmeticUser user, Gui gui) {
|
||||||
|
for (MenuItem item : items) {
|
||||||
|
Type type = item.getType();
|
||||||
|
for (int slot : item.getSlots()) {
|
||||||
|
ItemStack modifiedItem = getMenuItem(user, type, item.getItemConfig(), item.getItem().clone(), slot);
|
||||||
|
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
|
||||||
guiItem.setAction(event -> {
|
guiItem.setAction(event -> {
|
||||||
MessagesUtil.sendDebugMessages("Selected slot " + slot);
|
MessagesUtil.sendDebugMessages("Selected slot " + slot);
|
||||||
final ClickType clickType = event.getClick();
|
final ClickType clickType = event.getClick();
|
||||||
if (finalType != null) finalType.run(user, config, clickType);
|
if (type != null) type.run(user, item.getItemConfig(), clickType);
|
||||||
// Need to delay the update by a tick so it will actually update with new values
|
updateMenu(user, gui);
|
||||||
for (int guiSlot : slots) {
|
|
||||||
gui.updateItem(guiSlot, getMenuItem(user, finalType, config, item.clone(), guiSlot));
|
|
||||||
}
|
|
||||||
MessagesUtil.sendDebugMessages("Updated slot " + slot);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Added " + slots + " as " + guiItem + " in the menu");
|
MessagesUtil.sendDebugMessages("Added " + slot + " as " + guiItem + " in the menu");
|
||||||
gui.setItem(slot, guiItem);
|
gui.updateItem(slot, guiItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return gui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.gui;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MenuItem {
|
||||||
|
|
||||||
|
private List<Integer> slots;
|
||||||
|
private ItemStack item;
|
||||||
|
private Type type;
|
||||||
|
private ConfigurationNode itemConfig;
|
||||||
|
|
||||||
|
public MenuItem(List<Integer> slots, ItemStack item, Type type, ConfigurationNode itemConfig) {
|
||||||
|
this.slots = slots;
|
||||||
|
this.item = item;
|
||||||
|
this.type = type;
|
||||||
|
this.itemConfig = itemConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getSlots() {
|
||||||
|
return slots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigurationNode getItemConfig() {
|
||||||
|
return itemConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,7 +13,6 @@ import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -33,7 +32,7 @@ public class DyeMenu {
|
|||||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
if (originalItem == null || !cosmetic.isDyable()) return;
|
||||||
|
|
||||||
Gui gui = HMCColorApi.INSTANCE.colorMenu();
|
Gui gui = HMCColorApi.INSTANCE.colorMenu();
|
||||||
gui.updateTitle(Placeholder.applyPapiPlaceholders(player, Settings.getDyeMenuName()));
|
gui.updateTitle(Hooks.processPlaceholders(player, Settings.getDyeMenuName()));
|
||||||
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
||||||
gui.setDefaultTopClickAction(event -> {
|
gui.setDefaultTopClickAction(event -> {
|
||||||
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.gui.type;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
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.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
public abstract class Type {
|
public abstract class Type {
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
@@ -25,10 +22,8 @@ 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;
|
||||||
|
|
||||||
import java.lang.invoke.TypeDescriptor;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class TypeCosmetic extends Type {
|
public class TypeCosmetic extends Type {
|
||||||
|
|
||||||
@@ -38,16 +33,22 @@ public class TypeCosmetic extends Type {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||||
if (config.node("cosmetic").virtual()) return;
|
MessagesUtil.sendDebugMessages("Running Cosmetic Click Type");
|
||||||
|
if (config.node("cosmetic").virtual()) {
|
||||||
|
MessagesUtil.sendDebugMessages("Cosmetic Config Field Virtual");
|
||||||
|
return;
|
||||||
|
}
|
||||||
String cosmeticName = config.node("cosmetic").getString();
|
String cosmeticName = config.node("cosmetic").getString();
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
|
MessagesUtil.sendDebugMessages("No Cosmetic Found");
|
||||||
MessagesUtil.sendMessage(player, "invalid-cosmetic");
|
MessagesUtil.sendMessage(player, "invalid-cosmetic");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.canEquipCosmetic(cosmetic)) {
|
if (!user.canEquipCosmetic(cosmetic)) {
|
||||||
|
MessagesUtil.sendDebugMessages("No Cosmetic Permission");
|
||||||
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -55,6 +56,8 @@ public class TypeCosmetic extends Type {
|
|||||||
List<String> actionStrings = new ArrayList<>();
|
List<String> actionStrings = new ArrayList<>();
|
||||||
ConfigurationNode actionConfig = config.node("actions");
|
ConfigurationNode actionConfig = config.node("actions");
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("Running Actions");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
||||||
|
|
||||||
@@ -85,7 +88,7 @@ public class TypeCosmetic extends Type {
|
|||||||
Actions.runActions(user, actionStrings);
|
Actions.runActions(user, actionStrings);
|
||||||
|
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// Fixes issue with offhand cosmetics not appearing. Yes, I know this is dumb
|
// Fixes issue with offhand cosmetics not appearing. Yes, I know this is dumb
|
||||||
Runnable run = () -> user.updateCosmetic(cosmetic.getSlot());
|
Runnable run = () -> user.updateCosmetic(cosmetic.getSlot());
|
||||||
@@ -95,6 +98,7 @@ public class TypeCosmetic extends Type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
run.run();
|
run.run();
|
||||||
|
MessagesUtil.sendDebugMessages("Finished Type Click Run");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -152,10 +156,13 @@ public class TypeCosmetic extends Type {
|
|||||||
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
||||||
List<String> processedLore = new ArrayList<>();
|
List<String> processedLore = new ArrayList<>();
|
||||||
|
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
if (itemMeta.hasLore()) {
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI")) loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
processedLore.add(loreLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemMeta.setLore(processedLore);
|
itemMeta.setLore(processedLore);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
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;
|
||||||
@@ -58,11 +57,13 @@ public class TypeEmpty extends Type {
|
|||||||
List<String> processedLore = new ArrayList<>();
|
List<String> processedLore = new ArrayList<>();
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
if (itemMeta.hasLore()) {
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI"))
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
|
||||||
processedLore.add(loreLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.misc.*;
|
import com.hibiscusmc.hmccosmetics.hooks.misc.*;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -27,6 +29,7 @@ public class Hooks {
|
|||||||
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
||||||
private static HookCMI CMI_HOOK = new HookCMI();
|
private static HookCMI CMI_HOOK = new HookCMI();
|
||||||
private static HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
private static HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
||||||
|
private static HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine();
|
||||||
|
|
||||||
public static Hook getHook(@NotNull String id) {
|
public static Hook getHook(@NotNull String id) {
|
||||||
return hooks.get(id.toLowerCase());
|
return hooks.get(id.toLowerCase());
|
||||||
@@ -70,6 +73,12 @@ public class Hooks {
|
|||||||
return hook.getItem(split[1]);
|
return hook.getItem(split[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static String processPlaceholders(OfflinePlayer player, String raw) {
|
||||||
|
if (getHook("PlaceholderAPI").isActive()) return PlaceholderAPI.setPlaceholders(player, raw);
|
||||||
|
return raw;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isActiveHook(String id) {
|
public static boolean isActiveHook(String id) {
|
||||||
Hook hook = getHook(id);
|
Hook hook = getHook(id);
|
||||||
if (hook == null) return false;
|
if (hook == null) return false;
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
|
||||||
|
public class HookModelEngine extends Hook {
|
||||||
|
|
||||||
|
public HookModelEngine() {
|
||||||
|
super("ModelEngine");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,21 +17,26 @@ public class WGHook {
|
|||||||
/**
|
/**
|
||||||
* @implNote Please use {@link #getCosmeticEnableFlag()} instead
|
* @implNote Please use {@link #getCosmeticEnableFlag()} instead
|
||||||
*/
|
*/
|
||||||
public static StateFlag COSMETIC_ENABLE_FLAG;
|
private static StateFlag COSMETIC_ENABLE_FLAG;
|
||||||
|
|
||||||
|
private static StateFlag EMOTES_ENABLE_FLAG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
|
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
|
||||||
*/
|
*/
|
||||||
public static StringFlag COSMETIC_WARDROBE_FLAG;
|
private static StringFlag COSMETIC_WARDROBE_FLAG;
|
||||||
|
|
||||||
public WGHook() {
|
public WGHook() {
|
||||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||||
try {
|
try {
|
||||||
StateFlag cosmeticFlag = new StateFlag("cosmetic-enable", false);
|
StateFlag cosmeticFlag = new StateFlag("cosmetic-enable", false);
|
||||||
|
StateFlag emoteFlag = new StateFlag("emotes-enable", false);
|
||||||
StringFlag wardrobeFlag = new StringFlag("cosmetic-wardrobe");
|
StringFlag wardrobeFlag = new StringFlag("cosmetic-wardrobe");
|
||||||
registry.register(cosmeticFlag);
|
registry.register(cosmeticFlag);
|
||||||
|
registry.register(emoteFlag);
|
||||||
registry.register(wardrobeFlag);
|
registry.register(wardrobeFlag);
|
||||||
COSMETIC_ENABLE_FLAG = cosmeticFlag;
|
COSMETIC_ENABLE_FLAG = cosmeticFlag;
|
||||||
|
EMOTES_ENABLE_FLAG = emoteFlag;
|
||||||
COSMETIC_WARDROBE_FLAG = wardrobeFlag;
|
COSMETIC_WARDROBE_FLAG = wardrobeFlag;
|
||||||
} catch (FlagConflictException e) {
|
} catch (FlagConflictException e) {
|
||||||
Flag<?> existing = registry.get("cosmetic-enable");
|
Flag<?> existing = registry.get("cosmetic-enable");
|
||||||
@@ -53,6 +58,14 @@ public class WGHook {
|
|||||||
return COSMETIC_ENABLE_FLAG;
|
return COSMETIC_ENABLE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the emotes enable {@link StateFlag}
|
||||||
|
* @return The emotes enable {@link StateFlag}
|
||||||
|
*/
|
||||||
|
public static StateFlag getEmotesEnableFlag() {
|
||||||
|
return EMOTES_ENABLE_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cosmetic wardrobe {@link StateFlag}
|
* Gets the cosmetic wardrobe {@link StateFlag}
|
||||||
* @return The cosmetic wardrobe {@link StateFlag}
|
* @return The cosmetic wardrobe {@link StateFlag}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
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.MessagesUtil;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
@@ -12,6 +12,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|||||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
@@ -27,10 +28,7 @@ public class WGListener implements Listener {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
Location location = event.getPlayer().getLocation();
|
Location location = event.getPlayer().getLocation();
|
||||||
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
ApplicableRegionSet set = getRegions(location);
|
||||||
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
|
||||||
RegionQuery query = region.createQuery();
|
|
||||||
ApplicableRegionSet set = query.getApplicableRegions(loc);
|
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
@@ -58,10 +56,7 @@ public class WGListener implements Listener {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
Location location = event.getTo();
|
Location location = event.getTo();
|
||||||
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
ApplicableRegionSet set = getRegions(location);
|
||||||
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
|
||||||
RegionQuery query = region.createQuery();
|
|
||||||
ApplicableRegionSet set = query.getApplicableRegions(loc);
|
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
@@ -83,4 +78,28 @@ public class WGListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerEmote(PlayerEmoteStartEvent event) {
|
||||||
|
Player player = event.getUser().getPlayer();
|
||||||
|
if (player == null) return;
|
||||||
|
Location location = player.getLocation();
|
||||||
|
ApplicableRegionSet set = getRegions(location);
|
||||||
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
|
if (protectedRegion.getFlags().containsKey(WGHook.getEmotesEnableFlag())) {
|
||||||
|
if (protectedRegion.getFlags().get(WGHook.getEmotesEnableFlag()).toString().equalsIgnoreCase("DENY")) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicableRegionSet getRegions(Location location) {
|
||||||
|
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
||||||
|
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
RegionQuery query = region.createQuery();
|
||||||
|
return query.getApplicableRegions(loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,22 +114,21 @@ public class PlayerGameListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
if (user.isInWardrobe()) {
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
user.leaveWardrobe();
|
||||||
user.respawnBackpack();
|
|
||||||
user.updateCosmetic();
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||||
|
user.respawnBackpack();
|
||||||
|
}
|
||||||
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
|
user.respawnBalloon();
|
||||||
|
}
|
||||||
|
user.updateCosmetic();
|
||||||
|
}, 1);
|
||||||
|
|
||||||
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
|
||||||
final CosmeticBalloonType cosmeticBalloonType = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
|
|
||||||
user.despawnBalloon();
|
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
user.spawnBalloon(cosmeticBalloonType);
|
|
||||||
}, 2);
|
|
||||||
}
|
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ package com.hibiscusmc.hmccosmetics.nms;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import net.kyori.adventure.text.Component;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -26,8 +25,6 @@ public interface NMSHandler {
|
|||||||
|
|
||||||
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
||||||
|
|
||||||
Entity spawnHMCParticleCloud(Location location);
|
|
||||||
|
|
||||||
Entity spawnDisplayEntity(Location location, String text);
|
Entity spawnDisplayEntity(Location location, String text);
|
||||||
|
|
||||||
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
||||||
|
|||||||
@@ -9,19 +9,23 @@ import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
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.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
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 me.clip.placeholderapi.PlaceholderAPI;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.*;
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -59,7 +63,7 @@ public class CosmeticUser {
|
|||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO);
|
MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO);
|
||||||
updateCosmetic();
|
updateCosmetic();
|
||||||
if (getHidden()) MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
if (getHidden() && !getUserEmoteManager().isPlayingEmote()) MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
||||||
};
|
};
|
||||||
|
|
||||||
int tickPeriod = Settings.getTickPeriod();
|
int tickPeriod = Settings.getTickPeriod();
|
||||||
@@ -220,7 +224,7 @@ public class CosmeticUser {
|
|||||||
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullOwner(), PersistentDataType.STRING)) {
|
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullOwner(), PersistentDataType.STRING)) {
|
||||||
String owner = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullOwner(), PersistentDataType.STRING);
|
String owner = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullOwner(), PersistentDataType.STRING);
|
||||||
|
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI")) owner = PlaceholderAPI.setPlaceholders(getPlayer(), owner);
|
owner = Hooks.processPlaceholders(getPlayer(), owner);
|
||||||
|
|
||||||
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(owner));
|
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(owner));
|
||||||
//skullMeta.getPersistentDataContainer().remove(InventoryUtils.getSkullOwner()); // Don't really need this?
|
//skullMeta.getPersistentDataContainer().remove(InventoryUtils.getSkullOwner()); // Don't really need this?
|
||||||
@@ -228,7 +232,7 @@ public class CosmeticUser {
|
|||||||
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullTexture(), PersistentDataType.STRING)) {
|
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullTexture(), PersistentDataType.STRING)) {
|
||||||
String texture = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullTexture(), PersistentDataType.STRING);
|
String texture = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullTexture(), PersistentDataType.STRING);
|
||||||
|
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI")) texture = PlaceholderAPI.setPlaceholders(getPlayer(), texture);
|
texture = Hooks.processPlaceholders(getPlayer(), texture);
|
||||||
|
|
||||||
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
|
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
|
||||||
+ texture + "\"}]}}}");
|
+ texture + "\"}]}}}");
|
||||||
@@ -242,14 +246,12 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
if (itemMeta.hasLore()) {
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI")) loreLine = PlaceholderAPI.setPlaceholders(getPlayer(), loreLine);
|
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
|
||||||
processedLore.add(loreLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (itemMeta.hasDisplayName()) {
|
if (itemMeta.hasDisplayName()) {
|
||||||
String displayName = itemMeta.getDisplayName();
|
String displayName = itemMeta.getDisplayName();
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI")) displayName = PlaceholderAPI.setPlaceholders(getPlayer(), displayName);
|
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
|
||||||
itemMeta.setDisplayName(displayName);
|
|
||||||
}
|
}
|
||||||
itemMeta.setLore(processedLore);
|
itemMeta.setLore(processedLore);
|
||||||
|
|
||||||
@@ -348,7 +350,7 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
if (this.userBackpackManager != null) return;
|
if (this.userBackpackManager != null) return;
|
||||||
this.userBackpackManager = new UserBackpackManager(this, cosmeticBackpackType.getBackpackType());
|
this.userBackpackManager = new UserBackpackManager(this, cosmeticBackpackType.isFirstPersonCompadible());
|
||||||
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +367,7 @@ public class CosmeticUser {
|
|||||||
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
||||||
if (this.userBalloonManager != null) return;
|
if (this.userBalloonManager != null) return;
|
||||||
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
|
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
|
||||||
|
updateCosmetic(cosmeticBalloonType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void despawnBalloon() {
|
public void despawnBalloon() {
|
||||||
@@ -475,7 +478,7 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showCosmetics() {
|
public void showCosmetics() {
|
||||||
if (hideCosmetics == false) return;
|
if (!hideCosmetics) return;
|
||||||
|
|
||||||
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class UserBackpackCloudManager {
|
||||||
|
|
||||||
|
private ArrayList<Integer> ids;
|
||||||
|
private UUID owner;
|
||||||
|
private List<Player> viewers = new ArrayList<>();
|
||||||
|
private Long lastUpdate;
|
||||||
|
|
||||||
|
public UserBackpackCloudManager(UUID owner) {
|
||||||
|
this.ids = new ArrayList<>();
|
||||||
|
this.owner = owner;
|
||||||
|
this.lastUpdate = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Integer> getId() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> refreshViewers(Location location) {
|
||||||
|
if (System.currentTimeMillis() - lastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
||||||
|
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||||
|
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||||
|
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
||||||
|
|
||||||
|
for (Player player : players) {
|
||||||
|
//if (player.getUniqueId().toString().equalsIgnoreCase(owner.toString())) continue;
|
||||||
|
if (!viewers.contains(player)) {
|
||||||
|
viewers.add(player);
|
||||||
|
newPlayers.add(player);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// bad loopdy loops
|
||||||
|
for (Player viewerPlayer : viewers) {
|
||||||
|
if (!players.contains(viewerPlayer)) {
|
||||||
|
removePlayers.add(viewerPlayer);
|
||||||
|
PacketManager.sendEntityDestroyPacket(ids, List.of(viewerPlayer)); // prevents random leashes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewers.removeAll(removePlayers);
|
||||||
|
lastUpdate = System.currentTimeMillis();
|
||||||
|
return newPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideEffects() {
|
||||||
|
PacketManager.sendEntityDestroyPacket(ids, viewers);
|
||||||
|
viewers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getViewers() {
|
||||||
|
return viewers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,34 +1,38 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
|
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.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||||
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 org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.AreaEffectCloud;
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class UserBackpackManager {
|
public class UserBackpackManager {
|
||||||
|
|
||||||
private boolean hideBackpack;
|
private boolean hideBackpack;
|
||||||
private ArmorStand invisibleArmorStand;
|
private ArmorStand invisibleArmorStand;
|
||||||
private AreaEffectCloud particleCloud;
|
private ArrayList<Integer> particleCloud = new ArrayList<>();
|
||||||
private final CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
private BackpackType backpackType;
|
private boolean firstPerson;
|
||||||
|
private UserBackpackCloudManager cloudManager;
|
||||||
|
|
||||||
public UserBackpackManager(CosmeticUser user, BackpackType backpackType) {
|
public UserBackpackManager(CosmeticUser user, boolean firstPersonView) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
hideBackpack = false;
|
this.hideBackpack = false;
|
||||||
this.backpackType = backpackType;
|
this.firstPerson = firstPersonView;
|
||||||
|
this.cloudManager = new UserBackpackCloudManager(user.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFirstArmorStandId() {
|
public int getFirstArmorStandId() {
|
||||||
@@ -50,21 +54,24 @@ public class UserBackpackManager {
|
|||||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
|
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
|
||||||
|
|
||||||
if (getBackpackType().equals(BackpackType.NORMAL)) {
|
spawn(cosmeticBackpackType);
|
||||||
spawnNormalBackpack(cosmeticBackpackType);
|
|
||||||
}
|
|
||||||
if (getBackpackType().equals(BackpackType.FIRST_PERSON)) {
|
|
||||||
spawnFirstPersonBackpack(cosmeticBackpackType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnNormalBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
|
|
||||||
if (this.invisibleArmorStand != null) return;
|
if (this.invisibleArmorStand != null) return;
|
||||||
|
|
||||||
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
||||||
|
|
||||||
if (cosmeticBackpackType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) {
|
if (cosmeticBackpackType.isFirstPersonCompadible()) {
|
||||||
|
for (int i = particleCloud.size(); i < 5; i++) {
|
||||||
|
int entityId = NMSHandlers.getHandler().getNextEntityId();
|
||||||
|
PacketManager.sendEntitySpawnPacket(user.getPlayer().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
||||||
|
PacketManager.sendCloudEffect(entityId, PacketManager.getViewers(user.getPlayer().getLocation()));
|
||||||
|
this.particleCloud.add(entityId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (ModelEngineAPI.api.getModelRegistry().getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
if (ModelEngineAPI.api.getModelRegistry().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;
|
||||||
@@ -75,26 +82,7 @@ public class UserBackpackManager {
|
|||||||
modeledEntity.addModel(model, false);
|
modeledEntity.addModel(model, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
cosmeticBackpackType.update(user);
|
||||||
}
|
|
||||||
|
|
||||||
public void spawnFirstPersonBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
|
|
||||||
if (this.invisibleArmorStand != null) return;
|
|
||||||
|
|
||||||
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
|
||||||
this.particleCloud = (AreaEffectCloud) NMSHandlers.getHandler().spawnHMCParticleCloud(user.getPlayer().getLocation());
|
|
||||||
|
|
||||||
if (cosmeticBackpackType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) {
|
|
||||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
|
||||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ModeledEntity modeledEntity = ModelEngineAPI.getOrCreateModeledEntity(invisibleArmorStand);
|
|
||||||
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(cosmeticBackpackType.getModelName()));
|
|
||||||
model.setCanHurt(false);
|
|
||||||
modeledEntity.addModel(model, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
||||||
}
|
}
|
||||||
@@ -106,7 +94,9 @@ public class UserBackpackManager {
|
|||||||
this.invisibleArmorStand = null;
|
this.invisibleArmorStand = null;
|
||||||
}
|
}
|
||||||
if (particleCloud != null) {
|
if (particleCloud != null) {
|
||||||
particleCloud.remove();
|
for (int i = 0; i < particleCloud.size(); i++) {
|
||||||
|
PacketManager.sendEntityDestroyPacket(particleCloud.get(i), getCloudManager().getViewers());
|
||||||
|
}
|
||||||
this.particleCloud = null;
|
this.particleCloud = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,16 +119,8 @@ public class UserBackpackManager {
|
|||||||
hideBackpack = shown;
|
hideBackpack = shown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackpackType getBackpackType() {
|
public ArrayList<Integer> getAreaEffectEntityId() {
|
||||||
return backpackType;
|
return particleCloud;
|
||||||
}
|
|
||||||
|
|
||||||
public int getAreaEffectEntityId() {
|
|
||||||
return particleCloud.getEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void teleportEffectEntity(Location location) {
|
|
||||||
particleCloud.teleport(location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(ItemStack item) {
|
public void setItem(ItemStack item) {
|
||||||
@@ -150,8 +132,7 @@ public class UserBackpackManager {
|
|||||||
getArmorStand().getEquipment().setHelmet(item);
|
getArmorStand().getEquipment().setHelmet(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BackpackType {
|
public UserBackpackCloudManager getCloudManager() {
|
||||||
NORMAL,
|
return cloudManager;
|
||||||
FIRST_PERSON // First person not yet implemented
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
|
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.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
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.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
@@ -15,7 +15,6 @@ import org.bukkit.Color;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
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;
|
||||||
@@ -38,7 +37,7 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
public void spawnModel(@NotNull CosmeticBalloonType cosmeticBalloonType, Color color) {
|
public void spawnModel(@NotNull CosmeticBalloonType cosmeticBalloonType, Color color) {
|
||||||
// redo this
|
// redo this
|
||||||
if (cosmeticBalloonType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) {
|
if (cosmeticBalloonType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) {
|
||||||
balloonType = BalloonType.MODELENGINE;
|
balloonType = BalloonType.MODELENGINE;
|
||||||
} else {
|
} else {
|
||||||
if (cosmeticBalloonType.getItem() != null) {
|
if (cosmeticBalloonType.getItem() != null) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
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;
|
||||||
@@ -20,7 +19,7 @@ public class UserBalloonPufferfish {
|
|||||||
public UserBalloonPufferfish(int id, UUID uuid) {
|
public UserBalloonPufferfish(int id, UUID uuid) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.lastUpdate = System.currentTimeMillis();
|
this.lastUpdate = 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -55,4 +54,9 @@ public class UserBalloonPufferfish {
|
|||||||
lastUpdate = System.currentTimeMillis();
|
lastUpdate = System.currentTimeMillis();
|
||||||
return newPlayers;
|
return newPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void hidePufferfish() {
|
||||||
|
PacketManager.sendEntityDestroyPacket(id, viewers);
|
||||||
|
viewers.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ public class UserWardrobeManager {
|
|||||||
// NPC 2
|
// NPC 2
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
PacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
PacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
||||||
|
PacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
|
||||||
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
|
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
|
||||||
NMSHandlers.getHandler().hideNPCName(player, npcName);
|
NMSHandlers.getHandler().hideNPCName(player, npcName);
|
||||||
}, 4);
|
}, 4);
|
||||||
@@ -114,6 +115,7 @@ public class UserWardrobeManager {
|
|||||||
// Misc
|
// Misc
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(npcLocation.clone().add(0, 2, 0));
|
user.getUserBackpackManager().getArmorStand().teleport(npcLocation.clone().add(0, 2, 0));
|
||||||
|
NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
||||||
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@@ -89,7 +88,7 @@ public class MessagesUtil {
|
|||||||
public static void sendTitle(Player player, String message, int fadein, int stay, int fadeout) {
|
public static void sendTitle(Player player, String message, int fadein, int stay, int fadeout) {
|
||||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||||
|
|
||||||
Title.Times times = Title.Times.times(Duration.ofMillis(WardrobeSettings.getTransitionFadeIn()), Duration.ofMillis(3000), Duration.ofMillis(1000));
|
Title.Times times = Title.Times.times(Duration.ofMillis(fadein), Duration.ofMillis(stay), Duration.ofMillis(fadeout));
|
||||||
Title title = Title.title(processStringNoKey(player, message), Component.empty(), times);
|
Title title = Title.title(processStringNoKey(player, message), Component.empty(), times);
|
||||||
|
|
||||||
target.showTitle(title);
|
target.showTitle(title);
|
||||||
@@ -104,7 +103,7 @@ public class MessagesUtil {
|
|||||||
if (!MESSAGES.containsKey(key)) return null;
|
if (!MESSAGES.containsKey(key)) return null;
|
||||||
if (MESSAGES.get(key) == null) return null;
|
if (MESSAGES.get(key) == null) return null;
|
||||||
String message = MESSAGES.get(key);
|
String message = MESSAGES.get(key);
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(player, message);
|
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||||
message = message.replaceAll("%prefix%", prefix);
|
message = message.replaceAll("%prefix%", prefix);
|
||||||
if (placeholders != null ) {
|
if (placeholders != null ) {
|
||||||
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
||||||
@@ -125,7 +124,7 @@ public class MessagesUtil {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static Component processStringNoKey(Player player, String message, TagResolver placeholders) {
|
public static Component processStringNoKey(Player player, String message, TagResolver placeholders) {
|
||||||
message = message.replaceAll("%prefix%", prefix);
|
message = message.replaceAll("%prefix%", prefix);
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(player, message);
|
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||||
if (placeholders != null ) {
|
if (placeholders != null ) {
|
||||||
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
||||||
}
|
}
|
||||||
@@ -134,7 +133,7 @@ public class MessagesUtil {
|
|||||||
|
|
||||||
public static String processStringNoKeyString(Player player, String message) {
|
public static String processStringNoKeyString(Player player, String message) {
|
||||||
message = message.replaceAll("%prefix%", prefix);
|
message = message.replaceAll("%prefix%", prefix);
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(player, message);
|
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util;
|
package com.hibiscusmc.hmccosmetics.util;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -30,7 +31,7 @@ public class TranslationUtil {
|
|||||||
public static String getTranslation(String key, String message) {
|
public static String getTranslation(String key, String message) {
|
||||||
List<TranslationPair> pairs = keys.get(key);
|
List<TranslationPair> pairs = keys.get(key);
|
||||||
for (TranslationPair pair : pairs) {
|
for (TranslationPair pair : pairs) {
|
||||||
if (pair.getKey() == message) return pair.getValue();
|
if (pair.getKey() == message) return StringUtils.parseStringToString(pair.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
|
|||||||
@@ -1,215 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util.builder;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.jetbrains.annotations.Contract;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ItemBuilder {
|
|
||||||
|
|
||||||
protected Material material;
|
|
||||||
protected int amount;
|
|
||||||
protected ItemMeta itemMeta;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param material builder material
|
|
||||||
*/
|
|
||||||
|
|
||||||
ItemBuilder(final Material material) {
|
|
||||||
this.material = material;
|
|
||||||
this.itemMeta = Bukkit.getItemFactory().getItemMeta(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param itemStack builder ItemStack
|
|
||||||
*/
|
|
||||||
|
|
||||||
ItemBuilder(final @NotNull ItemStack itemStack) {
|
|
||||||
this.material = itemStack.getType();
|
|
||||||
this.itemMeta = itemStack.hasItemMeta() ? itemStack.getItemMeta()
|
|
||||||
: Bukkit.getItemFactory().getItemMeta(this.material);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param material builder material
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Contract("_ -> new")
|
|
||||||
@NotNull
|
|
||||||
public static ItemBuilder from(final Material material) {
|
|
||||||
return new ItemBuilder(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param itemStack builder ItemStack
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Contract("_ -> new")
|
|
||||||
@NotNull
|
|
||||||
public static ItemBuilder from(final ItemStack itemStack) {
|
|
||||||
return new ItemBuilder(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param amount ItemStack amount
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder amount(final int amount) {
|
|
||||||
this.amount = Math.min(Math.max(1, amount), 64);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name ItemStack name
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder name(final String name) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.setDisplayName(name);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param lore ItemStack lore
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder lore(final List<String> lore) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.setLore(lore);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder papiPlaceholders(final Player player) {
|
|
||||||
this.lorePapiPlaceholders(player);
|
|
||||||
this.namePapiPlaceholders(player);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void lorePapiPlaceholders(final Player player) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final List<String> newLore = new ArrayList<>();
|
|
||||||
|
|
||||||
final List<String> lore = this.itemMeta.getLore();
|
|
||||||
|
|
||||||
if (lore == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (final String line : this.itemMeta.getLore()) {
|
|
||||||
newLore.add(Placeholder.applyPapiPlaceholders(player, line));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.itemMeta.setLore(newLore);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void namePapiPlaceholders(final Player player) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.itemMeta.setDisplayName(
|
|
||||||
Placeholder.applyPapiPlaceholders(
|
|
||||||
player,
|
|
||||||
this.itemMeta.getDisplayName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param unbreakable whether the ItemStack is unbreakable
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder unbreakable(final boolean unbreakable) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.setUnbreakable(unbreakable);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder glow(final boolean glow) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
if (glow) {
|
|
||||||
this.itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
|
||||||
this.itemMeta.addEnchant(Enchantment.LUCK, 1, true);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param enchantments enchants to be added to the ItemStack
|
|
||||||
* @param ignoreLeveLRestrictions whether to ignore enchantment level restrictions
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder enchants(final Map<Enchantment, Integer> enchantments,
|
|
||||||
boolean ignoreLeveLRestrictions) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
enchantments.forEach((enchantment, level) -> this.itemMeta.addEnchant(enchantment, level,
|
|
||||||
ignoreLeveLRestrictions));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param itemFlags ItemStack ItemFlags
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder itemFlags(final Set<ItemFlag> itemFlags) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.addItemFlags(itemFlags.toArray(new ItemFlag[0]));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param modelData ItemStack modelData
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder modelData(final int modelData) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.setCustomModelData(modelData);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return built ItemStack
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemStack build() {
|
|
||||||
final ItemStack itemStack = new ItemStack(this.material, Math.max(this.amount, 1));
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util.misc;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class Keys {
|
|
||||||
|
|
||||||
static HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
|
||||||
public static final NamespacedKey ITEM_KEY = new NamespacedKey(plugin, "cosmetic");
|
|
||||||
public static final NamespacedKey TOKEN_KEY = new NamespacedKey(plugin, "token-key");
|
|
||||||
|
|
||||||
public static void setKey(final @NotNull ItemStack itemStack) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
itemMeta.getPersistentDataContainer().set(ITEM_KEY, PersistentDataType.BYTE, (byte) 1);
|
|
||||||
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, Z> void setKey(
|
|
||||||
final @NotNull ItemStack itemStack,
|
|
||||||
final NamespacedKey key,
|
|
||||||
final PersistentDataType<T, Z> type,
|
|
||||||
final Z value) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
itemMeta.getPersistentDataContainer().set(key, type, value);
|
|
||||||
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasKey(final @NotNull ItemStack itemStack) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemMeta.getPersistentDataContainer().has(ITEM_KEY, PersistentDataType.BYTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, Z> boolean hasKey(final @NotNull ItemStack itemStack, final NamespacedKey key, final PersistentDataType<T, Z> type) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemMeta.getPersistentDataContainer().has(key, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static <T, Z> Z getValue(final @NotNull ItemStack itemStack, final NamespacedKey key, final PersistentDataType<T, Z> type) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemMeta.getPersistentDataContainer().get(key, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util.misc;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public class Placeholder {
|
|
||||||
|
|
||||||
public static final String PREFIX = "%prefix%";
|
|
||||||
public static final String TYPE = "%type%";
|
|
||||||
public static final String ITEM = "%item%";
|
|
||||||
public static final String FILE = "%file%";
|
|
||||||
|
|
||||||
public static final String PLAYER = "%player%";
|
|
||||||
public static final String ENABLED = "%enabled%";
|
|
||||||
public static final String ALLOWED = "%allowed%";
|
|
||||||
public static final String ID = "%id%";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return message with placeholders applied
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static String applyPapiPlaceholders(@Nullable final Player player,
|
|
||||||
final String message) {
|
|
||||||
/*
|
|
||||||
if (HookManager.getInstance().isEnabled(PAPIHook.class)) {
|
|
||||||
return HookManager.getInstance().getPapiHook().parse(player, message);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,7 @@ import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEnt
|
|||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -31,6 +32,15 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class PacketManager extends BasePacket {
|
public class PacketManager extends BasePacket {
|
||||||
|
|
||||||
|
public static void sendEntitySpawnPacket(
|
||||||
|
final @NotNull Location location,
|
||||||
|
final int entityId,
|
||||||
|
final EntityType entityType,
|
||||||
|
final UUID uuid
|
||||||
|
) {
|
||||||
|
sendEntitySpawnPacket(location, entityId, entityType, uuid, getViewers(location));
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendEntitySpawnPacket(
|
public static void sendEntitySpawnPacket(
|
||||||
final @NotNull Location location,
|
final @NotNull Location location,
|
||||||
final int entityId,
|
final int entityId,
|
||||||
@@ -145,7 +155,29 @@ public class PacketManager extends BasePacket {
|
|||||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||||
}
|
}
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendCloudEffect(
|
||||||
|
int entityId,
|
||||||
|
List<Player> sendTo
|
||||||
|
) {
|
||||||
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
|
packet.getModifier().writeDefaults();
|
||||||
|
packet.getIntegers().write(0, entityId);
|
||||||
|
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||||
|
|
||||||
|
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().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());
|
||||||
|
} else {
|
||||||
|
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||||
|
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x20));
|
||||||
|
wrappedDataValueList.add(new WrappedDataValue(8, WrappedDataWatcher.Registry.get(Float.class), 0f));
|
||||||
|
//wrappedDataValueList.add(new WrappedDataValue(11, WrappedDataWatcher.Registry.get(Integer.class), 21));
|
||||||
|
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||||
|
}
|
||||||
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendLookPacket(
|
public static void sendLookPacket(
|
||||||
@@ -248,6 +280,18 @@ public class PacketManager extends BasePacket {
|
|||||||
for (final Player p : sendTo) sendPacket(p, packet);
|
for (final Player p : sendTo) sendPacket(p, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys an entity from a player
|
||||||
|
* @param sendTo The players the packet should be sent to
|
||||||
|
*/
|
||||||
|
public static void sendEntityDestroyPacket(final List<Integer> ids, @NotNull List<Player> sendTo) {
|
||||||
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
||||||
|
IntArrayList entities = new IntArrayList(new int[]{});
|
||||||
|
for (int id : ids) entities.add(id);
|
||||||
|
packet.getModifier().write(0, entities);
|
||||||
|
for (final Player p : sendTo) sendPacket(p, packet);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a camera packet
|
* Sends a camera packet
|
||||||
* @param entityId The Entity ID that camera will go towards
|
* @param entityId The Entity ID that camera will go towards
|
||||||
@@ -350,9 +394,16 @@ public class PacketManager extends BasePacket {
|
|||||||
packet.getModifier().writeDefaults();
|
packet.getModifier().writeDefaults();
|
||||||
packet.getIntegers().write(0, playerId);
|
packet.getIntegers().write(0, playerId);
|
||||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask);
|
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x10);
|
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask);
|
||||||
|
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||||
|
} else {
|
||||||
|
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||||
|
wrappedDataValueList.add(new WrappedDataValue(17, WrappedDataWatcher.Registry.get(Byte.class), mask));
|
||||||
|
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||||
|
}
|
||||||
|
|
||||||
for (final Player p : sendTo) {
|
for (final Player p : sendTo) {
|
||||||
sendPacket(p, packet);
|
sendPacket(p, packet);
|
||||||
}
|
}
|
||||||
@@ -468,15 +519,6 @@ public class PacketManager extends BasePacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendMovePacket(
|
|
||||||
final int entityId,
|
|
||||||
final Location from,
|
|
||||||
final Location to,
|
|
||||||
final boolean onGround
|
|
||||||
) {
|
|
||||||
sendMovePacket(entityId, from, to, onGround, getViewers(to));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<Player> getViewers(Location location) {
|
public static List<Player> getViewers(Location location) {
|
||||||
ArrayList<Player> viewers = new ArrayList();
|
ArrayList<Player> viewers = new ArrayList();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ config-version: 1
|
|||||||
default-menu: defaultmenu
|
default-menu: defaultmenu
|
||||||
debug-mode: false
|
debug-mode: false
|
||||||
database-settings:
|
database-settings:
|
||||||
type: sqlite #MYSQL, SQLite, INTERNAL (not recommended!)
|
type: sqlite #MYSQL, SQLite
|
||||||
mysql:
|
mysql:
|
||||||
database: database
|
database: database
|
||||||
password: cherryBomb
|
password: cherryBomb
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ backpack:
|
|||||||
model-data: 4
|
model-data: 4
|
||||||
name: "<blue>Backpack"
|
name: "<blue>Backpack"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
firstperson-item:
|
||||||
|
material: PAPER
|
||||||
|
model-data: 8
|
||||||
|
name: "<white>Backpack"
|
||||||
|
amount: 1
|
||||||
future_wings:
|
future_wings:
|
||||||
slot: BACKPACK
|
slot: BACKPACK
|
||||||
permission: "hmccosmetics.future_wings"
|
permission: "hmccosmetics.future_wings"
|
||||||
@@ -23,6 +28,11 @@ future_wings:
|
|||||||
model-data: 9
|
model-data: 9
|
||||||
name: "<#d24c9f>Future Wings"
|
name: "<#d24c9f>Future Wings"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
firstperson-item:
|
||||||
|
material: PAPER
|
||||||
|
model-data: 10
|
||||||
|
name: "<white>Future Wings"
|
||||||
|
amount: 1
|
||||||
lantern_cosmetic:
|
lantern_cosmetic:
|
||||||
slot: OFFHAND
|
slot: OFFHAND
|
||||||
permission: "hmccosmetics.lantern_cosmetic"
|
permission: "hmccosmetics.lantern_cosmetic"
|
||||||
@@ -55,6 +65,11 @@ jetpack:
|
|||||||
model-data: 12
|
model-data: 12
|
||||||
name: "<blue>Jetpack"
|
name: "<blue>Jetpack"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
firstperson-item:
|
||||||
|
material: PAPER
|
||||||
|
model-data: 14
|
||||||
|
name: "<white>Jetpack"
|
||||||
|
amount: 1
|
||||||
hammer:
|
hammer:
|
||||||
slot: OFFHAND
|
slot: OFFHAND
|
||||||
permission: "hmccosmetics.hammer"
|
permission: "hmccosmetics.hammer"
|
||||||
@@ -111,6 +126,11 @@ explorer_backpack:
|
|||||||
model-data: 3
|
model-data: 3
|
||||||
name: "<white>Explorer's Backpack"
|
name: "<white>Explorer's Backpack"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
firstperson-item:
|
||||||
|
material: LEATHER_HORSE_ARMOR
|
||||||
|
model-data: 5
|
||||||
|
name: "<white>Explorer's Backpack"
|
||||||
|
amount: 1
|
||||||
garbage_truck_balloon:
|
garbage_truck_balloon:
|
||||||
slot: BALLOON
|
slot: BALLOON
|
||||||
permission: "hmccosmetics.garbage_truck_balloon"
|
permission: "hmccosmetics.garbage_truck_balloon"
|
||||||
@@ -128,4 +148,13 @@ earth_day_grabber:
|
|||||||
material: LEATHER_HORSE_ARMOR
|
material: LEATHER_HORSE_ARMOR
|
||||||
model-data: 4
|
model-data: 4
|
||||||
name: "<green>Earth Day Grabber"
|
name: "<green>Earth Day Grabber"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
hibiscus_flower:
|
||||||
|
slot: HELMET
|
||||||
|
dyeable: true
|
||||||
|
permission: "hmccosmetics.hibiscus_flower"
|
||||||
|
item:
|
||||||
|
material: PAPER
|
||||||
|
model-data: 15
|
||||||
|
name: "<#d24c9f>Hibiscus Flower"
|
||||||
|
amount: 1
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
title: "<white>"
|
title: "<white>"
|
||||||
rows: 6
|
rows: 6
|
||||||
|
refresh-rate: 20 # Set to -1 or remove to disable auto-updating, leading to it only using event-based updates.
|
||||||
items:
|
items:
|
||||||
beanie:
|
beanie:
|
||||||
slots:
|
slots:
|
||||||
@@ -189,4 +190,15 @@ items:
|
|||||||
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_earth_day_grabber%"
|
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_earth_day_grabber%"
|
||||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
|
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
|
||||||
type: cosmetic
|
type: cosmetic
|
||||||
cosmetic: earth_day_grabber
|
cosmetic: earth_day_grabber
|
||||||
|
hibiscus_flower:
|
||||||
|
slots:
|
||||||
|
- 18
|
||||||
|
item:
|
||||||
|
material: hmccosmetics:hibiscus_flower
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_hibiscus_flower%"
|
||||||
|
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_hibiscus_flower%"
|
||||||
|
type: cosmetic
|
||||||
|
cosmetic: hibiscus_flower
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,14 +6,11 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -21,7 +18,6 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
@@ -35,7 +31,6 @@ 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.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -72,12 +67,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return hmcArmorStand.getBukkitEntity();
|
return hmcArmorStand.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
@@ -106,19 +95,13 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
org.bukkit.entity.Entity entity = user.getEntity();
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
Location newLoc = entity.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(entity.getLocation());
|
|
||||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(entity.getEntityId());
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,14 +6,11 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -21,7 +18,6 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
@@ -35,7 +31,6 @@ 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.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_19_R1.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -72,12 +67,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return hmcArmorStand.getBukkitEntity();
|
return hmcArmorStand.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
@@ -108,19 +97,13 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
org.bukkit.entity.Entity entity = user.getEntity();
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
Location newLoc = entity.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(entity.getLocation());
|
|
||||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(entity.getEntityId());
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,14 +6,11 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -21,7 +18,6 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
@@ -35,7 +31,6 @@ 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.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -72,12 +67,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return hmcArmorStand.getBukkitEntity();
|
return hmcArmorStand.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
@@ -107,19 +96,13 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
org.bukkit.entity.Entity entity = user.getEntity();
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
Location newLoc = entity.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(entity.getLocation());
|
|
||||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(entity.getEntityId());
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,12 +6,10 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
@@ -36,7 +34,6 @@ import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
|
|||||||
import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -73,12 +70,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return hmcArmorStand.getBukkitEntity();
|
return hmcArmorStand.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
@@ -114,19 +105,13 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
Entity entity = user.getEntity();
|
Entity entity = user.getEntity();
|
||||||
Location newLoc = entity.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(entity.getLocation());
|
|
||||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(entity.getEntityId());
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_20_R1;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,12 +6,10 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
@@ -22,7 +20,6 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.world.entity.Display;
|
import net.minecraft.world.entity.Display;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
@@ -36,7 +33,6 @@ 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.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_20_R1.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_20_R1.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -73,12 +69,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return hmcArmorStand.getBukkitEntity();
|
return hmcArmorStand.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
@@ -116,19 +106,13 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
org.bukkit.entity.Entity entity = user.getEntity();
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
Location newLoc = entity.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(entity.getLocation());
|
|
||||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(entity.getEntityId());
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user