Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.simple.JSONObject;

Expand All @@ -46,7 +47,7 @@
/**
* The implementation of a Multiverse handled world.
*/
public class MVWorld implements MultiverseWorld {
public class MVWorld implements MultiverseWorld, Comparable<MultiverseWorld> {
private static final int SPAWN_LOCATION_SEARCH_TOLERANCE = 16;
private static final int SPAWN_LOCATION_SEARCH_RADIUS = 16;

Expand Down Expand Up @@ -206,6 +207,14 @@ private void validateProperties() {
setGameMode(getGameMode());
}

/**
* Used to sort MVWorlds by alphabetical order.
*/
@Override
public int compareTo(@NotNull MultiverseWorld o) {
return this.getAlias().compareTo(o.getAlias());
}

/**
* Validates the scale-property.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,18 @@ boolean addWorld(String name, Environment env, String seedString, WorldType type
ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);

/**
* Returns a list of all the worlds Multiverse knows about.
* Returns a collection of all the worlds Multiverse knows about.
*
* @return A list of {@link MultiverseWorld}.
* @return A collection of {@link MultiverseWorld}.
*/
Collection<MultiverseWorld> getMVWorlds();

/**
* Returns a list of all the worlds Multiverse knows about in alphabetical order.
*
* @return A list of {@link MultiverseWorld}.
*/
List<MultiverseWorld> getSortedMVWorlds();

/**
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ListCommand(MultiverseCore plugin) {

private List<String> getFancyWorldList(Player p) {
List<String> worldList = new ArrayList<String>();
for (MultiverseWorld world : this.plugin.getMVWorldManager().getMVWorlds()) {
for (MultiverseWorld world : this.plugin.getMVWorldManager().getSortedMVWorlds()) {

if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
Expand Down Expand Up @@ -624,6 +623,16 @@ public Collection<MultiverseWorld> getMVWorlds() {
return this.worlds.values();
}

/**
* {@inheritDoc}
*/
@Override
public List<MultiverseWorld> getSortedMVWorlds() {
MultiverseWorld[] MVWorldList = this.getMVWorlds().toArray(new MultiverseWorld[0]);
Arrays.sort(MVWorldList);
return Arrays.asList(MVWorldList);
}

/**
* {@inheritDoc}
*/
Expand Down