Java Code Examples for net.minecraft.util.ChatComponentText

The following examples show how to use net.minecraft.util.ChatComponentText. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public void handleChat(String s) {
    if (s.toLowerCase().contains("reconnecting hyperium connection")) return;
    Hyperium.LOGGER.debug("Chat: {}", s);
    s = s.replace("&", C.COLOR_CODE_SYMBOL);
    IChatComponent chatComponent = new ChatComponentText("");

    Arrays.stream(s.split(" ")).forEach(s1 -> {
        ChatComponentText iChatComponents = new ChatComponentText(s1 + " ");
        if (s1.contains(".") && !s1.startsWith(".") && !s1.endsWith(".")) {
            ChatStyle chatStyle = new ChatStyle();
            chatStyle.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, s1.startsWith("http") ? s1 : "http://" + s1));
            iChatComponents.setChatStyle(chatStyle);
        }
        chatComponent.appendSibling(iChatComponents);
    });

    GeneralChatHandler.instance().sendMessage(chatComponent);
}
 
Example 2
Source Project: SkyblockAddons   Source File: Utils.java    License: MIT License 6 votes vote down vote up
public void sendMessage(String text, boolean prefix) {
    ClientChatReceivedEvent event = new ClientChatReceivedEvent((byte) 1, new ChatComponentText((prefix ? MESSAGE_PREFIX : "") + text));
    MinecraftForge.EVENT_BUS.post(event); // Let other mods pick up the new message
    if (!event.isCanceled()) {
        Minecraft.getMinecraft().thePlayer.addChatMessage(event.message); // Just for logs
    }
}
 
Example 3
public IChatComponent getDisplayName() {
    if (cachedName == null || System.currentTimeMillis() - lastChangeTime > 50L) {
        IChatComponent ichatcomponent = new ChatComponentText(ScorePlayerTeam
            .formatPlayerName(parent.getTeam(), displayName));
        ichatcomponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + parent.getName() + " "));
        //Unneeded for client
        if (Minecraft.getMinecraft().isIntegratedServerRunning()) {
            ichatcomponent.getChatStyle()
                .setChatHoverEvent(((IMixinEntity) parent).callGetHoverEvent());
        }
        ichatcomponent.getChatStyle().setInsertion(parent.getName());
        cachedName = ichatcomponent;
    }

    return cachedName;
}
 
Example 4
Source Project: mobycraft   Source File: StructureBuilder.java    License: Apache License 2.0 6 votes vote down vote up
private static void wrapSignText(String containerProperty,
		TileEntitySign sign) {
	if (containerProperty.length() < 14) {
		sign.signText[1] = new ChatComponentText(containerProperty);
	} else if (containerProperty.length() < 27) {
		sign.signText[1] = new ChatComponentText(
				containerProperty.substring(0, 13));
		sign.signText[2] = new ChatComponentText(
				containerProperty.substring(13, containerProperty.length()));
	} else {
		sign.signText[1] = new ChatComponentText(
				containerProperty.substring(0, 13));
		sign.signText[1] = new ChatComponentText(
				containerProperty.substring(13, 26));
		sign.signText[2] = new ChatComponentText(
				containerProperty.substring(26, containerProperty.length()));
	}
}
 
Example 5
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
	ItemStack stack = playerIn.getCurrentEquippedItem();
	if(stack != null)
	{
		if(stack.getItem() instanceof ItemCoordinateCache)
		{
			if(stack.getItem().hasEffect(stack))
			{
				TileEntityCoordTransporter tect = (TileEntityCoordTransporter) worldIn.getTileEntity(pos);
				stack.stackSize--;
				playerIn.addChatMessage(new ChatComponentText("Added cordinate cache to tile entity"));
			}
		}
	}
	return true;
}
 
Example 6
@SubscribeEvent
public void onBreak(BlockEvent.BreakEvent event) {
    if (!event.world.isRemote) {
        if (event.block == RegisteredBlocks.blockNodeManipulator) {
            TileEntity te = event.world.getTileEntity(event.x, event.y, event.z);
            if (te != null && te instanceof TileNodeManipulator) {
                if (((TileNodeManipulator) te).isInMultiblock())
                    ((TileNodeManipulator) te).breakMultiblock();
            }
        }
        if (event.block == RegisteredBlocks.blockStoneMachine && event.blockMetadata == 5) {
            TileAIShutdown.removeTrackedEntities(event.world, event.x, event.y, event.z);
        }
        if (event.world.provider.dimensionId == ModConfig.dimOuterId) {
            if(event.block == ConfigBlocks.blockEldritchNothing) {
                if(event.getPlayer().capabilities.isCreativeMode && MiscUtils.isANotApprovedOrMisunderstoodPersonFromMoreDoor(event.getPlayer())) return;
                event.setCanceled(true);
                event.getPlayer().addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + StatCollector.translateToLocal("gadomancy.eldritch.nobreakPortalNothing")));
            }
        }
    }
}
 
Example 7
@SubscribeEvent
public void on(LivingEvent.LivingUpdateEvent event) {
    if (event.entityLiving == null || !(event.entityLiving instanceof EntityPlayer)) return;
    EntityPlayer player = (EntityPlayer) event.entity;
    if ((event.entity.worldObj.provider.dimensionId == ModConfig.dimOuterId) && ((player.ticksExisted & 7) == 0) && ((player.capabilities.isFlying) || (Hover.getHover(player.getEntityId())))) {
        if(player.capabilities.isCreativeMode && MiscUtils.isANotApprovedOrMisunderstoodPersonFromMoreDoor(player)) return;
        player.capabilities.isFlying = false;
        Hover.setHover(player.getEntityId(), false);
        if (!((EntityPlayer) event.entityLiving).worldObj.isRemote) {
            String msg = StatCollector.translateToLocal("tc.break.fly");
            if (player.capabilities.isCreativeMode) {
                msg += " " + StatCollector.translateToLocal("gadomancy.eldritch.noflyCreative");
            }
            player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + msg));
        }
    }
}
 
Example 8
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
	ItemStack stack = playerIn.getCurrentEquippedItem();
	if(stack != null)
	{
		if(stack.getItem() instanceof ItemCoordinateCache)
		{
			if(stack.getItem().hasEffect(stack))
			{
				TileEntityCoordTransporter tect = (TileEntityCoordTransporter) worldIn.getTileEntity(pos);
				stack.stackSize--;
				playerIn.addChatMessage(new ChatComponentText("Added cordinate cache to tile entity"));
			}
		}
	}
	return true;
}
 
Example 9
Source Project: SkyblockAddons   Source File: Utils.java    License: MIT License 5 votes vote down vote up
public void sendMessage(ChatComponentText text, boolean prefix) {
    if (prefix) { // Add the prefix in front.
        ChatComponentText newText = new ChatComponentText(MESSAGE_PREFIX);
        newText.appendSibling(text);
        text = newText;
    }

    ClientChatReceivedEvent event = new ClientChatReceivedEvent((byte) 1, text);
    MinecraftForge.EVENT_BUS.post(event); // Let other mods pick up the new message
    if (!event.isCanceled()) {
        Minecraft.getMinecraft().thePlayer.addChatMessage(event.message); // Just for logs
    }
}
 
Example 10
Source Project: MediaMod   Source File: PlayerMessager.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void sendMessage(String message, boolean header) {
    if (message == null || Minecraft.getMinecraft().thePlayer == null) return;

    if (header) {
        Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(ChatColor.translateAlternateColorCodes('&',
                "&c[&fMediaMod&c]&r " + message)));
    } else {
        Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(ChatColor.translateAlternateColorCodes('&', message)));
    }
}
 
Example 11
/**
 * @author CCBlueX
 */
@Overwrite
protected void keyTyped(char typedChar, int keyCode) throws IOException {
    this.signCommand1.textboxKeyTyped(typedChar, keyCode);
    this.signCommand2.textboxKeyTyped(typedChar, keyCode);
    this.signCommand3.textboxKeyTyped(typedChar, keyCode);
    this.signCommand4.textboxKeyTyped(typedChar, keyCode);

    if(signCommand1.isFocused() || signCommand2.isFocused() || signCommand3.isFocused() || signCommand4.isFocused())
        return;

    if(keyCode == 200) {
        this.editLine = this.editLine - 1 & 3;
    }

    if(keyCode == 208 || keyCode == 28 || keyCode == 156) {
        this.editLine = this.editLine + 1 & 3;
    }

    String s = this.tileSign.signText[this.editLine].getUnformattedText();
    if(keyCode == 14 && s.length() > 0) {
        s = s.substring(0, s.length() - 1);
    }

    if((ChatAllowedCharacters.isAllowedCharacter(typedChar) || (enabled && typedChar == '§')) && this.fontRendererObj.getStringWidth(s + typedChar) <= 90) {
        s = s + typedChar;
    }

    this.tileSign.signText[this.editLine] = new ChatComponentText(s);
    if(keyCode == 1) {
        this.actionPerformed(this.doneBtn);
    }
}
 
Example 12
/**
 * @author CCBlueX
 */
@Overwrite
protected void keyTyped(char typedChar, int keyCode) throws IOException {
    this.signCommand1.textboxKeyTyped(typedChar, keyCode);
    this.signCommand2.textboxKeyTyped(typedChar, keyCode);
    this.signCommand3.textboxKeyTyped(typedChar, keyCode);
    this.signCommand4.textboxKeyTyped(typedChar, keyCode);

    if(signCommand1.isFocused() || signCommand2.isFocused() || signCommand3.isFocused() || signCommand4.isFocused())
        return;

    if(keyCode == 200) {
        this.editLine = this.editLine - 1 & 3;
    }

    if(keyCode == 208 || keyCode == 28 || keyCode == 156) {
        this.editLine = this.editLine + 1 & 3;
    }

    String s = this.tileSign.signText[this.editLine].getUnformattedText();
    if(keyCode == 14 && s.length() > 0) {
        s = s.substring(0, s.length() - 1);
    }

    if((ChatAllowedCharacters.isAllowedCharacter(typedChar) || (enabled && typedChar == '§')) && this.fontRendererObj.getStringWidth(s + typedChar) <= 90) {
        s = s + typedChar;
    }

    this.tileSign.signText[this.editLine] = new ChatComponentText(s);
    if(keyCode == 1) {
        this.actionPerformed(this.doneBtn);
    }
}
 
Example 13
Source Project: bartworks   Source File: BW_SimpleWindMeter.java    License: MIT License 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
    if (entityPlayer.worldObj.isRemote || world == null || WorldData.get(world) == null || WorldData.get(world).windSim == null)
        return itemStack;

    float windStrength = (float) WorldData.get(world).windSim.getWindAt(entityPlayer.posY);
    String windS = windStrength < 1f ? StatCollector.translateToLocal("tooltip.windmeter.2.name") : windStrength < 10f ? StatCollector.translateToLocal("tooltip.windmeter.3.name") : windStrength < 20f ? StatCollector.translateToLocal("tooltip.windmeter.4.name") : windStrength < 30f ? StatCollector.translateToLocal("tooltip.windmeter.5.name") : windStrength < 50f ? StatCollector.translateToLocal("tooltip.windmeter.6.name") : StatCollector.translateToLocal("tooltip.windmeter.7.name");
    entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip.windmeter.8.name") + " " + windS + "."));
    itemStack.damageItem(1, entityPlayer);
    return itemStack;
}
 
Example 14
public IChatComponent getDisplayName() {
    if (cachedName == null || System.currentTimeMillis() - nameCacheTime > 50L) {
        ChatComponentText chatcomponenttext = new ChatComponentText(parent.getName());
        //not needed otherwise
        if (Minecraft.getMinecraft().isIntegratedServerRunning())
            chatcomponenttext.getChatStyle().setChatHoverEvent(((IMixinEntity) parent).callGetHoverEvent());
        chatcomponenttext.getChatStyle().setInsertion(parent.getUniqueID().toString());
        cachedName = chatcomponenttext;
        nameCacheTime = System.currentTimeMillis();
    }
    return cachedName;
}
 
Example 15
Source Project: archimedes-ships   Source File: TileEntityHelm.java    License: MIT License 5 votes vote down vote up
public boolean mountShip(EntityPlayer player)
{
	if (!worldObj.isRemote)
	{
		if (assembleResult != null && assembleResult.isOK())
		{
			assembleResult.checkConsistent(worldObj);
			sendAssembleResult(player, false);
			if (assembleResult.getCode() == AssembleResult.RESULT_INCONSISTENT)
			{
				return false;
			}
			if (assembleResult.getCode() == AssembleResult.RESULT_OK_WITH_WARNINGS)
			{
				IChatComponent c = new ChatComponentText("Ship contains changes");
				player.addChatMessage(c);
			}
			
			EntityShip entity = assembleResult.getEntity(worldObj);
			if (entity != null)
			{
				entity.setInfo(info);
				if (worldObj.spawnEntityInWorld(entity))
				{
					player.mountEntity(entity);
					assembleResult = null;
					//entity.getCapabilities().mountEntity(entityplayer);
					return true;
				}
			}
		}
	}
	return false;
}
 
Example 16
@InvokeEvent
public void serverJoinEvent(ServerJoinEvent event) {
    if (asked) return; //If they were already asked, don't even make the new thread.
    UpdateUtils updateUtils = new UpdateUtils();
    Multithreading.runAsync(() -> {
        boolean latest = updateUtils.isAbsoluteLatest();
        boolean beta = updateUtils.isBeta();
        int version = Metadata.getVersionID();
        Hyperium.LOGGER.info("version is: " + version);
        if (beta) return; // dont alert beta users
        if (latest) return; //If they're on the latest version, I don't want to mess with them.

        Hyperium.INSTANCE.getNotification().display("You have an update pending.",
            "Click here to be sent to the installer.",
            10f,
            null, () -> {
                try {
                    Desktop.getDesktop().browse(new URI("https://hyperium.cc/downloads"));
                } catch (IOException | URISyntaxException e) {
                    IChatComponent urlComponent = new
                        ChatComponentText(ChatColor.RED + "[Hyperium] " +
                        ChatColor.GRAY + "Click to be sent to update Hyperium");
                    urlComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://hyperium.cc/downloads"));
                    Hyperium.INSTANCE.getHandlers().getGeneralChatHandler().sendMessage(urlComponent);
                }
            }, new Color(200, 150, 50));
        asked = true;
    });
}
 
Example 17
/**
 * Queues a message to be sent to the client. If the message is null, this will be ignored.
 *
 * @param message   the message to send to the client (can never be null)
 * @param addHeader if true, the message will show a Hyperium prefix before it
 */
public void sendMessage(String message, boolean addHeader) {
    if (message == null) return;

    if (addHeader) {
        message = Settings.HYPERIUM_CHAT_PREFIX ? ChatColor.RED + "[Hyperium] " + ChatColor.WHITE + message : ChatColor.WHITE + message;
    }

    sendMessage(new ChatComponentText(message));
}
 
Example 18
Source Project: ehacks-pro   Source File: KeybindCommand.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void process(String[] args) {
    if (args.length > 0) {
        Module smod = null;
        for (Module mod : ModuleController.INSTANCE.modules) {
            if (mod.getClass().getSimpleName().toLowerCase().replace(" ", "").equals(args[0])) {
                smod = mod;
            }
        }
        if (smod == null) {
            InteropUtils.log("&cNo such module '" + escape(args[0]) + "'", "Keybind");
            return;
        }
        if (args.length == 1) {
            smod.setKeybinding(0);
            InteropUtils.log("Keybinding cleared", "Keybind");
            ConfigurationManager.instance().saveConfigs();
            return;
        }
        if (Keyboard.getKeyIndex(args[1].toUpperCase()) == 0) {
            InteropUtils.log("&cNo such key '" + escape(args[1].toUpperCase()) + "'", "Keybind");
            return;
        }
        smod.setKeybinding(Keyboard.getKeyIndex(args[1].toUpperCase()));
        InteropUtils.log("Keybinding set", "Keybind");
        ConfigurationManager.instance().saveConfigs();
        return;
    }
    EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("\u00a7c/" + this.getName() + " " + this.getCommandArgs()));
}
 
Example 19
Source Project: ehacks-pro   Source File: HelpCommand.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void process(String[] args) {
    int mode = 0;
    int page = 0;
    if (args.length > 0) {
        if (CommandManager.INSTANCE.getCommand(args[0]) != null) {
            EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("\u00a7c/" + CommandManager.INSTANCE.getCommand(args[0]).getName() + " " + CommandManager.INSTANCE.getCommand(args[0]).getCommandArgs()));
            return;
        }
        try {
            if (mode == 0) {
                page = Integer.parseInt(args[0]);
                page--;
                if (page > CommandManager.INSTANCE.commands.size() / 6) {
                    EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.RED, "commands.generic.num.tooBig", page + 1, CommandManager.INSTANCE.commands.size() / 6 + 1));
                    return;
                }
                if (page < 0) {
                    EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.RED, "commands.generic.num.tooSmall", 1, 1));
                    return;
                }
            }
        } catch (Exception e) {
            EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.RED, "commands.generic.notFound"));
            return;
        }
    }
    String[] keys = CommandManager.INSTANCE.commands.keySet().toArray(new String[0]);
    EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.DARK_GREEN, "commands.help.header", page + 1, keys.length / 6 + 1));
    for (int i = page * 6; i < Math.min(page * 6 + 6, keys.length); i++) {
        EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("/" + keys[i] + " " + CommandManager.INSTANCE.commands.get(keys[i]).getCommandArgs() + " - " + CommandManager.INSTANCE.commands.get(keys[i]).getCommandDescription()));
    }
}
 
Example 20
Source Project: ehacks-pro   Source File: EHacksClickGui.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void log(String data, Object from) {
    if (from != null) {
        if (from instanceof Module) {
            data = "&7[&f" + ((Module) from).getName() + "&7] &e" + data;
        } else if (from instanceof String) {
            data = "&7[&f" + from + "&7] &e" + data;
        }
    }
    consoleGui.printChatMessage(new ChatComponentText(data.replace("&", "\u00a7").replace("\u00a7\u00a7", "&")));
}
 
Example 21
Source Project: mobycraft   Source File: MessageSender.java    License: Apache License 2.0 5 votes vote down vote up
public static void sendMessage(Object message) {
	if (sender != null) {
		sender.addChatMessage(new ChatComponentText(message.toString()));
	}
	else {
		System.out.println(message.toString());
	}
}
 
Example 22
@SuppressWarnings("unused")
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event)
{
    event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "=================================================="));
    event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Welcome to Gregtech:New Horizons " + EnumChatFormatting.GREEN + CoreModConfig.ModPackVersion) );
    event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Experimental recipe acceleration! Vanilla, Forestry Worktable, AE2." ));
    event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "May cause issues with oredicted wildcard recipes." ));
    event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + "Please bring comments to https://discord.gg/EXshrPV" ));
    event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "=================================================="));
}
 
Example 23
@Override
public void sendMessage(String msg) {
    for (String part : msg.split("\n")) {
        part = BBC.color(part);
        ChatComponentText component = new ChatComponentText(part);
        component.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE);
        this.parent.addChatMessage(component);
    }
}
 
Example 24
Source Project: SimplyJetpacks   Source File: PackBase.java    License: MIT License 5 votes vote down vote up
protected void toggleState(boolean on, ItemStack stack, String type, String tag, EntityPlayer player, boolean showInChat) {
    stack.stackTagCompound.setBoolean(tag, !on);
    
    if (player != null && showInChat) {
        String color = on ? StringHelper.LIGHT_RED : StringHelper.BRIGHT_GREEN;
        type = type != null && !type.equals("") ? "chat." + this.name + "." + type + ".on" : "chat." + this.name + ".on";
        String msg = SJStringHelper.localize(type) + " " + color + SJStringHelper.localize("chat." + (on ? "disabled" : "enabled"));
        player.addChatMessage(new ChatComponentText(msg));
    }
}
 
Example 25
@Override
public void sendMessage(String msg) {
    for (String part : msg.split("\n")) {
        part = BBC.color(part);
        ChatComponentText component = new ChatComponentText(part);
        component.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE);
        this.parent.addChatMessage(component);
    }
}
 
Example 26
public static void handleBossFinish(TCMazeSession session) {
    CellLoc spawnChunk = session.portalCell;
    WorldServer world = MinecraftServer.getServer().worldServerForDimension(ModConfig.dimOuterId);
    int lX = (spawnChunk.x << 4) + 8;
    int lZ = (spawnChunk.z << 4) + 8;
    world.setBlock(lX, 52, lZ, ConfigBlocks.blockEldritch, 3, 3);
    world.setBlock(lX, 53, lZ, RegisteredBlocks.blockAdditionalEldrichPortal);
    GenCommon.genObelisk(world, lX, 54, lZ);
    session.player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + StatCollector.translateToLocal("gadomancy.eldritch.portalSpawned")));
}
 
Example 27
Source Project: TickDynamic   Source File: CommandHandler.java    License: MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	if(args.length == 0)
	{
		sender.addChatMessage(new ChatComponentText("Usage: " + getCommandUsage(sender)));
		return;
	}
	
	if(args[0].equals("tps"))
	{
		
		sender.addChatMessage(new ChatComponentText("Average TPS: " + getTPSFormatted(mod) + " TPS"));
		return;
	} else if(args[0].equals("identify")) {
		sender.addChatMessage(new ChatComponentText("Command not yet implemented! This will allow you to check what group a Tile or Entity belongs to by right clicking it.(And other info, like TPS)"));
		return;
	} else if(args[0].equals("help")) {
		sender.addChatMessage(new ChatComponentText("You can find the documentation over at http://mods.stjerncraft.com/tickdynamic"));
		return;
	}
	
	//Send it over to subCommand handler
	ICommand subHandler = subCommandHandlers.get(args[0]);
	if(subHandler == null)
	{
		sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "No handler for the command " + EnumChatFormatting.ITALIC + args[0]));
		return;
	}
	subHandler.processCommand(sender, args);
}
 
Example 28
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) {
    if(!world.isRemote && player instanceof EntityPlayerMP) {
        Thaumcraft.addStickyWarpToPlayer(player, 1);
        player.addPotionEffect(getEffect(PotionFluxTaint.instance.id, 600, false));
        player.addPotionEffect(getEffect(Potion.hunger.id, 600, false));
        if(world.rand.nextFloat() < 0.4F){
            player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("warp.text.15")));
            player.addPotionEffect(getEffect(PotionThaumarhia.instance.id, 600, true));
        }
    }
    return super.onEaten(stack, world, player);
}
 
Example 29
Source Project: TickDynamic   Source File: CommandReload.java    License: MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	sender.addChatMessage(new ChatComponentText("Reloading configuration..."));
	sender.addChatMessage(new ChatComponentText("Note: Moving of (tile)entities to new groups might cause lag!"));
	mod.loadConfig(false);
	sender.addChatMessage(new ChatComponentText("Configuration reloaded!"));
}
 
Example 30
Source Project: archimedes-ships   Source File: CommandDisassembleShip.java    License: MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender icommandsender, String[] astring)
{
	if (icommandsender instanceof Entity)
	{
		Entity player = (Entity) icommandsender;
		if (player.ridingEntity instanceof EntityShip)
		{
			EntityShip ship = (EntityShip) player.ridingEntity;
			int mode = 0;
			if (astring != null && astring.length > 2)
			{
				if (astring[0].equals("overwrite") || astring[0].equals("override"))
				{
					icommandsender.addChatMessage(new ChatComponentText("Overwriting existing blocks with ship blocks"));
					mode = 1;
				} else if (astring[1].equals("drop"))
				{
					icommandsender.addChatMessage(new ChatComponentText("Dropping to items if rejoining ship with the world fails"));
					mode = 2;
				}
			} else
			{
				icommandsender.addChatMessage(new ChatComponentText("Trying to add ship blocks to world"));
			}
			
			if (!ship.disassemble(mode == 1))
			{
				if (mode == 2)
				{
					ship.dropAsItems();
				}
			}
			player.mountEntity(null);
			return;
		}
	}
	icommandsender.addChatMessage(new ChatComponentText("Not steering a ship"));
}