1 |
package dk.thoerup.bukkit.hoeruputils.web; |
package dk.thoerup.bukkit.hoeruputils.web; |
2 |
|
|
3 |
import java.io.File; |
import java.io.IOException; |
4 |
|
import java.io.OutputStream; |
5 |
|
import java.net.HttpURLConnection; |
6 |
import java.text.SimpleDateFormat; |
import java.text.SimpleDateFormat; |
7 |
import java.util.Date; |
import java.util.Date; |
8 |
import java.util.Set; |
|
|
import java.util.Map; |
|
|
import org.bukkit.Location; |
|
|
import org.bukkit.Server; |
|
9 |
import org.bukkit.OfflinePlayer; |
import org.bukkit.OfflinePlayer; |
10 |
import org.bukkit.entity.Player; |
import org.bukkit.Server; |
11 |
import org.bukkit.plugin.Plugin; |
import org.bukkit.plugin.Plugin; |
12 |
|
|
13 |
import org.bukkit.configuration.Configuration; |
import com.sun.net.httpserver.HttpExchange; |
14 |
|
import com.sun.net.httpserver.HttpHandler; |
15 |
|
|
|
/*import org.kokakiwi.apicraft.events.ApiEvent; |
|
|
import org.kokakiwi.apicraft.events.ApiListener;*/ |
|
|
import de.codeinfection.quickwango.ApiBukkit.ApiBukkit; |
|
|
import de.codeinfection.quickwango.ApiBukkit.ApiServer.*; |
|
16 |
|
|
17 |
|
|
18 |
@Controller( name = "bans", authenticate = false, serializer = "raw" ) |
public class BanListener implements HttpHandler { |
|
public class BanListener extends ApiController { |
|
19 |
|
|
20 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
21 |
|
|
25 |
String cachedText = ""; |
String cachedText = ""; |
26 |
|
|
27 |
public BanListener(Plugin plugin, Server server) { |
public BanListener(Plugin plugin, Server server) { |
|
super( new de.codeinfection.quickwango.Abstraction.Implementations.Bukkit.BukkitPlugin(plugin) ); |
|
|
//super( new de.codeinfection.quickwango.ApiBukkit.Abstraction.Implementations.Bukkit.BukkitPlugin(plugin) ); |
|
28 |
|
|
29 |
this.server = server; |
this.server = server; |
30 |
} |
} |
37 |
return format.format(d ); |
return format.format(d ); |
38 |
} |
} |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
@Override |
@Override |
43 |
public void defaultAction(ApiRequest request, ApiResponse response) { |
public void handle(HttpExchange http) throws IOException { |
44 |
/* if(!event.path[0].equalsIgnoreCase("webstatus")) { |
/* if(!event.path[0].equalsIgnoreCase("webstatus")) { |
45 |
return; |
return; |
46 |
}*/ |
}*/ |
47 |
|
|
57 |
text = cachedText; |
text = cachedText; |
58 |
} |
} |
59 |
} |
} |
|
|
|
60 |
|
|
61 |
/* event.setResponse(xml); |
byte bytes[] = text.getBytes(); |
62 |
event.setActionTaken(true);*/ |
http.sendResponseHeaders(HttpURLConnection.HTTP_OK, bytes.length ); |
63 |
|
final OutputStream os = http.getResponseBody(); |
64 |
response.setContent( text ); |
os.write(bytes); |
65 |
|
os.close(); |
66 |
|
http.close(); |
67 |
|
|
68 |
} |
} |
69 |
|
|
70 |
private String buildText() { |
private String buildText() { |
90 |
|
|
91 |
} |
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
} |
} |