mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-11 13:33:54 +00:00
Punishment logging!
This commit is contained in:
@ -10,7 +10,6 @@ import java.util.regex.Pattern;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_admins;
|
||||
@ -23,6 +22,7 @@ import me.totalfreedom.totalfreedommod.httpd.module.Module_logfile;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_logs;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_permbans;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_punishments;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -67,6 +67,7 @@ public class HTTPDaemon extends FreedomService
|
||||
module("logs", Module_logs.class, true);
|
||||
module("permbans", Module_permbans.class, true);
|
||||
module("players", Module_players.class, false);
|
||||
module("punishments", Module_punishments.class, true);
|
||||
module("schematic", Module_schematic.class, true);
|
||||
|
||||
try
|
||||
|
@ -72,7 +72,7 @@ public class Module_logfile extends HTTPDModule
|
||||
if (!isAuthorized(remoteAddress))
|
||||
{
|
||||
|
||||
out.append(HTMLGenerationTools.paragraph("Log files access denied: Your IP, " + remoteAddress + ", is not registered to a superadmin on this server."));
|
||||
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 access the log files");
|
||||
}
|
||||
else
|
||||
|
@ -0,0 +1,48 @@
|
||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||
|
||||
import java.io.File;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||
|
||||
public class Module_punishments extends HTTPDModule
|
||||
{
|
||||
|
||||
public Module_punishments(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(plugin, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NanoHTTPD.Response getResponse()
|
||||
{
|
||||
File adminFile = new File(plugin.getDataFolder(), PunishmentList.CONFIG_FILENAME);
|
||||
if (adminFile.exists())
|
||||
{
|
||||
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||
if (!isAuthorized(remoteAddress))
|
||||
{
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"You may not view the punishment list, Your IP, " + remoteAddress + ", is not registered to an admin on the server.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), PunishmentList.CONFIG_FILENAME));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAuthorized(String remoteAddress)
|
||||
{
|
||||
Admin entry = plugin.al.getEntryByIp(remoteAddress);
|
||||
return entry != null && entry.isActive();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user