Skip to content

Commit

Permalink
feat: add force-show-join to show regardless of hidden in database
Browse files Browse the repository at this point in the history
  • Loading branch information
LoJoSho committed Jun 27, 2023
1 parent 71a080a commit d1bfa5a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Settings {
private static final String TICK_PERIOD_PATH = "tick-period";
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
private static final String HOOK_SETTING_PATH = "hook-settings";
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
Expand Down Expand Up @@ -64,6 +65,7 @@ public class Settings {
private static boolean debugMode;
private static boolean unapplyOnDeath;
private static boolean forcePermissionJoin;
private static boolean forceShowOnJoin;
private static boolean itemsAdderChangeReload;
private static boolean worldGuardMoveCheck;
private static boolean cosmeticEmoteBlockCheck;
Expand Down Expand Up @@ -105,6 +107,7 @@ public static void load(ConfigurationNode source) {
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
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);
Expand Down Expand Up @@ -254,6 +257,10 @@ public static boolean getForcePermissionJoin() {
return forcePermissionJoin;
}

public static boolean isForceShowOnJoin() {
return forceShowOnJoin;
}

public static boolean getDebugMode() {
return debugMode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUse
}

@NotNull
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw, boolean checkpermissions) {
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw, boolean permissionCheck) {
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();

String[] rawData = raw.split(",");
Expand All @@ -67,6 +67,7 @@ public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUse
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
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]));
});
Expand All @@ -78,7 +79,7 @@ public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUse
String[] colorSplitData = splitData[1].split("&");
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
if (slot == null || cosmetic == null) continue;
if (checkpermissions && cosmetic.requiresPermission()) {
if (permissionCheck && cosmetic.requiresPermission()) {
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
continue;
}
Expand All @@ -87,7 +88,7 @@ public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUse
} else {
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
if (slot == null || cosmetic == null) continue;
if (checkpermissions && cosmetic.requiresPermission()) {
if (permissionCheck && cosmetic.requiresPermission()) {
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cosmetic-settings:

unapply-on-death: false # If when a player dies, their cosmetics should be unapplied. If this is true, use hmccosmetics.unapplydeath.bypass to bypass
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.

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)
Expand Down

0 comments on commit d1bfa5a

Please sign in to comment.