use of io.icker.factions.database.Faction in project factions by ickerio.
the class AllyCommand method accept.
public static int accept(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerPlayerEntity target = EntityArgumentType.getPlayer(context, "player");
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
Faction targetFaction = Member.get(player.getUuid()).getFaction();
Faction sourceFaction = Member.get(target.getUuid()).getFaction();
if (Ally.checkIfAlly(sourceFaction.name, targetFaction.name) || !Ally.checkIfAllyInvite(sourceFaction.name, targetFaction.name)) {
new Message(targetFaction.name + " is already allied or has not invited you").format(Formatting.RED).send(player, false);
} else if (sourceFaction.name == targetFaction.name) {
new Message("You can't ally yourself").format(Formatting.RED).send(player, false);
} else {
Ally.accept(sourceFaction.name, targetFaction.name);
new Message(targetFaction.name + " is now an ally").send(player, false);
new Message("You are now allies with " + sourceFaction.name).format(Formatting.YELLOW).send(target, false);
}
return 1;
}
use of io.icker.factions.database.Faction in project factions by ickerio.
the class AllyCommand method add.
public static int add(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerPlayerEntity target = EntityArgumentType.getPlayer(context, "player");
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
Faction sourceFaction = Member.get(player.getUuid()).getFaction();
Faction targetFaction = Member.get(target.getUuid()).getFaction();
if (Ally.checkIfAlly(sourceFaction.name, targetFaction.name) || Ally.checkIfAllyInvite(sourceFaction.name, targetFaction.name)) {
new Message(targetFaction.name + " is already allied or invited").format(Formatting.RED).send(player, false);
} else if (sourceFaction.name == targetFaction.name) {
new Message("You can't ally yourself").format(Formatting.RED).send(player, false);
} else {
Ally.add(sourceFaction.name, targetFaction.name);
new Message(targetFaction.name + " is now invited to be an ally").send(player, false);
new Message("You have been invited to be an ally with " + sourceFaction.name).format(Formatting.YELLOW).hover("Click to accept the invitation").click("/factions ally accept " + source.getName()).send(target, false);
}
return 1;
}
use of io.icker.factions.database.Faction 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.Faction in project factions by ickerio.
the class ClaimCommand method removeAll.
public static int removeAll(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
Faction faction = Member.get(player.getUuid()).getFaction();
faction.removeAllClaims();
new Message("%s removed all claims", player.getName().asString()).send(faction);
return 1;
}
use of io.icker.factions.database.Faction in project factions by ickerio.
the class ClaimCommand method add.
public static int add(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();
Member member = Member.get(player.getUuid());
Claim existingClaim = Claim.get(chunkPos.x, chunkPos.z, dimension);
if (existingClaim == null) {
Faction faction = member.getFaction();
faction.addClaim(chunkPos.x, chunkPos.z, dimension);
new Message("%s claimed chunk (%d, %d)", player.getName().asString(), chunkPos.x, chunkPos.z).send(faction);
return 1;
}
String owner = existingClaim.getFaction().name == member.getFaction().name ? "Your" : "Another";
new Message(owner + " faction already owns this chunk").fail().send(player, false);
return 0;
}
Aggregations