当前位置: 首页>>代码示例>>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;未经允许,请勿转载。