本文整理汇总了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);
}
}
}
示例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()));
}
示例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);
}
}
}
示例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 );
}
示例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;
}
示例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();
}
}
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
}
}
示例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);
}
}
}
}