Search in sources :

Example 16 with Message

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

the class TransferOwnerCommand method run.

@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
    ServerPlayerEntity target = EntityArgumentType.getPlayer(context, "player");
    ServerCommandSource source = context.getSource();
    ServerPlayerEntity player = source.getPlayer();
    if (target.getUuid().equals(player.getUuid())) {
        new Message("You cannot transfer ownership to yourself").format(Formatting.RED).send(player, false);
        return 0;
    }
    Faction faction = Member.get(player.getUuid()).getFaction();
    for (Member member : faction.getMembers()) if (member.uuid.equals(target.getUuid())) {
        member.updateRank(Member.Rank.OWNER);
        Member.get(player.getUuid()).updateRank(Member.Rank.CO_OWNER);
        context.getSource().getServer().getPlayerManager().sendCommandTree(player);
        context.getSource().getServer().getPlayerManager().sendCommandTree(target);
        new Message("Transferred ownership to " + target.getName().getString()).send(player, false);
        return 1;
    }
    new Message(target.getName().getString() + " is not in your faction").format(Formatting.RED).send(player, false);
    return 0;
}
Also used : Message(io.icker.factions.util.Message) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Member(io.icker.factions.database.Member) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) Faction(io.icker.factions.database.Faction)

Example 17 with Message

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

the class FactionEvents method powerTick.

public static void powerTick(ServerPlayerEntity player) {
    Member member = Member.get(player.getUuid());
    if (member == null)
        return;
    Faction faction = member.getFaction();
    int adjusted = adjustPower(faction, Config.TICKS_FOR_POWER_REWARD);
    if (adjusted != 0)
        new Message("%s gained %d power from surviving", player.getName().asString(), adjusted).send(faction);
}
Also used : Message(io.icker.factions.util.Message) Member(io.icker.factions.database.Member) Faction(io.icker.factions.database.Faction)

Example 18 with Message

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

the class FactionEvents method playerDeath.

public static void playerDeath(ServerPlayerEntity player) {
    Member member = Member.get(player.getUuid());
    if (member == null)
        return;
    Faction faction = member.getFaction();
    int adjusted = adjustPower(faction, -Config.POWER_DEATH_PENALTY);
    new Message("%s lost %d power from dying", player.getName().asString(), adjusted).send(faction);
}
Also used : Message(io.icker.factions.util.Message) Member(io.icker.factions.database.Member) Faction(io.icker.factions.database.Faction)

Example 19 with Message

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

the class HomeCommand method set.

public static int set(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
    ServerCommandSource source = context.getSource();
    ServerPlayerEntity player = source.getPlayer();
    Faction faction = Member.get(player.getUuid()).getFaction();
    if (checkLimitToClaim(faction, player.getWorld(), player.getBlockPos())) {
        new Message("Cannot set home to an unclaimed chunk").fail().send(player, false);
        return 0;
    }
    Home home = faction.setHome(player.getX(), player.getY(), player.getZ(), player.getHeadYaw(), player.getPitch(), player.getWorld().getRegistryKey().getValue().toString());
    new Message("%s set home to %.2f, %.2f, %.2f", player.getName().asString(), home.x, home.y, home.z).send(faction);
    return 1;
}
Also used : Message(io.icker.factions.util.Message) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Home(io.icker.factions.database.Home) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) Faction(io.icker.factions.database.Faction)

Example 20 with Message

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

the class InfoCommand method self.

public static int self(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
    ServerCommandSource source = context.getSource();
    ServerPlayerEntity player = source.getPlayer();
    Member member = Member.get(player.getUuid());
    if (member == null) {
        new Message("Command can only be used whilst in a faction").fail().send(player, false);
        return 0;
    }
    return info(player, member.getFaction());
}
Also used : Message(io.icker.factions.util.Message) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Member(io.icker.factions.database.Member) ServerCommandSource(net.minecraft.server.command.ServerCommandSource)

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