net.minecraft.util.text.TextComponentString Java Examples
The following examples show how to use
net.minecraft.util.text.TextComponentString.
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 check out the related API usage on the sidebar.
Example #1
Source File: BlockSurfaceRockNew.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public List<ITextComponent> getMagnifyResults(IBlockAccess world, BlockPos pos, IBlockState blockState, EntityPlayer player) { TileEntitySurfaceRock tileEntity = getTileEntity(world, pos); if (tileEntity == null) { return Collections.emptyList(); } List<Material> materials = tileEntity.getUndergroundMaterials(); ITextComponent materialComponent = new TextComponentTranslation(tileEntity.getMaterial().getUnlocalizedName()); materialComponent.getStyle().setColor(TextFormatting.GREEN); ITextComponent baseComponent = new TextComponentString(""); ITextComponent separator = new TextComponentString(", "); separator.getStyle().setColor(TextFormatting.GRAY); for (int i = 0; i < materials.size(); i++) { ITextComponent extraComponent = new TextComponentTranslation(materials.get(i).getUnlocalizedName()); extraComponent.getStyle().setColor(TextFormatting.YELLOW); baseComponent.appendSibling(extraComponent); if (i + 1 != materials.size()) baseComponent.appendSibling(separator); } ArrayList<ITextComponent> result = new ArrayList<>(); result.add(new TextComponentTranslation("gregtech.block.surface_rock.material", materialComponent)); result.add(new TextComponentTranslation("gregtech.block.surface_rock.underground_materials", baseComponent)); return result; }
Example #2
Source File: GTCommandTeleport.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException { if (!IC2.platform.isOp(sender.getCommandSenderEntity().getUniqueID())) { sender.sendMessage(new TextComponentString(TextFormatting.RED + "You do not have permission to use this command")); return; } if (args.length < 1) { return; } String s = args[0]; int dim; try { dim = Integer.parseInt(s); } catch (NumberFormatException e) { sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error parsing dimension!")); return; } if (sender instanceof EntityPlayer) { GTCommandTeleporter.teleportToDimension((EntityPlayer) sender, dim, 0, 100, 0); } }
Example #3
Source File: CraftHumanEntity.java From Kettle with GNU General Public License v3.0 | 6 votes |
private void openCustomInventory(Inventory inventory, EntityPlayerMP player, String windowType) { if (player.connection == null) return; Container container = new CraftContainer(inventory, this.getHandle(), player.getNextWindowIdCB()); container = CraftEventFactory.callInventoryOpenEvent(player, container); if (container == null) return; String title = container.getBukkitView().getTitle(); int size = container.getBukkitView().getTopInventory().getSize(); // Special cases if (windowType.equals("minecraft:crafting_table") || windowType.equals("minecraft:anvil") || windowType.equals("minecraft:enchanting_table") ) { size = 0; } player.connection.sendPacket(new SPacketOpenWindow(container.windowId, windowType, new TextComponentString(title), size)); getHandle().inventoryContainer = container; getHandle().inventoryContainer.addListener(player); }
Example #4
Source File: EventsCommon.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SubscribeEvent() public void onPlayerSleepInBedEvent(PlayerSleepInBedEvent event) { EntityPlayer player = event.getEntityPlayer(); BlockPos pos = event.getPos(); Optional<PhysicsObject> physicsObject = ValkyrienUtils .getPhysicsObject(player.getEntityWorld(), pos); if (physicsObject.isPresent()) { if (player instanceof EntityPlayerMP) { EntityPlayerMP playerMP = (EntityPlayerMP) player; player.sendMessage(new TextComponentString("Spawn Point Set!")); player.setSpawnPoint(pos, true); event.setResult(SleepResult.NOT_POSSIBLE_HERE); } } }
Example #5
Source File: HelpCommand.java From seppuku with GNU General Public License v3.0 | 6 votes |
@Override public void exec(String input) { if (!this.clamp(input, 1, 1)) { this.printUsage(); return; } final int size = Seppuku.INSTANCE.getCommandManager().getCommandList().size(); final TextComponentString msg = new TextComponentString("\2477Commands [" + size + "]\247f "); for (int i = 0; i < size; i++) { final Command cmd = Seppuku.INSTANCE.getCommandManager().getCommandList().get(i); msg.appendSibling(new TextComponentString("\247a" + cmd.getDisplayName() + "\2477" + ((i == size - 1) ? "" : ", ")) .setStyle(new Style() .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("\2476" + cmd.getDesc() + "\247f") .appendSibling(new TextComponentString("\n" + cmd.getUsage())))))); } Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(msg); }
Example #6
Source File: AutoLog.java From ForgeHax with MIT License | 6 votes |
@SubscribeEvent public void onPacketRecieved(PacketEvent.Incoming.Pre event) { if (event.getPacket() instanceof SPacketSpawnPlayer) { if (disconnectOnNewPlayer.getAsBoolean()) { AutoReconnectMod.hasAutoLogged = true; // dont automatically reconnect UUID id = ((SPacketSpawnPlayer) event.getPacket()).getUniqueId(); NetworkPlayerInfo info = MC.getConnection().getPlayerInfo(id); String name = info != null ? info.getGameProfile().getName() : "(Failed) " + id.toString(); getNetworkManager() .closeChannel(new TextComponentString(name + " entered render distance")); disable(); } } }
Example #7
Source File: BlockSuperchest.java From YouTubeModdingTutorial with MIT License | 6 votes |
public static void toggleMultiBlock(World world, BlockPos pos, IBlockState state, EntityPlayer player) { // Form or break the multiblock if (!world.isRemote) { SuperchestPartIndex formed = state.getValue(FORMED); if (formed == SuperchestPartIndex.UNFORMED) { if (MultiBlockTools.formMultiblock(SuperchestMultiBlock.INSTANCE, world, pos)) { player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "Made a superchest!"), false); } else { player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Could not form superchest!"), false); } } else { if (!MultiBlockTools.breakMultiblock(SuperchestMultiBlock.INSTANCE, world, pos)) { player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Not a valid superchest!"), false); } } } }
Example #8
Source File: PortalFinderModule.java From seppuku with GNU General Public License v3.0 | 6 votes |
private void printPortalToChat(Vec3d portal) { final TextComponentString portalTextComponent = new TextComponentString("Portal found!"); String overworld = ""; String nether = ""; if (Minecraft.getMinecraft().player.dimension == 0) { // overworld overworld = String.format("Overworld: X: %s, Y: %s, Z: %s", (int) portal.x, (int) portal.y, (int) portal.z); nether = String.format("Nether: X: %s, Y: %s, Z: %s", (int) portal.x / 8, (int) portal.y, (int) portal.z / 8); } else if (Minecraft.getMinecraft().player.dimension == -1) { // nether overworld = String.format("Overworld: X: %s, Y: %s, Z: %s", (int) portal.x * 8, (int) portal.y, (int) portal.z * 8); nether = String.format("Nether: X: %s, Y: %s, Z: %s", (int) portal.x, (int) portal.y, (int) portal.z); } int playerDistance = (int) Minecraft.getMinecraft().player.getDistance(portal.x, portal.y, portal.z); String distance = ChatFormatting.GRAY + "" + playerDistance + "m away"; String hoverText = overworld + "\n" + nether + "\n" + distance; portalTextComponent.setStyle(new Style().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(hoverText)))); Seppuku.INSTANCE.logcChat(portalTextComponent); }
Example #9
Source File: EventsCommon.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onPlayerTickEvent(PlayerTickEvent event) { if (!event.player.world.isRemote) { EntityPlayerMP p = (EntityPlayerMP) event.player; double[] pos = lastPositions.computeIfAbsent(p, k -> new double[3]); try { if (pos[0] != p.posX || pos[2] != p.posZ) { // Player has moved if (Math.abs(p.posX) > 27000000 || Math.abs(p.posZ) > 27000000) { // Player is outside of world // border, tp them back p.attemptTeleport(pos[0], pos[1], pos[2]); p.sendMessage(new TextComponentString( "You can't go beyond 27000000 blocks because airships are stored there!")); } } } catch (NullPointerException e) { logger.warn("Nullpointer EventsCommon.java:onPlayerTickEvent"); } pos[0] = p.posX; pos[1] = p.posY; pos[2] = p.posZ; } }
Example #10
Source File: MixinNetHandlerPlayServer.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
/** * Fixes things such that when mods try to teleport players into the ship space, VS will either * redirect the teleport or block it. Looking at you SimpleTeleporters mod >:/ */ @Inject(method = "setPlayerLocation(DDDFFLjava/util/Set;)V", at = @At("HEAD"), cancellable = true) public void onSetPlayerLocation(double x, double y, double z, float yaw, float pitch, Set<SPacketPlayerPosLook.EnumFlags> relativeSet, CallbackInfo callbackInfo) { if (!redirectingSetPlayerLocation) { BlockPos pos = new BlockPos(x, y, z); // If the player is being teleported to ship space then we have to stop it. if (PhysicsChunkManager.isLikelyShipChunk(pos.getX() >> 4, pos.getZ() >> 4)) { callbackInfo.cancel(); redirectingSetPlayerLocation = true; World world = player.getEntityWorld(); Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysicsObject(world, pos); if (physicsObject.isPresent()) { Vector tpPos = new Vector(x, y, z); physicsObject.get() .getShipTransformationManager() .getCurrentTickTransform() .transform(tpPos, TransformType.SUBSPACE_TO_GLOBAL); // Now call this again with the transformed position. // player.sendMessage(new TextComponentString("Transformed the player tp from <" // + x + ":" + y + ":" + z + "> to" + tpPos)); thisAsNetHandler .setPlayerLocation(tpPos.X, tpPos.Y, tpPos.Z, yaw, pitch, relativeSet); } else { player.sendMessage(new TextComponentString( "Tried teleporting you to an unloaded ship; teleportation canceled.")); } redirectingSetPlayerLocation = false; } } }
Example #11
Source File: ToroQuestCommand.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
private void listCommand(EntityPlayer player, String[] args) throws CommandException { List<Province> provinces = CivilizationsWorldSaveData.get(player.world).getProvinces(); StringBuilder sb = new StringBuilder(); for (Province province : provinces) { sb.append(province.toString()).append("\n"); } player.sendMessage(new TextComponentString(sb.toString())); }
Example #12
Source File: BlockNetworkDisplay.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { TileEntity tile = worldIn.getTileEntity(pos); if (tile instanceof TileEntityNetworkDisplay) { TileEntityNetworkDisplay displayTile = (TileEntityNetworkDisplay) tile; Iterable<IVSNode> networkedObjects = displayTile.getNetworkedConnections(); List<IVSNode> connectedNodes = new ArrayList<IVSNode>(); Map<String, Integer> networkedClassTypeCounts = new HashMap<String, Integer>(); for (IVSNode node : networkedObjects) { connectedNodes.add(node); Class nodeClass = node.getParentTile().getClass(); String tileClassName = nodeClass.getSimpleName(); if (!networkedClassTypeCounts.containsKey(tileClassName)) { networkedClassTypeCounts.put(tileClassName, 0); } networkedClassTypeCounts .put(tileClassName, networkedClassTypeCounts.get(tileClassName) + 1); } playerIn.sendMessage(new TextComponentString( "Networked objects connected: " + connectedNodes.size())); playerIn.sendMessage(new TextComponentString( "Types of objects connected: " + networkedClassTypeCounts.toString())); } } return true; }
Example #13
Source File: WeaponHelper.java From Levels with GNU General Public License v2.0 | 5 votes |
public static void create(ItemStack stack, EntityPlayer player) { NBTTagCompound nbt = NBTHelper.loadStackNBT(stack); if (nbt != null) { Rarity rarity = Rarity.getRarity(nbt); Random rand = player.getEntityWorld().rand; if (rarity == Rarity.DEFAULT) { Rarity.setRarity(nbt, Rarity.getRandomRarity(nbt, rand)); // sets random rarity if (Rarity.getRarity(nbt) == Rarity.MYTHIC) { SPacketTitle packet = new SPacketTitle(SPacketTitle.Type.TITLE, new TextComponentString(TextFormatting.GOLD + "MYTHIC"), -1, 20, -1); EntityPlayerMP playermp = (EntityPlayerMP) player; playermp.connection.sendPacket(packet); Levels.network.sendTo(new PacketMythicSound(), (EntityPlayerMP) player); } if (Config.unlimitedDurability) { nbt.setInteger("Unbreakable", 1); // adds Unbreakable tag to item } Experience.setLevel(nbt, 1); nbt.setDouble("Multiplier", getWeightedMultiplier(Rarity.getRarity(nbt))); // adds a randomized multiplier to the item, weighted by rarity nbt.setInteger("HideFlags", 6); // hides Attribute Modifier and Unbreakable tags setAttributeModifiers(nbt, stack); // sets up Attribute Modifiers NBTHelper.saveStackNBT(stack, nbt); } } }
Example #14
Source File: TileRocketLoader.java From AdvancedRocketry with MIT License | 5 votes |
@Override public boolean onLinkComplete(ItemStack item, TileEntity entity, EntityPlayer player, World world) { if(player.world.isRemote) Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage((new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.error.firstMachine")))); return false; }
Example #15
Source File: TileLandingPad.java From AdvancedRocketry with MIT License | 5 votes |
@Override public boolean onLinkComplete(ItemStack item, TileEntity entity, EntityPlayer player, World world) { TileEntity tile = world.getTileEntity(ItemLinker.getMasterCoords(item)); if(tile instanceof IInfrastructure) { HashedBlockPosition pos = new HashedBlockPosition(tile.getPos()); if(!blockPos.contains(pos)) { blockPos.add(pos); } AxisAlignedBB bbCache = new AxisAlignedBB(this.getPos().add(-1,0,-1), this.getPos().add(1,2,1)); List<EntityRocketBase> rockets = world.getEntitiesWithinAABB(EntityRocketBase.class, bbCache); for(EntityRocketBase rocket : rockets) { rocket.linkInfrastructure((IInfrastructure) tile); } if(!world.isRemote) { player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.success"))); if(tile instanceof IMultiblock) ((IMultiblock)tile).setMasterBlock(getPos()); } ItemLinker.resetPosition(item); return true; } return false; }
Example #16
Source File: CivilizationHandlers.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
public static TextComponentString enteringMessage(EntityPlayer player, Province province) { int rep = PlayerCivilizationCapabilityImpl.get(player).getReputation(province.civilization); String s; if (rep >= 10) { s = province.civilization.getFriendlyEnteringMessage(province); } else if (rep <= -10) { s = province.civilization.getHostileEnteringMessage(province); } else { s = province.civilization.getNeutralEnteringMessage(province); } return new TextComponentString(s); }
Example #17
Source File: CivilizationHandlers.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
public static TextComponentString leavingMessage(EntityPlayer player, Province province) { int rep = PlayerCivilizationCapabilityImpl.get(player).getReputation(province.civilization); String s; if (rep >= 10) { s = province.civilization.getFriendlyLeavingMessage(province); } else if (rep <= -10) { s = province.civilization.getHostileLeavingMessage(province); } else { s = province.civilization.getNeutralLeavingMessage(province); } return new TextComponentString(s); }
Example #18
Source File: TileSpaceElevator.java From AdvancedRocketry with MIT License | 5 votes |
@Override public boolean onLinkStart(ItemStack item, TileEntity entity, EntityPlayer player, World world) { ItemLinker.setMasterCoords(item, this.getPos()); ItemLinker.setDimId(item, world.provider.getDimension()); if(!world.isRemote) player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.program"))); return true; }
Example #19
Source File: GuiTextInput.java From ForgeHax with MIT License | 5 votes |
public void keyTyped(char typedChar, int keyCode) throws IOException { if (isActive) { switch (keyCode) { case Keyboard.KEY_ESCAPE: isActive = false; break; case Keyboard.KEY_RETURN: isActive = false; // setValue(input); MC.player.sendMessage(new TextComponentString(input.toString())); break; case Keyboard.KEY_BACK: if (selectedIndex > -1) { input.deleteCharAt(selectedIndex); selectedIndex--; } break; case Keyboard.KEY_LEFT: selectedIndex--; break; case Keyboard.KEY_RIGHT: selectedIndex++; break; default: if (isValidChar(typedChar)) { selectedIndex++; input.insert(selectedIndex, typedChar); } } selectedIndex = MathHelper.clamp(selectedIndex, -1, input.length() - 1); } }
Example #20
Source File: ForgePlayer.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
private void sendColorized(String msg, TextFormatting formatting) { for (String part : msg.split("\n")) { TextComponentString component = new TextComponentString(part); component.getStyle().setColor(formatting); this.player.addChatMessage(component); } }
Example #21
Source File: QuestMine.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
@Override public List<ItemStack> complete(QuestData data, List<ItemStack> in) { if (in == null) { return null; } List<ItemStack> givenItems = copyItems(in); int requiredLeft = getTargetAmount(data); boolean toolIncluded = false; for (ItemStack item : givenItems) { if (isForThisQuest(data, item)) { if (item.getItem() instanceof ItemTool) { toolIncluded = true; item.setCount(0); } else { requiredLeft -= item.getCount(); item.setCount(0); } } else { } } if (requiredLeft > 0) { data.getPlayer().sendMessage(new TextComponentString("You are " + requiredLeft + " short")); return null; } if (!toolIncluded) { data.getPlayer().sendMessage(new TextComponentString("You must turn in the tool that you were given")); return null; } givenItems = removeEmptyItemStacks(givenItems); addRewardItems(data, givenItems); return givenItems; }
Example #22
Source File: TileEntityMoniteringStation.java From AdvancedRocketry with MIT License | 5 votes |
@Override public boolean onLinkComplete(ItemStack item, TileEntity entity, EntityPlayer player, World world) { if(player.world.isRemote) Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage((new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.error.firstMachine")))); return false; }
Example #23
Source File: CommandFindBiome.java From Traverse-Legacy-1-12-2 with MIT License | 5 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { Biome biome = null; if (args.length == 0) { sender.sendMessage(new TextComponentString("No biome specified")); return; } for (Biome b : ForgeRegistries.BIOMES.getValues()) { String name = b.getRegistryName().toString().replaceAll(" ", "_").toLowerCase(); if (args[0].equalsIgnoreCase(name)) { biome = b; } } if (biome == null) { sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! Biome '" + args[0] + "' cannot be found!")); return; } long start = System.currentTimeMillis(); final Biome finalBiome = biome; new Thread(() -> { BlockPos pos = spiralOutwardsLookingForBiome(sender, sender.getEntityWorld(), finalBiome, sender.getPosition().getX(), sender.getPosition().getZ(), TraverseConfig.findBiomeCommandTimeout); if (pos == null) { server.addScheduledTask(() -> sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! Biome '" + args[0] + "' could not be found after " + TextFormatting.GRAY + TraverseConfig.findBiomeCommandTimeout + "ms" + TextFormatting.RED + "."))); return; } if (sender instanceof EntityPlayerMP) { server.addScheduledTask(() -> { EntityPlayerMP playerMP = (EntityPlayerMP) sender; playerMP.connection.setPlayerLocation(pos.getX(), 150, pos.getZ(), 0, 0); sender.sendMessage(new TextComponentString(TextFormatting.WHITE + "Found '" + finalBiome.getRegistryName().toString() + "' Biome! " + TextFormatting.GRAY + "(" + (System.currentTimeMillis() - start) + "ms)")); }); return; } server.addScheduledTask(() -> sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! An unknown error occurred."))); }, "Biome Finder - Traverse").start(); }
Example #24
Source File: CommandFindBiome.java From Traverse-Legacy-1-12-2 with MIT License | 5 votes |
public static BlockPos spiralOutwardsLookingForBiome(ICommandSender sender, World world, Biome biomeToFind, double startX, double startZ, int timeout) { double a = 16 / Math.sqrt(Math.PI); double b = 2 * Math.sqrt(Math.PI); double x; double z; double dist = 0; int n; long start = System.currentTimeMillis(); BlockPos.PooledMutableBlockPos pos = BlockPos.PooledMutableBlockPos.retain(); int previous = 0; int i = 0; for (n = 0; dist < Integer.MAX_VALUE; ++n) { if ((System.currentTimeMillis() - start) > timeout) { return null; } double rootN = Math.sqrt(n); dist = a * rootN; x = startX + (dist * Math.sin(b * rootN)); z = startZ + (dist * Math.cos(b * rootN)); pos.setPos(x, 0, z); if (sender instanceof EntityPlayer) { if (previous == 3) previous = 0; String s = (previous == 0 ? "." : previous == 1 ? ".." : "..."); ((EntityPlayer) sender).sendStatusMessage(new TextComponentString("Scanning" + s), true); if (i == 1501) { previous++; i = 0; } i++; } if (world.getBiome(pos).equals(biomeToFind)) { pos.release(); if (sender instanceof EntityPlayer) ((EntityPlayer) sender).sendStatusMessage(new TextComponentString("Found Biome"), true); return new BlockPos((int) x, 0, (int) z); } } return null; }
Example #25
Source File: TileEntityFuelingStation.java From AdvancedRocketry with MIT License | 5 votes |
@Override public boolean onLinkStart(ItemStack item, TileEntity entity, EntityPlayer player, World world) { ItemLinker.setMasterCoords(item, pos); if(this.linkedRocket != null) { this.linkedRocket.unlinkInfrastructure(this); this.unlinkRocket(); } if(player.world.isRemote) Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage((new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.fuelingStation.link") + ": " + this.pos.getX() + " " + this.pos.getY() + " " + this.pos.getZ()))); return true; }
Example #26
Source File: ChatMsgHandler.java From BakaDanmaku with MIT License | 5 votes |
/** * 发送普通弹幕 * * @param e 发送弹幕事件 */ @SubscribeEvent public static void receiveDanmaku(DanmakuEvent e) { EntityPlayer player = Minecraft.getMinecraft().player; Pattern readDanmakuUser = Pattern.compile(BakaDanmakuConfig.blockFunction.blockPlayer); // 屏蔽弹幕发送者 Pattern readDanmakuMsg = Pattern.compile(BakaDanmakuConfig.blockFunction.blockDanmaku); // 屏蔽弹幕关键词 // 先判定是否开启弹幕显示 if (player != null && BakaDanmakuConfig.chatMsg.showDanmaku) { // 获取弹幕信息 String msg = e.getMsg(); // 进行格式符消除,关键词屏蔽 if (BakaDanmakuConfig.blockFunction.blockFormatCode) { // 替换消除格式符,更有效的祛除格式符 msg = e.getMsg().replaceAll("(?:§(?=§*(\\1?+[0-9a-fk-or])))+\\1", ""); // 如果不为空,消除关键词 if (!BakaDanmakuConfig.blockFunction.blockKeyword.isEmpty()) msg = msg.replaceAll(BakaDanmakuConfig.blockFunction.blockKeyword, "*"); } // 进行指定玩家屏蔽,指定弹幕屏蔽 Matcher mUser = readDanmakuUser.matcher(e.getUser()); Matcher mMsg = readDanmakuMsg.matcher(msg); // 没找到,或者对应列表为空 if ((!mUser.find() || BakaDanmakuConfig.blockFunction.blockPlayer.isEmpty()) && (!mMsg.find() || BakaDanmakuConfig.blockFunction.blockDanmaku.isEmpty())) { player.sendMessage(new TextComponentString(String.format(BakaDanmakuConfig.chatMsg.danmakuStyle, e.getPlatform(), e.getUser(), msg))); } } }
Example #27
Source File: ItemWand.java From YouTubeModdingTutorial with MIT License | 5 votes |
public void toggleMode(EntityPlayer player, ItemStack stack) { WandMode mode = getMode(stack); if (mode == WandMode.SPHERE) { mode = WandMode.LEVITATE; } else { mode = WandMode.SPHERE; } player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "Switched to " + mode.name()), false); if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setInteger("mode", mode.ordinal()); }
Example #28
Source File: StandardPaperServerListPingEventImpl.java From Kettle with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") public static void processRequest(MinecraftServer server, NetworkManager networkManager) { StandardPaperServerListPingEventImpl event = new StandardPaperServerListPingEventImpl(server, networkManager, server.getServerStatusResponse()); server.server.getPluginManager().callEvent(event); // Close connection immediately if event is cancelled if (event.isCancelled()) { networkManager.closeChannel(null); return; } // Setup response ServerStatusResponse ping = new ServerStatusResponse(); // Description ping.setServerDescription(new TextComponentString(event.getMotd())); // Players if (!event.shouldHidePlayers()) { ping.setPlayers(new ServerStatusResponse.Players(event.getMaxPlayers(), event.getNumPlayers())); ping.getPlayers().setPlayers(event.getPlayerSampleHandle()); } // Version ping.setVersion(new ServerStatusResponse.Version(event.getVersion(), event.getProtocolVersion())); // Favicon if (event.getServerIcon() != null) { ping.setFavicon(event.getServerIcon().getData()); } // Send response networkManager.sendPacket(new SPacketServerInfo(ping)); }
Example #29
Source File: ServerEventHandler.java From HoloInventory with MIT License | 5 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onRightClick(PlayerInteractEvent.RightClickBlock event) { if (catchNext == Type.NONE) return; boolean ban = catchNext == Type.BAN; catchNext = Type.NONE; event.setCanceled(true); TileEntity te = event.getWorld().getTileEntity(event.getPos()); if (te == null) { event.getEntityPlayer().sendMessage(new TextComponentString("That block does not have a TileEntity.").setStyle(new Style().setColor(TextFormatting.RED))); return; } if (ban) { if (Helper.banned.add(te.getClass().getCanonicalName())) event.getEntityPlayer().sendMessage(new TextComponentString("Banned " + te.getClass().getCanonicalName()).setStyle(new Style().setColor(TextFormatting.GREEN))); else event.getEntityPlayer().sendMessage(new TextComponentString(te.getClass().getCanonicalName() + " is already banned.").setStyle(new Style().setColor(TextFormatting.RED))); } else { boolean wasBanned = Helper.banned.remove(te.getClass().getCanonicalName()); if (wasBanned) event.getEntityPlayer().sendMessage(new TextComponentString("Unbanned " + te.getClass().getCanonicalName()).setStyle(new Style().setColor(TextFormatting.GREEN))); else event.getEntityPlayer().sendMessage(new TextComponentString(te.getClass().getCanonicalName() + " is not banned. Perhaps it is banned on the " + (FMLCommonHandler.instance().getSide().isClient() ? "server" : "client") + "?").setStyle(new Style().setColor(TextFormatting.RED))); } HoloInventory.getInstance().saveBanned(); }
Example #30
Source File: CraftHumanEntity.java From Kettle with GNU General Public License v3.0 | 5 votes |
public void openInventory(InventoryView inventory) { if (!(getHandle() instanceof EntityPlayerMP)) return; // TODO: NPC support? if (((EntityPlayerMP) getHandle()).connection == null) return; if (getHandle().inventoryContainer != getHandle().inventoryContainer) { // fire INVENTORY_CLOSE if one already open ((EntityPlayerMP) getHandle()).connection.processCloseWindow(new CPacketCloseWindow(getHandle().inventoryContainer.windowId)); } EntityPlayerMP player = (EntityPlayerMP) getHandle(); Container container; if (inventory instanceof CraftInventoryView) { container = ((CraftInventoryView) inventory).getHandle(); } else { container = new CraftContainer(inventory, this.getHandle(), player.getNextWindowIdCB()); } // Trigger an INVENTORY_OPEN event container = CraftEventFactory.callInventoryOpenEvent(player, container); if (container == null) { return; } // Now open the window InventoryType type = inventory.getType(); String windowType = CraftContainer.getNotchInventoryType(type); String title = inventory.getTitle(); int size = inventory.getTopInventory().getSize(); player.connection.sendPacket(new SPacketOpenWindow(container.windowId, windowType, new TextComponentString(title), size)); player.inventoryContainer = container; player.inventoryContainer.addListener(player); }