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);
}
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);
}
}
}
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;
}
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));
}
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);
}
Aggregations