mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-02 16:59:56 +01:00
Add Custom world types to MVWho and MVEnv
This commit is contained in:
parent
09b6d72881
commit
63a2fc0f1f
@ -15,7 +15,7 @@ public class MVWorld {
|
||||
private Configuration config; // Hold the Configuration File.
|
||||
|
||||
public World world; // The World Instance.
|
||||
public Environment environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL
|
||||
public String environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL
|
||||
public Long seed;
|
||||
|
||||
public String name; // The Worlds Name, EG its folder name.
|
||||
@ -44,7 +44,7 @@ public class MVWorld {
|
||||
|
||||
this.world = world;
|
||||
this.name = world.getName();
|
||||
this.environment = world.getEnvironment();
|
||||
this.environment = env;
|
||||
this.seed = seed;
|
||||
|
||||
initLists();
|
||||
|
@ -3,6 +3,7 @@ package com.onarandombox.MultiverseCore;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -97,7 +98,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
public HashMap<String, MVWorld> worlds = new HashMap<String, MVWorld>();
|
||||
|
||||
// HashMap to contain all custom generators. Plugins will have to register!
|
||||
public HashMap<String, ChunkGenerator> worldGenerators = new HashMap<String, ChunkGenerator>();
|
||||
private HashMap<String, ChunkGenerator> worldGenerators = new HashMap<String, ChunkGenerator>();
|
||||
|
||||
// HashMap to contain information relating to the Players.
|
||||
public HashMap<String, MVPlayerSession> playerSessions = new HashMap<String, MVPlayerSession>();
|
||||
@ -307,6 +308,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
commandManager.addCommand(new InfoCommand(this));
|
||||
commandManager.addCommand(new ReloadCommand(this));
|
||||
commandManager.addCommand(new ModifyCommand(this));
|
||||
commandManager.addCommand(new EnvironmentCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -652,19 +654,22 @@ public class MultiverseCore extends JavaPlugin {
|
||||
try {
|
||||
return Environment.valueOf(env);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Sender will be null on loadWorlds
|
||||
return null;
|
||||
// TODO: Show the player the mvenvironments command.
|
||||
}
|
||||
}
|
||||
|
||||
public ChunkGenerator getChunkGenFromEnv(String env) {
|
||||
private ChunkGenerator getChunkGenFromEnv(String env) {
|
||||
if (worldGenerators.containsKey(env)) {
|
||||
return worldGenerators.get(env);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Other plugin devs can use this to tell MultiVerse about other environment types
|
||||
* @param name
|
||||
* @param generator
|
||||
* @return
|
||||
*/
|
||||
public boolean registerEnvType(String name, ChunkGenerator generator) {
|
||||
if (this.worldGenerators.containsKey(name)) {
|
||||
return false;
|
||||
@ -725,4 +730,12 @@ public class MultiverseCore extends JavaPlugin {
|
||||
queuedCommands.remove(c);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getWorldGenerators() {
|
||||
return this.worldGenerators.keySet();
|
||||
}
|
||||
|
||||
public Collection<MVWorld> getWorlds() {
|
||||
return this.worlds.values();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.onarandombox.MultiverseCore.command.commands;
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
@ -48,7 +47,8 @@ public class CreateCommand extends BaseCommand {
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
if(plugin.getEnvFromString(env) == null) {
|
||||
sender.sendMessage("I should show the envs I know here...");
|
||||
sender.sendMessage("That world type did not exist.");
|
||||
sender.sendMessage("For a list of available world types, type: /mvenv");
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -13,8 +13,8 @@ public class EnvironmentCommand extends BaseCommand{
|
||||
this.name = "List Environments";
|
||||
this.description = "Lists valid known environments";
|
||||
this.usage = "/mvenv";
|
||||
this.minArgs = 2;
|
||||
this.maxArgs = 2;
|
||||
this.minArgs = 0;
|
||||
this.maxArgs = 0;
|
||||
this.identifiers.add("mvenv");
|
||||
this.permission = "multiverse.world.list.environments";
|
||||
this.requiresOp = false;
|
||||
@ -22,10 +22,20 @@ public class EnvironmentCommand extends BaseCommand{
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
this.showEnvironments(sender);
|
||||
}
|
||||
|
||||
public void showEnvironments(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:");
|
||||
sender.sendMessage(ChatColor.GREEN + "NORMAL");
|
||||
sender.sendMessage(ChatColor.RED + "NETHER");
|
||||
sender.sendMessage(ChatColor.AQUA + "SKYLANDS");
|
||||
if(plugin.getWorldGenerators().size() > 0) {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "CUSTOM WORLD TYPES:");
|
||||
}
|
||||
for(String s : plugin.getWorldGenerators()) {
|
||||
sender.sendMessage(ChatColor.GOLD + s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.onarandombox.MultiverseCore.command.commands;
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
@ -40,7 +39,8 @@ public class ImportCommand extends BaseCommand {
|
||||
return;
|
||||
} else if(env == null) {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
sender.sendMessage("I should show valid envs here...");
|
||||
sender.sendMessage("That world type did not exist.");
|
||||
sender.sendMessage("For a list of available world types, type: /mvenv");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
sender.sendMessage("That world folder does not exist...");
|
||||
|
@ -25,6 +25,7 @@ public class ListCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
//TODO: Show custom worldtypes
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVCommandHandler;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
import com.onarandombox.utils.PurgeWorlds;
|
||||
|
@ -2,7 +2,6 @@ package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVCommandHandler;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
|
||||
@ -34,36 +35,42 @@ public class WhoCommand extends BaseCommand {
|
||||
p = (Player) sender;
|
||||
}
|
||||
|
||||
List<World> worlds = new ArrayList<World>();
|
||||
List<MVWorld> worlds = new ArrayList<MVWorld>();
|
||||
|
||||
if (args.length > 0) {
|
||||
World world = plugin.getServer().getWorld(args[0].toString());
|
||||
if (world != null) {
|
||||
worlds.add(world);
|
||||
if (plugin.worlds.containsKey(args[0])) {
|
||||
worlds.add(plugin.worlds.get(args[0]));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "World does not exist");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
worlds = plugin.getServer().getWorlds();
|
||||
worlds = new ArrayList<MVWorld>(plugin.getWorlds());
|
||||
}
|
||||
|
||||
for (World world : worlds) {
|
||||
if (!(plugin.worlds.containsKey(world.getName()))) {
|
||||
for (MVWorld world : worlds) {
|
||||
if (!(plugin.worlds.containsKey(world.name))) {
|
||||
continue;
|
||||
}
|
||||
if (p != null && (!plugin.ph.canEnterWorld(p, world))) {
|
||||
|
||||
World w = plugin.getServer().getWorld(world.name);
|
||||
if (p != null && (!plugin.ph.canEnterWorld(p, w))) {
|
||||
continue;
|
||||
}
|
||||
ChatColor color = ChatColor.BLUE;
|
||||
if (world.getEnvironment() == Environment.NETHER) {
|
||||
|
||||
ChatColor color = ChatColor.GOLD;
|
||||
Environment env = plugin.getEnvFromString(world.environment);
|
||||
if(plugin.getEnvFromString(world.environment) == null) {
|
||||
color = ChatColor.GOLD;
|
||||
}
|
||||
else if (env == Environment.NETHER) {
|
||||
color = ChatColor.RED;
|
||||
} else if (world.getEnvironment() == Environment.NORMAL) {
|
||||
} else if (env == Environment.NORMAL) {
|
||||
color = ChatColor.GREEN;
|
||||
} else if (world.getEnvironment() == Environment.SKYLANDS) {
|
||||
} else if (env == Environment.SKYLANDS) {
|
||||
color = ChatColor.AQUA;
|
||||
}
|
||||
List<Player> players = world.getPlayers();
|
||||
List<Player> players = w.getPlayers();
|
||||
|
||||
String result = "";
|
||||
if (players.size() <= 0) {
|
||||
@ -73,7 +80,7 @@ public class WhoCommand extends BaseCommand {
|
||||
result += player.getName() + " ";
|
||||
}
|
||||
}
|
||||
sender.sendMessage(color + world.getName() + ChatColor.WHITE + " - " + result);
|
||||
sender.sendMessage(color + world.name + ChatColor.WHITE + " - " + result);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -83,3 +83,7 @@ commands:
|
||||
description: Gets world info.
|
||||
usage: |
|
||||
/<command> [world]
|
||||
mvenv:
|
||||
description: Tells the user all possible world types.
|
||||
usage: |
|
||||
/<command>
|
||||
|
Loading…
Reference in New Issue
Block a user