truly fix personal groups saving issues. idk why i dont notice this right away

This commit is contained in:
Flemmli97 2021-05-12 20:24:14 +02:00
parent 0c3f006611
commit f06bf034a9
3 changed files with 13 additions and 8 deletions

View File

@ -100,7 +100,7 @@ public class PermissionRegistry {
public static ClaimPermission get(String id) {
if (!permissions.containsKey(id))
throw new NullPointerException("No such permission "+ id + " registered");
throw new NullPointerException("No such permission " + id + " registered");
return permissions.get(id);
}

View File

@ -250,7 +250,7 @@ public class EntityInteractEvents {
for (int x = -1; x <= 1; x++)
for (int z = -1; z <= 1; z++) {
IPermissionContainer claim = storage.getForPermissionCheck(wither.getBlockPos().add(x, 0, z));
if (!claim.canInteract(null, PermissionRegistry.WITHER, pos.set(pos.getX() + x, pos.getY() + 0, pos.getZ() + z), false))
if (!claim.canInteract(null, PermissionRegistry.WITHER, pos.set(pos.getX() + x, pos.getY() + 3, pos.getZ() + z), false))
return false;
}
return true;
@ -261,9 +261,7 @@ public class EntityInteractEvents {
return true;
ClaimStorage storage = ClaimStorage.get((ServerWorld) enderman.world);
IPermissionContainer claim = storage.getForPermissionCheck(pos);
if (!claim.canInteract(null, PermissionRegistry.ENDERMAN, pos, false))
return false;
return true;
return claim.canInteract(null, PermissionRegistry.ENDERMAN, pos, false);
}
public static boolean canSnowGolemInteract(SnowGolemEntity snowgolem) {

View File

@ -53,7 +53,7 @@ public class PlayerClaimData {
private boolean confirmDeleteAll, adminIgnoreClaim, claimBlockMessage;
private boolean dirty;
private Map<String, Map<ClaimPermission, Boolean>> defaultGroups = new HashMap<>();
private final Map<String, Map<ClaimPermission, Boolean>> defaultGroups = new HashMap<>();
public PlayerClaimData(ServerPlayerEntity player) {
this.player = player;
@ -291,8 +291,15 @@ public class PlayerClaimData {
this.additionalClaimBlocks = obj.get("AdditionalBlocks").getAsInt();
JsonObject defP = ConfigHandler.fromJson(obj, "DefaultGroups");
defP.entrySet().forEach(e -> {
Map<ClaimPermission, Boolean> perms = new HashMap<>();
perms.forEach((p, b) -> this.editDefaultPerms(e.getKey(), p, b ? 1 : 0));
if (e.getValue().isJsonObject()) {
e.getValue().getAsJsonObject().entrySet().forEach(p -> {
try {
this.editDefaultPerms(e.getKey(), PermissionRegistry.get(p.getKey()), p.getValue().getAsBoolean() ? 1 : 0);
} catch (NullPointerException ex) {
Flan.logger.error("Error reading Permission {} for personal group {} for player {}. Permission doesnt exist", p.getKey(), e.getKey(), this.player.getName().asString());
}
});
}
});
reader.close();
} catch (IOException e) {