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;
}
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);
}
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);
}
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;
}
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());
}
Aggregations