change global definition getter
This commit is contained in:
parent
5ebb73568e
commit
0cbb5a576a
@ -192,15 +192,13 @@ public class Claim implements IPermissionContainer {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!this.isAdminClaim() && ConfigHandler.config.globalDefaultPerms.containsKey(this.world.getRegistryKey().getValue().toString())) {
|
||||
Map<ClaimPermission, Boolean> permMap = ConfigHandler.config.globalDefaultPerms.get(this.world.getRegistryKey().getValue().toString());
|
||||
if (permMap.containsKey(perm)) {
|
||||
if (permMap.get(perm) || this.isAdminIgnore(player))
|
||||
return true;
|
||||
if (message)
|
||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true);
|
||||
return false;
|
||||
}
|
||||
Boolean global = ConfigHandler.config.getGlobal(this.world, perm);
|
||||
if (!this.isAdminClaim() && global != null) {
|
||||
if (global || this.isAdminIgnore(player))
|
||||
return true;
|
||||
if (message)
|
||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true);
|
||||
return false;
|
||||
}
|
||||
if (PermissionRegistry.globalPerms().contains(perm)) {
|
||||
for (Claim claim : this.subClaims) {
|
||||
|
@ -19,15 +19,13 @@ public class GlobalClaim implements IPermissionContainer {
|
||||
|
||||
@Override
|
||||
public boolean canInteract(ServerPlayerEntity player, ClaimPermission perm, BlockPos pos, boolean message) {
|
||||
if (ConfigHandler.config.globalDefaultPerms.containsKey(this.world.getRegistryKey().getValue().toString())) {
|
||||
Map<ClaimPermission, Boolean> permMap = ConfigHandler.config.globalDefaultPerms.get(this.world.getRegistryKey().getValue().toString());
|
||||
if (permMap.containsKey(perm)) {
|
||||
if (permMap.get(perm))
|
||||
return true;
|
||||
if (message)
|
||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true);
|
||||
return false;
|
||||
}
|
||||
Boolean global = ConfigHandler.config.getGlobal(this.world, perm);
|
||||
if (global != null) {
|
||||
if (global)
|
||||
return true;
|
||||
if (message)
|
||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -495,10 +495,8 @@ public class CommandClaim {
|
||||
ServerWorld world = context.getSource().getWorld();
|
||||
Claim claim = ClaimStorage.get(world).getClaimAt(new BlockPos(context.getSource().getPosition()));
|
||||
boolean admin = claim != null && claim.isAdminClaim();
|
||||
String serverWorld = world.getRegistryKey().getValue().toString();
|
||||
Map<ClaimPermission, Boolean> global = ConfigHandler.config.globalDefaultPerms.get(serverWorld);
|
||||
for (ClaimPermission perm : PermissionRegistry.getPerms()) {
|
||||
if (!admin && global != null && global.containsKey(perm)) {
|
||||
if (!admin && ConfigHandler.config.globallyDefined(world, perm)) {
|
||||
continue;
|
||||
}
|
||||
if (!group || !PermissionRegistry.globalPerms().contains(perm))
|
||||
|
@ -33,6 +33,7 @@ public class Config {
|
||||
|
||||
public String[] blacklistedWorlds = new String[0];
|
||||
public boolean worldWhitelist;
|
||||
public boolean allowMobSpawnToggle;
|
||||
|
||||
public Item claimingItem = Items.GOLDEN_HOE;
|
||||
public Item inspectionItem = Items.STICK;
|
||||
@ -42,7 +43,7 @@ public class Config {
|
||||
|
||||
public boolean log;
|
||||
|
||||
public final Map<String, Map<ClaimPermission, Boolean>> globalDefaultPerms = Maps.newHashMap();
|
||||
private final Map<String, Map<ClaimPermission, Boolean>> globalDefaultPerms = Maps.newHashMap();
|
||||
|
||||
public Config(MinecraftServer server) {
|
||||
File configDir = FabricLoader.getInstance().getConfigDir().resolve("flan").toFile();
|
||||
@ -76,6 +77,7 @@ public class Config {
|
||||
for (int i = 0; i < arr.size(); i++)
|
||||
this.blacklistedWorlds[i] = arr.get(i).getAsString();
|
||||
this.worldWhitelist = ConfigHandler.fromJson(obj, "worldWhitelist", this.worldWhitelist);
|
||||
this.allowMobSpawnToggle = ConfigHandler.fromJson(obj, "allowMobSpawnToggle", false);
|
||||
if (obj.has("claimingItem"))
|
||||
this.claimingItem = Registry.ITEM.get(new Identifier((obj.get("claimingItem").getAsString())));
|
||||
if (obj.has("inspectionItem"))
|
||||
@ -118,6 +120,7 @@ public class Config {
|
||||
arr.add(this.blacklistedWorlds[i]);
|
||||
obj.add("blacklistedWorlds", arr);
|
||||
obj.addProperty("worldWhitelist", this.worldWhitelist);
|
||||
obj.addProperty("allowMobSpawnToggle", this.allowMobSpawnToggle);
|
||||
obj.addProperty("claimingItem", Registry.ITEM.getId(this.claimingItem).toString());
|
||||
obj.addProperty("inspectionItem", Registry.ITEM.getId(this.inspectionItem).toString());
|
||||
obj.addProperty("claimDisplayTime", this.claimDisplayTime);
|
||||
@ -140,7 +143,13 @@ public class Config {
|
||||
}
|
||||
|
||||
public boolean globallyDefined(ServerWorld world, ClaimPermission perm) {
|
||||
Map<ClaimPermission, Boolean> global = ConfigHandler.config.globalDefaultPerms.get(world.getRegistryKey().getValue().toString());
|
||||
return global != null && global.containsKey(perm);
|
||||
return getGlobal(world, perm) != null;
|
||||
}
|
||||
|
||||
public Boolean getGlobal(ServerWorld world, ClaimPermission perm){
|
||||
if(perm == PermissionRegistry.MOBSPAWN && !this.allowMobSpawnToggle)
|
||||
return Boolean.FALSE;
|
||||
Map<ClaimPermission, Boolean> permMap = ConfigHandler.config.globalDefaultPerms.get(world.getRegistryKey().getValue().toString());
|
||||
return permMap == null ? null : permMap.getOrDefault(perm, null);
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ public class ServerScreenHelper {
|
||||
ListTag lore = new ListTag();
|
||||
Text trans = new LiteralText(perm.desc).setStyle(Style.EMPTY.withFormatting(Formatting.YELLOW));
|
||||
lore.add(StringTag.of(Text.Serializer.toJson(trans)));
|
||||
Map<ClaimPermission, Boolean> global = ConfigHandler.config.globalDefaultPerms.get(claim.getWorld().getRegistryKey().getValue().toString());
|
||||
if (!claim.isAdminClaim() && global != null && global.containsKey(perm)) {
|
||||
Boolean global = ConfigHandler.config.getGlobal(claim.getWorld(), perm);
|
||||
if (!claim.isAdminClaim() && global != null) {
|
||||
Text text = new LiteralText("Non Editable.").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED));
|
||||
lore.add(StringTag.of(Text.Serializer.toJson(text)));
|
||||
String permFlag = global.get(perm).toString();
|
||||
String permFlag = global.toString();
|
||||
Text text2 = new LiteralText("Enabled: " + permFlag).setStyle(Style.EMPTY.withFormatting(permFlag.equals("true") ? Formatting.GREEN : Formatting.RED));
|
||||
lore.add(StringTag.of(Text.Serializer.toJson(text2)));
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user