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:
Telesphoreo
2018-07-24 22:54:00 -07:00
committed by Seth
parent c0b43f26ea
commit 113ab62f0b
6 changed files with 55 additions and 23 deletions

View File

@ -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();
}
}