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