code cleanups
This commit is contained in:
parent
3c659c8d4a
commit
f0a1203f84
@ -337,6 +337,7 @@ public class Claim {
|
||||
public boolean editPerms(ServerPlayerEntity player, String group, EnumPermission perm, int mode) {
|
||||
return this.editPerms(player, group, perm, mode, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the permissions for a group. If not defined for the group creates a new default permission map for that group
|
||||
*
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.flemmli97.flan.claim;
|
||||
|
||||
import com.flemmli97.flan.Flan;
|
||||
import com.flemmli97.flan.IClaimData;
|
||||
import com.flemmli97.flan.config.ConfigHandler;
|
||||
import com.flemmli97.flan.player.EnumDisplayType;
|
||||
@ -15,16 +14,12 @@ import com.google.gson.JsonObject;
|
||||
import com.ibm.icu.impl.Pair;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectArrayMap;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.command.LocateBiomeCommand;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
import net.minecraft.text.HoverEvent;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.WorldSavePath;
|
||||
@ -40,13 +35,11 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ClaimStorage {
|
||||
|
||||
@ -55,6 +48,7 @@ public class ClaimStorage {
|
||||
private final Map<UUID, Claim> claimUUIDMap = Maps.newHashMap();
|
||||
private final Map<UUID, Set<Claim>> playerClaimMap = Maps.newHashMap();
|
||||
private final Set<UUID> dirty = Sets.newHashSet();
|
||||
|
||||
public static ClaimStorage get(ServerWorld world) {
|
||||
return (ClaimStorage) ((IClaimData) world).getClaimData();
|
||||
}
|
||||
@ -258,8 +252,7 @@ public class ClaimStorage {
|
||||
if (this.dirty.contains(owner.equals(adminClaimString) ? null : e.getKey())) {
|
||||
dirty = true;
|
||||
this.dirty.clear();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (Claim claim : e.getValue())
|
||||
if (claim.isDirty()) {
|
||||
dirty = true;
|
||||
@ -315,8 +308,7 @@ public class ClaimStorage {
|
||||
if (values.get("Parent Claim ID").equals(-1)) {
|
||||
try {
|
||||
intFileMap.put(Integer.valueOf(f.getName().replace(".yml", "")), f);
|
||||
}
|
||||
catch (NumberFormatException e){
|
||||
} catch (NumberFormatException e) {
|
||||
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), Formatting.RED)), false);
|
||||
}
|
||||
}
|
||||
@ -358,8 +350,7 @@ public class ClaimStorage {
|
||||
src.sendFeedback(text, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, parent.getName(), Formatting.RED)), false);
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -393,8 +384,7 @@ public class ClaimStorage {
|
||||
if (!perm.isAlwaysGlobalPerm())
|
||||
claim.editGlobalPerms(perm, 1);
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
perms.get("builders").forEach(perm -> claim.editPerms(null, "Builders", perm, 1, true));
|
||||
builders.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Builders", true));
|
||||
}
|
||||
@ -405,8 +395,7 @@ public class ClaimStorage {
|
||||
if (!perm.isAlwaysGlobalPerm())
|
||||
claim.editGlobalPerms(perm, 1);
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
perms.get("managers").forEach(perm -> claim.editPerms(null, "Managers", perm, 1, true));
|
||||
managers.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Managers", true));
|
||||
}
|
||||
@ -417,8 +406,7 @@ public class ClaimStorage {
|
||||
if (!perm.isAlwaysGlobalPerm())
|
||||
claim.editGlobalPerms(perm, 1);
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
perms.get("containers").forEach(perm -> claim.editPerms(null, "Containers", perm, 1, true));
|
||||
containers.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Containers", true));
|
||||
}
|
||||
@ -429,8 +417,7 @@ public class ClaimStorage {
|
||||
if (!perm.isAlwaysGlobalPerm())
|
||||
claim.editGlobalPerms(perm, 1);
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
perms.get("accessors").forEach(perm -> claim.editPerms(null, "Accessors", perm, 1, true));
|
||||
accessors.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Accessors", true));
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
|
@ -15,12 +15,10 @@ import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
@ -40,7 +38,6 @@ import net.minecraft.world.World;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -246,8 +243,7 @@ public class CommandClaim {
|
||||
PlayerClaimData data = PlayerClaimData.get(player);
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat,
|
||||
data.getClaimBlocks(), data.getAdditionalClaims(), data.usedClaimBlocks()), Formatting.GOLD), false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
OfflinePlayerData data = new OfflinePlayerData(server, of);
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat,
|
||||
data.claimBlocks, data.additionalClaimBlocks, data.getUsedClaimBlocks(server)), Formatting.GOLD), false);
|
||||
|
@ -32,7 +32,6 @@ import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.security.Permission;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemInteractEvents {
|
||||
@ -97,8 +96,7 @@ public class ItemInteractEvents {
|
||||
claim.extendDownwards(placePos);
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
else if(actualInClaim) {
|
||||
} else if (actualInClaim) {
|
||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true);
|
||||
BlockState other = context.getWorld().getBlockState(placePos.up());
|
||||
player.networkHandler.sendPacket(new BlockUpdateS2CPacket(placePos.up(), other));
|
||||
|
@ -121,8 +121,7 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
|
||||
length -= EnumPermission.alwaysGlobalLength();
|
||||
if (id < length) {
|
||||
this.slots.get(i).setStack(ServerScreenHelper.fromPermission(this.claim, EnumPermission.values()[id], this.group));
|
||||
}
|
||||
else
|
||||
} else
|
||||
this.slots.get(i).setStack(ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public class OfflinePlayerData {
|
||||
|
||||
public final int claimBlocks, additionalClaimBlocks;
|
||||
public final UUID owner;
|
||||
|
||||
public OfflinePlayerData(MinecraftServer server, UUID uuid) {
|
||||
File dir = new File(server.getSavePath(WorldSavePath.PLAYERDATA).toFile(), "/claimData/");
|
||||
int claim = ConfigHandler.config.startingBlocks;
|
||||
|
@ -146,8 +146,7 @@ public class PlayerClaimData {
|
||||
state = this.player.world.getBlockState(pos);
|
||||
}
|
||||
this.cornerRenderPos = ClaimDisplay.getPosFrom(this.player.getServerWorld(), pos.getX(), pos.getZ(), pos.getY());
|
||||
}
|
||||
else
|
||||
} else
|
||||
this.cornerRenderPos = null;
|
||||
this.firstCorner = pos;
|
||||
}
|
||||
@ -305,8 +304,7 @@ public class PlayerClaimData {
|
||||
}
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), Formatting.RED)), false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user