当前位置: 首页>>代码示例>>Java>>正文


Java World.getPlayers方法代码示例

本文整理汇总了Java中org.bukkit.World.getPlayers方法的典型用法代码示例。如果您正苦于以下问题:Java World.getPlayers方法的具体用法?Java World.getPlayers怎么用?Java World.getPlayers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.World的用法示例。


在下文中一共展示了World.getPlayers方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deliverSupplyDrop

import org.bukkit.World; //导入方法依赖的package包/类
public void deliverSupplyDrop(World world) {
	Random r = new Random();

	// Supply drops between -500, + 500
	double x = r.nextInt(1000) - 500;
	double y = 0.0D;
	double z = r.nextInt(1000) - 500;

	Location dropLocation = new Location(world, x, y, z);

	// Get the highest block at that location.
	dropLocation.setY(world.getHighestBlockYAt(dropLocation));

	dropLocation.getBlock().setType(Material.CHEST);
	Chest dropChest = (Chest) dropLocation.getBlock().getState();

	SupplyDropObject supplyDrop = new SupplyDropObject(dropLocation, dropChest, dropChest.getInventory());
	addSupplyDrop(supplyDrop);

	for (Player p : world.getPlayers()) {
		p.sendMessage(MortuusTerraCore.ALERT_PREFIX + StringUtilities
				.color("&eSupply Drop spotted at: &6" + x + ", " + dropLocation.getY() + ", " + z + "&e!"));
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:25,代码来源:SupplyDropManager.java

示例2: AzurePlayerList

import org.bukkit.World; //导入方法依赖的package包/类
private AzurePlayerList() {
    names = Collections.synchronizedSet(AzureAPI.newCaseInsensitiveSet()); // access in AsyncPreLoginEvent
    players = Lists.newArrayListWithExpectedSize(Bukkit.getMaxPlayers());
    
    join = Lists.newArrayList();
    quit = Lists.newArrayList();
    
    for (World world : Bukkit.getWorlds()) {
        for (Player each : world.getPlayers()) {
            names.add(each.getName());
            players.add(each);
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:15,代码来源:AzurePlayerList.java

示例3: getOnlinePlayer

import org.bukkit.World; //导入方法依赖的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

示例4: sendParticles

import org.bukkit.World; //导入方法依赖的package包/类
public void sendParticles(World world, String type, float x, float y, float z, float offsetX, float offsetY, float offsetZ, float data, int amount) {
	PacketPlayOutWorldParticles particles = new PacketPlayOutWorldParticles(getEffect(type), x, y, z, offsetX, offsetY, offsetZ, data, amount);
	for (Player player: world.getPlayers()) {
		CraftPlayer start = (CraftPlayer) player; //Replace player with your player.
		EntityPlayer target = start.getHandle();
		PlayerConnection connect = target.playerConnection;
		connect.sendPacket(particles);
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:10,代码来源:NMSHandler.java

示例5: sendParticles

import org.bukkit.World; //导入方法依赖的package包/类
public void sendParticles(World world, String type, float x, float y, float z, float offsetX, float offsetY, float offsetZ, float data, int amount) {
	EnumParticle particle = EnumParticle.valueOf(type);
	PacketPlayOutWorldParticles particles = new PacketPlayOutWorldParticles(particle, false, x, y, z, offsetX, offsetY, offsetZ, data, amount, 1);
	for (Player player: world.getPlayers()) {
		CraftPlayer start = (CraftPlayer) player; //Replace player with your player.
		EntityPlayer target = start.getHandle();
		PlayerConnection connect = target.playerConnection;
		connect.sendPacket(particles);
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:11,代码来源:NMSHandler.java

示例6: run

import org.bukkit.World; //导入方法依赖的package包/类
@Override
public boolean run() {
	Location spawn = SkyWarsReloaded.getCfg().getSpawn();
	if (spawn == null) {
		sender.sendMessage(ChatColor.RED + "YOU MUST SET SPAWN BEFORE YOU CAN SAVE A MAP");
		return true;
	}
	String worldName = args[1].toLowerCase();
	for (World world: SkyWarsReloaded.get().getServer().getWorlds()) {
		if (world.getName().equalsIgnoreCase(worldName)) {
			World editWorld = SkyWarsReloaded.get().getServer().getWorld(worldName);
			for (Player player: editWorld.getPlayers()) {
				player.teleport(spawn, TeleportCause.PLUGIN);
			}
			editWorld.save();
			SkyWarsReloaded.getWC().unloadWorld(worldName);
			File dataDirectory = new File (SkyWarsReloaded.get().getDataFolder(), "maps");
			File target = new File (dataDirectory, worldName);
			SkyWarsReloaded.getWC().deleteWorld(target);
			File source = new File (SkyWarsReloaded.get().getServer().getWorldContainer().getAbsolutePath(), worldName);
			SkyWarsReloaded.getWC().copyWorld(source, target);
			SkyWarsReloaded.getWC().deleteWorld(source);
			sender.sendMessage(new Messaging.MessageFormatter().setVariable("mapname", worldName).format("maps.saved"));
			if (SkyWarsReloaded.getMC().mapRegistered(worldName)) {
				sender.sendMessage(new Messaging.MessageFormatter().format("maps.register-reminder"));
			}
			return true;
		}
	}
	sender.sendMessage(new Messaging.MessageFormatter().setVariable("mapname", worldName).format("error.map-not-in-edit"));
	return true;
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:33,代码来源:SaveMapCmd.java

示例7: getPingAndSort

import org.bukkit.World; //导入方法依赖的package包/类
public static LinkedHashMap<String, Integer> getPingAndSort() {
	HashMap<String, Integer> pingRecord = new HashMap<>();
	for (World world : Bukkit.getWorlds()) {
		for (Player p : world.getPlayers()) {
			pingRecord.put(p.getName(), getPing(p));
		}
	}
	return NeverLagUtils.sortMapByValues(pingRecord);
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:10,代码来源:PingUtils.java

示例8: checkOnline

import org.bukkit.World; //导入方法依赖的package包/类
private boolean checkOnline(String username) {
	try {
		for (World w : Bukkit.getWorlds()) {
			for (Player p : w.getPlayers()) {
				if (p != null && p.getName().equalsIgnoreCase(username)) {
					return true;
				}
			}
		}
	} catch (Exception ignore) {
		// 忽略
	}
	return false;
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:15,代码来源:AntiDoubleLogin.java

示例9: messagePlayers

import org.bukkit.World; //导入方法依赖的package包/类
private void messagePlayers(int ticksLeft, World world) {
	int seconds = ticksLeft / 20;
	int hours = seconds / 3600;
	int minutes = (seconds % 3600) / 60;
	seconds = seconds % 60;

	for (Player p : world.getPlayers()) {
		p.sendMessage(MortuusTerraCore.ALERT_PREFIX + StringUtilities
				.color("&eNext Supply Drop in: &6" + hours + "h, " + minutes + "m, " + seconds + "s."));
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:12,代码来源:SupplyDropTimer.java

示例10: AzurePlayerList

import org.bukkit.World; //导入方法依赖的package包/类
private AzurePlayerList() {
    names = Collections.synchronizedSet(AzureAPI.newCaseInsensitiveSet()); // access in AsyncPreLoginEvent
    players = Lists.newArrayListWithExpectedSize(Bukkit.getMaxPlayers());
    
    for (World world : Bukkit.getWorlds()) {
        for (Player each : world.getPlayers()) {
            names.add(each.getName());
            players.add(each);
        }
    }
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:12,代码来源:AzurePlayerList.java

示例11: rollback

import org.bukkit.World; //导入方法依赖的package包/类
public void rollback(World world) {
    for (Player player : world.getPlayers()) {
        player.teleport(Skywars.getInstance().getLobbyPoint());
    }

    Skywars.getInstance().getServer().unloadWorld(world, false);

    String originalName = world.getName().split("_")[0];

    rollback(originalName);
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:12,代码来源:RollbackHandler.java

示例12: clear

import org.bukkit.World; //导入方法依赖的package包/类
/**
 * Clear the actionbar inside a {@link World}
 *
 * @param world the {@link World} to clear the actionbar in
 */
public static void clear(World world) {
    for (Player p : world.getPlayers()) {
        clear(p);
    }
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:11,代码来源:SimpleActionBar.java

示例13: send

import org.bukkit.World; //导入方法依赖的package包/类
/**
 * Send a actionbar into a {@link World}
 *
 * @param world   to send the actionbar to
 * @param message to be displayed inside the actionbar
 */
public static void send(World world, String message) {
    for (Player p : world.getPlayers()) {
        send(p, message);
    }
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:12,代码来源:SimpleActionBar.java


注:本文中的org.bukkit.World.getPlayers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。