9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-19 15:09:19 +00:00

feat: add disabled worlds option

This commit is contained in:
LoJoSho
2024-01-02 20:45:18 -06:00
parent 63bda02869
commit 27d3a1df42
4 changed files with 18 additions and 1 deletions

View File

@@ -44,6 +44,7 @@ public class Settings {
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_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_FORCE_OFFHAND_COSMETIC_SHOW_PATH = "offhand-always-show";
@@ -118,6 +119,8 @@ public class Settings {
@Getter
private static List<String> disabledGamemodes;
@Getter
private static List<String> disabledWorlds;
@Getter
private static int viewDistance;
@Getter
private static int tickPeriod;
@@ -176,8 +179,10 @@ public class Settings {
disabledGamemodesEnabled = disabledGamemodeSettings.node(ENABLED_PATH).getBoolean(true);
try {
disabledGamemodes = disabledGamemodeSettings.node(DISABLED_GAMEMODE_GAMEMODES_PATH).getList(String.class);
disabledWorlds = cosmeticSettings.node(COSMETIC_DISABLED_WORLDS_PATH).getList(String.class);
} catch (Exception e) {
disabledGamemodes = new ArrayList<>();
disabledWorlds = new ArrayList<>();
}
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);

View File

@@ -131,6 +131,13 @@ public class PlayerGameListener implements Listener {
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
if (user.getEntity() == null || user.isInWardrobe()) return; // fixes disconnecting when in wardrobe (the entity stuff)
if (Settings.getDisabledWorlds().contains(user.getEntity().getLocation().getWorld().getName())) {
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
} else {
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.WORLD)) {
user.showCosmetics();
}
}
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
user.respawnBackpack();
}

View File

@@ -560,6 +560,7 @@ public class CosmeticUser {
ACTION,
COMMAND,
EMOTE,
GAMEMODE
GAMEMODE,
WORLD
}
}

View File

@@ -24,6 +24,10 @@ cosmetic-settings:
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
# This is a list of worlds that cosmetics are hidden in. When a player enters one of these worlds, their cosmetics will be hidden.
disabled-worlds:
- "disabledworld"
disabled-gamemode:
enabled: true
# Which gamemodes should cosmetics be disabled for. This is useful for servers that have a creative world. All options are here, https://hub.spigotmc.org/javadocs/spigot/org/bukkit/GameMode.html