Search in sources :

Example 71 with Colony

use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.

the class MakeNotAutoDeletableCommand method execute.

@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final ActionMenu actionMenu) throws CommandException {
    final Colony colony = actionMenu.getColonyForArgument("colony");
    final boolean canBeDeleted = actionMenu.getBooleanValueForArgument("canBeDeleted", false);
    executeShared(server, sender, colony, canBeDeleted);
}
Also used : Colony(com.minecolonies.coremod.colony.Colony)

Example 72 with Colony

use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.

the class RefreshColonyCommand method execute.

@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final ActionMenu actionMenu) throws CommandException {
    Colony colony = actionMenu.getColonyForArgument("colony");
    if (null == colony) {
        final EntityPlayer player = actionMenu.getPlayerForArgument("player");
        if (null != player) {
            IColony iColony = ColonyManager.getIColonyByOwner(server.getEntityWorld(), player);
            if (null == iColony) {
                if (sender instanceof EntityPlayer) {
                    final Entity senderEntity = sender.getCommandSenderEntity();
                    if (senderEntity != null) {
                        final UUID mayorID = senderEntity.getUniqueID();
                        iColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), mayorID);
                    }
                }
            }
            if (null != iColony) {
                colony = ColonyManager.getColony(iColony.getID());
            }
        }
    }
    if (colony == null) {
        sender.sendMessage(new TextComponentString(NO_COLONY_FOUND_MESSAGE));
        return;
    }
    executeShared(server, sender, colony);
}
Also used : Entity(net.minecraft.entity.Entity) Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.api.colony.IColony) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IColony(com.minecolonies.api.colony.IColony) UUID(java.util.UUID) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 73 with Colony

use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.

the class RefreshColonyCommand method execute.

@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final String... args) throws CommandException {
    final int colonyId;
    colonyId = getIthArgument(args, 0, -1);
    IColony tempColony = ColonyManager.getColony(colonyId);
    if (colonyId == -1 && args.length >= 1) {
        final EntityPlayer player = server.getEntityWorld().getPlayerEntityByName(args[0]);
        if (player != null) {
            tempColony = ColonyManager.getIColonyByOwner(server.getEntityWorld(), player);
        }
    }
    if (sender instanceof EntityPlayer) {
        final Entity senderEntity = sender.getCommandSenderEntity();
        if (senderEntity == null) {
            return;
        }
        final UUID mayorID = senderEntity.getUniqueID();
        if (tempColony == null) {
            tempColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), mayorID);
        }
    }
    if (tempColony == null) {
        if (colonyId == -1 && args.length != 0) {
            sender.sendMessage(new TextComponentString(String.format(NO_COLONY_WITH_PLAYER_FOUND_MESSAGE, args[0])));
        } else {
            sender.sendMessage(new TextComponentString(String.format(NO_COLONY_WITH_ID_FOUND_MESSAGE, colonyId)));
        }
        return;
    }
    final Colony colony = ColonyManager.getColony(tempColony.getID());
    if (colony == null) {
        sender.sendMessage(new TextComponentString(NO_COLONY_FOUND_MESSAGE));
        return;
    }
    executeShared(server, sender, colony);
}
Also used : Entity(net.minecraft.entity.Entity) IColony(com.minecolonies.api.colony.IColony) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.api.colony.IColony) UUID(java.util.UUID) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 74 with Colony

use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.

the class AbstractCitizensCommands method execute.

@NotNull
@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final String... args) throws CommandException {
    if (args.length == 0) {
        sender.sendMessage(new TextComponentString(NO_ARGUMENTS));
        return;
    }
    boolean firstArgumentColonyId = true;
    int colonyId = -1;
    if (args.length >= 2) {
        colonyId = getIthArgument(args, 0, -1);
        if (colonyId == -1) {
            final EntityPlayer player = server.getEntityWorld().getPlayerEntityByName(args[0]);
            if (player != null) {
                final IColony tempColony = ColonyManager.getIColonyByOwner(server.getEntityWorld(), player);
                if (tempColony != null) {
                    colonyId = tempColony.getID();
                }
            }
            firstArgumentColonyId = false;
        }
    }
    final Colony colony;
    if (sender instanceof EntityPlayer && colonyId == -1) {
        final IColony tempColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), (EntityPlayer) sender);
        if (tempColony != null) {
            colonyId = tempColony.getID();
            firstArgumentColonyId = false;
        }
    }
    colony = ColonyManager.getColony(colonyId);
    if (colony == null) {
        sender.sendMessage(new TextComponentString(NO_ARGUMENTS));
        return;
    }
    if (sender instanceof EntityPlayer) {
        final EntityPlayer player = (EntityPlayer) sender;
        if (!canPlayerUseCommand(player, getCommand(), colonyId)) {
            player.sendMessage(new TextComponentString(NOT_PERMITTED));
            return;
        }
    }
    final int citizenId = getValidCitizenId(colony, firstArgumentColonyId, args);
    if (citizenId == -1 || colony.getCitizenManager().getCitizen(citizenId) == null) {
        sender.sendMessage(new TextComponentString(NO_ARGUMENTS));
        return;
    }
    executeSpecializedCode(server, sender, colony, citizenId);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) IColony(com.minecolonies.api.colony.IColony) Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.api.colony.IColony) TextComponentString(net.minecraft.util.text.TextComponentString) NotNull(org.jetbrains.annotations.NotNull)

Example 75 with Colony

use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.

the class ListCitizensCommand method execute.

@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final String... args) throws CommandException {
    int colonyId = getIthArgument(args, 0, getColonyId(sender));
    final Integer page = getIthArgument(args, 1, 1);
    Colony colony = null;
    if (sender instanceof EntityPlayer) {
        if (colonyId == -1) {
            final IColony icolony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), (EntityPlayer) sender);
            if (icolony != null) {
                colonyId = icolony.getID();
            }
        }
    }
    colony = ColonyManager.getColony(colonyId);
    executeShared(server, sender, colony, page);
}
Also used : Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.api.colony.IColony) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IColony(com.minecolonies.api.colony.IColony)

Aggregations

Colony (com.minecolonies.coremod.colony.Colony)81 TextComponentString (net.minecraft.util.text.TextComponentString)29 IColony (com.minecolonies.api.colony.IColony)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 BlockPos (net.minecraft.util.math.BlockPos)19 Nullable (org.jetbrains.annotations.Nullable)16 CitizenData (com.minecolonies.coremod.colony.CitizenData)13 AbstractBuilding (com.minecolonies.coremod.colony.buildings.AbstractBuilding)13 NotNull (org.jetbrains.annotations.NotNull)11 ItemStack (net.minecraft.item.ItemStack)9 Entity (net.minecraft.entity.Entity)8 TileEntity (net.minecraft.tileentity.TileEntity)8 World (net.minecraft.world.World)6 List (java.util.List)5 UUID (java.util.UUID)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)4 Delivery (com.minecolonies.api.colony.requestsystem.requestable.Delivery)4 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)4 AbstractBlockHut (com.minecolonies.coremod.blocks.AbstractBlockHut)4