codechicken.lib.util.ServerUtils Java Examples
The following examples show how to use
codechicken.lib.util.ServerUtils.
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: NEIServerConfig.java From NotEnoughItems with MIT License | 6 votes |
/** * Checks if a player is in the specified list. * * @param playerName The players name. * @param list The list of players. * @param allowCards Allows some wild cars when checking, Specifically, OP, Server Owner, and the "ALL" user. * @return If the player is in the list. */ public static boolean isPlayerInList(String playerName, Set<String> list, boolean allowCards) { if (playerName.equals("CONSOLE")) { return list.contains(playerName); } playerName = playerName.toLowerCase(); if (allowCards) { if (list.contains("ALL")) { return true; } if ((ServerUtils.isPlayerOP(playerName) || ServerUtils.isPlayerOwner(playerName)) && list.contains("OP")) { return true; } } return list.contains(playerName); }
Example #2
Source File: NEIServerUtils.java From NotEnoughItems with MIT License | 6 votes |
public static void sendNotice(ICommandSender sender, ITextComponent msg, String permission) { TextComponentTranslation notice = new TextComponentTranslation("chat.type.admin", sender.getName(), msg.createCopy()); notice.getStyle().setColor(TextFormatting.GRAY).setItalic(true); if (NEIServerConfig.canPlayerPerformAction("CONSOLE", permission)) { ServerUtils.mc().sendMessage(notice); } for (EntityPlayer p : ServerUtils.getPlayers()) { if (p == sender) { p.sendMessage(msg); } else if (NEIServerConfig.canPlayerPerformAction(p.getName(), permission)) { p.sendMessage(notice); } } }
Example #3
Source File: EnderItemStorage.java From EnderStorage with MIT License | 5 votes |
public void openContainer(ServerPlayerEntity player, ITextComponent title) { ServerUtils.openContainer(player, new SimpleNamedContainerProvider((id, inv, p) -> new ContainerEnderItemStorage(id, inv, EnderItemStorage.this), title),// packet -> { freq.writeToPacket(packet); packet.writeByte(size); }); }
Example #4
Source File: PacketCustom.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static void sendToOps(IPacket<?> packet) { OpList opList = ServerUtils.getServer().getPlayerList().getOppedPlayers(); for (ServerPlayerEntity player : ServerUtils.getServer().getPlayerList().getPlayers()) { if (opList.hasEntry(player.getGameProfile())) { sendToPlayer(packet, player); } } }
Example #5
Source File: NEIServerConfig.java From NotEnoughItems with MIT License | 5 votes |
public static void load(World world) { if (ServerUtils.mc() != server) { LogHelper.debug("Loading NEI Server"); server = ServerUtils.mc(); saveDir = new File(DimensionManager.getCurrentSaveRootDirectory(), "NEI"); dimTags.clear(); loadConfig(); loadBannedItems(); } loadWorld(world); }
Example #6
Source File: NEIServerPacketHandler.java From NotEnoughItems with MIT License | 5 votes |
private void openEnchantmentGui(EntityPlayerMP player) { ServerUtils.openSMPContainer(player, new ContainerEnchantmentModifier(player.inventory, player.world), (player1, windowId) -> { PacketCustom packet = new PacketCustom(channel, 21); packet.writeByte(windowId); packet.sendToPlayer(player1); }); }
Example #7
Source File: NEIServerPacketHandler.java From NotEnoughItems with MIT License | 5 votes |
private void openPotionGui(EntityPlayerMP player, PacketCustom packet) { InventoryBasic b = new InventoryBasic("potionStore", true, 9); for (int i = 0; i < b.getSizeInventory(); i++) { b.setInventorySlotContents(i, packet.readItemStack()); } ServerUtils.openSMPContainer(player, new ContainerPotionCreator(player.inventory, b), (player1, windowId) -> { PacketCustom packet1 = new PacketCustom(channel, 24); packet1.writeByte(windowId); packet1.sendToPlayer(player1); }); }
Example #8
Source File: PlayerSave.java From NotEnoughItems with MIT License | 5 votes |
public PlayerSave(EntityPlayerMP player, File saveLocation) { this.player = player; wasOp = ServerUtils.mc().getPlayerList().canSendCommands(player.getGameProfile()); saveFile = new File(saveLocation, player.getName() + ".dat"); if (!saveFile.getParentFile().exists()) { saveFile.getParentFile().mkdirs(); } load(); }
Example #9
Source File: PlayerSave.java From NotEnoughItems with MIT License | 5 votes |
public void updateOpChange() { boolean isOp = ServerUtils.mc().getPlayerList().canSendCommands(player.getGameProfile()); if (isOp != wasOp) { NEIServerPacketHandler.sendServerSideCheck(player); wasOp = isOp; } }
Example #10
Source File: NEIServerUtils.java From NotEnoughItems with MIT License | 5 votes |
public static void toggleRaining(World world, boolean notify) { boolean raining = !world.isRaining(); if (!raining)//turn off { ((WorldServer) world).provider.resetRainAndThunder(); } else { world.getWorldInfo().setRaining(!isRaining(world)); } if (notify) { ServerUtils.sendChatToAll(new TextComponentTranslation("nei.chat.rain." + (raining ? "on" : "off"))); } }
Example #11
Source File: NEIServerUtils.java From NotEnoughItems with MIT License | 5 votes |
public static void setHourForward(World world, int hour, boolean notify) { long day = (getTime(world) / 24000L) * 24000L; long newTime = day + 24000L + hour * 1000; setTime(newTime, world); if (notify) { ServerUtils.sendChatToAll(new TextComponentTranslation("nei.chat.time", getTime(world) / 24000L, hour)); } }
Example #12
Source File: TankSynchroniser.java From EnderStorage with MIT License | 4 votes |
@SubscribeEvent public void onWorldUnload(WorldEvent.Unload event) { if (!event.getWorld().isRemote() && !ServerUtils.getServer().isServerRunning()) { playerItemTankStates = null; } }
Example #13
Source File: PacketCustom.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public static void sendToClients(IPacket<?> packet) { ServerUtils.getServer().getPlayerList().sendPacketToAllPlayers(packet); }
Example #14
Source File: PacketCustom.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public static void sendToAllAround(IPacket<?> packet, double x, double y, double z, double range, DimensionType dim) { ServerUtils.getServer().getPlayerList().sendToAllNearExcept(null, x, y, z, range, dim, packet); }
Example #15
Source File: PacketCustom.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public static void sendToDimension(IPacket<?> packet, DimensionType dim) { ServerUtils.getServer().getPlayerList().sendPacketToAllPlayersInDimension(packet, dim); }