Search in sources :

Example 1 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project RecurrentComplex by Ivorforce.

the class GuiHider method hideGUI.

public static boolean hideGUI() {
    if (!canHide())
        return false;
    Minecraft mc = Minecraft.getMinecraft();
    hiddenGUI = mc.currentScreen;
    if (hiddenGUI == null)
        return false;
    mc.displayGuiScreen(null);
    ITextComponent reopen = new TextComponentString("/" + RCCommands.reopen.getName());
    reopen.getStyle().setColor(TextFormatting.GREEN);
    reopen.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.reopen.getName()));
    reopen.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcreopen.run")));
    mc.player.sendMessage(ServerTranslations.format("commands.rc.didhide", reopen));
    return true;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) Minecraft(net.minecraft.client.Minecraft) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project SecurityCraft by Geforce132.

the class ForgeEventHandler method onPlayerLoggedIn.

@SubscribeEvent
public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
    mod_SecurityCraft.instance.createIrcBot(event.player.getName());
    String tipKey = getRandomTip();
    ITextComponent TextComponentString;
    if (tipsWithLink.containsKey(tipKey.split("\\.")[2])) {
        TextComponentString = new TextComponentString("[" + TextFormatting.GOLD + "SecurityCraft" + TextFormatting.WHITE + "] " + I18n.translateToLocal("messages.thanks").replace("#", mod_SecurityCraft.getVersion()) + " " + I18n.translateToLocal("messages.tip") + " " + I18n.translateToLocal(tipKey) + " ").appendSibling(ForgeHooks.newChatWithLinks(tipsWithLink.get(tipKey.split("\\.")[2])));
    } else {
        TextComponentString = new TextComponentString("[" + TextFormatting.GOLD + "SecurityCraft" + TextFormatting.WHITE + "] " + I18n.translateToLocal("messages.thanks").replace("#", mod_SecurityCraft.getVersion()) + " " + I18n.translateToLocal("messages.tip") + " " + I18n.translateToLocal(tipKey));
    }
    if (mod_SecurityCraft.configHandler.sayThanksMessage) {
        event.player.addChatComponentMessage(TextComponentString);
    }
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project RFToolsDimensions by McJty.

the class CmdInfo method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    int dim = 0;
    World world = sender.getEntityWorld();
    if (args.length == 2) {
        dim = fetchInt(sender, args, 1, 0);
    } else if (args.length > 2) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    } else {
        dim = world.provider.getDimension();
    }
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    ITextComponent component2 = new TextComponentString(TextFormatting.YELLOW + "Dimension ID " + dim);
    if (sender instanceof EntityPlayer) {
        ((EntityPlayer) sender).sendStatusMessage(component2, false);
    } else {
        sender.sendMessage(component2);
    }
    ITextComponent component1 = new TextComponentString(TextFormatting.YELLOW + "Description string " + information.getDescriptor().getDescriptionString());
    if (sender instanceof EntityPlayer) {
        ((EntityPlayer) sender).sendStatusMessage(component1, false);
    } else {
        sender.sendMessage(component1);
    }
    String ownerName = information.getOwnerName();
    if (ownerName != null && !ownerName.isEmpty()) {
        ITextComponent component = new TextComponentString(TextFormatting.YELLOW + "Owned by: " + ownerName);
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
    }
    if (sender instanceof EntityPlayer) {
        information.dump((EntityPlayer) sender);
    }
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 4 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project RFToolsDimensions by McJty.

the class CmdSafeDelete method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (!(GeneralConfiguration.playersCanDeleteDimensions || sender.canUseCommand(3, getCommand()))) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "You have no permission to execute this command!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    if (args.length < 2) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "The dimension parameter is missing!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    } else if (args.length > 2) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    World w = DimensionManager.getWorld(dim);
    if (w != null) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Dimension is still in use!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    if (!sender.canUseCommand(3, "safedel")) {
        DimensionInformation information = dimensionManager.getDimensionInformation(dim);
        if (information.getOwner() == null) {
            ITextComponent component = new TextComponentString(TextFormatting.RED + "This dimension has no owner. You cannot delete it!");
            if (sender instanceof EntityPlayer) {
                ((EntityPlayer) sender).sendStatusMessage(component, false);
            } else {
                sender.sendMessage(component);
            }
            return;
        }
        if (!(sender instanceof EntityPlayerMP)) {
            ITextComponent component = new TextComponentString(TextFormatting.RED + "This command must be run as a player!");
            if (sender instanceof EntityPlayer) {
                ((EntityPlayer) sender).sendStatusMessage(component, false);
            } else {
                sender.sendMessage(component);
            }
            return;
        }
        EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
        if (!information.getOwner().equals(entityPlayerMP.getGameProfile().getId())) {
            ITextComponent component = new TextComponentString(TextFormatting.RED + "You are not the owner of this dimension. You cannot delete it!");
            if (sender instanceof EntityPlayer) {
                ((EntityPlayer) sender).sendStatusMessage(component, false);
            } else {
                sender.sendMessage(component);
            }
            return;
        }
    }
    RFToolsDim.teleportationManager.removeReceiverDestinations(world, dim);
    dimensionManager.removeDimension(dim);
    dimensionManager.reclaimId(dim);
    dimensionManager.save(world);
    DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
    dimensionStorage.removeDimension(dim);
    dimensionStorage.save(world);
    if (GeneralConfiguration.dimensionFolderIsDeletedWithSafeDel) {
        File rootDirectory = DimensionManager.getCurrentSaveRootDirectory();
        try {
            FileUtils.deleteDirectory(new File(rootDirectory.getPath() + File.separator + "RFTOOLS" + dim));
            ITextComponent component = new TextComponentString("Dimension deleted and dimension folder succesfully wiped!");
            if (sender instanceof EntityPlayer) {
                ((EntityPlayer) sender).sendStatusMessage(component, false);
            } else {
                sender.sendMessage(component);
            }
        } catch (IOException e) {
            ITextComponent component = new TextComponentString(TextFormatting.RED + "Dimension deleted but dimension folder could not be completely wiped!");
            if (sender instanceof EntityPlayer) {
                ((EntityPlayer) sender).sendStatusMessage(component, false);
            } else {
                sender.sendMessage(component);
            }
        }
    } else {
        ITextComponent component = new TextComponentString("Dimension deleted. Please remove the dimension folder from disk!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
    }
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IOException(java.io.IOException) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) File(java.io.File) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 5 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project RFToolsDimensions by McJty.

the class CmdSetOwner method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 3) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "The dimension and player parameters are missing!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    } else if (args.length > 3) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    String playerName = fetchString(sender, args, 2, null);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    for (EntityPlayerMP entityPlayerMP : world.getMinecraftServer().getPlayerList().getPlayers()) {
        if (playerName.equals(entityPlayerMP.getName())) {
            DimensionInformation information = dimensionManager.getDimensionInformation(dim);
            information.setOwner(playerName, entityPlayerMP.getGameProfile().getId());
            ITextComponent component = new TextComponentString(TextFormatting.GREEN + "Owner of dimension changed!");
            if (sender instanceof EntityPlayer) {
                ((EntityPlayer) sender).sendStatusMessage(component, false);
            } else {
                sender.sendMessage(component);
            }
            dimensionManager.save(world);
            return;
        }
    }
    ITextComponent component = new TextComponentString(TextFormatting.RED + "Could not find player!");
    if (sender instanceof EntityPlayer) {
        ((EntityPlayer) sender).sendStatusMessage(component, false);
    } else {
        sender.sendMessage(component);
    }
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TextComponentString(net.minecraft.util.text.TextComponentString) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

ITextComponent (net.minecraft.util.text.ITextComponent)96 TextComponentString (net.minecraft.util.text.TextComponentString)54 EntityPlayer (net.minecraft.entity.player.EntityPlayer)26 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)25 ClickEvent (net.minecraft.util.text.event.ClickEvent)16 ItemStack (net.minecraft.item.ItemStack)11 Style (net.minecraft.util.text.Style)8 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 HoverEvent (net.minecraft.util.text.event.HoverEvent)7 World (net.minecraft.world.World)7 ArrayList (java.util.ArrayList)6 BlockPos (net.minecraft.util.math.BlockPos)6 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)5 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 Minecraft (net.minecraft.client.Minecraft)4 Text (org.spongepowered.api.text.Text)4 MagicBook (cavern.magic.MagicBook)3 SpecialMagic (cavern.magic.SpecialMagic)3 Matcher (java.util.regex.Matcher)3