Search in sources :

Example 1 with Message

use of io.icker.factions.util.Message 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;
}
Also used : Message(io.icker.factions.util.Message) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) Faction(io.icker.factions.database.Faction)

Example 2 with Message

use of io.icker.factions.util.Message 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;
}
Also used : Message(io.icker.factions.util.Message) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) Faction(io.icker.factions.database.Faction)

Example 3 with Message

use of io.icker.factions.util.Message in project factions by ickerio.

the class ChatCommand method set.

private static int set(ServerCommandSource source, ChatOption option) throws CommandSyntaxException {
    ServerPlayerEntity player = source.getPlayer();
    PlayerConfig.get(player.getUuid()).setChat(option);
    new Message("Successfully updated your chat preference").send(player, false);
    return 1;
}
Also used : Message(io.icker.factions.util.Message) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 4 with Message

use of io.icker.factions.util.Message 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;
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) Message(io.icker.factions.util.Message) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ChunkPos(net.minecraft.util.math.ChunkPos) Claim(io.icker.factions.database.Claim) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) Faction(io.icker.factions.database.Faction) PlayerConfig(io.icker.factions.database.PlayerConfig)

Example 5 with Message

use of io.icker.factions.util.Message 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;
}
Also used : Message(io.icker.factions.util.Message) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) Faction(io.icker.factions.database.Faction)

Aggregations

Message (io.icker.factions.util.Message)34 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)29 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)28 Faction (io.icker.factions.database.Faction)24 Member (io.icker.factions.database.Member)14 ServerWorld (net.minecraft.server.world.ServerWorld)5 Formatting (net.minecraft.util.Formatting)5 CommandContext (com.mojang.brigadier.context.CommandContext)4 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)4 Claim (io.icker.factions.database.Claim)4 Invite (io.icker.factions.database.Invite)4 ChunkPos (net.minecraft.util.math.ChunkPos)4 PlayerConfig (io.icker.factions.database.PlayerConfig)3 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3 GameProfile (com.mojang.authlib.GameProfile)2 Ally (io.icker.factions.database.Ally)2 Home (io.icker.factions.database.Home)2 UserCache (net.minecraft.util.UserCache)2 Util (net.minecraft.util.Util)2