use of io.icker.factions.util.Message in project factions by ickerio.
the class ClaimCommand method list.
public static int list(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
ArrayList<Claim> claims = Member.get(player.getUuid()).getFaction().getClaims();
int count = claims.size();
new Message("You have ").add(new Message(String.valueOf(count)).format(Formatting.YELLOW)).add(" claim%s", count == 1 ? "" : "s").send(source.getPlayer(), false);
if (count == 0)
return 1;
String claimText = // TODO: show dimension
claims.stream().map(claim -> String.format("(%d, %d)", claim.x, claim.z)).collect(Collectors.joining(", "));
new Message(claimText).format(Formatting.ITALIC).send(source.getPlayer(), false);
return 1;
}
use of io.icker.factions.util.Message 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;
}
use of io.icker.factions.util.Message in project factions by ickerio.
the class HomeCommand method go.
public static int go(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
Faction faction = Member.get(player.getUuid()).getFaction();
Home home = faction.getHome();
if (home == null) {
new Message("No faction home set").fail().send(player, false);
return 0;
}
ServerWorld world = player.getServer().getWorld(RegistryKey.of(Registry.WORLD_KEY, new Identifier(home.level)));
if (checkLimitToClaim(faction, world, new BlockPos(home.x, home.y, home.z))) {
new Message("Cannot warp home to an unclaimed chunk").fail().send(player, false);
return 0;
}
DamageTracker tracker = player.getDamageTracker();
if (tracker.getMostRecentDamage() == null || tracker.getTimeSinceLastAttack() > Config.SAFE_TICKS_TO_WARP) {
player.teleport(world, home.x, home.y, home.z, home.yaw, home.pitch);
new Message("Warped to faction home").send(player, false);
} else {
new Message("Cannot warp while in combat").fail().send(player, false);
}
return 1;
}
use of io.icker.factions.util.Message in project factions by ickerio.
the class InfoCommand method any.
public static int any(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
// TODO: Suggestions for factions
String factionName = StringArgumentType.getString(context, "faction");
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
Faction faction = Faction.get(factionName);
if (faction == null) {
new Message("Faction does not exist").fail().send(player, false);
return 0;
}
return info(player, faction);
}
use of io.icker.factions.util.Message in project factions by ickerio.
the class JoinCommand method run.
@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
String name = StringArgumentType.getString(context, "name");
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
Faction faction = Faction.get(name);
if (faction == null) {
new Message("Cannot join faction as none exist with that name").fail().send(player, false);
return 0;
}
Invite invite = Invite.get(player.getUuid(), faction.name);
if (!faction.open && invite == null) {
new Message("Cannot join faction as it is not open and you are not invited").fail().send(player, false);
return 0;
}
if (faction.getMembers().size() >= Config.MAX_FACTION_SIZE && Config.MAX_FACTION_SIZE != -1) {
new Message("Cannot join faction as it is currently full").fail().send(player, false);
return 0;
}
if (invite != null)
invite.remove();
faction.addMember(player.getUuid());
source.getServer().getPlayerManager().sendCommandTree(player);
new Message(player.getName().asString() + " joined").send(faction);
// TODO: change this, its ew
FactionEvents.adjustPower(faction, Config.MEMBER_POWER);
return 1;
}
Aggregations