Search in sources :

Example 6 with ClickEvent

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

the class RCTextStyle method sight.

public static ITextComponent sight(WorldStructureGenerationData.Entry entry, boolean useID) {
    TextComponentString forget = new TextComponentString("X");
    String uuidString = entry.getUuid().toString();
    forget.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s %s id %s", RCCommands.sight.getName(), RCCommands.sight.delete.getName(), uuidString)));
    forget.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.format("commands.rcforget.forget", uuidString)));
    forget.getStyle().setColor(TextFormatting.RED);
    ITextComponent name;
    if (useID)
        name = copy(entry.getUuid().toString());
    else {
        name = new TextComponentString(entry.description());
        name.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcsightinfo.lookup")));
        name.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s %s %s", RCCommands.sight.getName(), RCCommands.sight.info.getName(), entry.getUuid())));
    }
    name.getStyle().setColor(TextFormatting.AQUA);
    return new TextComponentTranslation("%s (%s)", name, forget);
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent)

Example 7 with ClickEvent

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

the class RCForgeEventHandler method onPlayerJoin.

@SubscribeEvent
public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
    if (RCConfig.postWorldStatus && event.player.canUseCommand(3, "op")) {
        WorldRandomData randomData = WorldRandomData.get(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld());
        if (randomData.postWorldStatus(event.player.getName())) {
            event.player.getServer().commandManager.executeCommand(event.player, RCCommands.sanity.getName() + " --silent --short");
            ITextComponent count = new TextComponentString("" + StructureRegistry.INSTANCE.activeIDs().size());
            count.getStyle().setColor(TextFormatting.AQUA);
            ITextComponent list = new TextComponentString("[List]");
            list.getStyle().setColor(TextFormatting.AQUA);
            list.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Show List")));
            list.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s", RCCommands.list.getName())));
            ITextComponent add = new TextComponentString("[Add]");
            add.getStyle().setColor(TextFormatting.GREEN);
            add.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Browse Repository")));
            add.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, Repository.browseURL()));
            ITextComponent remove = new TextComponentString("[Remove]");
            remove.getStyle().setColor(TextFormatting.RED);
            remove.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Disabling Structures")));
            remove.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, Wiki.DISABLING_STRUCTURES));
            ITextComponent help = new TextComponentString("[Help]");
            help.getStyle().setColor(TextFormatting.AQUA);
            help.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Open Wiki")));
            help.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, Wiki.HOME));
            ITextComponent statusMessage = ServerTranslations.format("reccomplex.server.status", count, list, add, remove, help);
            event.player.sendMessage(statusMessage);
        }
    }
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) WorldRandomData(ivorius.reccomplex.world.gen.feature.WorldRandomData) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with ClickEvent

use of net.minecraft.util.text.event.ClickEvent 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 9 with ClickEvent

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

the class CommandLookupStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    String id = parameters.get().first().require();
    GenericStructure structure = parameters.rc().genericStructure().require();
    Metadata metadata = structure.metadata;
    boolean hasWeblink = !metadata.weblink.trim().isEmpty();
    ITextComponent weblink = hasWeblink ? new TextComponentString(RCStrings.abbreviateFormatted(metadata.weblink, 30)) : ServerTranslations.format("commands.rclookup.reply.nolink");
    if (hasWeblink) {
        weblink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, metadata.weblink));
        weblink.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(metadata.weblink)));
    }
    ITextComponent level = new TextComponentString(StructureRegistry.INSTANCE.status(id).getLevel().toString());
    level.getStyle().setColor(TextFormatting.YELLOW);
    commandSender.sendMessage(ServerTranslations.format(StructureRegistry.INSTANCE.hasActive(id) ? "commands.rclookup.reply.generates" : "commands.rclookup.reply.silent", id, RCTextStyle.users(metadata.authors), level, weblink));
    if (!metadata.comment.trim().isEmpty())
        commandSender.sendMessage(ServerTranslations.format("commands.rclookup.reply.comment", metadata.comment));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) Metadata(ivorius.reccomplex.world.gen.feature.structure.generic.Metadata) ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 10 with ClickEvent

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

the class CommandListStructures method linkToPage.

public static void linkToPage(ITextComponent component, int page, ITextComponent hoverTitle) {
    component.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s %d", RCCommands.list.getName(), page)));
    component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverTitle));
    component.getStyle().setColor(TextFormatting.AQUA);
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent)

Aggregations

ClickEvent (net.minecraft.util.text.event.ClickEvent)21 HoverEvent (net.minecraft.util.text.event.HoverEvent)16 TextComponentString (net.minecraft.util.text.TextComponentString)9 ITextComponent (net.minecraft.util.text.ITextComponent)8 Nonnull (javax.annotation.Nonnull)7 Style (net.minecraft.util.text.Style)4 Colony (com.minecolonies.coremod.colony.Colony)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 BlockPos (net.minecraft.util.math.BlockPos)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 CitizenData (com.minecolonies.coremod.colony.CitizenData)1 IColony (com.minecolonies.coremod.colony.IColony)1 RCEntityInfo (ivorius.reccomplex.capability.RCEntityInfo)1 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)1 WorldRandomData (ivorius.reccomplex.world.gen.feature.WorldRandomData)1 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)1 Metadata (ivorius.reccomplex.world.gen.feature.structure.generic.Metadata)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1