本文整理汇总了Java中org.bukkit.World.setSpawnLocation方法的典型用法代码示例。如果您正苦于以下问题:Java World.setSpawnLocation方法的具体用法?Java World.setSpawnLocation怎么用?Java World.setSpawnLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.World
的用法示例。
在下文中一共展示了World.setSpawnLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadMap
import org.bukkit.World; //导入方法依赖的package包/类
public boolean loadMap(int gNumber) {
WorldController wc = SkyWarsReloaded.getWC();
String mapName = name + "_" + gNumber;
boolean mapExists = false;
File target = new File(rootDirectory, mapName);
if(target.isDirectory()) {
if(target.list().length > 0) {
mapExists = true;
}
}
if (mapExists) {
SkyWarsReloaded.getWC().deleteWorld(mapName);
}
wc.copyWorld(source, target);
boolean loaded = SkyWarsReloaded.getWC().loadWorld(mapName);
if (loaded) {
World world = SkyWarsReloaded.get().getServer().getWorld(mapName);
world.setAutoSave(false);
world.setThundering(false);
world.setStorm(false);
world.setDifficulty(Difficulty.NORMAL);
world.setSpawnLocation(2000, 0, 2000);
world.setTicksPerAnimalSpawns(1);
world.setTicksPerMonsterSpawns(1);
world.setGameRuleValue("doMobSpawning", "false");
world.setGameRuleValue("mobGriefing", "false");
world.setGameRuleValue("doFireTick", "false");
world.setGameRuleValue("showDeathMessages", "false");
}
return loaded;
}
示例2: onCommand
import org.bukkit.World; //导入方法依赖的package包/类
@SuppressWarnings("unused")
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof ConsoleCommandSender) {
return true;
}
Player player = (Player) sender;
World world = player.getWorld();
if (label.equalsIgnoreCase("setspawn")) {
if (!sender.hasPermission("core.admin")) {
player.sendMessage(" ");
player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + " ERROR!");
player.sendMessage(ChatColor.YELLOW + " Sorry, you need core.admin permission to execute /setspawn.");
player.sendMessage(" ");
return true;
}
plugin.getConfig().set("spawn.world", player.getLocation().getWorld().getName());
plugin.getConfig().set("spawn.x", player.getLocation().getX());
plugin.getConfig().set("spawn.y", player.getLocation().getY());
plugin.getConfig().set("spawn.z", player.getLocation().getZ());
plugin.getConfig().set("spawn.yaw", player.getLocation().getYaw());
plugin.getConfig().set("spawn.pitch", player.getLocation().getPitch());
world.setSpawnLocation(player.getLocation());
plugin.saveConfig();
player.sendMessage(ChatColor.YELLOW + "You have setspawn at " + ChatColor.GREEN + "X: " + plugin.getConfig().getString("spawn.x") + " " + "Y: " + plugin.getConfig().getString("spawn.y") + " " + "Z: " + plugin.getConfig().getString("spawn.z"));
return true;
}
if (label.equalsIgnoreCase("spawn")) {
if (!sender.hasPermission("core.spawn")) {
player.sendMessage(" ");
player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + " ERROR!");
player.sendMessage(ChatColor.YELLOW + " Sorry, you need core.admin permission to execute /setspawn.");
player.sendMessage(" ");
return true;
}
if (plugin.getConfig().getConfigurationSection("spawn") == null) {
player.sendMessage(" ");
player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + " ERROR!");
player.sendMessage(ChatColor.YELLOW + " You must set spawn to use /spawn (use /setspawn to set)");
player.sendMessage(" ");
return true;
}
World w = Bukkit.getServer().getWorld(plugin.getConfig().getString("spawn.world"));
double x = plugin.getConfig().getDouble("spawn.x");
double y = plugin.getConfig().getDouble("spawn.y");
double z = plugin.getConfig().getDouble("spawn.z");
float yaw = (float) plugin.getConfig().getDouble("spawn.yaw");
float pitch = (float) plugin.getConfig().getDouble("spawn.pitch");
player.teleport(new Location(w, x, y, z, yaw, pitch));
player.sendMessage(ChatColor.YELLOW + "You have teleported to spawn set at" + ChatColor.GREEN + " X:" + x + " Y:" + y + " Z:" + z + ChatColor.YELLOW + "!");
return true;
}
return false;
}