mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-11 13:33:54 +00:00
Bug fixes (#92)
* Bug fixes - Now checks if nothing was ejected - Fix NPE in saconfig - Module_permbans now checks if you are an admin * Discord is better
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
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.banning.PermbanList;
|
||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Module_permbans extends HTTPDModule
|
||||
{
|
||||
|
||||
@ -18,6 +20,12 @@ public class Module_permbans extends HTTPDModule
|
||||
public NanoHTTPD.Response getResponse()
|
||||
{
|
||||
File permbanFile = new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME);
|
||||
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 permban list. Your IP, " + remoteAddress + ", is not registered to an admin on the server.");
|
||||
}
|
||||
if (permbanFile.exists())
|
||||
{
|
||||
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
|
||||
@ -28,4 +36,10 @@ public class Module_permbans extends HTTPDModule
|
||||
"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