org.bukkit.Server.getWorld()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(217)

本文整理了Java中org.bukkit.Server.getWorld()方法的一些代码示例,展示了Server.getWorld()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.getWorld()方法的具体详情如下:
包路径:org.bukkit.Server
类名称:Server
方法名:getWorld

Server.getWorld介绍

[英]Gets the world with the given name.
[中]获取具有给定名称的世界。

代码示例

代码示例来源:origin: Bukkit/Bukkit

/**
 * @see Server#getWorld(String name)
 */
public static World getWorld(String name) {
  return server.getWorld(name);
}

代码示例来源:origin: Bukkit/Bukkit

/**
 * @see Server#getWorld(UUID uid)
 */
public static World getWorld(UUID uid) {
  return server.getWorld(uid);
}

代码示例来源:origin: EngineHub/WorldEdit

@Nullable
@Override
public BukkitWorld matchWorld(com.sk89q.worldedit.world.World world) {
  if (world instanceof BukkitWorld) {
    return (BukkitWorld) world;
  } else {
    World bukkitWorld = server.getWorld(world.getName());
    return bukkitWorld != null ? new BukkitWorld(bukkitWorld) : null;
  }
}

代码示例来源:origin: EngineHub/WorldEdit

/**
 * Create a Bukkit world from a WorldEdit world.
 *
 * @param world the WorldEdit world
 * @return a Bukkit world
 */
public static org.bukkit.World adapt(World world) {
  checkNotNull(world);
  if (world instanceof BukkitWorld) {
    return ((BukkitWorld) world).getWorld();
  } else {
    org.bukkit.World match = Bukkit.getServer().getWorld(world.getName());
    if (match != null) {
      return match;
    } else {
      throw new IllegalArgumentException("Can't find a Bukkit world for " + world);
    }
  }
}

代码示例来源:origin: EngineHub/WorldEdit

@Override
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
  if (nameNotSafe(permission)) {
    return false;
  }
  String name = player.getName();
  World world = worldName != null ? server.getWorld(worldName) : player.getPlayer().getWorld();
  AnjoPermissionsHandler permissionHandler = getPermissionHandler(world);
  return permissionHandler != null && permissionHandler.permission(name, permission);
}

代码示例来源:origin: webbukkit/dynmap

@Override
public int getBlockIDAt(String wname, int x, int y, int z) {
  World w = getServer().getWorld(wname);
  if((w != null) && w.isChunkLoaded(x >> 4, z >> 4)) {
    return w.getBlockTypeIdAt(x,  y,  z);
  }
  return -1;
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#getWorld(String name)
 */
public static World getWorld(String name) {
  return server.getWorld(name);
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#getWorld(UUID uid)
 */
public static World getWorld(UUID uid) {
  return server.getWorld(uid);
}

代码示例来源:origin: Multiverse/Multiverse-Core

/**
 * {@inheritDoc}
 */
@Override
public World getCBWorld() {
  final World world = plugin.getServer().getWorld(worldUID);
  if (world == null) {
    throw new IllegalStateException("Lost reference to bukkit world '" + name + "'");
  }
  return world;
}

代码示例来源:origin: aadnk/ProtocolLib

private World getWorld(String name) {
  try {
    // Try to get the world at least
    return Bukkit.getServer().getWorld(name);
  } catch (Exception e) {
    // Screw it
    return null;
  }
}

代码示例来源:origin: Rsl1122/Plan-PlayerAnalytics

private void checkOldWorld(String worldName) {
  if (worlds.containsKey(worldName)) {
    return;
  }
  World world = plugin.getServer().getWorld(worldName);
  boolean old = world == null;
  worlds.put(worldName, old);
}

代码示例来源:origin: BentoBoxWorld/BentoBox

@Override
  public World read(JsonReader reader) throws IOException {
    if (reader.peek() == JsonToken.NULL) {
      reader.nextNull();
      return null;
    }
    return plugin.getServer().getWorld(reader.nextString());
  }
}

代码示例来源:origin: Multiverse/Multiverse-Core

/**
 * {@inheritDoc}
 */
@Override
public World getRespawnToWorld() {
  return this.plugin.getServer().getWorld(props.getRespawnToWorld());
}

代码示例来源:origin: EngineHub/WorldGuard

@Override
public World getWorldByName(String worldName) {
  return BukkitAdapter.adapt(Bukkit.getServer().getWorld(worldName));
}

代码示例来源:origin: MilkBowl/Vault

@Override
public boolean has(String playerName, String worldName, double amount) {
  OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
  World world = plugin.getServer().getWorld(worldName);
  
  double playerBalance = economy.getAccountBalance(player, world);
  
  if(playerBalance >= amount) {
    return true;
  } else {
    return false;
  }
}

代码示例来源:origin: MilkBowl/Vault

@Override
public boolean hasAccount(String playerName, String worldName) {
  OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
  World world = plugin.getServer().getWorld(worldName);
  
  return economy.isAccountCreated(player, world);
}

代码示例来源:origin: MilkBowl/Vault

@Override
public double getBalance(String playerName, String worldName) {   
  OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
  World world = plugin.getServer().getWorld(worldName);
  
  return economy.getAccountBalance(player, world);
}

代码示例来源:origin: MilkBowl/Vault

@Override
public boolean createPlayerAccount(String playerName, String worldName) {
  OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
  World world = plugin.getServer().getWorld(worldName);
  
  if(!economy.isAccountCreated(player, world)) {
    economy.createAccount(player, 0, world);
    
    return true;
  } else {
    return false;
  }
}

代码示例来源:origin: Multiverse/Multiverse-Core

@Override
  public GameMode validateChange(String property, GameMode newValue, GameMode oldValue,
      MVWorld object) throws ChangeDeniedException {
    for (Player p : plugin.getServer().getWorld(getName()).getPlayers()) {
      plugin.log(Level.FINER, String.format("Setting %s's GameMode to %s",
          p.getName(), newValue.toString()));
      plugin.getPlayerListener().handleGameModeAndFlight(p, MVWorld.this);
    }
    return super.validateChange(property, newValue, oldValue, object);
  }
}

代码示例来源:origin: MilkBowl/Vault

@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
  OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
  World world = plugin.getServer().getWorld(worldName);
  
  double balance = economy.getAccountBalance(player, world);
  
  if(economy.addAccountBalance(player, amount, world)) {
    balance = economy.getAccountBalance(player, world);
    return new EconomyResponse(amount, balance, EconomyResponse.ResponseType.SUCCESS, "");
  } else {
    return new EconomyResponse(0, balance, EconomyResponse.ResponseType.FAILURE, "Failed to add funds to account");
  }
}

相关文章

Server类方法