org.bukkit.Bukkit#getWorlds ( )源码实例Demo

下面列出了org.bukkit.Bukkit#getWorlds ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GlobalWarming   文件: GScoreboard.java
/**
 * 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));
            }
        }
    }
}
 
源代码2 项目: civcraft   文件: ImprovedOfflinePlayer.java
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;
}
 
@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);
	}
}
 
源代码4 项目: NPCFactory   文件: NPCFactory.java
/**
 * 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;
}
 
源代码5 项目: Slimefun4   文件: SlimefunStartupTask.java
@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());
    }
}
 
源代码6 项目: GlobalWarming   文件: PermanentSlowness.java
@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());
            }
        }
    }
}
 
源代码7 项目: UHC   文件: GlobalPVPModule.java
@Override
public void onDisable() {
    for (final World world : Bukkit.getWorlds()) {
        if (worlds.worldMatches(world)) {
            world.setPVP(false);
        }
    }
}
 
源代码8 项目: RedProtect   文件: RegionManager.java
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;
    }
}
 
源代码9 项目: Transport-Pipes   文件: ThreadService.java
/**
 * 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);
                }
            }
        }
    }
}
 
源代码10 项目: StackMob-3   文件: ServerLoad.java
@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);
    }
}
 
源代码11 项目: AstralEdit   文件: Utils.java
/**
 * 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;
}
 
源代码12 项目: iDisguise   文件: EntityIdList.java
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);
		}
	}
}
 
源代码13 项目: LagMonitor   文件: SystemCommand.java
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));
}
 
源代码14 项目: Thermos   文件: CustomTimingsHandler.java
/**
 * 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 );
}
 
源代码15 项目: GriefDefender   文件: TaxApplyTask.java
@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);
                }
            }
        }
    }
}
 
源代码16 项目: HolographicDisplays   文件: DebugCommand.java
@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).");
	}
	
}
 
源代码17 项目: civcraft   文件: DebugWorldCommand.java
public void list_cmd() {
	CivMessage.sendHeading(sender, "Worlds");
	for (World world : Bukkit.getWorlds()) {
		CivMessage.send(sender, world.getName());
	}
}
 
源代码18 项目: NPCFactory   文件: NPCFactory.java
/**
 * Despawn all npc's on all worlds.
 */
public void despawnAll() {
    for(World world : Bukkit.getWorlds()) {
        despawnAll(world);
    }
}
 
源代码19 项目: RedProtect   文件: RegionManager.java
public void loadAll() throws Exception {
    for (World w : Bukkit.getWorlds()) {
        load(w.getName());
    }
}
 
源代码20 项目: civcraft   文件: ChunkCoord.java
public static void buildWorldList() {		
	for (World world : Bukkit.getWorlds()) {
		worlds.put(world.getName(), world);
	}	
}