Search in sources :

Example 11 with IColony

use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.

the class EventHandler method onWareHousePlaced.

private static boolean onWareHousePlaced(final World world, final EntityPlayer player, final BlockPos pos) {
    if (onBlockHutPlaced(world, player, pos)) {
        final IColony colony = ColonyManager.getClosestIColony(world, pos);
        if (colony != null && (!Configurations.gameplay.limitToOneWareHousePerColony || !colony.hasWarehouse())) {
            return true;
        }
        LanguageHandler.sendPlayerMessage(player, "tile.blockHut.warehouse.limit");
    }
    return false;
}
Also used : IColony(com.minecolonies.api.colony.IColony)

Example 12 with IColony

use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.

the class ShowColonyInfoCommand method execute.

public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final ActionMenu actionMenu) throws CommandException {
    // See if we have a valid colony,
    Colony colony = actionMenu.getColonyForArgument("colony");
    EntityPlayer player = null;
    if (null == colony) {
        // see if we have a valid player
        player = actionMenu.getPlayerForArgument("player");
        if (null != player) {
            final IColony iColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), player);
            if (iColony != null) {
                if (!canPlayerUseCommand(player, SHOWCOLONYINFO, iColony.getID())) {
                    sender.sendMessage(new TextComponentString(NOT_PERMITTED));
                    return;
                }
                colony = ColonyManager.getColony(iColony.getID());
            }
        }
    }
    if (null == colony) {
        // see if we have a sender that is a valid player
        if (sender instanceof EntityPlayer) {
            player = (EntityPlayer) sender;
            final UUID mayorID = player.getUniqueID();
            final IColony iColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), mayorID);
            if (iColony != null) {
                if (!canPlayerUseCommand(player, SHOWCOLONYINFO, iColony.getID())) {
                    sender.sendMessage(new TextComponentString(NOT_PERMITTED));
                    return;
                }
                colony = ColonyManager.getColony(iColony.getID());
            }
        }
    }
    if (colony == null) {
        if (null != player) {
            sender.sendMessage(new TextComponentString(String.format(NO_COLONY_FOR_PLAYER_FOUND_MESSAGE, player.getName())));
        } else {
            sender.sendMessage(new TextComponentString(String.format(NO_COLONY_FOUND_MESSAGE)));
        }
        return;
    }
    executeShared(server, sender, colony);
}
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) UUID(java.util.UUID) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 13 with IColony

use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.

the class RSResetCommand method execute.

@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;
    }
    final Entity senderEntity = sender.getCommandSenderEntity();
    int colonyId = getIthArgument(args, 0, -1);
    if (colonyId == -1 && senderEntity instanceof EntityPlayer) {
        final IColony colony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), ((EntityPlayer) sender).getUniqueID());
        if (colony == null) {
            senderEntity.sendMessage(new TextComponentString(COLONY_NULL));
            return;
        }
        colonyId = colony.getID();
    }
    final Colony colony = ColonyManager.getColony(colonyId);
    if (colony == null) {
        sender.sendMessage(new TextComponentString(String.format(COLONY_NULL, colonyId)));
        return;
    }
    executeShared(server, sender, colony);
}
Also used : Entity(net.minecraft.entity.Entity) 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)

Example 14 with IColony

use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.

the class WhereAmICommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender) throws CommandException {
    if (!(sender instanceof EntityPlayer)) {
        Log.getLogger().info("In the console...");
        return;
    }
    final BlockPos playerPos = sender.getPosition();
    final IColony colony = ColonyManager.getClosestColony(server.getEntityWorld(), playerPos);
    if (colony == null) {
        sender.sendMessage(new TextComponentString(NONE));
        return;
    }
    final BlockPos center = colony.getCenter();
    final double distance = BlockPosUtil.getDistanceSquared(center, new BlockPos(playerPos.getX(), center.getY(), playerPos.getZ()));
    if (!ColonyManager.isTooCloseToColony(sender.getEntityWorld(), playerPos)) {
        sender.sendMessage(new TextComponentString(String.format(NONE_CLOSE, Math.sqrt(distance))));
        return;
    }
    final String colonyName = colony.getName();
    final String id = Integer.toString(colony.getID());
    sender.sendMessage(new TextComponentString(String.format(INSIDE, colonyName, id, Math.sqrt(distance))));
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) IColony(com.minecolonies.api.colony.IColony) BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 15 with IColony

use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.

the class DeleteColonyCommand method execute.

@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final String... args) throws CommandException {
    final int colonyId;
    boolean canDestroy = true;
    boolean confirmDelete = false;
    if (args.length == 0) {
        IColony colony = null;
        if (sender instanceof EntityPlayer) {
            colony = ColonyManager.getIColonyByOwner(CompatibilityUtils.getWorld((EntityPlayer) sender), (EntityPlayer) sender);
        }
        if (colony == null) {
            sender.sendMessage(new TextComponentString(NO_COLONY_MESSAGE));
            return;
        }
        colonyId = colony.getID();
    } else {
        colonyId = getIthArgument(args, 0, -1);
        if (args.length > 1) {
            canDestroy = Boolean.parseBoolean(args[1]);
        }
        if (args.length > 2) {
            confirmDelete = Boolean.parseBoolean(args[2]);
        }
    }
    final Colony colony = ColonyManager.getColony(colonyId);
    if (colony == null) {
        final String noColonyFoundMessage = String.format(COLONY_X_NULL, colonyId);
        sender.sendMessage(new TextComponentString(noColonyFoundMessage));
        return;
    }
    executeShared(server, sender, colony, canDestroy, confirmDelete);
}
Also used : IColony(com.minecolonies.api.colony.IColony) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.api.colony.IColony) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

IColony (com.minecolonies.api.colony.IColony)22 EntityPlayer (net.minecraft.entity.player.EntityPlayer)16 TextComponentString (net.minecraft.util.text.TextComponentString)14 Colony (com.minecolonies.coremod.colony.Colony)12 Entity (net.minecraft.entity.Entity)7 UUID (java.util.UUID)5 Player (com.minecolonies.api.colony.permissions.Player)2 ColonyView (com.minecolonies.coremod.colony.ColonyView)2 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 NotNull (org.jetbrains.annotations.NotNull)2 IDeliverable (com.minecolonies.api.colony.requestsystem.requestable.IDeliverable)1 AbstractBlockHut (com.minecolonies.coremod.blocks.AbstractBlockHut)1 CitizenData (com.minecolonies.coremod.colony.CitizenData)1 AbstractBuilding (com.minecolonies.coremod.colony.buildings.AbstractBuilding)1 BuildingBasedRequester (com.minecolonies.coremod.colony.requestsystem.requesters.BuildingBasedRequester)1 TeleportToColony (com.minecolonies.coremod.util.TeleportToColony)1 GameProfile (com.mojang.authlib.GameProfile)1 BlockSilverfish (net.minecraft.block.BlockSilverfish)1