Search in sources :

Example 1 with Ally

use of io.icker.factions.database.Ally 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;
}
Also used : Config(io.icker.factions.config.Config) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) CommandContext(com.mojang.brigadier.context.CommandContext) Faction(io.icker.factions.database.Faction) Util(net.minecraft.util.Util) Ally(io.icker.factions.database.Ally) GameProfile(com.mojang.authlib.GameProfile) UserCache(net.minecraft.util.UserCache) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) Formatting(net.minecraft.util.Formatting) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) FactionsMod(io.icker.factions.FactionsMod) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) Message(io.icker.factions.util.Message) Member(io.icker.factions.database.Member) Message(io.icker.factions.util.Message) GameProfile(com.mojang.authlib.GameProfile) Ally(io.icker.factions.database.Ally) UserCache(net.minecraft.util.UserCache) Member(io.icker.factions.database.Member)

Example 2 with Ally

use of io.icker.factions.database.Ally in project factions by ickerio.

the class AllyCommand method list.

public static int list(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
    ServerCommandSource source = context.getSource();
    ServerPlayerEntity player = source.getPlayer();
    Faction faction = Member.get(player.getUuid()).getFaction();
    ArrayList<Ally> invites = Ally.getAllyInvites(faction.name);
    for (Ally ally : invites) {
        new Message(ally.source + " has invited you").format(Formatting.YELLOW).hover("Click to accept them as an ally").click("/factions ally accept " + ally.source).send(player, false);
    }
    return 1;
}
Also used : Message(io.icker.factions.util.Message) Ally(io.icker.factions.database.Ally) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) Faction(io.icker.factions.database.Faction)

Aggregations

Ally (io.icker.factions.database.Ally)2 Faction (io.icker.factions.database.Faction)2 Message (io.icker.factions.util.Message)2 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 GameProfile (com.mojang.authlib.GameProfile)1 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)1 CommandContext (com.mojang.brigadier.context.CommandContext)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 FactionsMod (io.icker.factions.FactionsMod)1 Config (io.icker.factions.config.Config)1 Member (io.icker.factions.database.Member)1 ArrayList (java.util.ArrayList)1 Collectors (java.util.stream.Collectors)1 Formatting (net.minecraft.util.Formatting)1 UserCache (net.minecraft.util.UserCache)1 Util (net.minecraft.util.Util)1