Search in sources :

Example 51 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class ColonyTeleportCommand 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 (player != null) {
            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();
                        if (iColony == null) {
                            iColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), mayorID);
                        }
                    }
                }
            }
            if (null != iColony) {
                colony = ColonyManager.getColony(iColony.getID());
            }
        }
    }
    // Required argument: would never be null at this point.
    if (null == colony) {
        sender.sendMessage(new TextComponentString("You are not allowed to do this"));
        return;
    }
    executeShared(server, sender, colony);
}
Also used : Entity(net.minecraft.entity.Entity) Colony(com.minecolonies.coremod.colony.Colony) TeleportToColony(com.minecolonies.coremod.util.TeleportToColony) 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 52 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class ColonyTeleportCommand method execute.

@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final String... args) throws CommandException {
    Colony colony = null;
    // see if player is allowed to use in the configs
    if (args.length == 1) {
        try {
            final int colonyId = Integer.parseInt(args[0]);
            colony = ColonyManager.getColony(colonyId);
        } catch (final NumberFormatException e) {
        // we ignore the exception and deal with a null colony below.
        }
    }
    if (null == colony) {
        sender.sendMessage(new TextComponentString("You are not allowed to do this"));
        return;
    }
    executeShared(server, sender, colony);
}
Also used : Colony(com.minecolonies.coremod.colony.Colony) TeleportToColony(com.minecolonies.coremod.util.TeleportToColony) IColony(com.minecolonies.api.colony.IColony) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 53 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class DisableBarbarianSpawnsCommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final Colony colony, final boolean canHaveBarbEvents) throws CommandException {
    if (sender instanceof EntityPlayer && !isPlayerOpped(sender)) {
        sender.sendMessage(new TextComponentString("Must be OP to use this command"));
    }
    colony.getBarbManager().setCanHaveBarbEvents(canHaveBarbEvents);
    sender.sendMessage(new TextComponentString("Colony \" Can have Barbarian Events \" now set to: " + colony.isCanHaveBarbEvents()));
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 54 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class DoRaidNowCommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @Nullable final Colony colony) {
    if (sender instanceof EntityPlayer && !isPlayerOpped(sender)) {
        sender.sendMessage(new TextComponentString("Must be OP to use command"));
        return;
    }
    MobEventsUtils.barbarianEvent(colony.getWorld(), colony);
    sender.sendMessage(SUCCESSFUL);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 55 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class DoRaidTonightCommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @Nullable final Colony colony) {
    if (sender instanceof EntityPlayer && !isPlayerOpped(sender)) {
        sender.sendMessage(new TextComponentString("Must be OP to use command"));
        return;
    }
    colony.getBarbManager().setWillRaidTonight(true);
    sender.sendMessage(SUCCESSFUL);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TextComponentString (net.minecraft.util.text.TextComponentString)343 EntityPlayer (net.minecraft.entity.player.EntityPlayer)79 ItemStack (net.minecraft.item.ItemStack)68 BlockPos (net.minecraft.util.math.BlockPos)60 ITextComponent (net.minecraft.util.text.ITextComponent)48 TileEntity (net.minecraft.tileentity.TileEntity)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)35 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)32 Colony (com.minecolonies.coremod.colony.Colony)26 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)26 IBlockState (net.minecraft.block.state.IBlockState)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 Style (net.minecraft.util.text.Style)21 IColony (com.minecolonies.api.colony.IColony)19 ClickEvent (net.minecraft.util.text.event.ClickEvent)19 Entity (net.minecraft.entity.Entity)18 Block (net.minecraft.block.Block)17 World (net.minecraft.world.World)17 ArrayList (java.util.ArrayList)16 ActionResult (net.minecraft.util.ActionResult)13