use of io.icker.factions.database.PlayerConfig in project factions by ickerio.
the class ClaimCommand method remove.
public static int remove(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
ServerWorld world = player.getWorld();
ChunkPos chunkPos = world.getChunk(player.getBlockPos()).getPos();
String dimension = world.getRegistryKey().getValue().toString();
Claim existingClaim = Claim.get(chunkPos.x, chunkPos.z, dimension);
if (existingClaim == null) {
new Message("Cannot remove a claim on an unclaimed chunk").fail().send(player, false);
return 0;
}
Faction faction = Member.get(player.getUuid()).getFaction();
PlayerConfig config = PlayerConfig.get(player.getUuid());
if (existingClaim.getFaction().name != faction.name && !config.bypass) {
new Message("Cannot remove a claim owned by another faction").fail().send(player, false);
return 0;
}
existingClaim.remove();
new Message("%s removed claim at chunk (%d, %d)", player.getName().asString(), existingClaim.x, existingClaim.z).send(faction);
return 1;
}
use of io.icker.factions.database.PlayerConfig in project factions by ickerio.
the class PlayerInteractEvents method actionPermitted.
public static boolean actionPermitted(BlockPos pos, World world, ServerPlayerEntity player) {
PlayerConfig config = PlayerConfig.get(player.getUuid());
if (config.bypass) {
if (player.hasPermissionLevel(Config.REQUIRED_BYPASS_LEVEL)) {
return true;
} else {
config.setBypass(false);
}
}
String dimension = world.getRegistryKey().getValue().toString();
ChunkPos actionPos = world.getChunk(pos).getPos();
Claim claim = Claim.get(actionPos.x, actionPos.z, dimension);
if (claim == null)
return true;
Member member = Member.get(player.getUuid());
Faction owner = claim.getFaction();
boolean overclaimed = owner.getClaims().size() * Config.CLAIM_WEIGHT > owner.power;
boolean validMember = member == null ? false : member.getFaction().name == owner.name;
boolean allied = Ally.checkIfAlly(owner.name, member.getFaction().name);
boolean permitted = overclaimed || validMember || allied;
if (!permitted)
syncBlocks(player, world, pos);
return permitted;
}
use of io.icker.factions.database.PlayerConfig in project factions by ickerio.
the class BypassCommand method run.
@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
PlayerConfig config = PlayerConfig.get(player.getUuid());
boolean bypass = !config.bypass;
config.setBypass(bypass);
new Message("Successfully toggled claim bypass").filler("ยท").add(new Message(bypass ? "ON" : "OFF").format(bypass ? Formatting.GREEN : Formatting.RED)).send(player, false);
return 1;
}
Aggregations