mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-29 19:46:42 +00:00
Codacy complacency
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||
|
||||
import java.util.Collection;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||
@ -14,7 +13,7 @@ import org.json.simple.JSONObject;
|
||||
public class Module_list extends HTTPDModule
|
||||
{
|
||||
|
||||
public Module_list(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||
public Module_list(NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
@ -67,12 +66,12 @@ public class Module_list extends HTTPDModule
|
||||
owners.add(player.getName());
|
||||
}
|
||||
|
||||
if (!plugin.al.isAdmin(player) && !hasSpecialTitle(player))
|
||||
if (!plugin.al.isAdmin(player) && hasSpecialTitle(player))
|
||||
{
|
||||
operators.add(player.getName());
|
||||
}
|
||||
|
||||
if (!hasSpecialTitle(player) && plugin.al.isAdmin(player) && !plugin.al.isVanished(player.getName()))
|
||||
if (hasSpecialTitle(player) && plugin.al.isAdmin(player) && !plugin.al.isVanished(player.getName()))
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
switch (admin.getRank())
|
||||
@ -125,9 +124,7 @@ public class Module_list extends HTTPDModule
|
||||
|
||||
body.append("</ul>\r\n");
|
||||
|
||||
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_HTML, body.toString());
|
||||
|
||||
return response;
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_HTML, body.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +135,7 @@ public class Module_list extends HTTPDModule
|
||||
|
||||
public boolean hasSpecialTitle(Player player)
|
||||
{
|
||||
return FUtil.DEVELOPERS.contains(player.getUniqueId().toString()) || ConfigEntry.SERVER_EXECUTIVES.getList().contains(player.getName()) || ConfigEntry.SERVER_OWNERS.getList().contains(player.getName());
|
||||
return !FUtil.DEVELOPERS.contains(player.getUniqueId().toString()) && !ConfigEntry.SERVER_EXECUTIVES.getList().contains(player.getName()) && !ConfigEntry.SERVER_OWNERS.getList().contains(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,10 +3,8 @@ package me.totalfreedom.totalfreedommod.httpd.module;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools;
|
||||
@ -29,14 +27,14 @@ public class Module_logfile extends HTTPDModule
|
||||
"gz"
|
||||
};
|
||||
|
||||
public Module_logfile(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||
public Module_logfile(NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
private static String getArg(String[] args, int index)
|
||||
private static String getArg(String[] args)
|
||||
{
|
||||
String out = (args.length == index + 1 ? args[index] : null);
|
||||
String out = (args.length == 1 + 1 ? args[1] : null);
|
||||
return (out == null ? null : (out.trim().isEmpty() ? null : out.trim()));
|
||||
}
|
||||
|
||||
@ -69,13 +67,13 @@ public class Module_logfile extends HTTPDModule
|
||||
final StringBuilder out = new StringBuilder();
|
||||
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||
final String[] args = StringUtils.split(uri, "/");
|
||||
final ModuleMode mode = ModuleMode.getMode(getArg(args, 1));
|
||||
final ModuleMode mode = ModuleMode.getMode(getArg(args));
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case LIST:
|
||||
{
|
||||
if (!isAuthorized(remoteAddress))
|
||||
if (isAuthorized(remoteAddress))
|
||||
{
|
||||
|
||||
out.append(HTMLGenerationTools.paragraph("Log files access denied: Your IP, " + remoteAddress + ", is not registered to an admin on this server."));
|
||||
@ -94,14 +92,7 @@ public class Module_logfile extends HTTPDModule
|
||||
|
||||
}
|
||||
|
||||
Collections.sort(LogFilesFormatted, new Comparator<String>()
|
||||
{
|
||||
@Override
|
||||
public int compare(String a, String b)
|
||||
{
|
||||
return a.toLowerCase().compareTo(b.toLowerCase());
|
||||
}
|
||||
});
|
||||
LogFilesFormatted.sort(Comparator.comparing(String::toLowerCase));
|
||||
|
||||
out
|
||||
.append(HTMLGenerationTools.heading("Logfiles:", 1))
|
||||
@ -113,7 +104,7 @@ public class Module_logfile extends HTTPDModule
|
||||
}
|
||||
case DOWNLOAD:
|
||||
{
|
||||
if (!isAuthorized(remoteAddress))
|
||||
if (isAuthorized(remoteAddress))
|
||||
{
|
||||
out.append(HTMLGenerationTools.paragraph("Log files access denied: Your IP, " + remoteAddress + ", is not registered to an admin on this server."));
|
||||
FLog.info("An unregistered IP (" + remoteAddress + ") has tried to download a log file");
|
||||
@ -172,7 +163,7 @@ public class Module_logfile extends HTTPDModule
|
||||
private boolean isAuthorized(String remoteAddress)
|
||||
{
|
||||
Admin entry = plugin.al.getEntryByIp(remoteAddress);
|
||||
return entry != null && entry.isActive();
|
||||
return entry == null || !entry.isActive();
|
||||
}
|
||||
|
||||
private enum ModuleMode
|
||||
@ -211,11 +202,6 @@ public class Module_logfile extends HTTPDModule
|
||||
|
||||
private static class LogFileTransferException extends Exception
|
||||
{
|
||||
|
||||
public LogFileTransferException()
|
||||
{
|
||||
}
|
||||
|
||||
public LogFileTransferException(String string)
|
||||
{
|
||||
super(string);
|
||||
|
@ -9,7 +9,7 @@ import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
public class Module_logs extends Module_file
|
||||
{
|
||||
|
||||
public Module_logs(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||
public Module_logs(NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import org.json.simple.JSONObject;
|
||||
public class Module_players extends HTTPDModule
|
||||
{
|
||||
|
||||
public Module_players(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||
public Module_players(NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
@ -25,7 +25,7 @@ public class Module_players extends HTTPDModule
|
||||
final JSONObject responseObject = new JSONObject();
|
||||
|
||||
final JSONArray players = new JSONArray();
|
||||
final JSONArray onlineadmins = new JSONArray();
|
||||
final JSONArray onlineadmins = new JSONArray(); // updated, never queried.
|
||||
final JSONArray masterbuilders = new JSONArray();
|
||||
final JSONArray admins = new JSONArray();
|
||||
final JSONArray senioradmins = new JSONArray();
|
||||
|
@ -10,7 +10,7 @@ import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||
public class Module_punishments extends HTTPDModule
|
||||
{
|
||||
|
||||
public Module_punishments(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||
public Module_punishments(NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
@ -8,12 +8,10 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools;
|
||||
@ -46,14 +44,14 @@ public class Module_schematic extends HTTPDModule
|
||||
+ "<button type=\"submit\">Submit</button>\n"
|
||||
+ "</form>";
|
||||
|
||||
public Module_schematic(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||
public Module_schematic(NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
private static String getArg(String[] args, int index)
|
||||
private static String getArg(String[] args)
|
||||
{
|
||||
String out = (args.length == index + 1 ? args[index] : null);
|
||||
String out = (args.length == 1 + 1 ? args[1] : null);
|
||||
return (out == null ? null : (out.trim().isEmpty() ? null : out.trim()));
|
||||
}
|
||||
|
||||
@ -85,7 +83,7 @@ public class Module_schematic extends HTTPDModule
|
||||
final StringBuilder out = new StringBuilder();
|
||||
|
||||
final String[] args = StringUtils.split(uri, "/");
|
||||
final ModuleMode mode = ModuleMode.getMode(getArg(args, 1));
|
||||
final ModuleMode mode = ModuleMode.getMode(getArg(args));
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
@ -112,14 +110,7 @@ public class Module_schematic extends HTTPDModule
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(schematicsFormatted, new Comparator<String>()
|
||||
{
|
||||
@Override
|
||||
public int compare(String a, String b)
|
||||
{
|
||||
return a.toLowerCase().compareTo(b.toLowerCase());
|
||||
}
|
||||
});
|
||||
schematicsFormatted.sort(Comparator.comparing(String::toLowerCase));
|
||||
|
||||
out.append(HTMLGenerationTools.heading("Schematics:", 1))
|
||||
.append("<ul>")
|
||||
@ -190,7 +181,7 @@ public class Module_schematic extends HTTPDModule
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
private boolean uploadSchematic(String remoteAddress) throws SchematicTransferException
|
||||
private void uploadSchematic(String remoteAddress) throws SchematicTransferException
|
||||
{
|
||||
Map<String, String> files = getFiles();
|
||||
|
||||
@ -244,7 +235,7 @@ public class Module_schematic extends HTTPDModule
|
||||
}
|
||||
try
|
||||
{
|
||||
ClipboardReader reader = format.getReader(new FileInputStream(targetFile));
|
||||
format.getReader(new FileInputStream(targetFile));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@ -261,7 +252,6 @@ public class Module_schematic extends HTTPDModule
|
||||
throw new SchematicTransferException();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Response downloadSchematic(String schematicName) throws SchematicTransferException
|
||||
|
Reference in New Issue
Block a user