Skip to content

Instantly share code, notes, and snippets.

@shawshark
Created May 27, 2014 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawshark/a8c20aa8adb11be5618c to your computer and use it in GitHub Desktop.
Save shawshark/a8c20aa8adb11be5618c to your computer and use it in GitHub Desktop.
public static String[] worlds;
//onenable.
if(config.getString("worlds") != null) {
worlds = config.getString("worlds").split(",");
for ( String worldName : worlds) {
getServer().createWorld(new WorldCreator(worldName));
}
}
//ondisable
String worldNames = "";
for ( World world : getServer().getWorlds()) {
if(
!world.getName().equalsIgnoreCase("world") ||
!world.getName().equalsIgnoreCase("world_nether") ||
!world.getName().equalsIgnoreCase("world_the_end")
) {
worldNames = worldNames + world.getName() + ",";
}
}
config.set("worlds", worldNames);
saveConfig();
//create world command.
if(c.getName().equalsIgnoreCase("createworld")) {
if(!s.hasPermission("world.create")) {
s.sendMessage(ChatColor.RED + "You don't have permissions for this command!");
return true;
}
if(!(args.length == 1)) {
s.sendMessage(ChatColor.GOLD + "Invaild! /createworld [worldname]");
return true;
}
String worldName = args[0];
for ( World worlds : Bukkit.getWorlds()) {
if(worlds.getName().equalsIgnoreCase(worldName)) {
s.sendMessage(ChatColor.RED + "World " + worldName + " exists!");
return true;
}
}
//create world.
Main.plugin.getServer().createWorld(new WorldCreator(worldName));
s.sendMessage(ChatColor.GOLD + "Created world '" + worldName + "'");
return true;
}
// world tp command.
if(c.getName().equalsIgnoreCase("worldtp")) {
if(!s.hasPermission("world.tp")) {
s.sendMessage(ChatColor.RED + "You don't have permissions for this command!");
return true;
}
if(!(args.length == 1)) {
s.sendMessage(ChatColor.GOLD + "Invaild! /worldtp [worldname]");
return true;
}
String worldName = args[0];
for ( World worlds : Bukkit.getWorlds()) {
if(worlds.getName().equalsIgnoreCase(worldName)) {
s.sendMessage(ChatColor.RED + "World " + worldName + " exists!");
World world = Bukkit.getWorld(worldName);
player.teleport(new Location(world, 2, 100, 2));
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment