本文整理匯總了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);
}
}
}
}