From 1416429910bc1180398d3a131e7eedc98ba13f4a Mon Sep 17 00:00:00 2001 From: StevenLawson Date: Sat, 14 Sep 2013 21:59:11 -0400 Subject: [PATCH] Add permbans module for HTTPd. --- .../HTTPD/Module_permbans.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_permbans.java diff --git a/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_permbans.java b/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_permbans.java new file mode 100644 index 0000000..f261ffe --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_permbans.java @@ -0,0 +1,29 @@ +package me.StevenLawson.TotalFreedomMod.HTTPD; + +import java.io.File; +import java.net.Socket; +import java.util.Map; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; + +public class Module_permbans extends TFM_HTTPD_Module +{ + public Module_permbans(String uri, NanoHTTPD.Method method, Map headers, Map params, Map files, Socket socket) + { + super(uri, method, headers, params, files, socket); + } + + @Override + public NanoHTTPD.Response getResponse() + { + File permbanFile = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PERMBAN_FILE); + if (permbanFile.exists()) + { + return TFM_HTTPD_Manager.serveFileBasic(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PERMBAN_FILE)); + } + 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."); + } + } +}