mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-23 17:09:24 +00:00
Compare commits
31 Commits
display_en
...
v2.7.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bebee807bc | ||
|
|
26c579b69f | ||
|
|
ef665e7e83 | ||
|
|
7a6475c467 | ||
|
|
63963cccc3 | ||
|
|
7cf6a3c75c | ||
|
|
22a5bb4cf1 | ||
|
|
148d163d9c | ||
|
|
ef36e66c51 | ||
|
|
e5fda588c3 | ||
|
|
3baf2694be | ||
|
|
a1dafdee5b | ||
|
|
e3a42d8b4a | ||
|
|
b366f5930b | ||
|
|
45eb1fa668 | ||
|
|
c466405a81 | ||
|
|
172ffc0333 | ||
|
|
41ac857a11 | ||
|
|
737d63642c | ||
|
|
7b9b7678a3 | ||
|
|
fe88d0c608 | ||
|
|
e14935af7b | ||
|
|
3e83d370f8 | ||
|
|
874a7f5624 | ||
|
|
3af992a291 | ||
|
|
9ef7791998 | ||
|
|
1cbe17ddd4 | ||
|
|
2841742af9 | ||
|
|
6e2f333404 | ||
|
|
af8949b713 | ||
|
|
d6f7d0fcb3 |
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.7.7${getGitCommitHash()}"
|
version = "2.7.8${getGitCommitHash()}"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -86,7 +86,7 @@ allprojects {
|
|||||||
compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library
|
compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library
|
||||||
//compileOnly("it.unimi.dsi:fastutil:8.5.14")
|
//compileOnly("it.unimi.dsi:fastutil:8.5.14")
|
||||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||||
compileOnly("me.lojosho:HibiscusCommons:0.6.2-d21ebed8")
|
compileOnly("me.lojosho:HibiscusCommons:0.6.3-0f0baaf4")
|
||||||
|
|
||||||
// Handled by Spigot Library Loader
|
// Handled by Spigot Library Loader
|
||||||
compileOnly("net.kyori:adventure-api:4.19.0")
|
compileOnly("net.kyori:adventure-api:4.19.0")
|
||||||
@@ -97,7 +97,7 @@ allprojects {
|
|||||||
testCompileOnly("org.projectlombok:lombok:1.18.36")
|
testCompileOnly("org.projectlombok:lombok:1.18.36")
|
||||||
testAnnotationProcessor("org.projectlombok:lombok:1.18.36")
|
testAnnotationProcessor("org.projectlombok:lombok:1.18.36")
|
||||||
|
|
||||||
implementation("dev.triumphteam:triumph-gui:3.1.12-SNAPSHOT") {
|
implementation("dev.triumphteam:triumph-gui:3.2.0-SNAPSHOT") {
|
||||||
exclude("net.kyori") // Already have adventure API
|
exclude("net.kyori") // Already have adventure API
|
||||||
}
|
}
|
||||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
@@ -139,7 +139,7 @@ tasks {
|
|||||||
downloadPlugins {
|
downloadPlugins {
|
||||||
hangar("PlaceholderAPI", "2.11.6")
|
hangar("PlaceholderAPI", "2.11.6")
|
||||||
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
|
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
|
||||||
url("https://download.luckperms.net/1567/bukkit/loader/LuckPerms-Bukkit-5.4.150.jar")
|
url("https://download.luckperms.net/1582/bukkit/loader/LuckPerms-Bukkit-5.4.165.jar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.hibiscusmc.hmccosmetics;
|
package com.hibiscusmc.hmccosmetics;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticsAPI;
|
|
||||||
import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
|
import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
||||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
||||||
@@ -10,7 +9,6 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
|
||||||
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.hooks.items.HookHMCCosmetics;
|
import com.hibiscusmc.hmccosmetics.hooks.items.HookHMCCosmetics;
|
||||||
@@ -26,7 +24,6 @@ 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.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||||
import com.ticxo.playeranimator.PlayerAnimatorImpl;
|
|
||||||
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||||
import me.lojosho.hibiscuscommons.HibiscusPlugin;
|
import me.lojosho.hibiscuscommons.HibiscusPlugin;
|
||||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||||
@@ -68,9 +65,6 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
|||||||
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
|
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
|
||||||
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
|
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
|
||||||
|
|
||||||
// Player Animator ~ Do no longer support running this on a version that PlayerAnimator is supported
|
|
||||||
// if (HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R3") || HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R1")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet
|
|
||||||
|
|
||||||
// Configuration Sync
|
// Configuration Sync
|
||||||
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
||||||
final File messageFile = Path.of(getInstance().getDataFolder().getPath(), "messages.yml").toFile();
|
final File messageFile = Path.of(getInstance().getDataFolder().getPath(), "messages.yml").toFile();
|
||||||
@@ -125,9 +119,6 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
|||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) continue;
|
if (user == null) continue;
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
|
||||||
player.setInvisible(false);
|
|
||||||
}
|
|
||||||
if (user.isInWardrobe()) {
|
if (user.isInWardrobe()) {
|
||||||
user.leaveWardrobe(true);
|
user.leaveWardrobe(true);
|
||||||
}
|
}
|
||||||
@@ -229,8 +220,6 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (Settings.isEmotesEnabled() && (HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R3") || HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R1"))) EmoteManager.loadEmotes(); // PlayerAnimator does not support 1.20.2 yet
|
|
||||||
|
|
||||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||||
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus Successfully Setup");
|
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus Successfully Setup");
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api.events;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a player starts playing an emote.
|
|
||||||
*/
|
|
||||||
public class PlayerEmoteStartEvent extends PlayerCosmeticEvent implements Cancellable {
|
|
||||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
|
||||||
|
|
||||||
private final String animationId;
|
|
||||||
|
|
||||||
private boolean cancel = false;
|
|
||||||
|
|
||||||
public PlayerEmoteStartEvent(@NotNull CosmeticUser who, @NotNull String animationId) {
|
|
||||||
super(who);
|
|
||||||
this.animationId = animationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the animation id of the emote the player started playing.
|
|
||||||
*
|
|
||||||
* @implNote The returned string of this method may be an invalid animation id.
|
|
||||||
* Make sure to validate it before use by calling {@link com.hibiscusmc.hmccosmetics.emotes.EmoteManager#get(String)}.
|
|
||||||
*
|
|
||||||
* @return the animation id of the emote which the player started playing
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
public String getAnimationId() {
|
|
||||||
return animationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
this.cancel = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull HandlerList getHandlers() {
|
|
||||||
return HANDLER_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static @NotNull HandlerList getHandlerList() {
|
|
||||||
return HANDLER_LIST;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api.events;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a player stops playing an emote.
|
|
||||||
*/
|
|
||||||
public class PlayerEmoteStopEvent extends PlayerCosmeticEvent implements Cancellable {
|
|
||||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
|
||||||
|
|
||||||
private final UserEmoteManager.StopEmoteReason reason;
|
|
||||||
|
|
||||||
private boolean cancel = false;
|
|
||||||
|
|
||||||
public PlayerEmoteStopEvent(@NotNull CosmeticUser who, @NotNull UserEmoteManager.StopEmoteReason reason) {
|
|
||||||
super(who);
|
|
||||||
this.reason = reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
|
|
||||||
*
|
|
||||||
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
|
|
||||||
* @deprecated As of release 2.2.5+, replaced by {@link #getReason()}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@NotNull
|
|
||||||
public UserEmoteManager.StopEmoteReason getStopEmoteReason() {
|
|
||||||
return reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing.
|
|
||||||
*
|
|
||||||
* @return the reason why the emote has stopped playing
|
|
||||||
* @since 2.2.5
|
|
||||||
*/
|
|
||||||
public @NotNull UserEmoteManager.StopEmoteReason getReason() {
|
|
||||||
return reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
this.cancel = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull HandlerList getHandlers() {
|
|
||||||
return HANDLER_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static @NotNull HandlerList getHandlerList() {
|
|
||||||
return HANDLER_LIST;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before a player's data is un-loaded from the plugin.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* If this event is cancelled, the player's data will not be un-loaded,
|
||||||
|
* and will be kept in memory.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class PlayerPreUnloadEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
|
||||||
|
private boolean cancelled = false;
|
||||||
|
|
||||||
|
public PlayerPreUnloadEvent(@NotNull CosmeticUser who) {
|
||||||
|
super(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers() {
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @NotNull HandlerList getHandlerList() {
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,9 +10,7 @@ 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.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
|
||||||
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.special.DyeMenu;
|
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||||
@@ -23,7 +21,6 @@ import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
|||||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@@ -403,6 +400,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getEntityManager().getLocation());
|
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getEntityManager().getLocation());
|
||||||
}
|
}
|
||||||
|
player.sendMessage("Cosmetic Passengers -> " + user.getUserBackpackManager().getAreaEffectEntityId());
|
||||||
player.sendMessage("Cosmetics -> " + user.getCosmetics());
|
player.sendMessage("Cosmetics -> " + user.getCosmetics());
|
||||||
player.sendMessage("EntityId -> " + player.getEntityId());
|
player.sendMessage("EntityId -> " + player.getEntityId());
|
||||||
return true;
|
return true;
|
||||||
@@ -464,59 +462,6 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
if (!silent) MessagesUtil.sendMessage(sender, "debug-enabled");
|
if (!silent) MessagesUtil.sendMessage(sender, "debug-enabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ("emote") -> {
|
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.emote")) {
|
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (sender.hasPermission("hmccosmetics.cmd.emote.other")) {
|
|
||||||
if (args.length >= 2) player = Bukkit.getPlayer(args[1]);
|
|
||||||
}
|
|
||||||
if (player == null) {
|
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
|
||||||
if (!user.hasCosmeticInSlot(CosmeticSlot.EMOTE)) {
|
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "emote-none");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CosmeticEmoteType cosmeticEmoteType = (CosmeticEmoteType) user.getCosmetic(CosmeticSlot.EMOTE);
|
|
||||||
cosmeticEmoteType.run(user);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ("playemote") -> {
|
|
||||||
// /cosmetic playEmote <emoteId> [playerName]
|
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.playemote")) {
|
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 2) {
|
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!EmoteManager.has(args[1])) {
|
|
||||||
MessagesUtil.sendDebugMessages("Did not contain " + args[1]);
|
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "emote-invalid");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sender.hasPermission("hmccosmetics.cmd.playemote.other")) {
|
|
||||||
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
|
||||||
}
|
|
||||||
if (player == null) {
|
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
|
||||||
user.getUserEmoteManager().playEmote(args[1]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "disableall" -> {
|
case "disableall" -> {
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.disableall")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.disableall")) {
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ 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.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
|
||||||
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;
|
||||||
@@ -44,8 +43,6 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
if (hasPermission(sender, "hmccosmetics.cmd.hide")) completions.add("hide");
|
if (hasPermission(sender, "hmccosmetics.cmd.hide")) completions.add("hide");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.show")) completions.add("show");
|
if (hasPermission(sender, "hmccosmetics.cmd.show")) completions.add("show");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
|
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.emote")) completions.add("emote");
|
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.playemote")) completions.add("playemote");
|
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.disableall")) completions.add("disableall");
|
if (hasPermission(sender, "hmccosmetics.cmd.disableall")) completions.add("disableall");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.hiddenreasons")) completions.add("hiddenreasons");
|
if (hasPermission(sender, "hmccosmetics.cmd.hiddenreasons")) completions.add("hiddenreasons");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.clearhiddenreasons")) completions.add("clearhiddenreasons");
|
if (hasPermission(sender, "hmccosmetics.cmd.clearhiddenreasons")) completions.add("clearhiddenreasons");
|
||||||
@@ -74,7 +71,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
if (menu.canOpen(user.getPlayer())) completions.add(menu.getId());
|
if (menu.canOpen(user.getPlayer())) completions.add(menu.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "dataclear", "hide", "show", "emote", "hiddenreasons", "clearhiddenreasons" -> {
|
case "dataclear", "hide", "show", "hiddenreasons", "clearhiddenreasons" -> {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
completions.add(player.getName());
|
completions.add(player.getName());
|
||||||
}
|
}
|
||||||
@@ -102,7 +99,6 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
completions.add(wardrobe.getId());
|
completions.add(wardrobe.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "playemote" -> completions.addAll(EmoteManager.getAllNames());
|
|
||||||
}
|
}
|
||||||
StringUtil.copyPartialMatches(args[1], completions, finalCompletions);
|
StringUtil.copyPartialMatches(args[1], completions, finalCompletions);
|
||||||
}
|
}
|
||||||
@@ -112,7 +108,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
case "dye" -> {
|
case "dye" -> {
|
||||||
completions.add("#FFFFFF");
|
completions.add("#FFFFFF");
|
||||||
}
|
}
|
||||||
case "menu", "wardrobe", "apply", "unapply", "playemote" -> {
|
case "menu", "wardrobe", "apply", "unapply" -> {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
completions.add(player.getName());
|
completions.add(player.getName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ public class Settings {
|
|||||||
private static final String ITEM_PROCESS_LORE_PATH = "lore";
|
private static final String ITEM_PROCESS_LORE_PATH = "lore";
|
||||||
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
|
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
|
||||||
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
|
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
|
||||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
|
||||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||||
private static final String HOOK_NEXO_PATH = "nexo";
|
private static final String HOOK_NEXO_PATH = "nexo";
|
||||||
@@ -43,13 +42,6 @@ public class Settings {
|
|||||||
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||||
private static final String COSMETIC_EMOTE_ENABLE = "emote-enable";
|
|
||||||
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
|
||||||
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
|
||||||
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
|
||||||
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
|
||||||
private static final String COSMETIC_EMOTE_CAMERA_PATH = "emote-camera";
|
|
||||||
private static final String COSMETIC_EMOTE_MOVE_CHECK_PATH = "emote-move";
|
|
||||||
private static final String COSMETIC_DISABLED_WORLDS_PATH = "disabled-worlds";
|
private static final String COSMETIC_DISABLED_WORLDS_PATH = "disabled-worlds";
|
||||||
private static final String COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH = "entity-cooldown-teleport-packet";
|
private static final String COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH = "entity-cooldown-teleport-packet";
|
||||||
private static final String COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH = "backpack-force-riding-packet";
|
private static final String COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH = "backpack-force-riding-packet";
|
||||||
@@ -61,6 +53,7 @@ public class Settings {
|
|||||||
private static final String COSMETIC_TYPE_SETTINGS_PATH = "cosmetic-type";
|
private static final String COSMETIC_TYPE_SETTINGS_PATH = "cosmetic-type";
|
||||||
private static final String EQUIP_CLICK_TYPE = "equip-click";
|
private static final String EQUIP_CLICK_TYPE = "equip-click";
|
||||||
private static final String UNEQUIP_CLICK_TYPE = "unequip-click";
|
private static final String UNEQUIP_CLICK_TYPE = "unequip-click";
|
||||||
|
private static final String DYE_CLICK_TYPE = "dye-click";
|
||||||
private static final String SHADING_PATH = "shading";
|
private static final String SHADING_PATH = "shading";
|
||||||
private static final String FIRST_ROW_SHIFT_PATH = "first-row-shift";
|
private static final String FIRST_ROW_SHIFT_PATH = "first-row-shift";
|
||||||
private static final String SEQUENT_ROW_SHIFT_PATH = "sequent-row-shift";
|
private static final String SEQUENT_ROW_SHIFT_PATH = "sequent-row-shift";
|
||||||
@@ -104,22 +97,12 @@ public class Settings {
|
|||||||
private static boolean nexoChangeReload;
|
private static boolean nexoChangeReload;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean worldGuardMoveCheck;
|
private static boolean worldGuardMoveCheck;
|
||||||
@Getter
|
|
||||||
private static boolean cosmeticEmoteBlockCheck;
|
|
||||||
private static final HashMap<EquipmentSlot, SlotOptionConfig> slotOptions = new HashMap<>();
|
private static final HashMap<EquipmentSlot, SlotOptionConfig> slotOptions = new HashMap<>();
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean emoteAirCheck;
|
|
||||||
@Getter
|
|
||||||
private static boolean emoteDamageLeave;
|
|
||||||
@Getter
|
|
||||||
private static boolean emoteInvincible;
|
|
||||||
@Getter
|
|
||||||
private static boolean destroyLooseCosmetics;
|
private static boolean destroyLooseCosmetics;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean backpackForceRidingEnabled;
|
private static boolean backpackForceRidingEnabled;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean emotesEnabled;
|
|
||||||
@Getter
|
|
||||||
private static boolean disabledGamemodesEnabled;
|
private static boolean disabledGamemodesEnabled;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean balloonHeadForward;
|
private static boolean balloonHeadForward;
|
||||||
@@ -148,6 +131,8 @@ public class Settings {
|
|||||||
@Getter
|
@Getter
|
||||||
private static String cosmeticUnEquipClickType;
|
private static String cosmeticUnEquipClickType;
|
||||||
@Getter
|
@Getter
|
||||||
|
private static String cosmeticDyeClickType;
|
||||||
|
@Getter
|
||||||
private static boolean defaultShading;
|
private static boolean defaultShading;
|
||||||
@Getter
|
@Getter
|
||||||
private static String firstRowShift;
|
private static String firstRowShift;
|
||||||
@@ -165,10 +150,6 @@ public class Settings {
|
|||||||
private static String equipableCosmeticColor;
|
private static String equipableCosmeticColor;
|
||||||
@Getter
|
@Getter
|
||||||
private static String lockedCosmeticColor;
|
private static String lockedCosmeticColor;
|
||||||
@Getter
|
|
||||||
private static boolean emoteCameraEnabled;
|
|
||||||
@Getter
|
|
||||||
private static boolean emoteMoveCheck;
|
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private static boolean allPlayersHidden;
|
private static boolean allPlayersHidden;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -209,12 +190,6 @@ public class Settings {
|
|||||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||||
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
||||||
emotesEnabled = cosmeticSettings.node(COSMETIC_EMOTE_ENABLE).getBoolean(true);
|
|
||||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
|
||||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
|
||||||
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
|
||||||
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
|
||||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
|
||||||
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||||
backpackForceRidingEnabled = cosmeticSettings.node(COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH).getBoolean(false);
|
backpackForceRidingEnabled = cosmeticSettings.node(COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH).getBoolean(false);
|
||||||
|
|
||||||
@@ -231,8 +206,6 @@ public class Settings {
|
|||||||
|
|
||||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||||
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt(-3);
|
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt(-3);
|
||||||
emoteCameraEnabled = cosmeticSettings.node(COSMETIC_EMOTE_CAMERA_PATH).getBoolean(true);
|
|
||||||
emoteMoveCheck = cosmeticSettings.node(COSMETIC_EMOTE_MOVE_CHECK_PATH).getBoolean(false);
|
|
||||||
packetEntityTeleportCooldown = cosmeticSettings.node(COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH).getInt(-1);
|
packetEntityTeleportCooldown = cosmeticSettings.node(COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH).getInt(-1);
|
||||||
balloonHeadForward = cosmeticSettings.node(COSMETIC_BALLOON_HEAD_FORWARD_PATH).getBoolean(false);
|
balloonHeadForward = cosmeticSettings.node(COSMETIC_BALLOON_HEAD_FORWARD_PATH).getBoolean(false);
|
||||||
backpackPreventDarkness = cosmeticSettings.node(BACKPACK_PREVENT_DARKNESS_PATH).getBoolean(true);
|
backpackPreventDarkness = cosmeticSettings.node(BACKPACK_PREVENT_DARKNESS_PATH).getBoolean(true);
|
||||||
@@ -257,6 +230,7 @@ public class Settings {
|
|||||||
ConfigurationNode cosmeticTypeSettings = menuSettings.node(COSMETIC_TYPE_SETTINGS_PATH);
|
ConfigurationNode cosmeticTypeSettings = menuSettings.node(COSMETIC_TYPE_SETTINGS_PATH);
|
||||||
cosmeticEquipClickType = cosmeticTypeSettings.node(EQUIP_CLICK_TYPE).getString("ALL");
|
cosmeticEquipClickType = cosmeticTypeSettings.node(EQUIP_CLICK_TYPE).getString("ALL");
|
||||||
cosmeticUnEquipClickType = cosmeticTypeSettings.node(UNEQUIP_CLICK_TYPE).getString("ALL");
|
cosmeticUnEquipClickType = cosmeticTypeSettings.node(UNEQUIP_CLICK_TYPE).getString("ALL");
|
||||||
|
cosmeticDyeClickType = cosmeticTypeSettings.node(DYE_CLICK_TYPE).getString("ALL");
|
||||||
|
|
||||||
final var balloonSection = cosmeticSettings.node(BALLOON_OFFSET);
|
final var balloonSection = cosmeticSettings.node(BALLOON_OFFSET);
|
||||||
balloonOffset = loadVector(balloonSection);
|
balloonOffset = loadVector(balloonSection);
|
||||||
|
|||||||
@@ -2,33 +2,59 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
|
|||||||
|
|
||||||
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 lombok.AccessLevel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
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;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public abstract class Cosmetic {
|
public abstract class Cosmetic {
|
||||||
|
protected static ItemStack UNDEFINED_DISPLAY_ITEM_STACK;
|
||||||
|
|
||||||
@Getter @Setter
|
static {
|
||||||
|
UNDEFINED_DISPLAY_ITEM_STACK = new ItemStack(Material.BARRIER);
|
||||||
|
UNDEFINED_DISPLAY_ITEM_STACK.editMeta(meta -> {
|
||||||
|
meta.displayName(Component.text("Undefined Item Display", NamedTextColor.RED));
|
||||||
|
meta.lore(List.of(
|
||||||
|
Component.text("Please check your configurations & console to", NamedTextColor.RED),
|
||||||
|
Component.text("ensure there are no errors.", NamedTextColor.RED)
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Identifier of the cosmetic. */
|
||||||
private String id;
|
private String id;
|
||||||
@Getter @Setter
|
|
||||||
private String permission;
|
|
||||||
private ItemStack item;
|
|
||||||
@Getter @Setter
|
|
||||||
private String material;
|
|
||||||
@Getter @Setter
|
|
||||||
private CosmeticSlot slot;
|
|
||||||
@Getter @Setter
|
|
||||||
private boolean dyable;
|
|
||||||
|
|
||||||
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
|
/** Permission to use the cosmetic. */
|
||||||
|
private String permission;
|
||||||
|
|
||||||
|
/** The display {@link ItemStack} of the cosmetic. */
|
||||||
|
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
|
||||||
|
private ItemStack item;
|
||||||
|
|
||||||
|
/** The material string of the cosmetic. */
|
||||||
|
private String material;
|
||||||
|
|
||||||
|
/** The {@link CosmeticSlot} this cosmetic occupies. */
|
||||||
|
private CosmeticSlot slot;
|
||||||
|
|
||||||
|
/** Whether the cosmetic is dyeable or not. */
|
||||||
|
private boolean dyeable;
|
||||||
|
|
||||||
|
protected Cosmetic(@NotNull String id, @NotNull ConfigurationNode config) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
if (!config.node("permission").virtual()) {
|
if (!config.node("permission").virtual()) {
|
||||||
@@ -39,23 +65,49 @@ public abstract class Cosmetic {
|
|||||||
|
|
||||||
if (!config.node("item").virtual()) {
|
if (!config.node("item").virtual()) {
|
||||||
this.material = config.node("item", "material").getString();
|
this.material = config.node("item", "material").getString();
|
||||||
this.item = generateItemStack(config.node("item"));
|
try {
|
||||||
|
this.item = generateItemStack(config.node("item"));
|
||||||
|
} catch(Exception ex) {
|
||||||
|
MessagesUtil.sendDebugMessages("Forcing %s to use undefined display".formatted(getId()));
|
||||||
|
this.item = UNDEFINED_DISPLAY_ITEM_STACK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
|
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
|
||||||
|
this.slot = CosmeticSlot.valueOf(config.node("slot").getString());
|
||||||
|
|
||||||
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
|
this.dyeable = config.node("dyeable").getBoolean(false);
|
||||||
setDyable(config.node("dyeable").getBoolean(false));
|
MessagesUtil.sendDebugMessages("Dyeable " + dyeable);
|
||||||
|
}
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
|
protected Cosmetic(String id, String permission, ItemStack item, String material, CosmeticSlot slot, boolean dyeable) {
|
||||||
Cosmetics.addCosmetic(this);
|
this.id = id;
|
||||||
|
this.permission = permission;
|
||||||
|
this.item = item;
|
||||||
|
this.material = material;
|
||||||
|
this.slot = slot;
|
||||||
|
this.dyeable = dyeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean requiresPermission() {
|
public boolean requiresPermission() {
|
||||||
return permission != null;
|
return permission != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void update(CosmeticUser user);
|
/**
|
||||||
|
* Dispatched when an update is requested upon the cosmetic.
|
||||||
|
* @param user the user to preform the update against
|
||||||
|
*/
|
||||||
|
public final void update(CosmeticUser user) {
|
||||||
|
this.doUpdate(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action preformed on the update.
|
||||||
|
* @param user the user to preform the update against
|
||||||
|
*/
|
||||||
|
protected void doUpdate(final CosmeticUser user) {
|
||||||
|
// NO-OP.
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
@@ -63,6 +115,11 @@ public abstract class Cosmetic {
|
|||||||
return item.clone();
|
return item.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate an {@link ItemStack} from a {@link ConfigurationNode}.
|
||||||
|
* @param config the configuration node
|
||||||
|
* @return the {@link ItemStack}
|
||||||
|
*/
|
||||||
protected ItemStack generateItemStack(ConfigurationNode config) {
|
protected ItemStack generateItemStack(ConfigurationNode config) {
|
||||||
try {
|
try {
|
||||||
ItemStack item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config);
|
ItemStack item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config);
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ public abstract class CosmeticProvider {
|
|||||||
|
|
||||||
Map.entry(CosmeticSlot.BACKPACK, CosmeticBackpackType::new),
|
Map.entry(CosmeticSlot.BACKPACK, CosmeticBackpackType::new),
|
||||||
|
|
||||||
Map.entry(CosmeticSlot.BALLOON, CosmeticBalloonType::new),
|
Map.entry(CosmeticSlot.BALLOON, CosmeticBalloonType::new)
|
||||||
|
|
||||||
Map.entry(CosmeticSlot.EMOTE, CosmeticEmoteType::new)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final String EXCEPTION_MESSAGE = "Unknown slot %s provided for mapping, if you registered your own CosmeticSlot please ensure that you've also registered a custom CosmeticProvider! Or if you have already registered a custom CosmeticProvider ensure it is registered in your plugins `onLoad` method instead of `onEnable`!";
|
private static final String EXCEPTION_MESSAGE = "Unknown slot %s provided for mapping, if you registered your own CosmeticSlot please ensure that you've also registered a custom CosmeticProvider! Or if you have already registered a custom CosmeticProvider ensure it is registered in your plugins `onLoad` method instead of `onEnable`!";
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ public class CosmeticSlot {
|
|||||||
public static final CosmeticSlot OFFHAND = register("OFFHAND");
|
public static final CosmeticSlot OFFHAND = register("OFFHAND");
|
||||||
public static final CosmeticSlot BACKPACK = register("BACKPACK");
|
public static final CosmeticSlot BACKPACK = register("BACKPACK");
|
||||||
public static final CosmeticSlot BALLOON = register("BALLOON");
|
public static final CosmeticSlot BALLOON = register("BALLOON");
|
||||||
public static final CosmeticSlot EMOTE = register("EMOTE");
|
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(@NotNull CosmeticUser user) {
|
protected void doUpdate(@NotNull CosmeticUser user) {
|
||||||
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) return;
|
if (user.isInWardrobe()) return;
|
||||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
if (Settings.getSlotOption(equipSlot).isRequireEmpty() && entity instanceof HumanEntity humanEntity) {
|
if (Settings.getSlotOption(equipSlot).isRequireEmpty() && entity instanceof HumanEntity humanEntity) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(@NotNull CosmeticUser user) {
|
protected void doUpdate(@NotNull CosmeticUser user) {
|
||||||
Entity entity = user.getEntity();
|
Entity entity = user.getEntity();
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
@@ -22,7 +23,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
@Getter
|
@Getter
|
||||||
private final String modelName;
|
private final String modelName;
|
||||||
@Getter
|
@Getter
|
||||||
private List<String> dyableParts;
|
private List<String> dyeableParts;
|
||||||
@Getter
|
@Getter
|
||||||
private final boolean showLead;
|
private final boolean showLead;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -41,8 +42,8 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
balloonOffset = Settings.loadVector(balloonOffsetNode);
|
balloonOffset = Settings.loadVector(balloonOffsetNode);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!config.node("dyable-parts").virtual()) {
|
if (!config.node("dyeable-parts").virtual()) {
|
||||||
dyableParts = config.node("dyable-parts").getList(String.class);
|
dyeableParts = config.node("dyeable-parts").getList(String.class);
|
||||||
}
|
}
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
// Seriously?
|
// Seriously?
|
||||||
@@ -53,7 +54,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(@NotNull CosmeticUser user) {
|
protected void doUpdate(@NotNull CosmeticUser user) {
|
||||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
UserBalloonManager userBalloonManager = user.getBalloonManager();
|
UserBalloonManager userBalloonManager = user.getBalloonManager();
|
||||||
|
|
||||||
@@ -82,6 +83,11 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
userBalloonManager.setLocation(newLocation);
|
userBalloonManager.setLocation(newLocation);
|
||||||
userBalloonManager.setVelocity(velocity.multiply(1.1));
|
userBalloonManager.setVelocity(velocity.multiply(1.1));
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("Balloon Cosmetic Update for " + user.getEntity().getName());
|
||||||
|
MessagesUtil.sendDebugMessages("Ballon previous location is " + currentLocation);
|
||||||
|
MessagesUtil.sendDebugMessages("Balloon location set to " + newLocation);
|
||||||
|
MessagesUtil.sendDebugMessages("Balloon velocity set to " + velocity);
|
||||||
|
|
||||||
HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||||
HMCCPacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
HMCCPacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
||||||
if (user.isHidden()) {
|
if (user.isHidden()) {
|
||||||
@@ -95,10 +101,10 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDyablePart(String name) {
|
public boolean isDyeablePart(String name) {
|
||||||
// If player does not define parts, dye whole model
|
// If player does not define parts, dye whole model
|
||||||
if (dyableParts == null) return true;
|
if (dyeableParts == null) return true;
|
||||||
if (dyableParts.isEmpty()) return true;
|
if (dyeableParts.isEmpty()) return true;
|
||||||
return dyableParts.contains(name);
|
return dyeableParts.contains(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class CosmeticEmoteType extends Cosmetic {
|
|
||||||
|
|
||||||
private final String animationId;
|
|
||||||
private final String text;
|
|
||||||
|
|
||||||
public CosmeticEmoteType(String id, ConfigurationNode config) {
|
|
||||||
super(id, config);
|
|
||||||
|
|
||||||
animationId = config.node("animation").getString();
|
|
||||||
text = config.node("text").getString();
|
|
||||||
MessagesUtil.sendDebugMessages("CosmeticEmoteType Animation id " + animationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(CosmeticUser user) {
|
|
||||||
// Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run(@NotNull CosmeticUser user) {
|
|
||||||
user.getUserEmoteManager().playEmote(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAnimationId() {
|
|
||||||
return animationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,7 @@ public class CosmeticMainhandType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(@NotNull CosmeticUser user) {
|
protected void doUpdate(@NotNull CosmeticUser user) {
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
|
|
||||||
HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), HMCCPacketManager.getViewers(player.getLocation()));
|
HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), HMCCPacketManager.getViewers(player.getLocation()));
|
||||||
|
|||||||
@@ -39,10 +39,12 @@ public class MySQLData extends SQLData {
|
|||||||
try {
|
try {
|
||||||
openConnection();
|
openConnection();
|
||||||
if (connection == null) throw new NullPointerException("Connection is null");
|
if (connection == null) throw new NullPointerException("Connection is null");
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
try (PreparedStatement preparedStatement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
||||||
"(UUID varchar(36) PRIMARY KEY, " +
|
"(UUID varchar(36) PRIMARY KEY, " +
|
||||||
"COSMETICS MEDIUMTEXT " +
|
"COSMETICS MEDIUMTEXT " +
|
||||||
");").execute();
|
");")) {
|
||||||
|
preparedStatement.execute();
|
||||||
|
}
|
||||||
} catch (SQLException | NullPointerException e) {
|
} catch (SQLException | NullPointerException e) {
|
||||||
plugin.getLogger().severe("");
|
plugin.getLogger().severe("");
|
||||||
plugin.getLogger().severe("");
|
plugin.getLogger().severe("");
|
||||||
@@ -60,17 +62,11 @@ public class MySQLData extends SQLData {
|
|||||||
@Override
|
@Override
|
||||||
public void clear(UUID uniqueId) {
|
public void clear(UUID uniqueId) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
PreparedStatement preparedSt = null;
|
try (PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;")) {
|
||||||
try {
|
|
||||||
preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
|
||||||
preparedSt.setString(1, uniqueId.toString());
|
preparedSt.setString(1, uniqueId.toString());
|
||||||
preparedSt.executeUpdate();
|
preparedSt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (preparedSt != null) preparedSt.close();
|
|
||||||
} catch (SQLException e) {}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,22 +23,17 @@ public abstract class SQLData extends Data {
|
|||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
UserData data = new UserData(uniqueId);
|
UserData data = new UserData(uniqueId);
|
||||||
|
|
||||||
PreparedStatement preparedStatement = null;
|
try (PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;")){
|
||||||
try {
|
|
||||||
preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
|
||||||
preparedStatement.setString(1, uniqueId.toString());
|
preparedStatement.setString(1, uniqueId.toString());
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
try (ResultSet rs = preparedStatement.executeQuery()) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
String rawData = rs.getString("COSMETICS");
|
String rawData = rs.getString("COSMETICS");
|
||||||
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = deserializeData(rawData);
|
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = deserializeData(rawData);
|
||||||
data.setCosmetics(cosmetics);
|
data.setCosmetics(cosmetics);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (preparedStatement != null) preparedStatement.close();
|
|
||||||
} catch (SQLException e) {}
|
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
@@ -48,18 +43,12 @@ public abstract class SQLData extends Data {
|
|||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
public void save(CosmeticUser user) {
|
public void save(CosmeticUser user) {
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
PreparedStatement preparedSt = null;
|
try (PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);")) {
|
||||||
try {
|
|
||||||
preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
|
||||||
preparedSt.setString(1, user.getUniqueId().toString());
|
preparedSt.setString(1, user.getUniqueId().toString());
|
||||||
preparedSt.setString(2, serializeData(user));
|
preparedSt.setString(2, serializeData(user));
|
||||||
preparedSt.executeUpdate();
|
preparedSt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (preparedSt != null) preparedSt.close();
|
|
||||||
} catch (SQLException e) {}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!HMCCosmeticsPlugin.getInstance().isDisabled()) {
|
if (!HMCCosmeticsPlugin.getInstance().isDisabled()) {
|
||||||
|
|||||||
@@ -35,10 +35,12 @@ public class SQLiteData extends SQLData {
|
|||||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
||||||
|
|
||||||
openConnection();
|
openConnection();
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
try (PreparedStatement preparedStatement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
||||||
"(UUID varchar(36) PRIMARY KEY, " +
|
"(UUID varchar(36) PRIMARY KEY, " +
|
||||||
"COSMETICS MEDIUMTEXT " +
|
"COSMETICS MEDIUMTEXT " +
|
||||||
");").execute();
|
");")) {
|
||||||
|
preparedStatement.execute();
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -48,17 +50,11 @@ public class SQLiteData extends SQLData {
|
|||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
public void clear(UUID uniqueId) {
|
public void clear(UUID uniqueId) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
PreparedStatement preparedSt = null;
|
try (PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;")){
|
||||||
try {
|
|
||||||
preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
|
||||||
preparedSt.setString(1, uniqueId.toString());
|
preparedSt.setString(1, uniqueId.toString());
|
||||||
preparedSt.executeUpdate();
|
preparedSt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (preparedSt != null) preparedSt.close();
|
|
||||||
} catch (SQLException e) {}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.emotes;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.ticxo.playeranimator.api.PlayerAnimator;
|
|
||||||
import com.ticxo.playeranimator.api.animation.pack.AnimationPack;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manages Emotes
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
|
||||||
public class EmoteManager {
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
public static void loadEmotes() {
|
|
||||||
// Clear the PlayerAnimator and local registries
|
|
||||||
PlayerAnimator.api.getAnimationManager().clearRegistry();
|
|
||||||
emotes.clear();
|
|
||||||
|
|
||||||
// Get the emote directory and check if it exists
|
|
||||||
File emoteDir = new File(HMCCosmeticsPlugin.getInstance().getDataFolder().getPath() + "/emotes/");
|
|
||||||
if (!emoteDir.exists()) return;
|
|
||||||
|
|
||||||
// Get all the files inside the directory and check if it isn't 0
|
|
||||||
File[] emoteFiles = emoteDir.listFiles();
|
|
||||||
if (emoteFiles == null || emoteFiles.length == 0) return;
|
|
||||||
|
|
||||||
// Remove any files that don't have the file extension ".bbmodel" and check if there are still resulting files
|
|
||||||
emoteFiles = Arrays.stream(emoteFiles).filter(file -> file.getPath().endsWith(".bbmodel")).distinct().toArray(File[]::new);
|
|
||||||
if (emoteFiles.length == 0) return;
|
|
||||||
|
|
||||||
// Loop through all files, importing all block bench animations into the registry
|
|
||||||
for (File animationFile : emoteFiles) {
|
|
||||||
String animationKey = FilenameUtils.removeExtension(animationFile.getName());
|
|
||||||
PlayerAnimator.api.getAnimationManager().importAnimations(animationKey, animationFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loops through all the entries in the registries and unpacks any animation packs to ensure if there were multiple animations
|
|
||||||
// inside a singular file, that they are added to the local registry individually for tab completion
|
|
||||||
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
|
|
||||||
packEntry.getValue().getAnimations().keySet().forEach(animationName -> {
|
|
||||||
// API key is the format "animationKey.animationFileName.animationName"
|
|
||||||
String apiKey = packEntry.getKey().replace(":", ".") + "." + animationName;
|
|
||||||
emotes.put(animationName, apiKey);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if there is an animation with the specified name
|
|
||||||
* @param animationName Name whose presence is to be tested
|
|
||||||
* @return True if this registry contains a mapping for the specified name
|
|
||||||
*/
|
|
||||||
public static boolean has(@NotNull String animationName) {
|
|
||||||
return emotes.containsKey(animationName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@code API key} to which the specified name is mapped, or {@code null} if this map contains no mapping for the name.
|
|
||||||
* @param animationName Name whose {@code API key} is to be fetched
|
|
||||||
* @return The {@code API key} of the specified name or {@code null} if there was no animation name found
|
|
||||||
*/
|
|
||||||
public static @Nullable String get(@NotNull String animationName) {
|
|
||||||
return emotes.get(animationName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a set of all the laoded animation names
|
|
||||||
* @return A set of all loaded animation names
|
|
||||||
*/
|
|
||||||
public static @NotNull Set<String> getAllNames() {
|
|
||||||
return emotes.keySet();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -57,7 +57,7 @@ public class Menu {
|
|||||||
private final boolean shading;
|
private final boolean shading;
|
||||||
|
|
||||||
public Menu(String id, @NotNull ConfigurationNode config) {
|
public Menu(String id, @NotNull ConfigurationNode config) {
|
||||||
this.id = id;
|
this.id = config.node("id").getString(id);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
title = config.node("title").getString("chest");
|
title = config.node("title").getString("chest");
|
||||||
@@ -154,8 +154,7 @@ public class Menu {
|
|||||||
Gui gui = Gui.gui()
|
Gui gui = Gui.gui()
|
||||||
.title(component)
|
.title(component)
|
||||||
.type(GuiType.CHEST)
|
.type(GuiType.CHEST)
|
||||||
.rows(this.rows)
|
.inventory((title, owner, type) -> Bukkit.createInventory(owner, rows * 9, title))
|
||||||
.inventory((title, owner, rows) -> Bukkit.createInventory(owner, rows, title))
|
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||||
@@ -248,7 +247,7 @@ public class Menu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MessagesUtil.sendDebugMessages("Updated menu with title " + title);
|
MessagesUtil.sendDebugMessages("Updated menu with title " + title);
|
||||||
gui.updateTitle(StringUtils.parseStringToString(Hooks.processPlaceholders(viewer, title.toString())));
|
gui.updateTitle(AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(viewer, title.toString())));
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < gui.getInventory().getSize(); i++) {
|
for (int i = 0; i < gui.getInventory().getSize(); i++) {
|
||||||
if (items.containsKey(i)) {
|
if (items.containsKey(i)) {
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import me.lojosho.hibiscuscommons.util.ColorBuilder;
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
|
import me.lojosho.hibiscuscommons.util.AdventureUtils;
|
||||||
import me.lojosho.hibiscuscommons.util.StringUtils;
|
import me.lojosho.hibiscuscommons.util.StringUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.*;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -25,31 +27,17 @@ public class DyeMenu {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack originalItem = cosmetic.getItem();
|
ItemStack originalItem = cosmetic.getItem();
|
||||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
if (originalItem == null || !cosmetic.isDyeable()) return;
|
||||||
|
|
||||||
Gui gui = HMCColorApi.createColorMenu(viewer);
|
Gui gui = HMCColorApi.createColorMenu(viewer);
|
||||||
gui.updateTitle(Hooks.processPlaceholders(viewer, StringUtils.parseStringToString(Settings.getDyeMenuName())));
|
gui.updateTitle(AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(viewer, StringUtils.parseStringToString(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()) {
|
||||||
ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot());
|
ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot());
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
ItemMeta meta = item.getItemMeta();
|
|
||||||
if (meta == null) return;
|
|
||||||
|
|
||||||
Color color = null;
|
Color color = NMSHandlers.getHandler().getUtilHandler().getColor(item);
|
||||||
if (meta instanceof LeatherArmorMeta leatherMeta) {
|
|
||||||
color = leatherMeta.getColor();
|
|
||||||
} else if (meta instanceof PotionMeta potionMeta) {
|
|
||||||
color = potionMeta.getColor();
|
|
||||||
} else if (meta instanceof MapMeta mapMeta) {
|
|
||||||
color = mapMeta.getColor();
|
|
||||||
} else if (meta instanceof FireworkEffectMeta fireworkEffectMeta) {
|
|
||||||
FireworkEffect effect = fireworkEffectMeta.getEffect();
|
|
||||||
if (effect != null) {
|
|
||||||
color = effect.getColors().stream().findFirst().isPresent() ? effect.getColors().stream().findFirst().get() : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (color == null) return;
|
if (color == null) return;
|
||||||
|
|
||||||
addCosmetic(viewer, cosmeticHolder, cosmetic, color);
|
addCosmetic(viewer, cosmeticHolder, cosmetic, color);
|
||||||
|
|||||||
@@ -2,10 +2,22 @@ package com.hibiscusmc.hmccosmetics.gui.type;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
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;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class Type {
|
public abstract class Type {
|
||||||
|
|
||||||
@@ -48,4 +60,59 @@ public abstract class Type {
|
|||||||
* @deprecated Override {@link #setItem(Player, CosmeticHolder, ConfigurationNode, ItemStack, int)} instead.
|
* @deprecated Override {@link #setItem(Player, CosmeticHolder, ConfigurationNode, ItemStack, int)} instead.
|
||||||
*/
|
*/
|
||||||
public abstract ItemStack setItem(CosmeticUser user, ConfigurationNode config, ItemStack itemStack, int slot);
|
public abstract ItemStack setItem(CosmeticUser user, ConfigurationNode config, ItemStack itemStack, int slot);
|
||||||
|
|
||||||
|
@Contract("_, _ -> param2")
|
||||||
|
@NotNull
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
|
protected ItemMeta processItemMeta(Player viewer, @NotNull ItemMeta itemMeta) {
|
||||||
|
// New implementation - Paper and forks
|
||||||
|
// I know this is a kinda batshit way to do it (with serializing and deserializing MiniMessage)
|
||||||
|
// But currently I can't think of another good way of doing it without a big refactor. I'll come back to this
|
||||||
|
// At a later date.
|
||||||
|
if (HibiscusCommonsPlugin.isOnPaper()) {
|
||||||
|
List<Component> processedLore = new ArrayList<>();
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
String displayName = MiniMessage.miniMessage().serialize(itemMeta.displayName());
|
||||||
|
displayName = Hooks.processPlaceholders(viewer, displayName);
|
||||||
|
itemMeta.displayName(MiniMessage.miniMessage().deserialize(displayName).decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemMeta.hasLore()) {
|
||||||
|
for (Component loreLine : itemMeta.lore()) {
|
||||||
|
String loreStringLine = MiniMessage.miniMessage().serialize(loreLine);
|
||||||
|
loreStringLine = Hooks.processPlaceholders(viewer, loreStringLine);
|
||||||
|
processedLore.add(MiniMessage.miniMessage().deserialize(loreStringLine).decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
|
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
||||||
|
skullMeta.setOwner(Hooks.processPlaceholders(viewer, skullMeta.getOwner()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itemMeta.lore(processedLore);
|
||||||
|
} else {
|
||||||
|
// Legacy implementation - Spigot
|
||||||
|
List<String> processedLore = new ArrayList<>();
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
itemMeta.setDisplayName(Hooks.processPlaceholders(viewer, itemMeta.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemMeta.hasLore()) {
|
||||||
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
|
processedLore.add(Hooks.processPlaceholders(viewer, loreLine));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
|
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
||||||
|
skullMeta.setOwner(Hooks.processPlaceholders(viewer, skullMeta.getOwner()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itemMeta.setLore(processedLore);
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMeta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.jetbrains.annotations.Contract;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -62,17 +59,22 @@ public class TypeCosmetic extends Type {
|
|||||||
boolean isUnEquippingCosmetic = false;
|
boolean isUnEquippingCosmetic = false;
|
||||||
if (cosmeticHolder.getCosmetic(cosmetic.getSlot()) == cosmetic) isUnEquippingCosmetic = true;
|
if (cosmeticHolder.getCosmetic(cosmetic.getSlot()) == cosmetic) isUnEquippingCosmetic = true;
|
||||||
|
|
||||||
|
String dyeClick = Settings.getCosmeticDyeClickType();
|
||||||
String requiredClick;
|
String requiredClick;
|
||||||
if (isUnEquippingCosmetic) requiredClick = Settings.getCosmeticUnEquipClickType();
|
if (isUnEquippingCosmetic) requiredClick = Settings.getCosmeticUnEquipClickType();
|
||||||
else requiredClick = Settings.getCosmeticEquipClickType();
|
else requiredClick = Settings.getCosmeticEquipClickType();
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Required click type: " + requiredClick);
|
MessagesUtil.sendDebugMessages("Required click type: " + requiredClick);
|
||||||
MessagesUtil.sendDebugMessages("Click type: " + clickType.name());
|
MessagesUtil.sendDebugMessages("Click type: " + clickType.name());
|
||||||
if (!requiredClick.equalsIgnoreCase("ANY") && !requiredClick.equalsIgnoreCase(clickType.name())) {
|
boolean isRequiredClick = requiredClick.equalsIgnoreCase("ANY") || requiredClick.equalsIgnoreCase(clickType.name());
|
||||||
|
boolean isDyeClick = dyeClick.equalsIgnoreCase("ANY") || dyeClick.equalsIgnoreCase(clickType.name());
|
||||||
|
if (!isRequiredClick && !isDyeClick) {
|
||||||
MessagesUtil.sendMessage(viewer.getPlayer(), "invalid-click-type");
|
MessagesUtil.sendMessage(viewer.getPlayer(), "invalid-click-type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isRequiredClick && isDyeClick) isUnEquippingCosmetic = false;
|
||||||
|
|
||||||
List<String> actionStrings = new ArrayList<>();
|
List<String> actionStrings = new ArrayList<>();
|
||||||
ConfigurationNode actionConfig = config.node("actions");
|
ConfigurationNode actionConfig = config.node("actions");
|
||||||
|
|
||||||
@@ -104,9 +106,9 @@ public class TypeCosmetic extends Type {
|
|||||||
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
|
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
|
||||||
MessagesUtil.sendDebugMessages("on-equip");
|
MessagesUtil.sendDebugMessages("on-equip");
|
||||||
// TODO: Redo this
|
// TODO: Redo this
|
||||||
if (cosmetic.isDyable() && Hooks.isActiveHook("HMCColor")) {
|
if (cosmetic.isDyeable() && isDyeClick && Hooks.isActiveHook("HMCColor")) {
|
||||||
DyeMenu.openMenu(viewer, cosmeticHolder, cosmetic);
|
DyeMenu.openMenu(viewer, cosmeticHolder, cosmetic);
|
||||||
} else {
|
} else if (isRequiredClick) {
|
||||||
cosmeticHolder.addCosmetic(cosmetic);
|
cosmeticHolder.addCosmetic(cosmetic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,7 +141,7 @@ public class TypeCosmetic extends Type {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack setItem(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
|
public ItemStack setItem(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
|
||||||
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(viewer, itemStack.getItemMeta()));
|
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processItemMeta(viewer, itemStack.getItemMeta()));
|
||||||
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta?");
|
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta?");
|
||||||
|
|
||||||
if (config.node("cosmetic").virtual()) {
|
if (config.node("cosmetic").virtual()) {
|
||||||
@@ -164,7 +166,7 @@ public class TypeCosmetic extends Type {
|
|||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(viewer, itemStack.getItemMeta()));
|
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processItemMeta(viewer, itemStack.getItemMeta()));
|
||||||
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in equipped item?");
|
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in equipped item?");
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
@@ -182,35 +184,10 @@ public class TypeCosmetic extends Type {
|
|||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(viewer, itemStack.getItemMeta()));
|
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processItemMeta(viewer, itemStack.getItemMeta()));
|
||||||
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in locked item?");
|
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in locked item?");
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract("_, _ -> param2")
|
|
||||||
@NotNull
|
|
||||||
@SuppressWarnings("Duplicates")
|
|
||||||
private ItemMeta processLoreLines(Player viewer, @NotNull ItemMeta itemMeta) {
|
|
||||||
List<String> processedLore = new ArrayList<>();
|
|
||||||
|
|
||||||
if (itemMeta.hasDisplayName()) {
|
|
||||||
itemMeta.setDisplayName(Hooks.processPlaceholders(viewer, itemMeta.getDisplayName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
|
||||||
processedLore.add(Hooks.processPlaceholders(viewer, loreLine));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemMeta instanceof SkullMeta skullMeta) {
|
|
||||||
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
|
||||||
skullMeta.setOwner(Hooks.processPlaceholders(viewer, skullMeta.getOwner()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
itemMeta.setLore(processedLore);
|
|
||||||
return itemMeta;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
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.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
|
||||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||||
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;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -78,27 +76,9 @@ public class TypeEmpty extends Type {
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
public ItemStack setItem(Player viewer, CosmeticHolder cosmeticHolder, ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
|
public ItemStack setItem(Player viewer, CosmeticHolder cosmeticHolder, ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
|
||||||
List<String> processedLore = new ArrayList<>();
|
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
if (itemMeta.hasDisplayName()) {
|
itemStack.setItemMeta(processItemMeta(viewer, itemMeta));
|
||||||
itemMeta.setDisplayName(Hooks.processPlaceholders(viewer, itemMeta.getDisplayName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
|
||||||
processedLore.add(Hooks.processPlaceholders(viewer, loreLine));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemMeta instanceof SkullMeta skullMeta) {
|
|
||||||
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
|
||||||
skullMeta.setOwner(Hooks.processPlaceholders(viewer, skullMeta.getOwner()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
itemMeta.setLore(processedLore);
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
@@ -8,6 +7,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
|||||||
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;
|
||||||
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
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;
|
||||||
@@ -20,32 +20,44 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains {@link com.sk89q.worldguard.WorldGuard WorldGuard} related event listeners
|
* Contains {@link com.sk89q.worldguard.WorldGuard WorldGuard} related event listeners
|
||||||
*/
|
*/
|
||||||
public class WGListener implements Listener {
|
public class WGListener implements Listener {
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
Player player = event.getPlayer();
|
||||||
|
Location from = event.getFrom();
|
||||||
|
Location to = event.getTo();
|
||||||
|
if (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ()) return;
|
||||||
|
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
Location location = event.getPlayer().getLocation();
|
Location location = player.getLocation();
|
||||||
ApplicableRegionSet set = getRegions(location);
|
ApplicableRegionSet set = getRegions(location);
|
||||||
if (user.isHidden()) {
|
if (user.isHidden() && set.getRegions().isEmpty()) {
|
||||||
if (set.getRegions().isEmpty()) {
|
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set<String> wardrobeNames = WardrobeSettings.getWardrobeNames();
|
||||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
Map<Flag<?>, Object> flags = protectedRegion.getFlags();
|
||||||
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
if (flags.containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||||
|
if (flags.get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
} else {
|
} else {
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
if (flags.containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||||
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
|
String wardrobeName = flags.getOrDefault(WGHook.getCosmeticWardrobeFlag(), "").toString();
|
||||||
Wardrobe wardrobe = WardrobeSettings.getWardrobe(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString());
|
if (wardrobeName.isEmpty() || !wardrobeNames.contains(wardrobeName)) return;
|
||||||
|
Wardrobe wardrobe = WardrobeSettings.getWardrobe(wardrobeName);
|
||||||
|
if (wardrobe == null) return;
|
||||||
user.enterWardrobe(wardrobe, true);
|
user.enterWardrobe(wardrobe, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,23 +91,6 @@ public class WGListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
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) {
|
private ApplicableRegionSet getRegions(Location location) {
|
||||||
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
||||||
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
|||||||
@@ -3,15 +3,16 @@ package com.hibiscusmc.hmccosmetics.listener;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerLoadEvent;
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerLoadEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerPreLoadEvent;
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerPreLoadEvent;
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerPreUnloadEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerUnloadEvent;
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerUnloadEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
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 com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -22,86 +23,89 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerConnectionListener implements Listener {
|
public class PlayerConnectionListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(@NotNull PlayerJoinEvent event) {
|
public void onPlayerJoin(@NotNull PlayerJoinEvent event) {
|
||||||
if (event.getPlayer().isOp() || event.getPlayer().hasPermission("hmccosmetics.notifyupdate")) {
|
|
||||||
if (!HMCCosmeticsPlugin.getInstance().getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getInstance().getLatestVersion().isEmpty())
|
|
||||||
MessagesUtil.sendMessageNoKey(
|
|
||||||
event.getPlayer(),
|
|
||||||
"<br>" +
|
|
||||||
"<GRAY>There is a new version of <light_purple><Bold>HMCCosmetics<reset><gray> available!<br>" +
|
|
||||||
"<GRAY>Current version: <red>" + HMCCosmeticsPlugin.getInstance().getDescription().getVersion() + " <GRAY>| Latest version: <light_purple>" + HMCCosmeticsPlugin.getInstance().getLatestVersion() + "<br>" +
|
|
||||||
"<GRAY>Download it on <gold><click:OPEN_URL:'https://www.spigotmc.org/resources/100107/'>Spigot<reset> <gray>or <gold><click:OPEN_URL:'https://polymart.org/resource/1879'>Polymart<reset><gray>!" +
|
|
||||||
"<br>"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This literally makes me want to end it all but I can't do that so I'll just cry instead
|
|
||||||
Runnable run = () -> {
|
|
||||||
if (!event.getPlayer().isOnline()) return; // If a player is no longer online, don't run this.
|
|
||||||
UUID uuid = event.getPlayer().getUniqueId();
|
|
||||||
|
|
||||||
PlayerPreLoadEvent preLoadEvent = new PlayerPreLoadEvent(uuid);
|
|
||||||
Bukkit.getPluginManager().callEvent(preLoadEvent);
|
|
||||||
if (preLoadEvent.isCancelled()) return;
|
|
||||||
|
|
||||||
Database.get(uuid).thenAccept(userData -> {
|
|
||||||
if (userData == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
CosmeticUser cosmeticUser = CosmeticUsers.getProvider()
|
|
||||||
.createCosmeticUser(uuid)
|
|
||||||
.initialize(userData);
|
|
||||||
cosmeticUser.startTicking();
|
|
||||||
|
|
||||||
CosmeticUsers.addUser(cosmeticUser);
|
|
||||||
MessagesUtil.sendDebugMessages("Run User Join for " + uuid);
|
|
||||||
|
|
||||||
PlayerLoadEvent playerLoadEvent = new PlayerLoadEvent(cosmeticUser);
|
|
||||||
Bukkit.getPluginManager().callEvent(playerLoadEvent);
|
|
||||||
|
|
||||||
// And finally, launch an update for the cosmetics they have.
|
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
if (cosmeticUser.getPlayer() == null) return;
|
|
||||||
cosmeticUser.updateCosmetic();
|
|
||||||
}, 4);
|
|
||||||
});
|
|
||||||
}).exceptionally(ex -> {
|
|
||||||
MessagesUtil.sendDebugMessages("Unable to load Cosmetic User " + uuid + ". Exception: " + ex.getMessage());
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (DatabaseSettings.isEnabledDelay()) {
|
if (DatabaseSettings.isEnabledDelay()) {
|
||||||
MessagesUtil.sendDebugMessages("Delay Enabled with " + DatabaseSettings.getDelayLength() + " ticks");
|
MessagesUtil.sendDebugMessages("Delay Enabled with " + DatabaseSettings.getDelayLength() + " ticks");
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, DatabaseSettings.getDelayLength());
|
Bukkit.getScheduler().runTaskLater(
|
||||||
|
HMCCosmeticsPlugin.getInstance(),
|
||||||
|
() -> this.loadUserData(event.getPlayer()),
|
||||||
|
DatabaseSettings.getDelayLength()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
run.run();
|
this.loadUserData(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadUserData(final Player player) {
|
||||||
|
if(!player.isOnline()) return;
|
||||||
|
final UUID playerId = player.getUniqueId();
|
||||||
|
|
||||||
|
PlayerPreLoadEvent preLoadEvent = new PlayerPreLoadEvent(playerId);
|
||||||
|
Bukkit.getPluginManager().callEvent(preLoadEvent);
|
||||||
|
if (preLoadEvent.isCancelled()) return;
|
||||||
|
|
||||||
|
Database.get(playerId).thenAccept(userData -> {
|
||||||
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
CosmeticUser cosmeticUser = CosmeticUsers.getProvider()
|
||||||
|
.createCosmeticUser(playerId)
|
||||||
|
.initialize(userData);
|
||||||
|
cosmeticUser.startTicking();
|
||||||
|
|
||||||
|
CosmeticUsers.addUser(cosmeticUser);
|
||||||
|
MessagesUtil.sendDebugMessages("Run User Join for " + playerId);
|
||||||
|
|
||||||
|
PlayerLoadEvent playerLoadEvent = new PlayerLoadEvent(cosmeticUser);
|
||||||
|
Bukkit.getPluginManager().callEvent(playerLoadEvent);
|
||||||
|
|
||||||
|
// And finally, launch an update for the cosmetics they have.
|
||||||
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
if (cosmeticUser.getPlayer() == null) return;
|
||||||
|
cosmeticUser.updateCosmetic();
|
||||||
|
}, 4);
|
||||||
|
});
|
||||||
|
}).exceptionally(ex -> {
|
||||||
|
MessagesUtil.sendDebugMessages("Unable to load Cosmetic User " + playerId + ". Exception: " + ex.getMessage());
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(@NotNull PlayerQuitEvent event) {
|
public void onPlayerQuit(@NotNull PlayerQuitEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return; // Player never initialized, don't do anything
|
if (user == null) return; // Player never initialized, don't do anything
|
||||||
|
|
||||||
|
PlayerPreUnloadEvent preUnloadEvent = new PlayerPreUnloadEvent(user);
|
||||||
|
Bukkit.getPluginManager().callEvent(preUnloadEvent);
|
||||||
|
if (preUnloadEvent.isCancelled()) return;
|
||||||
|
|
||||||
PlayerUnloadEvent playerUnloadEvent = new PlayerUnloadEvent(user);
|
PlayerUnloadEvent playerUnloadEvent = new PlayerUnloadEvent(user);
|
||||||
Bukkit.getPluginManager().callEvent(playerUnloadEvent);
|
Bukkit.getPluginManager().callEvent(playerUnloadEvent);
|
||||||
|
|
||||||
if (user.isInWardrobe()) {
|
if (user.isInWardrobe()) {
|
||||||
user.leaveWardrobe(true);
|
user.leaveWardrobe(true);
|
||||||
user.getPlayer().setInvisible(false);
|
|
||||||
}
|
final Player player = user.getPlayer();
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if(player != null) player.setInvisible(false);
|
||||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
|
||||||
event.getPlayer().setInvisible(false);
|
|
||||||
}
|
}
|
||||||
Menus.removeCooldown(event.getPlayer().getUniqueId()); // Removes any menu cooldowns a player might have
|
Menus.removeCooldown(event.getPlayer().getUniqueId()); // Removes any menu cooldowns a player might have
|
||||||
Database.save(user);
|
Database.save(user);
|
||||||
user.destroy();
|
user.destroy();
|
||||||
CosmeticUsers.removeUser(user.getUniqueId());
|
CosmeticUsers.removeUser(user.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void notifyAdminUpdate(final PlayerJoinEvent event) {
|
||||||
|
if (event.getPlayer().isOp() || event.getPlayer().hasPermission("hmccosmetics.notifyupdate")) {
|
||||||
|
if (!HMCCosmeticsPlugin.getInstance().getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getInstance().getLatestVersion().isEmpty())
|
||||||
|
MessagesUtil.sendMessageNoKey(
|
||||||
|
event.getPlayer(),
|
||||||
|
"<br>" +
|
||||||
|
"<GRAY>There is a new version of <light_purple><Bold>HMCCosmetics<reset><gray> available!<br>" +
|
||||||
|
"<GRAY>Current version: <red>" + HMCCosmeticsPlugin.getInstance().getDescription().getVersion() + " <GRAY>| Latest version: <light_purple>" + HMCCosmeticsPlugin.getInstance().getLatestVersion() + "<br>" +
|
||||||
|
"<GRAY>Download it on <gold><click:OPEN_URL:'https://www.spigotmc.org/resources/100107/'>Spigot<reset> <gray>or <gold><click:OPEN_URL:'https://polymart.org/resource/1879'>Polymart<reset><gray>!" +
|
||||||
|
"<br>"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,17 +14,17 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
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.CosmeticEmoteType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
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.user.manager.UserEmoteManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import me.lojosho.hibiscuscommons.api.events.*;
|
import me.lojosho.hibiscuscommons.api.events.*;
|
||||||
|
import me.lojosho.hibiscuscommons.nms.MinecraftVersion;
|
||||||
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -95,10 +95,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (event.isSneaking()) {
|
|
||||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.SNEAK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event.isSneaking()) return;
|
if (!event.isSneaking()) return;
|
||||||
if (!user.isInWardrobe()) return;
|
if (!user.isInWardrobe()) return;
|
||||||
|
|
||||||
@@ -136,9 +132,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
}, 2);
|
}, 2);
|
||||||
|
|
||||||
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.getUserEmoteManager().isPlayingEmote()) {
|
|
||||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
@@ -180,14 +173,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (!(event.getEntity() instanceof Player player)) return;
|
if (!(event.getEntity() instanceof Player player)) return;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
|
||||||
if (Settings.isEmoteInvincible()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (Settings.isEmoteDamageLeave()) {
|
|
||||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.DAMAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (user.isInWardrobe()) {
|
if (user.isInWardrobe()) {
|
||||||
if (WardrobeSettings.isPreventDamage()) {
|
if (WardrobeSettings.isPreventDamage()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@@ -202,10 +187,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (!Settings.isEmoteMoveCheck() && user.getUserEmoteManager().isPlayingEmote()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
user.updateCosmetic(CosmeticSlot.BACKPACK);
|
user.updateCosmetic(CosmeticSlot.BACKPACK);
|
||||||
user.updateCosmetic(CosmeticSlot.BALLOON);
|
user.updateCosmetic(CosmeticSlot.BALLOON);
|
||||||
}
|
}
|
||||||
@@ -269,12 +250,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
// Really need to look into optimization of this
|
// Really need to look into optimization of this
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.EMOTE) && event.getPlayer().isSneaking() && event.getPlayer().hasPermission("hmccosmetics.emote.shiftrun")) {
|
|
||||||
CosmeticEmoteType cosmeticEmoteType = (CosmeticEmoteType) user.getCosmetic(CosmeticSlot.EMOTE);
|
|
||||||
cosmeticEmoteType.run(user);
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
if (user.getEntity() == null) return; // Player has likely logged off
|
if (user.getEntity() == null) return; // Player has likely logged off
|
||||||
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
||||||
@@ -457,7 +432,12 @@ public class PlayerGameListener implements Listener {
|
|||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
int invTypeClicked = event.getPacket().getIntegers().read(0);
|
int invTypeClicked = event.getPacket().getIntegers().read(0);
|
||||||
int slotClicked = event.getPacket().getIntegers().read(2);
|
int slotClicked = -999;
|
||||||
|
if (NMSHandlers.getVersion().isHigherOrEqual(MinecraftVersion.v1_21_5)) {
|
||||||
|
slotClicked = event.getPacket().getShorts().read(0);
|
||||||
|
} else {
|
||||||
|
slotClicked = event.getPacket().getIntegers().read(2);
|
||||||
|
}
|
||||||
|
|
||||||
// Must be a player inventory.
|
// Must be a player inventory.
|
||||||
if (invTypeClicked != 0) return;
|
if (invTypeClicked != 0) return;
|
||||||
@@ -666,10 +646,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!user.isInWardrobe()) return;
|
if (!user.isInWardrobe()) return;
|
||||||
if (!user.getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
if (!user.getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
||||||
|
|
||||||
@@ -688,7 +664,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (event.getPlayer() == null) return;
|
if (event.getPlayer() == null) return;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) {
|
if (user.isInWardrobe()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,15 @@ import me.lojosho.hibiscuscommons.hooks.items.HookNexo;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ServerListener implements Listener {
|
public class ServerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onHookReload(HibiscusHookReload event) {
|
public void onHookReload(@NotNull HibiscusHookReload event) {
|
||||||
Hook hook = event.getHook();
|
final Hook hook = event.getHook();
|
||||||
HibiscusHookReload.ReloadType reloadType = event.getReloadType();
|
final HibiscusHookReload.ReloadType reloadType = event.getReloadType();
|
||||||
|
|
||||||
if (hook instanceof HookItemAdder) {
|
if (hook instanceof HookItemAdder) {
|
||||||
if (reloadType == HibiscusHookReload.ReloadType.RELOAD) {
|
if (reloadType == HibiscusHookReload.ReloadType.RELOAD) {
|
||||||
if (!Settings.isItemsAdderChangeReload()) return;
|
if (!Settings.isItemsAdderChangeReload()) return;
|
||||||
@@ -31,8 +33,8 @@ public class ServerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onAllHooksReady(HibiscusHooksAllActiveEvent event) {
|
public void onAllHooksReady(@NotNull HibiscusHooksAllActiveEvent event) {
|
||||||
HMCCosmeticsPlugin.setup();
|
HMCCosmeticsPlugin.setup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,14 @@ import com.hibiscusmc.hmccosmetics.database.UserData;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
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.user.manager.UserEmoteManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
|
import com.ticxo.modelengine.api.nms.NMSHandler;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
import me.lojosho.hibiscuscommons.util.InventoryUtils;
|
import me.lojosho.hibiscuscommons.util.InventoryUtils;
|
||||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -54,8 +55,6 @@ public class CosmeticUser implements CosmeticHolder {
|
|||||||
private UserBalloonManager userBalloonManager;
|
private UserBalloonManager userBalloonManager;
|
||||||
@Getter
|
@Getter
|
||||||
private UserBackpackManager userBackpackManager;
|
private UserBackpackManager userBackpackManager;
|
||||||
@Getter
|
|
||||||
private final UserEmoteManager userEmoteManager;
|
|
||||||
|
|
||||||
// Cosmetic Settings/Toggles
|
// Cosmetic Settings/Toggles
|
||||||
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
|
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
|
||||||
@@ -74,7 +73,6 @@ public class CosmeticUser implements CosmeticHolder {
|
|||||||
|
|
||||||
public CosmeticUser(@NotNull UUID uuid) {
|
public CosmeticUser(@NotNull UUID uuid) {
|
||||||
this.uniqueId = uuid;
|
this.uniqueId = uuid;
|
||||||
this.userEmoteManager = new UserEmoteManager(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,7 +144,7 @@ public class CosmeticUser implements CosmeticHolder {
|
|||||||
showCosmetics(HiddenReason.GAMEMODE);
|
showCosmetics(HiddenReason.GAMEMODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bukkitPlayer != null && Settings.getDisabledWorlds().contains(getEntity().getLocation().getWorld().getName())) {
|
if (bukkitPlayer != null && Settings.getDisabledWorlds().contains(bukkitPlayer.getLocation().getWorld().getName())) {
|
||||||
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to world");
|
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to world");
|
||||||
hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||||
} else if (this.isHidden(HiddenReason.WORLD)) {
|
} else if (this.isHidden(HiddenReason.WORLD)) {
|
||||||
@@ -194,7 +192,7 @@ public class CosmeticUser implements CosmeticHolder {
|
|||||||
|
|
||||||
this.updateCosmetic();
|
this.updateCosmetic();
|
||||||
|
|
||||||
if(isHidden() && !getUserEmoteManager().isPlayingEmote() && !playerCosmetics.isEmpty()) {
|
if(isHidden() && !playerCosmetics.isEmpty()) {
|
||||||
MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,9 +280,6 @@ public class CosmeticUser implements CosmeticHolder {
|
|||||||
if (slot == CosmeticSlot.BALLOON) {
|
if (slot == CosmeticSlot.BALLOON) {
|
||||||
despawnBalloon();
|
despawnBalloon();
|
||||||
}
|
}
|
||||||
if (slot == CosmeticSlot.EMOTE) {
|
|
||||||
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
|
|
||||||
}
|
|
||||||
colors.remove(slot);
|
colors.remove(slot);
|
||||||
playerCosmetics.remove(slot);
|
playerCosmetics.remove(slot);
|
||||||
removeArmor(slot);
|
removeArmor(slot);
|
||||||
@@ -317,7 +312,7 @@ public class CosmeticUser implements CosmeticHolder {
|
|||||||
|
|
||||||
for (Cosmetic cosmetic : playerCosmetics.values()) {
|
for (Cosmetic cosmetic : playerCosmetics.values()) {
|
||||||
if (cosmetic instanceof CosmeticArmorType armorType) {
|
if (cosmetic instanceof CosmeticArmorType armorType) {
|
||||||
if (getUserEmoteManager().isPlayingEmote() || isInWardrobe()) return;
|
if (isInWardrobe()) return;
|
||||||
if (!(getEntity() instanceof HumanEntity humanEntity)) return;
|
if (!(getEntity() instanceof HumanEntity humanEntity)) return;
|
||||||
|
|
||||||
boolean requireEmpty = Settings.getSlotOption(armorType.getEquipSlot()).isRequireEmpty();
|
boolean requireEmpty = Settings.getSlotOption(armorType.getEquipSlot()).isRequireEmpty();
|
||||||
@@ -412,29 +407,15 @@ public class CosmeticUser implements CosmeticHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (colors.containsKey(cosmetic.getSlot())) {
|
|
||||||
Color color = colors.get(cosmetic.getSlot());
|
|
||||||
if (itemMeta instanceof LeatherArmorMeta leatherMeta) {
|
|
||||||
leatherMeta.setColor(color);
|
|
||||||
} else if (itemMeta instanceof PotionMeta potionMeta) {
|
|
||||||
potionMeta.setColor(color);
|
|
||||||
} else if (itemMeta instanceof MapMeta mapMeta) {
|
|
||||||
mapMeta.setColor(color);
|
|
||||||
} else if (itemMeta instanceof FireworkEffectMeta fireworkMeta) {
|
|
||||||
fireworkMeta.setEffect(
|
|
||||||
FireworkEffect.builder()
|
|
||||||
.with(FireworkEffect.Type.BALL)
|
|
||||||
.withColor(color)
|
|
||||||
.trail(false)
|
|
||||||
.flicker(false)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
itemMeta.getPersistentDataContainer().set(HMCCInventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
|
itemMeta.getPersistentDataContainer().set(HMCCInventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
|
||||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString());
|
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString());
|
||||||
|
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
|
|
||||||
|
if (colors.containsKey(cosmetic.getSlot())) {
|
||||||
|
Color color = colors.get(cosmetic.getSlot());
|
||||||
|
item = NMSHandlers.getHandler().getUtilHandler().setColor(item, color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@@ -630,13 +611,13 @@ public class CosmeticUser implements CosmeticHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<CosmeticSlot> getDyeableSlots() {
|
public List<CosmeticSlot> getDyeableSlots() {
|
||||||
ArrayList<CosmeticSlot> dyableSlots = new ArrayList<>();
|
ArrayList<CosmeticSlot> dyeableSlots = new ArrayList<>();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : playerCosmetics.values()) {
|
for (Cosmetic cosmetic : playerCosmetics.values()) {
|
||||||
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
if (cosmetic.isDyeable()) dyeableSlots.add(cosmetic.getSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
return dyableSlots;
|
return dyeableSlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class UserBackpackManager {
|
|||||||
if (i == 0) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
if (i == 0) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||||
else HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
else HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||||
}
|
}
|
||||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
HMCCPacketManager.sendRidingPacket(particleCloud.getLast(), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||||
if (!user.isHidden()) PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
if (!user.isHidden()) PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
||||||
}
|
}
|
||||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.ticxo.modelengine.api.ModelEngineAPI;
|
|||||||
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
|
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||||
import com.ticxo.modelengine.api.nms.RenderParsers;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
@@ -82,7 +81,7 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
modeledEntity.getModels().forEach((d, singleModel) -> {
|
modeledEntity.getModels().forEach((d, singleModel) -> {
|
||||||
if (cosmeticBalloonType.isDyablePart(d)) {
|
if (cosmeticBalloonType.isDyeablePart(d)) {
|
||||||
singleModel.setDefaultTint(color);
|
singleModel.setDefaultTint(color);
|
||||||
singleModel.getModelRenderer().sendToClient(ModelEngineAPI.getNMSHandler().createParsers());
|
singleModel.getModelRenderer().sendToClient(ModelEngineAPI.getNMSHandler().createParsers());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
|
||||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStopEvent;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class UserEmoteManager {
|
|
||||||
|
|
||||||
private CosmeticUser user;
|
|
||||||
private UserEmoteModel model;
|
|
||||||
private Entity textEntity;
|
|
||||||
|
|
||||||
public UserEmoteManager(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playEmote(String animationId) {
|
|
||||||
MessagesUtil.sendDebugMessages("playEmote " + animationId);
|
|
||||||
playEmote(EmoteManager.get(animationId), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playEmote(@NotNull CosmeticEmoteType cosmeticEmoteType) {
|
|
||||||
MessagesUtil.sendDebugMessages("playEmote " + cosmeticEmoteType.getAnimationId());
|
|
||||||
playEmote(EmoteManager.get(cosmeticEmoteType.getAnimationId()), cosmeticEmoteType.getText());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playEmote(String emoteAnimation, String text) {
|
|
||||||
if (isPlayingEmote()) return;
|
|
||||||
if (user.isInWardrobe()) return;
|
|
||||||
// API
|
|
||||||
PlayerEmoteStartEvent event = new PlayerEmoteStartEvent(user, emoteAnimation);
|
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Internal
|
|
||||||
try {
|
|
||||||
model = new UserEmoteModel(user);
|
|
||||||
// Play animation id
|
|
||||||
if (emoteAnimation != null) {
|
|
||||||
model.playAnimation(emoteAnimation);
|
|
||||||
}
|
|
||||||
// Show the text
|
|
||||||
if (text != null && textEntity == null) {
|
|
||||||
// removed in 2.7.0
|
|
||||||
//textEntity = HMCCNMSHandlers.getHandler().spawnDisplayEntity(user.getPlayer().getLocation().add(0, 3, 0), text);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPlayingEmote() {
|
|
||||||
if (model == null) return false;
|
|
||||||
return model.isPlayingAnimation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopEmote(StopEmoteReason emoteReason) {
|
|
||||||
if (!isPlayingEmote()) return;
|
|
||||||
// API
|
|
||||||
PlayerEmoteStopEvent event = new PlayerEmoteStopEvent(user, emoteReason);
|
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Internal
|
|
||||||
model.stopAnimation();
|
|
||||||
if (textEntity != null) {
|
|
||||||
textEntity.remove();
|
|
||||||
textEntity = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void despawnTextEntity() {
|
|
||||||
if (textEntity != null) {
|
|
||||||
textEntity.remove();
|
|
||||||
textEntity = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum StopEmoteReason {
|
|
||||||
SNEAK,
|
|
||||||
DAMAGE,
|
|
||||||
CONNECTION,
|
|
||||||
TELEPORT,
|
|
||||||
UNEQUIP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
|
||||||
import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
|
||||||
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class UserEmoteModel extends PlayerModel {
|
|
||||||
|
|
||||||
private final CosmeticUser user;
|
|
||||||
private String emotePlaying;
|
|
||||||
private final int armorStandId;
|
|
||||||
private GameMode originalGamemode;
|
|
||||||
|
|
||||||
public UserEmoteModel(@NotNull CosmeticUser user) {
|
|
||||||
super(user.getPlayer());
|
|
||||||
this.user = user;
|
|
||||||
armorStandId = ServerUtils.getNextEntityId();
|
|
||||||
getRangeManager().setRenderDistance(Settings.getViewDistance());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playAnimation(@NotNull String id) {
|
|
||||||
super.playAnimation(id);
|
|
||||||
|
|
||||||
emotePlaying = id;
|
|
||||||
|
|
||||||
// Add config option that either allows player to move or forces them into a spot.
|
|
||||||
Player player = user.getPlayer();
|
|
||||||
List<Player> viewer = Collections.singletonList(user.getPlayer());
|
|
||||||
List<Player> outsideViewers = HMCCPacketManager.getViewers(player.getLocation());
|
|
||||||
// Send equipment packet to the player as well (Fixes Optifine still rendering armor when emoting)
|
|
||||||
HMCCPacketManager.equipmentSlotUpdate(player, true, outsideViewers);
|
|
||||||
outsideViewers.remove(player);
|
|
||||||
|
|
||||||
user.getPlayer().setInvisible(true);
|
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
|
||||||
|
|
||||||
originalGamemode = player.getGameMode();
|
|
||||||
|
|
||||||
if (Settings.isEmoteCameraEnabled()) {
|
|
||||||
Location newLocation = player.getLocation().clone();
|
|
||||||
newLocation.setPitch(0);
|
|
||||||
|
|
||||||
double DISTANCE = Settings.getEmoteDistance();
|
|
||||||
|
|
||||||
Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE));
|
|
||||||
if (DISTANCE > 0) {
|
|
||||||
MessagesUtil.sendDebugMessages("Yaw " + (int) thirdPersonLocation.getYaw());
|
|
||||||
MessagesUtil.sendDebugMessages("New Yaw " + ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180));
|
|
||||||
thirdPersonLocation.setYaw(ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180));
|
|
||||||
}
|
|
||||||
if (Settings.isCosmeticEmoteBlockCheck() && thirdPersonLocation.getBlock().getType().isOccluding()) {
|
|
||||||
stopAnimation();
|
|
||||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Check if block below player is an air block
|
|
||||||
if (Settings.isEmoteAirCheck() && newLocation.clone().subtract(0, 1, 0).getBlock().getType().isAir()) {
|
|
||||||
stopAnimation();
|
|
||||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
|
||||||
}
|
|
||||||
|
|
||||||
HMCCPacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
|
||||||
HMCCPacketManager.sendInvisibilityPacket(armorStandId, viewer);
|
|
||||||
HMCCPacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
|
|
||||||
|
|
||||||
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
|
||||||
HMCCPacketManager.sendCameraPacket(armorStandId, viewer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("playAnimation run");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean update() {
|
|
||||||
if (super.getAnimationProperty() == null) {
|
|
||||||
stopAnimation();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
boolean update = (super.update() && isPlayingAnimation());
|
|
||||||
if (!update) {
|
|
||||||
stopAnimation();
|
|
||||||
}
|
|
||||||
return update;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopAnimation() {
|
|
||||||
emotePlaying = null;
|
|
||||||
despawn();
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
Player player = user.getPlayer();
|
|
||||||
if (player == null) return;
|
|
||||||
|
|
||||||
List<Player> viewer = Collections.singletonList(player);
|
|
||||||
List<Player> outsideViewers = HMCCPacketManager.getViewers(player.getLocation());
|
|
||||||
// Send Equipment packet to all (Fixes Optifine Issue)
|
|
||||||
HMCCPacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
|
||||||
outsideViewers.remove(player);
|
|
||||||
|
|
||||||
int entityId = player.getEntityId();
|
|
||||||
HMCCPacketManager.sendCameraPacket(entityId, viewer);
|
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(armorStandId, viewer);
|
|
||||||
if (this.originalGamemode != null) {
|
|
||||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode));
|
|
||||||
player.setGameMode(this.originalGamemode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.getPlayer() != null) player.setInvisible(false);
|
|
||||||
user.getUserEmoteManager().despawnTextEntity();
|
|
||||||
user.showPlayer();
|
|
||||||
user.showCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPlayingAnimation() {
|
|
||||||
return emotePlaying != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -40,17 +40,6 @@ cosmetic-settings:
|
|||||||
gamemodes:
|
gamemodes:
|
||||||
- "SPECTATOR"
|
- "SPECTATOR"
|
||||||
|
|
||||||
# This disables the entire internal emote system within the plugin. This option requires a restart.
|
|
||||||
emote-enable: true
|
|
||||||
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
|
||||||
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
|
||||||
emote-air-check: true # Check if there is air under a player, if there is, don't play emote
|
|
||||||
emote-damage-leave: true # If the player should leave the emote when they take damage
|
|
||||||
emote-invincible: false # If the player should not take damage while doing an emote
|
|
||||||
# If a player should be put into camera mode when looking at an emote. Highly recommend keeping it as true.
|
|
||||||
emote-camera: true
|
|
||||||
# If a player should be able to move in an emote. This option really only affects if "emote-camera" is false
|
|
||||||
emote-move: false
|
|
||||||
# This make it so it always sends the riding packets for the backpack. This sends more packets but is more reliable for servers which modify player passengers.
|
# This make it so it always sends the riding packets for the backpack. This sends more packets but is more reliable for servers which modify player passengers.
|
||||||
backpack-force-riding-packet: false
|
backpack-force-riding-packet: false
|
||||||
# This prevents the backpack from being dark when the player is below a block at the expense of making the backpack bright
|
# This prevents the backpack from being dark when the player is below a block at the expense of making the backpack bright
|
||||||
|
|||||||
@@ -108,15 +108,6 @@ kite:
|
|||||||
model-data: 7
|
model-data: 7
|
||||||
name: "<blue>Kite"
|
name: "<blue>Kite"
|
||||||
amount: 1
|
amount: 1
|
||||||
handstand:
|
|
||||||
slot: EMOTE
|
|
||||||
animation: handstand
|
|
||||||
meditate:
|
|
||||||
slot: EMOTE
|
|
||||||
animation: meditate
|
|
||||||
thinking:
|
|
||||||
slot: EMOTE
|
|
||||||
animation: thinking
|
|
||||||
explorer_backpack:
|
explorer_backpack:
|
||||||
slot: BACKPACK
|
slot: BACKPACK
|
||||||
permission: "hmccosmetics.explorer_backpack"
|
permission: "hmccosmetics.explorer_backpack"
|
||||||
|
|||||||
@@ -134,31 +134,6 @@ items:
|
|||||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_kite%"
|
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_kite%"
|
||||||
type: cosmetic
|
type: cosmetic
|
||||||
cosmetic: kite
|
cosmetic: kite
|
||||||
# EMOTES DO NOT WORK IN RECENT HMCCOSMETICS VERSIONS.
|
|
||||||
# handstand:
|
|
||||||
# slots:
|
|
||||||
# - 12
|
|
||||||
# item:
|
|
||||||
# material: PAPER
|
|
||||||
# name: "<blue>Handstand Emote"
|
|
||||||
# type: cosmetic
|
|
||||||
# cosmetic: handstand
|
|
||||||
# meditate:
|
|
||||||
# slots:
|
|
||||||
# - 13
|
|
||||||
# item:
|
|
||||||
# material: PAPER
|
|
||||||
# name: "<blue>Meditate Emote"
|
|
||||||
# type: cosmetic
|
|
||||||
# cosmetic: meditate
|
|
||||||
# thinking:
|
|
||||||
# slots:
|
|
||||||
# - 14
|
|
||||||
# item:
|
|
||||||
# material: PAPER
|
|
||||||
# name: "<blue>Thinking Emote"
|
|
||||||
# type: cosmetic
|
|
||||||
# cosmetic: thinking
|
|
||||||
explorer_backpack:
|
explorer_backpack:
|
||||||
slots:
|
slots:
|
||||||
- 12
|
- 12
|
||||||
|
|||||||
Binary file not shown.
BIN
lib/HMCColor-2.4-all.jar
Normal file
BIN
lib/HMCColor-2.4-all.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user