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