public static void writeChatMessage(EntityPlayer player, String translationKey, TextFormatting color) { TextComponentTranslation component = new TextComponentTranslation(translationKey); component.getStyle().setColor(color); player.sendMessage(component); }
@SubscribeEvent public void onPlayerLogout(PlayerLoggedOutEvent event) { World logoutWorld = event.player.world; List<EntityPlayer> players = logoutWorld.playerEntities; if(players.size() == 1) { EntityPlayer lastPlayer = players.get(0); if(lastPlayer.getEntityData().getBoolean(TAG_AFK)) { lastPlayer.getEntityData().setBoolean(TAG_AFK, false); TextComponentTranslation text = new TextComponentTranslation("quarkmisc.leftAfk"); text.getStyle().setColor(TextFormatting.AQUA); lastPlayer.sendMessage(text); } } }
componentTranslation1.getStyle().setColor(TextFormatting.DARK_GREEN); sender.sendMessage(componentTranslation1); ICommand icommand1 = list.get(l); TextComponentTranslation componentTranslation = new TextComponentTranslation(icommand1.getUsage(sender)); componentTranslation.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getName() + " ")); sender.sendMessage(componentTranslation);
public static void updateAfk(EntityPlayer player, boolean afk) { if(!enableAfk) return; if(player.world.playerEntities.size() != 1) { if(afk) { player.getEntityData().setBoolean(TAG_AFK, true); TextComponentTranslation text = new TextComponentTranslation("quarkmisc.nowAfk"); text.getStyle().setColor(TextFormatting.AQUA); player.sendMessage(text); } else { player.getEntityData().setBoolean(TAG_AFK, false); TextComponentTranslation text = new TextComponentTranslation("quarkmisc.leftAfk"); text.getStyle().setColor(TextFormatting.AQUA); player.sendMessage(text); } } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { Entity entity = getTeleportedEntity(server, sender, args); EarthCapability earthData = entity.world.getCapability(TerrariumEarth.earthCap, null); if (earthData != null) { String argument = String.join(" ", args).replace(',', ' '); String[] locationInput = argument.split("\\s+"); Thread thread = new Thread(() -> { try { CommandLocation location = this.parseLocation(sender, locationInput); this.teleport(entity, location.getCoordinate(sender, earthData)); } catch (CommandException e) { TextComponentTranslation message = new TextComponentTranslation(e.getMessage(), e.getErrorObjects()); message.getStyle().setColor(TextFormatting.RED); sender.sendMessage(message); } }); thread.setDaemon(true); thread.start(); } else { throw DeferredTranslator.createException(entity, "commands.earth.wrong_world"); } }
if(sender != null){ chat = new TextComponentTranslation("message.you.have.outdated", outOfDateCount); chat.getStyle().setColor(TextFormatting.RED); sender.sendMessage(chat); chat = new TextComponentTranslation("message.type.to.view"); chat.getStyle().setColor(TextFormatting.RED).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/mud")); sender.sendMessage(chat); if(sender != null){ chat = new TextComponentTranslation("message.up.to.date"); chat.getStyle().setColor(TextFormatting.DARK_GREEN); sender.sendMessage(chat);
tc.getStyle().setUnderlined(true); tc.appendText("\n"); tc.appendSibling(new TextComponentString("\n" + color + cmd.getName() + " ")); TextComponentTranslation tt = new TextComponentTranslation(cmd.getCommandDescription(sender)); tt.getStyle().setColor(TextFormatting.GRAY); tt.getStyle().setUnderlined(false); tc.appendSibling(tt); tc.appendSibling(new TextComponentString("" + TextFormatting.RESET));
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { // We only count on the server side. if (side == state.getValue(FACING)) { int counter; if (hitY < .5f) { counter = getTE(world, pos).decrement(); } else { counter = getTE(world, pos).increment(); } TextComponentTranslation component = new TextComponentTranslation("message.modtut.counter_par", counter); component.getStyle().setColor(TextFormatting.GREEN); player.sendStatusMessage(component, false); } } // Return true also on the client to make sure that MC knows we handled this and will not try to place // a block on the client return true; }
@Override public void runCommand(MinecraftServer server, CommandBase command, ICommandSender sender, String[] args) throws CommandException { if(!server.isSinglePlayer() || !server.getServerOwner().equalsIgnoreCase(sender.getName())) { TextComponentTranslation cc = new TextComponentTranslation("commands.generic.permission"); cc.getStyle().setColor(TextFormatting.RED); sender.sendMessage(cc); return; } QuestSettings.INSTANCE.setProperty(NativeProps.HARDCORE, true); sender.sendMessage(new TextComponentTranslation("betterquesting.cmd.hardcore", new TextComponentTranslation("options.on"))); PacketSender.INSTANCE.sendToAll(QuestSettings.INSTANCE.getSyncPacket()); } }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(hand == EnumHand.OFF_HAND) { return new ActionResult(EnumActionResult.FAIL, stack); } if(world.provider.getDimension() != ConfigurationHandler.Settings.dimensionId) { player.openGui(CompactMachines3.instance, GuiIds.PSD_GUIDE.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); return new ActionResult(EnumActionResult.SUCCESS, stack); } if(!world.isRemote && world.provider.getDimension() == ConfigurationHandler.Settings.dimensionId && player instanceof EntityPlayerMP) { EntityPlayerMP serverPlayer = (EntityPlayerMP)player; if(player.isSneaking()) { int coords = StructureTools.getCoordsForPos(player.getPosition()); Vec3d pos = player.getPositionVector(); WorldSavedDataMachines.INSTANCE.addSpawnPoint(coords, pos.x, pos.y, pos.z); TextComponentTranslation tc = new TextComponentTranslation("item.compactmachines3.psd.spawnpoint_set"); tc.getStyle().setColor(TextFormatting.GREEN); player.sendStatusMessage(tc, false); return new ActionResult(EnumActionResult.SUCCESS, stack); } TeleportationTools.teleportPlayerOutOfMachine(serverPlayer); return new ActionResult(EnumActionResult.SUCCESS, stack); } return new ActionResult(EnumActionResult.FAIL, stack); }