Many changes for TFM 5.0

Refractoring
Reworked /saconfig
Reworked part of the command system
Removed unused config sections
Refractored part of the config
Fixed bugs with admin list
Actually allow CONSOLE to have senior perms
This commit is contained in:
JeromSar
2016-03-02 20:28:01 +01:00
parent 19ced05110
commit 055973aa37
143 changed files with 939 additions and 954 deletions

View File

@ -308,7 +308,7 @@ public abstract class NanoHTTPD
*/
public Response serve(HTTPSession session)
{
Map<String, String> files = new HashMap<String, String>();
Map<String, String> files = new HashMap<>();
Method method = session.getMethod();
if (Method.PUT.equals(method) || Method.POST.equals(method))
{
@ -369,7 +369,7 @@ public abstract class NanoHTTPD
*/
protected Map<String, List<String>> decodeParameters(String queryString)
{
Map<String, List<String>> parms = new HashMap<String, List<String>>();
Map<String, List<String>> parms = new HashMap<>();
if (queryString != null)
{
StringTokenizer st = new StringTokenizer(queryString, "&");
@ -531,7 +531,7 @@ public abstract class NanoHTTPD
public DefaultTempFileManager()
{
tmpdir = System.getProperty("java.io.tmpdir");
tempFiles = new ArrayList<TempFile>();
tempFiles = new ArrayList<>();
}
@Override
@ -618,7 +618,7 @@ public abstract class NanoHTTPD
/**
* Headers for the HTTP response. Use addHeader() to add lines.
*/
private Map<String, String> header = new HashMap<String, String>();
private Map<String, String> header = new HashMap<>();
/**
* The request method that spawned this response.
*/
@ -948,14 +948,14 @@ public abstract class NanoHTTPD
inputStream = sequenceInputStream;
}
parms = new HashMap<String, String>();
headers = new HashMap<String, String>();
parms = new HashMap<>();
headers = new HashMap<>();
// Create a BufferedReader for parsing the header.
BufferedReader hin = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(buf, 0, rlen)));
// Decode the header into parms and header java properties
Map<String, String> pre = new HashMap<String, String>();
Map<String, String> pre = new HashMap<>();
decodeHeader(hin, pre, parms, headers);
method = Method.lookup(pre.get("method"));
@ -1195,7 +1195,7 @@ public abstract class NanoHTTPD
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but next chunk does not start with boundary. Usage: GET /example/file.html");
}
boundarycount++;
Map<String, String> item = new HashMap<String, String>();
Map<String, String> item = new HashMap<>();
mpline = in.readLine();
while (mpline != null && mpline.trim().length() > 0)
{
@ -1214,7 +1214,7 @@ public abstract class NanoHTTPD
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but no content-disposition info found. Usage: GET /example/file.html");
}
StringTokenizer st = new StringTokenizer(contentDisposition, "; ");
Map<String, String> disposition = new HashMap<String, String>();
Map<String, String> disposition = new HashMap<>();
while (st.hasMoreTokens())
{
String token = st.nextToken();
@ -1297,7 +1297,7 @@ public abstract class NanoHTTPD
{
int matchcount = 0;
int matchbyte = -1;
List<Integer> matchbytes = new ArrayList<Integer>();
List<Integer> matchbytes = new ArrayList<>();
for (int i = 0; i < b.limit(); i++)
{
if (b.get(i) == boundary[matchcount])
@ -1504,8 +1504,8 @@ public abstract class NanoHTTPD
public class CookieHandler implements Iterable<String>
{
private HashMap<String, String> cookies = new HashMap<String, String>();
private ArrayList<Cookie> queue = new ArrayList<Cookie>();
private HashMap<String, String> cookies = new HashMap<>();
private ArrayList<Cookie> queue = new ArrayList<>();
public CookieHandler(Map<String, String> httpHeaders)
{

View File

@ -56,7 +56,7 @@ public abstract class HTTPDModule
protected final Map<String, String> getFiles()
{
Map<String, String> files = new HashMap<String, String>();
Map<String, String> files = new HashMap<>();
try
{

View File

@ -25,7 +25,7 @@ public class Module_file extends HTTPDModule
{
private final File rootDir = new File(ConfigEntry.HTTPD_PUBLIC_FOLDER.getString());
public static final Map<String, String> MIME_TYPES = new HashMap<String, String>();
public static final Map<String, String> MIME_TYPES = new HashMap<>();
static
{

View File

@ -9,7 +9,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.commands.FreedomCommand;
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.heading;
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.paragraph;
@ -46,7 +46,7 @@ public class Module_help extends HTTPDModule
+ "Please note that it does not include vanilla server commands."));
final Collection<Command> knownCommands = ((SimpleCommandMap) map).getCommands();
final Map<String, List<Command>> commandsByPlugin = new HashMap<String, List<Command>>();
final Map<String, List<Command>> commandsByPlugin = new HashMap<>();
for (Command command : knownCommands)
{
@ -86,7 +86,7 @@ public class Module_help extends HTTPDModule
continue;
}
Rank tfmCommandLevel = FreedomCommand.getCommand(command).getPerms().level();
Rank tfmCommandLevel = FreedomCommand.getFrom(command).getPerms().level();
if (lastTfmCommandLevel == null || lastTfmCommandLevel != tfmCommandLevel)
{
responseBody.append("</ul>\r\n").append(heading(tfmCommandLevel.getName(), 3)).append("<ul>\r\n");
@ -142,8 +142,8 @@ public class Module_help extends HTTPDModule
@Override
public int compare(Command a, Command b)
{
FreedomCommand ca = FreedomCommand.getCommand(a);
FreedomCommand cb = FreedomCommand.getCommand(b);
FreedomCommand ca = FreedomCommand.getFrom(a);
FreedomCommand cb = FreedomCommand.getFrom(b);
if (ca == null
|| cb == null

View File

@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.httpd.module;
import java.io.File;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.banning.PermbanList;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
@ -16,10 +17,10 @@ public class Module_permbans extends HTTPDModule
@Override
public NanoHTTPD.Response getResponse()
{
File permbanFile = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PERMBAN_FILENAME);
File permbanFile = new File(TotalFreedomMod.plugin.getDataFolder(), PermbanList.CONFIG_FILENAME);
if (permbanFile.exists())
{
return HTTPDaemon.serveFileBasic(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PERMBAN_FILENAME));
return HTTPDaemon.serveFileBasic(new File(TotalFreedomMod.plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
}
else
{

View File

@ -80,7 +80,7 @@ public class Module_schematic extends HTTPDModule
{
Collection<File> schematics = FileUtils.listFiles(SCHEMATIC_FOLDER, SCHEMATIC_FILTER, false);
final List<String> schematicsFormatted = new ArrayList<String>();
final List<String> schematicsFormatted = new ArrayList<>();
for (File schematic : schematics)
{
String filename = StringEscapeUtils.escapeHtml4(schematic.getName());