Java Code Examples for org.bukkit.Bukkit#getWorlds()
The following examples show how to use
org.bukkit.Bukkit#getWorlds() .
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: WorldPlayerCounterTask.java From HolographicDisplays with GNU General Public License v3.0 | 6 votes |
@Override public void run() { worlds.clear(); for (World world : Bukkit.getWorlds()) { List<Player> players = world.getPlayers(); int count = 0; for (Player player : players) { if (!player.hasMetadata("NPC")) { count++; } } worlds.put(world.getName(), count); } }
Example 2
Source File: GScoreboard.java From GlobalWarming with GNU Lesser General Public License v3.0 | 6 votes |
/** * Update the global score for all worlds */ private void updateGlobalScores() { for (World world : Bukkit.getWorlds()) { //Do not update worlds with disabled climate-engines: WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(world.getUID()); if (climateEngine != null && climateEngine.isEnabled()) { //Get the scoreboard for this world: Scoreboard scoreboard = getScoreboard(world.getUID(), false); //Get its objective (scoreboard title / group): Objective objective = null; if (scoreboard != null) { objective = scoreboard.getObjective(GLOBAL_WARMING); } //Update the title to show this world's temperature: if (objective != null) { double temperature = climateEngine.getTemperature(); objective.setDisplayName(climateEngine.formatTemp(temperature)); } } } }
Example 3
Source File: ImprovedOfflinePlayer.java From civcraft with GNU General Public License v2.0 | 6 votes |
private boolean loadPlayerData(String name) { try { this.player = name; for(World w : Bukkit.getWorlds()) { this.file = new File(w.getWorldFolder(), "players" + File.separator + this.player + ".dat"); if(this.file.exists()){ this.compound = NBTCompressedStreamTools.a(new FileInputStream(this.file)); this.player = this.file.getCanonicalFile().getName().replace(".dat", ""); return true; } } } catch(Exception e) { e.printStackTrace(); } return false; }
Example 4
Source File: ThreadService.java From Transport-Pipes with MIT License | 5 votes |
/** * does the same as tickDuctSpawnAndDespawn(Duct duct) but for all ducts in all worlds */ private void tickDuctSpawnAndDespawn() { synchronized (globalDuctManager.getDucts()) { for (World world : Bukkit.getWorlds()) { Map<BlockLocation, Duct> ductMap = globalDuctManager.getDucts(world); if (ductMap != null) { for (Duct duct : ductMap.values()) { tickDuctSpawnAndDespawn(duct); } } } } }
Example 5
Source File: CustomTimingsHandler.java From Thermos with GNU General Public License v3.0 | 5 votes |
/** * Prints the timings and extra data to the given stream. * * @param printStream */ public static void printTimings(PrintStream printStream) { printStream.println( "Minecraft" ); for ( CustomTimingsHandler timings : HANDLERS ) { long time = timings.totalTime; long count = timings.count; if ( count == 0 ) { continue; } long avg = time / count; printStream.println( " " + timings.name + " Time: " + time + " Count: " + count + " Avg: " + avg + " Violations: " + timings.violations ); } printStream.println( "# Version " + Bukkit.getVersion() ); int entities = 0; int livingEntities = 0; for ( World world : Bukkit.getWorlds() ) { entities += world.getEntities().size(); livingEntities += world.getLivingEntities().size(); } printStream.println( "# Entities " + entities ); printStream.println( "# LivingEntities " + livingEntities ); }
Example 6
Source File: SystemCommand.java From LagMonitor with MIT License | 5 votes |
private void displayWorldInfo(CommandSender sender) { int entities = 0; int chunks = 0; int livingEntities = 0; int tileEntities = 0; long usedWorldSize = 0; List<World> worlds = Bukkit.getWorlds(); for (World world : worlds) { for (Chunk loadedChunk : world.getLoadedChunks()) { tileEntities += loadedChunk.getTileEntities().length; } livingEntities += world.getLivingEntities().size(); entities += world.getEntities().size(); chunks += world.getLoadedChunks().length; File worldFolder = Bukkit.getWorld(world.getUID()).getWorldFolder(); usedWorldSize += LagUtils.getFolderSize(plugin.getLogger(), worldFolder.toPath()); } sendMessage(sender, "Entities", String.format("%d/%d", livingEntities, entities)); sendMessage(sender, "Tile Entities", String.valueOf(tileEntities)); sendMessage(sender, "Loaded Chunks", String.valueOf(chunks)); sendMessage(sender, "Worlds", String.valueOf(worlds.size())); sendMessage(sender, "World Size", readableBytes(usedWorldSize)); }
Example 7
Source File: EntityIdList.java From iDisguise with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
public static void init() { entityUIDs = new ConcurrentHashMap<Integer, UUID>(); playerNames = Maps.synchronizedBiMap(HashBiMap.<UUID, String>create()); entityTypes = new ConcurrentHashMap<UUID, EntityType>(); for(World world : Bukkit.getWorlds()) { for(LivingEntity livingEntity : world.getLivingEntities()) { addEntity(livingEntity); } } }
Example 8
Source File: Utils.java From AstralEdit with Apache License 2.0 | 5 votes |
/** * Returns online players. * * @return players */ public static List<Player> getOnlinePlayers() { final List<Player> players = new ArrayList<>(); for (final World world : Bukkit.getWorlds()) { players.addAll(world.getPlayers()); } return players; }
Example 9
Source File: ServerLoad.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onServerLoad(ServerLoadEvent event) { List<World> worlds = Bukkit.getWorlds(); for (int i = 0; i < worlds.size(); i++) { int period = (int) Math.round(sm.getCustomConfig().getDouble("task-delay") / worlds.size()) * (i == 0 ? 1 : i); new StackTask(sm, worlds.get(i)).runTaskTimer(sm, 100, period); } }
Example 10
Source File: RegionManager.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public long getCanPurgePlayer(String player, String world) { if (RedProtect.get().config.configRoot().purge.purge_limit_perworld) { return regionManagers.get(world).getCanPurgeCount(player, false); } else { long total = 0; for (World wr : Bukkit.getWorlds()) { total += regionManagers.get(wr.getName()).getCanPurgeCount(player, false); } return total; } }
Example 11
Source File: GlobalPVPModule.java From UHC with MIT License | 5 votes |
@Override public void onDisable() { for (final World world : Bukkit.getWorlds()) { if (worlds.worldMatches(world)) { world.setPVP(false); } } }
Example 12
Source File: PermanentSlowness.java From GlobalWarming with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void run() { for (World world : Bukkit.getWorlds()) { WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(world.getUID()); if (climateEngine != null && climateEngine.isEffectEnabled(ClimateEffectType.PERMANENT_SLOWNESS)) { for (Player player : world.getPlayers()) { updatePlayerSlowness(player, climateEngine.getTemperature()); } } } }
Example 13
Source File: SlimefunStartupTask.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Override public void run() { runnable.run(); // Load all items PostSetup.loadItems(); // Load all worlds SlimefunPlugin.getWorldSettingsService().load(Bukkit.getWorlds()); for (World world : Bukkit.getWorlds()) { try { new BlockStorage(world); } catch (Exception x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occured while trying to load World \"" + world.getName() + "\" for Slimefun v" + SlimefunPlugin.getVersion()); } } // Load all listeners that depend on items to be enabled if (isEnabled("ELEVATOR_PLATE", "GPS_ACTIVATION_DEVICE_SHARED", "GPS_ACTIVATION_DEVICE_PERSONAL")) { new TeleporterListener(plugin); } if (isEnabled("PROGRAMMABLE_ANDROID_BUTCHER", "PROGRAMMABLE_ANDROID_2_BUTCHER", "PROGRAMMABLE_ANDROID_3_BUTCHER")) { new ButcherAndroidListener(plugin); } if (isEnabled("ENERGY_REGULATOR", "CARGO_MANAGER")) { new NetworkListener(plugin, SlimefunPlugin.getNetworkManager()); } }
Example 14
Source File: NPCFactory.java From NPCFactory with MIT License | 5 votes |
/** * Get all npc's from all worlds. * * @return A list of all npc's */ public List<NPC> getNPCs() { List<NPC> npcList = new ArrayList<NPC>(); for(World world : Bukkit.getWorlds()) { npcList.addAll(getNPCs(world)); } return npcList; }
Example 15
Source File: TaxApplyTask.java From GriefDefender with MIT License | 4 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public void run() { if (this.economy == null) { this.economy = GriefDefenderPlugin.getInstance().getVaultProvider().getApi(); } for (World world : Bukkit.getWorlds()) { if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { continue; } GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(world.getUID()); ArrayList<Claim> claimList = (ArrayList<Claim>) new ArrayList<>(claimManager.getWorldClaims()); if (claimList.size() == 0) { return; } Iterator<GDClaim> iterator = ((ArrayList) claimList.clone()).iterator(); while (iterator.hasNext()) { GDClaim claim = iterator.next(); final GDPlayerData playerData = claim.getOwnerPlayerData(); if (claim.isWilderness()) { continue; } if (playerData == null) { continue; } if (!playerData.dataInitialized) { continue; } if (claim.isAdminClaim()) { // search for town final Set<Claim> children = claim.getChildren(false); for (Claim child : children) { if (child.isTown()) { handleTownTax((GDClaim) child, playerData); } else if (child.isBasicClaim()) { handleClaimTax((GDClaim) child, playerData, false); } } } else { if (claim.isTown()) { handleTownTax(claim, playerData); } else if (claim.isBasicClaim()){ handleClaimTax(claim, playerData, false); } } } } }
Example 16
Source File: DebugWorldCommand.java From civcraft with GNU General Public License v2.0 | 4 votes |
public void list_cmd() { CivMessage.sendHeading(sender, "Worlds"); for (World world : Bukkit.getWorlds()) { CivMessage.send(sender, world.getName()); } }
Example 17
Source File: NPCFactory.java From NPCFactory with MIT License | 4 votes |
/** * Despawn all npc's on all worlds. */ public void despawnAll() { for(World world : Bukkit.getWorlds()) { despawnAll(world); } }
Example 18
Source File: RegionManager.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public void loadAll() throws Exception { for (World w : Bukkit.getWorlds()) { load(w.getName()); } }
Example 19
Source File: ChunkCoord.java From civcraft with GNU General Public License v2.0 | 4 votes |
public static void buildWorldList() { for (World world : Bukkit.getWorlds()) { worlds.put(world.getName(), world); } }
Example 20
Source File: DebugCommand.java From HolographicDisplays with GNU General Public License v3.0 | 4 votes |
@Override public void execute(CommandSender sender, String label, String[] args) throws CommandException { boolean foundAnyHologram = false; for (World world : Bukkit.getWorlds()) { Map<Hologram, HologramDebugInfo> hologramsDebugInfo = new HashMap<>(); for (Chunk chunk : world.getLoadedChunks()) { for (Entity entity : chunk.getEntities()) { NMSEntityBase nmsEntity = HolographicDisplays.getNMSManager().getNMSEntityBase(entity); if (nmsEntity == null) { continue; } Hologram ownerHologram = nmsEntity.getHologramLine().getParent(); HologramDebugInfo hologramDebugInfo = hologramsDebugInfo.computeIfAbsent(ownerHologram, mapKey -> new HologramDebugInfo()); if (nmsEntity.isDeadNMS()) { hologramDebugInfo.deadEntities++; } else { hologramDebugInfo.aliveEntities++; } } } if (!hologramsDebugInfo.isEmpty()) { foundAnyHologram = true; sender.sendMessage(Colors.PRIMARY + "Holograms in world '" + world.getName() + "':"); for (Entry<Hologram, HologramDebugInfo> entry : hologramsDebugInfo.entrySet()) { Hologram hologram = entry.getKey(); String displayName = getHologramDisplayName(hologram); HologramDebugInfo debugInfo = entry.getValue(); sender.sendMessage(Colors.PRIMARY_SHADOW + "- '" + displayName + "': " + hologram.size() + " lines, " + debugInfo.getTotalEntities() + " entities (" + debugInfo.aliveEntities + " alive, " + debugInfo.deadEntities + " dead)"); } } } if (!foundAnyHologram) { sender.sendMessage(Colors.ERROR + "Couldn't find any loaded hologram (holograms may be in unloaded chunks)."); } }