當前位置: 首頁>>代碼示例>>Java>>正文


Java Bukkit.getWorlds方法代碼示例

本文整理匯總了Java中org.bukkit.Bukkit.getWorlds方法的典型用法代碼示例。如果您正苦於以下問題:Java Bukkit.getWorlds方法的具體用法?Java Bukkit.getWorlds怎麽用?Java Bukkit.getWorlds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Bukkit的用法示例。


在下文中一共展示了Bukkit.getWorlds方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadFile

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public void loadFile() {
	file = new PluginFile(main, "generators", FileType.YAML);
	for (World w : Bukkit.getWorlds()) {
		powerable.put(w.getName(), new ManyMap<>());
		generators.put(w.getName(), new ManyMap<>());
	}

	YamlConfiguration config = file.returnYaml();

	for (String locString : config.getStringList("gens")) {
		Location loc = StringUtilities.stringToLocation(locString);

		ManyMap<String, Location> mm = generators.get(loc.getWorld().getName());
		mm.addValue(loc.getChunk().getX() + ";" + loc.getChunk().getZ(), loc);
		generators.put(loc.getWorld().getName(), mm);

		for (Block bloc : getNearbyBlocks(loc.getBlock(), 15)) {
			Location ploc = bloc.getLocation();
			ManyMap<String, Location> pmm = powerable.get(ploc.getWorld().getName());
			pmm.addValue(ploc.getChunk().getX() + ";" + ploc.getChunk().getZ(), ploc);
			powerable.put(ploc.getWorld().getName(), pmm);
		}
	}

}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:26,代碼來源:GeneratorListener.java

示例2: execute

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public void execute() {
	Runtime runtime = Runtime.getRuntime();
	long i = runtime.maxMemory();
	long j = runtime.totalMemory();
	long k = runtime.freeMemory();
	long max = i / 1024L / 1024L;
	long total = j / 1024L / 1024L;
	long free = k / 1024L / 1024L;
	
	getSender().sendMessage(ChatColor.BLUE + "Worlds:");
	for (World w : Bukkit.getWorlds()) {
		getSender().sendMessage(ChatColor.BLUE + "World Name: " +ChatColor.WHITE + w.getName());
		getSender().sendMessage(ChatColor.BLUE + "Loaded Chunks: " +ChatColor.WHITE + w.getLoadedChunks().length);
		getSender().sendMessage(ChatColor.BLUE + "Loaded Entities: " +ChatColor.WHITE + w.getEntities().size());
	}
	getSender().sendMessage(ChatColor.BLUE + "--------------------------");
	getSender().sendMessage(ChatColor.BLUE + "Players: " + ChatColor.WHITE +  PlayerModule.getInstance().getPlayers().size());
	getSender().sendMessage(ChatColor.BLUE + "Maximum Memory: " +ChatColor.WHITE + max + " MB");
	getSender().sendMessage(ChatColor.BLUE + "Allocated Memory: " +ChatColor.WHITE + total + " MB");
	getSender().sendMessage(ChatColor.BLUE + "Free Memory: " +ChatColor.WHITE + free + " MB");
	getSender().sendMessage(ChatColor.BLUE + "TPS: " + colorTps(KingdomFactionsPlugin.getInstance().getTPS()));



}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:27,代碼來源:LagCommand.java

示例3: run

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public void run() {
	// 服務端卡頓超過了500ms就向所有在線玩家發送KeepAlive防止掉線
	long now = System.currentTimeMillis();
	if (now - this.lastTickTime >= 1000L) {
		// 安裝了ProtocoLib前置插件且間隔3秒才發送新的心跳包
		if (NeverLag.isInstallProtocoLib() && now - this.lastSendTime >= 3000L) {
			this.lastSendTime = now;
			// 兼容不同版本
			List<Player> onlinePlayer = new ArrayList<>();
			for (World world : Bukkit.getWorlds()) {
				onlinePlayer.addAll(world.getPlayers());
			}
			ProtocolUtils.sendKeepAlive(onlinePlayer);
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:18,代碼來源:WatchDog.java

示例4: printTimings

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * 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 );
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:32,代碼來源:CustomTimingsHandler.java

示例5: getOnlinePlayer

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private Player getOnlinePlayer(String name) {
    for (final World world : Bukkit.getWorlds()) {
        for (final Player player : world.getPlayers()) {
            if (player.getName().equals(name))
                return player;
        }
    }
    return null;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:10,代碼來源:PetBlockCommandExecutor.java

示例6: registerHolograms

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static void registerHolograms() {
	holograms.clear();
	for (World w : Bukkit.getWorlds()) {
		for (ArmorStand e : w.getEntitiesByClass(ArmorStand.class)) {
			if (e.getScoreboardTags().contains("hologram") && !e.getScoreboardTags().contains("dindicator")) {
				holograms.add(new Hologram(e));
				System.out.println("Hologram Init: " + e.getCustomName());
			}
			else if (e.getScoreboardTags().contains("dindicator")) {
				e.remove();
			}
		}
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:15,代碼來源:Hologram.java

示例7: WestRoadFaction

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public WestRoadFaction() {
    super("WestRoad");
    for (World world : Bukkit.getWorlds()) {
        World.Environment environment = world.getEnvironment();
        if (environment != World.Environment.THE_END) {
            int roadLength = SettingsYML.ROAD_LENGTHS.get(environment);
            int offset = SettingsYML.SPAWN_RADIUS_MAP.get(environment) + 1;
            addClaim(new Claim(this, new Location(world, -offset, ROAD_MIN_HEIGHT, ROAD_WIDTH_LEFT), new Location(world, -roadLength + ROAD_EDGE_DIFF, ROAD_MAX_HEIGHT, -ROAD_WIDTH_RIGHT)),
                    null);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:13,代碼來源:RoadFaction.java

示例8: getAllChunk

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private List<Chunk> getAllChunk() {
	List<Chunk> chunks = new ArrayList<>();
	for (World world : Bukkit.getWorlds()) {
		chunks.addAll(Arrays.asList(world.getLoadedChunks()));
	}
	return chunks;
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:8,代碼來源:CommandChunkInfo.java

示例9: EastRoadFaction

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public EastRoadFaction() {
    super("EastRoad");
    for (World world : Bukkit.getWorlds()) {
        World.Environment environment = world.getEnvironment();
        if (environment != World.Environment.THE_END) {
            int roadLength = SettingsYML.ROAD_LENGTHS.get(environment);
            int offset = SettingsYML.SPAWN_RADIUS_MAP.get(environment) + 1;
            addClaim(new Claim(this, new Location(world, offset, ROAD_MIN_HEIGHT, -ROAD_WIDTH_LEFT), new Location(world, roadLength - ROAD_EDGE_DIFF, ROAD_MAX_HEIGHT, ROAD_WIDTH_RIGHT)), null);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:12,代碼來源:RoadFaction.java

示例10: NorthRoadFaction

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public NorthRoadFaction() {
    super("NorthRoad");
    for (World world : Bukkit.getWorlds()) {
        World.Environment environment = world.getEnvironment();
        if (environment != World.Environment.THE_END) {
            int roadLength = SettingsYML.ROAD_LENGTHS.get(environment);
            int offset = SettingsYML.SPAWN_RADIUS_MAP.get(environment) + 1;
            addClaim(new Claim(this, new Location(world, -ROAD_WIDTH_LEFT, ROAD_MIN_HEIGHT, -offset), new Location(world, ROAD_WIDTH_RIGHT, ROAD_MAX_HEIGHT, -roadLength + ROAD_EDGE_DIFF)),
                    null);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:13,代碼來源:RoadFaction.java

示例11: getFirstPlayer

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private Player getFirstPlayer() {
    for (final World world : Bukkit.getWorlds()) {
        if (!world.getPlayers().isEmpty())
            return world.getPlayers().get(0);
    }
    return null;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:8,代碼來源:BungeeCordProvider.java

示例12: close

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * Closes this resource, relinquishing any underlying resources.
 * This method is invoked automatically on objects managed by the
 * {@code try}-with-resources statement.
 * @throws Exception if this resource cannot be closed
 */
@Override
public void close() throws Exception {
    if (this.scoreboard == null)
        return;
    for (final World world : Bukkit.getWorlds()) {
        this.removePlayer(world.getPlayers());
    }
    this.scoreboard = null;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:16,代碼來源:SimpleScoreboard.java

示例13: getOnlinePlayers

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static List<Player> getOnlinePlayers() {
    final List<Player> players = new ArrayList<>();
    for (final World world : Bukkit.getWorlds()) {
        players.addAll(world.getPlayers());
    }
    return players;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:8,代碼來源:SFileUtils.java

示例14: checkAndCleanMobFarm

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private void checkAndCleanMobFarm() {
	for (World world : Bukkit.getWorlds()) {
		for (LivingEntity entity : world.getLivingEntities()) {
			if (entity instanceof Monster || entity instanceof Animals || entity instanceof Villager || entity.getType() == EntityType.SQUID) {
				if (NeverLagUtils.checkCustomNpc(entity)) {
					continue;
				}
				if (this.getNearbyEntityCount(entity, false) >= cm.mobCollisionLargeLimit || this.getNearbyEntityCount(entity, true) >= cm.mobCollisionSmallLimit) {
					entity.remove();
				}
			}
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:15,代碼來源:MobFarmCleaner.java

示例15: updateHoloMessage

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * @param remain 小於 0 則為清除
 */
private void updateHoloMessage(int remain) {
	String message = remain > 0 ? i18n.tr("item.holoTitle", remain) : null;
	for (World world : Bukkit.getWorlds()) {
		if (cm.cleanItemWorldWhitelist.contains(world.getName())) {
			continue;
		}

		for (Item item : world.getEntitiesByClass(Item.class)) {
			// 當前是否已經在顯示倒計時
			boolean displaying = holoMessage.contains(item);

			if (canCleanItem(item, false)) {
				/*
					隻有滿足了如下條件之一才顯示倒計時:
					1. 已在顯示倒計時的
					2. custom name 未被設置的 (與其他插件兼容)
				*/
				if (displaying || (item.getCustomName() == null || !item.isCustomNameVisible())) {
					item.setCustomName(message);
					item.setCustomNameVisible(message != null);

					// 更新記錄
					if (message != null) {
						if (!displaying) holoMessage.add(item);
					} else {
						if (displaying) holoMessage.remove(item);
					}
				}
			} else if (displaying) { // 如果之前在顯示倒計時, 但現在不再滿足顯示條件了
				item.setCustomName(null);
				holoMessage.remove(item);
			}
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:39,代碼來源:EntityCleaner.java


注:本文中的org.bukkit.Bukkit.getWorlds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。