Search in sources :

Example 46 with Style

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

the class WindowTownHall method teleportToColony.

/**
 * On Button click teleport to the colony..
 *
 * @param button the clicked button.
 */
private void teleportToColony(@NotNull final Button button) {
    final int row = alliesList.getListElementIndexByPane(button);
    final ColonyView ally = allies.get(row);
    final ITextComponent teleport = new TextComponentString(LanguageHandler.format(DO_REALLY_WANNA_TP, ally.getName())).setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, TELEPORT_COMMAND + ally.getID())));
    Minecraft.getMinecraft().player.sendMessage(teleport);
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 47 with Style

use of net.minecraft.util.text.Style in project Minestuck by mraof.

the class SkaianetHandler method requestInfo.

public static void requestInfo(EntityPlayer player, PlayerIdentifier p1) {
    checkData();
    PlayerIdentifier p0 = IdentifierHandler.encode(player);
    PlayerIdentifier[] s = infoToSend.get(p0);
    if (s == null) {
        Debug.error("[SKAIANET] Something went wrong with player \"" + player.getName() + "\"'s skaianet data!");
        return;
    }
    UserListOpsEntry opsEntry = player.getServer().getPlayerList().getOppedPlayers().getEntry(player.getGameProfile());
    if (MinestuckConfig.privateComputers && !p0.equals(p1) && !(opsEntry != null && opsEntry.getPermissionLevel() >= 2)) {
        player.sendMessage(new TextComponentString("[Minestuck] ").setStyle(new Style().setColor(TextFormatting.RED)).appendSibling(new TextComponentTranslation("message.privateComputerMessage")));
        return;
    }
    int i = 0;
    for (; i < s.length; i++) {
        if (s[i] == null)
            break;
        if (s[i].equals(p1)) {
            Debug.warnf("[Skaianet] Player %s already got the requested data.", player.getName());
            // Update anyway, to fix whatever went wrong
            updatePlayer(p0);
            return;
        }
    }
    if (// If the array is full, increase size with 5.
    i == s.length) {
        PlayerIdentifier[] newS = new PlayerIdentifier[s.length + 5];
        System.arraycopy(s, 0, newS, 0, s.length);
        s = newS;
        infoToSend.put(p0, s);
    }
    s[i] = p1;
    updatePlayer(p0);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Style(net.minecraft.util.text.Style) PlayerIdentifier(com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier) UserListOpsEntry(net.minecraft.server.management.UserListOpsEntry) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 48 with Style

use of net.minecraft.util.text.Style in project Minestuck by mraof.

the class SburbHandler method predefineTitleLandAspect.

public static void predefineTitleLandAspect(MinecraftServer server, ICommandSender sender, ICommand command, String playerName, String sessionName, TitleLandAspect aspect) throws CommandException {
    PlayerIdentifier identifier = predefineCheck(server, sender, playerName, sessionName);
    Session session = sessionsByName.get(sessionName);
    SburbConnection clientConnection = SkaianetHandler.getClientConnection(identifier);
    PredefineData data = session.predefinedPlayers.get(identifier);
    if (clientConnection != null && clientConnection.enteredGame())
        throw new CommandException("You can't change your land aspects after having entered the medium.");
    if (sender.sendCommandFeedback())
        if (data.title == null)
            sender.sendMessage(new TextComponentString("Beware that the title generated might not be suited for this land aspect.").setStyle(new Style().setColor(TextFormatting.YELLOW)));
        else if (!LandAspectRegistry.containsTitleLandAspect(data.title.getHeroAspect(), aspect))
            sender.sendMessage(new TextComponentString("Beware that the title predefined isn't suited for this land aspect.").setStyle(new Style().setColor(TextFormatting.YELLOW)));
    if (data.landTerrain != null && !aspect.isAspectCompatible(data.landTerrain)) {
        data.landTerrain = null;
        if (sender.sendCommandFeedback())
            sender.sendMessage(new TextComponentString("The terrain aspect previously chosen isn't compatible with this land aspect, and has therefore been removed.").setStyle(new Style().setColor(TextFormatting.YELLOW)));
    }
    data.landTitle = aspect;
    CommandBase.notifyCommandListener(sender, command, "commands.sburbSession.landTitleSuccess", playerName, aspect.getPrimaryName());
}
Also used : Style(net.minecraft.util.text.Style) CommandException(net.minecraft.command.CommandException) PlayerIdentifier(com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 49 with Style

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

the class CheckForAutoDeletesCommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, final boolean confirmDelete) throws CommandException {
    if (sender instanceof EntityPlayer && !isPlayerOpped(sender)) {
        sender.sendMessage(new TextComponentString("Must be OP to use command"));
        return;
    } else if (sender instanceof TileEntity) {
        return;
    }
    final List<Colony> colonies = ColonyManager.getColonies();
    final List<Colony> coloniesToDelete = new ArrayList<>();
    for (int index = 0; colonies.size() - 1 >= index; index++) {
        final Colony colony = colonies.get(index);
        if (colony.canBeAutoDeleted() && Configurations.gameplay.autoDeleteColoniesInHours != 0 && colony.getLastContactInHours() >= Configurations.gameplay.autoDeleteColoniesInHours) {
            coloniesToDelete.add(colony);
        }
    }
    if (confirmDelete) {
        sender.sendMessage(new TextComponentString("Successful"));
        for (final Colony col : coloniesToDelete) {
            server.addScheduledTask(() -> ColonyManager.deleteColony(col.getID(), Configurations.gameplay.autoDestroyColonyBlocks));
        }
    } else {
        final ITextComponent deleteButton = new TextComponentString("[DELETE]").setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, COMMAND_CHECK_FOR_AUTODELETES)));
        sender.sendMessage(new TextComponentString("There are: " + coloniesToDelete.size() + " of a total of " + colonies.size() + " to delete."));
        sender.sendMessage(new TextComponentString("Click [DELETE] to confirm"));
        sender.sendMessage(deleteButton);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ClickEvent(net.minecraft.util.text.event.ClickEvent) ArrayList(java.util.ArrayList) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Colony(com.minecolonies.coremod.colony.Colony) Style(net.minecraft.util.text.Style) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 50 with Style

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

the class DeleteColonyCommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, final Colony colony, final boolean canDestroy, final boolean confirmDelete) throws CommandException {
    if (!confirmDelete) {
        final ITextComponent deleteButton = new TextComponentString("[DELETE]").setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format(DELETE_COLONY_CONFIRM_DELETE_COMMAND_SUGGESTED, colony.getID(), canDestroy ? "true" : "false"))));
        sender.sendMessage(new TextComponentString("Click [DELETE] to confirm the deletion of colony: " + colony.getID()));
        sender.sendMessage(deleteButton);
        return;
    }
    final Entity senderEntity = sender.getCommandSenderEntity();
    if (senderEntity instanceof EntityPlayer) {
        final EntityPlayer player = (EntityPlayer) sender;
        if (!canPlayerUseCommand(player, DELETECOLONY, colony.getID())) {
            senderEntity.sendMessage(new TextComponentString(NOT_PERMITTED));
            return;
        }
    }
    final boolean shouldDestroy = canDestroy;
    // TODO: pass in sender and notify when the delete task finishes.
    server.addScheduledTask(() -> ColonyManager.deleteColony(colony.getID(), shouldDestroy));
    senderEntity.sendMessage(new TextComponentString(DELETE_COLONY_TASK_SCHEDULED));
}
Also used : Entity(net.minecraft.entity.Entity) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

Style (net.minecraft.util.text.Style)51 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)30 TextComponentString (net.minecraft.util.text.TextComponentString)21 ITextComponent (net.minecraft.util.text.ITextComponent)17 ClickEvent (net.minecraft.util.text.event.ClickEvent)10 BlockPos (net.minecraft.util.math.BlockPos)9 CommandException (net.minecraft.command.CommandException)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ItemStack (net.minecraft.item.ItemStack)4 World (net.minecraft.world.World)4 Colony (com.minecolonies.coremod.colony.Colony)3 PlayerIdentifier (com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 GameProfile (com.mojang.authlib.GameProfile)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 HoverEvent (net.minecraft.util.text.event.HoverEvent)2 Biome (net.minecraft.world.biome.Biome)2 FluidStack (net.minecraftforge.fluids.FluidStack)2