use of io.icker.factions.util.Message in project factions by ickerio.
the class InfoCommand method info.
public static int info(ServerPlayerEntity player, Faction faction) {
ArrayList<Member> members = faction.getMembers();
ArrayList<Ally> allies = Ally.getAllies(faction.name);
String memberText = members.size() + (Config.MAX_FACTION_SIZE != -1 ? "/" + Config.MAX_FACTION_SIZE : (" member" + (members.size() != 1 ? "s" : "")));
String allyText = allies.size() + (allies.size() != 1 ? " allies" : " ally");
UserCache cache = player.getServer().getUserCache();
String membersList = members.stream().map(member -> cache.getByUuid(member.uuid).orElse(new GameProfile(Util.NIL_UUID, "{Uncached Player}")).getName()).collect(Collectors.joining(", "));
String alliesList = allies.stream().map(ally -> ally.target).collect(Collectors.joining(", "));
int requiredPower = faction.getClaims().size() * Config.CLAIM_WEIGHT;
int maxPower = Config.BASE_POWER + (members.size() * Config.MEMBER_POWER);
FactionsMod.LOGGER.info(alliesList);
new Message("").add(new Message(memberText).hover(membersList)).filler("·").add(new Message(allyText).hover(alliesList)).filler("·").add(new Message(Formatting.GREEN.toString() + faction.power + slash() + requiredPower + slash() + maxPower).hover("Current / Required / Max")).prependFaction(faction).send(player, false);
return 1;
}
use of io.icker.factions.util.Message in project factions by ickerio.
the class InviteCommand method list.
public static int list(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerCommandSource source = context.getSource();
ArrayList<Invite> invites = Member.get(source.getPlayer().getUuid()).getFaction().getInvites();
int count = invites.size();
new Message("You have ").add(new Message(String.valueOf(count)).format(Formatting.YELLOW)).add(" outgoing invite%s", count == 1 ? "" : "s").send(source.getPlayer(), false);
if (count == 0)
return 1;
UserCache cache = source.getServer().getUserCache();
String players = invites.stream().map(invite -> cache.getByUuid(invite.playerId).orElse(new GameProfile(Util.NIL_UUID, "{Uncached Player}")).getName()).collect(Collectors.joining(", "));
new Message(players).format(Formatting.ITALIC).send(source.getPlayer(), false);
return 1;
}
use of io.icker.factions.util.Message in project factions by ickerio.
the class InviteCommand 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 faction = Member.get(source.getPlayer().getUuid()).getFaction();
Invite invite = Invite.get(target.getUuid(), faction.name);
if (invite != null) {
new Message(target.getName().getString() + " was already invited to your faction").format(Formatting.RED).send(player, false);
return 0;
}
for (Member member : faction.getMembers()) if (member.uuid.equals(target.getUuid()))
new Message(target.getName().getString() + " is already in your faction").format(Formatting.RED).send(player, false);
Invite.add(target.getUuid(), faction.name);
new Message(target.getName().getString() + " has been invited").send(faction);
new Message("You have been invited to join this faction").format(Formatting.YELLOW).hover("Click to join").click("/factions join " + faction.name).prependFaction(faction).send(target, false);
return 1;
}
use of io.icker.factions.util.Message in project factions by ickerio.
the class InviteCommand method remove.
public static int remove(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerPlayerEntity target = EntityArgumentType.getPlayer(context, "player");
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
Faction faction = Member.get(player.getUuid()).getFaction();
new Invite(target.getUuid(), faction.name).remove();
new Message(target.getName().getString() + " is no longer invited to your faction").send(player, false);
return 1;
}
use of io.icker.factions.util.Message in project factions by ickerio.
the class ModifyCommand method open.
public static int open(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
boolean open = BoolArgumentType.getBool(context, "open");
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
Member.get(player.getUuid()).getFaction().setOpen(open);
new Message("Successfully updated faction to " + (open ? "open" : "closed")).send(player, false);
return 1;
}
Aggregations