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