mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-29 03:49:19 +00:00
fix: hidden reasons for gamemodes + world not working, spawning entity cosmetics while hidden
This commit is contained in:
@@ -59,6 +59,7 @@ public abstract class Data {
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||
|
||||
String[] rawData = raw.split(",");
|
||||
CosmeticUser.HiddenReason hiddenReason = null;
|
||||
for (String a : rawData) {
|
||||
if (a == null || a.isEmpty()) continue;
|
||||
String[] splitData = a.split("=");
|
||||
@@ -68,9 +69,7 @@ public abstract class Data {
|
||||
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
||||
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
||||
if (Settings.isForceShowOnJoin()) continue;
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
||||
});
|
||||
hiddenReason = CosmeticUser.HiddenReason.valueOf(splitData[1]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -98,6 +97,37 @@ public abstract class Data {
|
||||
cosmetics.put(slot, cosmeticColorHashMap);
|
||||
}
|
||||
}
|
||||
|
||||
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 (hiddenReason != null) {
|
||||
user.hideCosmetics(hiddenReason);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// Handle gamemode check
|
||||
if (user.getPlayer() != null && Settings.getDisabledGamemodes().contains(user.getPlayer().getGameMode().toString())) {
|
||||
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to gamemode");
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||
return;
|
||||
} else {
|
||||
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.GAMEMODE)) {
|
||||
MessagesUtil.sendDebugMessages("Join Gamemode Check: Showing Cosmetics");
|
||||
user.showCosmetics();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Handle world check
|
||||
if (Settings.getDisabledWorlds().contains(user.getPlayer().getWorld().getName())) {
|
||||
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to world");
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||
} else {
|
||||
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.WORLD)) {
|
||||
MessagesUtil.sendDebugMessages("Join World Check: Showing Cosmetics");
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return cosmetics;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,22 +38,6 @@ public class PlayerConnectionListener implements Listener {
|
||||
CosmeticUsers.addUser(user);
|
||||
MessagesUtil.sendDebugMessages("Run User Join");
|
||||
|
||||
// Handle gamemode check
|
||||
if (Settings.getDisabledGamemodes().contains(user.getPlayer().getGameMode().toString())) {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||
} else {
|
||||
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.GAMEMODE)) {
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
// Handle world check
|
||||
if (Settings.getDisabledWorlds().contains(user.getPlayer().getWorld().getName())) {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||
} else {
|
||||
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.WORLD)) {
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
// And finally, launch an update for the cosmetics they have.
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
if (user.getPlayer() == null) return;
|
||||
|
||||
@@ -114,14 +114,16 @@ public class CosmeticUser {
|
||||
playerCosmetics.put(cosmetic.getSlot(), cosmetic);
|
||||
if (color != null) colors.put(cosmetic.getSlot(), color);
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic[id=" + cosmetic.getId() + "]");
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
|
||||
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
|
||||
spawnBackpack(backpackType);
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic[spawnBackpack,id=" + cosmetic.getId() + "]");
|
||||
}
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
|
||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||
spawnBalloon(balloonType);
|
||||
if (!getHidden()) {
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
|
||||
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
|
||||
spawnBackpack(backpackType);
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic[spawnBackpack,id=" + cosmetic.getId() + "]");
|
||||
}
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
|
||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||
spawnBalloon(balloonType);
|
||||
}
|
||||
}
|
||||
// API
|
||||
PlayerCosmeticPostEquipEvent postEquipEvent = new PlayerCosmeticPostEquipEvent(this, cosmetic);
|
||||
|
||||
Reference in New Issue
Block a user