Merge pull request #5 from Geczy/sorted

Sort script names and server names
This commit is contained in:
Jeroen Ketelaar
2014-04-21 17:53:18 +02:00
4 changed files with 21 additions and 4 deletions
@@ -6,7 +6,7 @@ package org.parabot.core.desc;
* @author Everel
*
*/
public class ScriptDescription {
public class ScriptDescription implements Comparable<ScriptDescription> {
public String scriptName;
public String author;
public String category;
@@ -131,4 +131,9 @@ public class ScriptDescription {
return b.toString();
}
@Override
public int compareTo( ScriptDescription o ) {
return scriptName.compareTo( o.scriptName );
}
}
@@ -7,7 +7,7 @@ package org.parabot.core.desc;
* @author Everel
*
*/
public class ServerDescription {
public class ServerDescription implements Comparable<ServerDescription> {
private String serverName;
private String author;
private double revision;
@@ -37,4 +37,9 @@ public class ServerDescription {
this.serverName, this.author, this.revision);
}
@Override
public int compareTo( ServerDescription o ) {
return this.getServerName().compareTo( o.getServerName() );
}
}
@@ -2,12 +2,15 @@ package org.parabot.core.parsers.scripts;
import org.parabot.core.Core;
import org.parabot.core.desc.ScriptDescription;
import org.parabot.core.desc.ServerDescription;
import org.parabot.core.lib.jython.Jython;
import org.parabot.environment.scripts.ScriptExecuter;
import org.parabot.environment.servers.ServerExecuter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
/**
* Abstract class for parsing scripts
@@ -49,8 +52,10 @@ public abstract class ScriptParser {
}
Core.verbose("Scripts parsed.");
}
Map<ScriptDescription, ScriptExecuter> SORTED_SCRIPT_CACHE = new TreeMap<ScriptDescription, ScriptExecuter>( SCRIPT_CACHE );
return SCRIPT_CACHE.keySet().toArray(new ScriptDescription[SCRIPT_CACHE.size()]);
return SORTED_SCRIPT_CACHE.keySet().toArray(new ScriptDescription[SORTED_SCRIPT_CACHE.size()]);
}
}
@@ -7,6 +7,7 @@ import org.parabot.environment.servers.ServerExecuter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
/**
* Abstract class for parsing server providers
@@ -42,8 +43,9 @@ public abstract class ServerParser {
Core.verbose("Server providers parsed.");
}
Map<ServerDescription, ServerExecuter> SORTED_SERVER_CACHE = new TreeMap<ServerDescription, ServerExecuter>( SERVER_CACHE );
return SERVER_CACHE.keySet().toArray(new ServerDescription[SERVER_CACHE.size()]);
return SORTED_SERVER_CACHE.keySet().toArray(new ServerDescription[SORTED_SERVER_CACHE.size()]);
}
}