mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-25 01:49:24 +00:00
Add force-permission-join option
This commit is contained in:
@@ -28,6 +28,7 @@ public class Settings {
|
||||
private static final String DEBUG_ENABLE_PETH = "debug-mode";
|
||||
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 String defaultMenu;
|
||||
private static String dyeMenuName;
|
||||
@@ -39,6 +40,7 @@ public class Settings {
|
||||
private static boolean requireEmptyBoots;
|
||||
private static boolean debugMode;
|
||||
private static boolean unapplyOnDeath;
|
||||
private static boolean forcePermissionJoin;
|
||||
private static int lookDownPitch;
|
||||
private static int viewDistance;
|
||||
private static int tickPeriod;
|
||||
@@ -67,6 +69,7 @@ public class Settings {
|
||||
requireEmptyPants = cosmeticSettings.node(REQUIRE_EMPTY_PANTS_PATH).getBoolean();
|
||||
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);
|
||||
|
||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
||||
@@ -183,6 +186,9 @@ public class Settings {
|
||||
public static boolean getUnapplyOnDeath() {
|
||||
return unapplyOnDeath;
|
||||
}
|
||||
public static boolean getForcePermissionJoin() {
|
||||
return forcePermissionJoin;
|
||||
}
|
||||
|
||||
public static boolean getDebugMode() {
|
||||
return debugMode;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics.database.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
@@ -55,6 +56,7 @@ public class Data {
|
||||
|
||||
public Map<CosmeticSlot, Map<Cosmetic, Color>> desteralizedata(CosmeticUser user, String raw) {
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||
boolean checkPermission = Settings.getForcePermissionJoin();
|
||||
|
||||
String[] rawData = raw.split(",");
|
||||
for (String a : rawData) {
|
||||
@@ -76,10 +78,20 @@ public class Data {
|
||||
String[] colorSplitData = splitData[1].split("&");
|
||||
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
||||
if (slot == null || cosmetic == null) continue;
|
||||
if (cosmetic.requiresPermission() && checkPermission) {
|
||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
cosmetics.put(slot, Map.of(cosmetic, Color.fromRGB(Integer.parseInt(colorSplitData[1]))));
|
||||
} else {
|
||||
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
||||
if (slot == null || cosmetic == null) continue;
|
||||
if (cosmetic.requiresPermission() && checkPermission) {
|
||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
HashMap<Cosmetic, Color> cosmeticColorHashMap = new HashMap<>();
|
||||
cosmeticColorHashMap.put(cosmetic, null);
|
||||
cosmetics.put(slot, cosmeticColorHashMap);
|
||||
|
||||
@@ -287,6 +287,7 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public void despawnBackpack() {
|
||||
if (userBackpackManager == null) return;
|
||||
userBackpackManager.despawnBackpack();
|
||||
userBackpackManager = null;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ cosmetic-settings:
|
||||
# Ticking periods is something that ensures new players near a player get the packets to actually apply to the user.
|
||||
|
||||
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.
|
||||
|
||||
# view distance in blocks that other players will see the backpack cosmetic
|
||||
# setting this to lower than the server player view distance should fix the
|
||||
|
||||
Reference in New Issue
Block a user