mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
feat: hidden reasons now in lists, add disableall command (hides all players cosmetics)
This commit is contained in:
@@ -244,6 +244,15 @@ bukkit {
|
|||||||
register("hmccosmetics.unapplydeath.bypass") {
|
register("hmccosmetics.unapplydeath.bypass") {
|
||||||
default = BukkitPluginDescription.Permission.Default.OP
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
}
|
}
|
||||||
|
register("hmccosmetics.cmd.disableall") {
|
||||||
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
|
}
|
||||||
|
register("hmccosmetics.cmd.hiddenreasons") {
|
||||||
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
|
}
|
||||||
|
register("hmccosmetics.cmd.clearhiddenreasons") {
|
||||||
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "show-cosmetic");
|
if (!silent) MessagesUtil.sendMessage(sender, "show-cosmetic");
|
||||||
user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.COMMAND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case ("debug") -> {
|
case ("debug") -> {
|
||||||
@@ -496,6 +496,63 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
user.getUserEmoteManager().playEmote(args[1]);
|
user.getUserEmoteManager().playEmote(args[1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "disableall" -> {
|
||||||
|
if (!sender.hasPermission("hmccosmetics.cmd.disableall")) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length == 1) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args[1].equalsIgnoreCase("true")) {
|
||||||
|
Settings.setAllPlayersHidden(true);
|
||||||
|
for (CosmeticUser user : CosmeticUsers.values()) user.hideCosmetics(CosmeticUser.HiddenReason.DISABLED);
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "disabled-all");
|
||||||
|
} else if (args[1].equalsIgnoreCase("false")) {
|
||||||
|
Settings.setAllPlayersHidden(false);
|
||||||
|
for (CosmeticUser user : CosmeticUsers.values()) user.showCosmetics(CosmeticUser.HiddenReason.DISABLED);
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "enabled-all");
|
||||||
|
} else {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-args");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "hiddenreasons" -> {
|
||||||
|
if (!sender.hasPermission("hmccosmetics.cmd.hiddenreasons")) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
sender.sendMessage(user.getHiddenReasons().toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "clearhiddenreasons" -> {
|
||||||
|
if (!sender.hasPermission("hmccosmetics.cmd.clearhiddenreasons")) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
user.clearHiddenReasons();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
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.emote")) completions.add("emote");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.playemote")) completions.add("playemote");
|
if (hasPermission(sender, "hmccosmetics.cmd.playemote")) completions.add("playemote");
|
||||||
|
if (hasPermission(sender, "hmccosmetics.cmd.disableall")) completions.add("disableall");
|
||||||
|
if (hasPermission(sender, "hmccosmetics.cmd.hiddenreasons")) completions.add("hiddenreasons");
|
||||||
|
if (hasPermission(sender, "hmccosmetics.cmd.clearhiddenreasons")) completions.add("clearhiddenreasons");
|
||||||
|
|
||||||
StringUtil.copyPartialMatches(args[0], completions, finalCompletions);
|
StringUtil.copyPartialMatches(args[0], completions, finalCompletions);
|
||||||
}
|
}
|
||||||
@@ -71,11 +74,15 @@ 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" -> {
|
case "dataclear", "hide", "show", "emote", "hiddenreasons", "clearhiddenreasons" -> {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
completions.add(player.getName());
|
completions.add(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "disableall" -> {
|
||||||
|
completions.add("true");
|
||||||
|
completions.add("false");
|
||||||
|
}
|
||||||
case "wardrobe" -> {
|
case "wardrobe" -> {
|
||||||
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
|
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
|
||||||
if (wardrobe.hasPermission()) {
|
if (wardrobe.hasPermission()) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.config;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@@ -159,6 +160,8 @@ public class Settings {
|
|||||||
private static boolean emoteCameraEnabled;
|
private static boolean emoteCameraEnabled;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean emoteMoveCheck;
|
private static boolean emoteMoveCheck;
|
||||||
|
@Getter @Setter
|
||||||
|
private static boolean allPlayersHidden;
|
||||||
|
|
||||||
|
|
||||||
public static void load(ConfigurationNode source) {
|
public static void load(ConfigurationNode source) {
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ import org.bukkit.Color;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public abstract class Data {
|
public abstract class Data {
|
||||||
|
|
||||||
@@ -33,8 +31,8 @@ public abstract class Data {
|
|||||||
public final String serializeData(@NotNull CosmeticUser user) {
|
public final String serializeData(@NotNull CosmeticUser user) {
|
||||||
StringBuilder data = new StringBuilder();
|
StringBuilder data = new StringBuilder();
|
||||||
if (user.isHidden()) {
|
if (user.isHidden()) {
|
||||||
if (shouldHiddenSave(user.getHiddenReason())) {
|
for (CosmeticUser.HiddenReason reason : user.getHiddenReasons()) {
|
||||||
data.append("HIDDEN=").append(user.getHiddenReason());
|
if (shouldHiddenSave(reason)) data.append("HIDDEN=").append(reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
@@ -59,7 +57,7 @@ public abstract class Data {
|
|||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||||
|
|
||||||
String[] rawData = raw.split(",");
|
String[] rawData = raw.split(",");
|
||||||
CosmeticUser.HiddenReason hiddenReason = null;
|
ArrayList<CosmeticUser.HiddenReason> hiddenReason = new ArrayList<>();
|
||||||
for (String a : rawData) {
|
for (String a : rawData) {
|
||||||
if (a == null || a.isEmpty()) continue;
|
if (a == null || a.isEmpty()) continue;
|
||||||
String[] splitData = a.split("=");
|
String[] splitData = a.split("=");
|
||||||
@@ -69,7 +67,7 @@ public abstract class Data {
|
|||||||
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
||||||
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
||||||
if (Settings.isForceShowOnJoin()) continue;
|
if (Settings.isForceShowOnJoin()) continue;
|
||||||
hiddenReason = CosmeticUser.HiddenReason.valueOf(splitData[1]);
|
hiddenReason.add(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -100,8 +98,8 @@ public abstract class Data {
|
|||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Hidden Reason: " + hiddenReason);
|
MessagesUtil.sendDebugMessages("Hidden Reason: " + hiddenReason);
|
||||||
// if else this, if else that, if else I got to deal with this anymore i'll lose my mind
|
// if else this, if else that, if else I got to deal with this anymore i'll lose my mind
|
||||||
if (hiddenReason != null) {
|
if (!hiddenReason.isEmpty()) {
|
||||||
user.hideCosmetics(hiddenReason);
|
for (CosmeticUser.HiddenReason reason : hiddenReason) user.hideCosmetics(reason);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
// Handle gamemode check
|
// Handle gamemode check
|
||||||
@@ -110,9 +108,9 @@ public abstract class Data {
|
|||||||
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.GAMEMODE)) {
|
if (user.isHidden(CosmeticUser.HiddenReason.GAMEMODE)) {
|
||||||
MessagesUtil.sendDebugMessages("Join Gamemode Check: Showing Cosmetics");
|
MessagesUtil.sendDebugMessages("Join Gamemode Check: Showing Cosmetics");
|
||||||
user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +119,14 @@ public abstract class Data {
|
|||||||
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to world");
|
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to world");
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||||
} else {
|
} else {
|
||||||
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.WORLD)) {
|
if (user.isHidden(CosmeticUser.HiddenReason.WORLD)) {
|
||||||
MessagesUtil.sendDebugMessages("Join World Check: Showing Cosmetics");
|
MessagesUtil.sendDebugMessages("Join World Check: Showing Cosmetics");
|
||||||
user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Settings.isAllPlayersHidden()) {
|
||||||
|
user.hideCosmetics(CosmeticUser.HiddenReason.DISABLED);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return cosmetics;
|
return cosmetics;
|
||||||
@@ -133,7 +134,7 @@ public abstract class Data {
|
|||||||
|
|
||||||
private boolean shouldHiddenSave(CosmeticUser.HiddenReason reason) {
|
private boolean shouldHiddenSave(CosmeticUser.HiddenReason reason) {
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case EMOTE, NONE, GAMEMODE, WORLD -> {
|
case EMOTE, NONE, GAMEMODE, WORLD, DISABLED -> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class ActionCosmeticShow extends Action {
|
|||||||
if (!user.isHidden()) return;
|
if (!user.isHidden()) return;
|
||||||
|
|
||||||
// Do not hide if it's already off for WG
|
// Do not hide if it's already off for WG
|
||||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
if (!user.isHidden(CosmeticUser.HiddenReason.ACTION) && !user.isHidden(CosmeticUser.HiddenReason.COMMAND)) return;
|
||||||
user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ public class ActionCosmeticToggle extends Action {
|
|||||||
@Override
|
@Override
|
||||||
public void run(@NotNull CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
if (user.isHidden()) {
|
if (user.isHidden()) {
|
||||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
if (!user.isHidden(CosmeticUser.HiddenReason.ACTION) && !user.isHidden(CosmeticUser.HiddenReason.COMMAND)) return;
|
||||||
user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ public class WGListener implements Listener {
|
|||||||
Location location = event.getPlayer().getLocation();
|
Location location = event.getPlayer().getLocation();
|
||||||
ApplicableRegionSet set = getRegions(location);
|
ApplicableRegionSet set = getRegions(location);
|
||||||
if (user.isHidden()) {
|
if (user.isHidden()) {
|
||||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().isEmpty()) {
|
if (set.getRegions().isEmpty()) {
|
||||||
user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||||
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD) user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
@@ -59,14 +59,14 @@ public class WGListener implements Listener {
|
|||||||
Location location = event.getTo();
|
Location location = event.getTo();
|
||||||
ApplicableRegionSet set = getRegions(location);
|
ApplicableRegionSet set = getRegions(location);
|
||||||
if (user.isHidden()) {
|
if (user.isHidden()) {
|
||||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().isEmpty()) {
|
if (set.getRegions().isEmpty()) {
|
||||||
user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||||
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD) user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
|
|||||||
@@ -135,9 +135,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (Settings.getDisabledWorlds().contains(user.getEntity().getLocation().getWorld().getName())) {
|
if (Settings.getDisabledWorlds().contains(user.getEntity().getLocation().getWorld().getName())) {
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||||
} else {
|
} else {
|
||||||
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.WORLD)) {
|
user.showCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||||
user.showCosmetics();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||||
user.respawnBackpack();
|
user.respawnBackpack();
|
||||||
@@ -311,7 +309,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getAction().equals(EntityPotionEffectEvent.Action.CLEARED) || event.getAction().equals(EntityPotionEffectEvent.Action.REMOVED)) {
|
if (event.getAction().equals(EntityPotionEffectEvent.Action.CLEARED) || event.getAction().equals(EntityPotionEffectEvent.Action.REMOVED)) {
|
||||||
user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.POTION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,9 +356,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (Settings.getDisabledGamemodes().contains(event.getNewGameMode().toString())) {
|
if (Settings.getDisabledGamemodes().contains(event.getNewGameMode().toString())) {
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||||
} else {
|
} else {
|
||||||
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.GAMEMODE)) {
|
user.showCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||||
user.showCosmetics();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,7 +416,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (!user.isHidden()) return;
|
if (!user.isHidden()) return;
|
||||||
if (user.getHiddenReason().equals(CosmeticUser.HiddenReason.PLUGIN)) user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ public class CosmeticUser {
|
|||||||
private final UserEmoteManager userEmoteManager;
|
private final UserEmoteManager userEmoteManager;
|
||||||
|
|
||||||
// Cosmetic Settings/Toggles
|
// Cosmetic Settings/Toggles
|
||||||
private boolean hideCosmetics;
|
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
|
||||||
@Getter
|
|
||||||
private HiddenReason hiddenReason;
|
|
||||||
private final HashMap<CosmeticSlot, Color> colors = new HashMap<>();
|
private final HashMap<CosmeticSlot, Color> colors = new HashMap<>();
|
||||||
|
|
||||||
public CosmeticUser(UUID uuid) {
|
public CosmeticUser(UUID uuid) {
|
||||||
@@ -218,7 +216,7 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
if (hideCosmetics) {
|
if (!hiddenReason.isEmpty()) {
|
||||||
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
|
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
|
||||||
return getPlayer().getInventory().getItem(HMCCInventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
|
return getPlayer().getInventory().getItem(HMCCInventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
|
||||||
}
|
}
|
||||||
@@ -421,7 +419,7 @@ public class CosmeticUser {
|
|||||||
if (!hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
if (!hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||||
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BACKPACK);
|
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BACKPACK);
|
||||||
despawnBackpack();
|
despawnBackpack();
|
||||||
if (hideCosmetics) return;
|
if (!hiddenReason.isEmpty()) return;
|
||||||
spawnBackpack((CosmeticBackpackType) cosmetic);
|
spawnBackpack((CosmeticBackpackType) cosmetic);
|
||||||
MessagesUtil.sendDebugMessages("Respawned Backpack for " + getEntity().getName());
|
MessagesUtil.sendDebugMessages("Respawned Backpack for " + getEntity().getName());
|
||||||
}
|
}
|
||||||
@@ -430,7 +428,7 @@ public class CosmeticUser {
|
|||||||
if (!hasCosmeticInSlot(CosmeticSlot.BALLOON)) return;
|
if (!hasCosmeticInSlot(CosmeticSlot.BALLOON)) return;
|
||||||
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BALLOON);
|
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BALLOON);
|
||||||
despawnBalloon();
|
despawnBalloon();
|
||||||
if (hideCosmetics) return;
|
if (!hiddenReason.isEmpty()) return;
|
||||||
spawnBalloon((CosmeticBalloonType) cosmetic);
|
spawnBalloon((CosmeticBalloonType) cosmetic);
|
||||||
MessagesUtil.sendDebugMessages("Respawned Balloon for " + getEntity().getName());
|
MessagesUtil.sendDebugMessages("Respawned Balloon for " + getEntity().getName());
|
||||||
}
|
}
|
||||||
@@ -508,15 +506,13 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void hideCosmetics(HiddenReason reason) {
|
public void hideCosmetics(HiddenReason reason) {
|
||||||
if (hideCosmetics) return;
|
|
||||||
PlayerCosmeticHideEvent event = new PlayerCosmeticHideEvent(this, reason);
|
PlayerCosmeticHideEvent event = new PlayerCosmeticHideEvent(this, reason);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hideCosmetics = true;
|
if (!hiddenReason.contains(reason)) hiddenReason.add(reason);
|
||||||
hiddenReason = reason;
|
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
despawnBalloon();
|
despawnBalloon();
|
||||||
//getBalloonManager().removePlayerFromModel(getPlayer());
|
//getBalloonManager().removePlayerFromModel(getPlayer());
|
||||||
@@ -529,8 +525,8 @@ public class CosmeticUser {
|
|||||||
MessagesUtil.sendDebugMessages("HideCosmetics");
|
MessagesUtil.sendDebugMessages("HideCosmetics");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showCosmetics() {
|
public void showCosmetics(HiddenReason reason) {
|
||||||
if (!hideCosmetics) return;
|
if (hiddenReason.isEmpty()) return;
|
||||||
|
|
||||||
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
@@ -538,8 +534,8 @@ public class CosmeticUser {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hideCosmetics = false;
|
hiddenReason.remove(reason);
|
||||||
hiddenReason = HiddenReason.NONE;
|
if (isHidden()) return;
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
if (!isBalloonSpawned()) respawnBalloon();
|
if (!isBalloonSpawned()) respawnBalloon();
|
||||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON);
|
CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON);
|
||||||
@@ -564,11 +560,23 @@ public class CosmeticUser {
|
|||||||
*/
|
*/
|
||||||
@Deprecated(since = "2.7.2-DEV", forRemoval = true)
|
@Deprecated(since = "2.7.2-DEV", forRemoval = true)
|
||||||
public boolean getHidden() {
|
public boolean getHidden() {
|
||||||
return this.hideCosmetics;
|
return !hiddenReason.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHidden() {
|
public boolean isHidden() {
|
||||||
return this.hideCosmetics;
|
return !hiddenReason.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHidden(HiddenReason reason) {
|
||||||
|
return hiddenReason.contains(reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HiddenReason> getHiddenReasons() {
|
||||||
|
return hiddenReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearHiddenReasons() {
|
||||||
|
hiddenReason.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum HiddenReason {
|
public enum HiddenReason {
|
||||||
@@ -580,6 +588,7 @@ public class CosmeticUser {
|
|||||||
COMMAND,
|
COMMAND,
|
||||||
EMOTE,
|
EMOTE,
|
||||||
GAMEMODE,
|
GAMEMODE,
|
||||||
WORLD
|
WORLD,
|
||||||
|
DISABLED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
if (user.getPlayer() != null) player.setInvisible(false);
|
if (user.getPlayer() != null) player.setInvisible(false);
|
||||||
user.getUserEmoteManager().despawnTextEntity();
|
user.getUserEmoteManager().despawnTextEntity();
|
||||||
user.showPlayer();
|
user.showPlayer();
|
||||||
user.showCosmetics();
|
user.showCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user