1 |
package dk.thoerup.bukkit.hoeruputils; |
package dk.thoerup.bukkit.hoeruputils; |
2 |
|
|
3 |
|
|
4 |
|
import java.net.InetSocketAddress; |
5 |
import java.util.ArrayList; |
import java.util.ArrayList; |
6 |
import java.util.List; |
import java.util.List; |
7 |
|
import java.util.logging.Level; |
8 |
|
|
9 |
import org.bukkit.plugin.PluginManager; |
import org.bukkit.plugin.PluginManager; |
10 |
import org.bukkit.plugin.java.JavaPlugin; |
import org.bukkit.plugin.java.JavaPlugin; |
11 |
|
|
12 |
|
import com.sun.net.httpserver.HttpServer; |
13 |
|
|
14 |
import dk.thoerup.bukkit.hoeruputils.chests.AdvancedChest; |
import dk.thoerup.bukkit.hoeruputils.chests.AdvancedChest; |
15 |
import dk.thoerup.bukkit.hoeruputils.chests.ChestBean; |
import dk.thoerup.bukkit.hoeruputils.chests.ChestBean; |
16 |
import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands; |
import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands; |
17 |
import dk.thoerup.bukkit.hoeruputils.message.MessageBean; |
import dk.thoerup.bukkit.hoeruputils.message.MessageBean; |
18 |
import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper; |
import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper; |
19 |
import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener; |
import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener; |
20 |
import dk.thoerup.bukkit.hoeruputils.web.WebLoader; |
import dk.thoerup.bukkit.hoeruputils.web.BanListener; |
21 |
|
import dk.thoerup.bukkit.hoeruputils.web.StatusListener; |
22 |
import dk.thoerup.bukkit.hoeruputils.web.WebUser; |
import dk.thoerup.bukkit.hoeruputils.web.WebUser; |
23 |
import dk.thoerup.bukkit.hoeruputils.web.WebUserCommand; |
import dk.thoerup.bukkit.hoeruputils.web.WebUserCommand; |
24 |
|
|
26 |
|
|
27 |
@Override |
@Override |
28 |
public void onDisable() { |
public void onDisable() { |
29 |
// TODO Auto-generated method stub |
if ( server != null ) { |
30 |
|
server.stop( 0 ); |
31 |
|
} |
32 |
} |
} |
33 |
|
|
34 |
MessageWrapper messageWrapper; |
MessageWrapper messageWrapper; |
35 |
|
HttpServer server = null; |
36 |
|
|
37 |
|
|
38 |
@Override |
@Override |
124 |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new StatusListener(getServer(), logintimeHandler.getConfig(), home.getConfig() ), Priority.Normal, this); |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new StatusListener(getServer(), logintimeHandler.getConfig(), home.getConfig() ), Priority.Normal, this); |
125 |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
126 |
|
|
127 |
try { |
/*try { |
128 |
try { |
try { |
129 |
//først probes om klassen i det hele taget findes |
//først probes om klassen i det hele taget findes |
130 |
Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception |
Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception |
137 |
} |
} |
138 |
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
139 |
getLogger().warning("Could not find ApiBukkit - web status is disabled (" + e.getClass().getName() + ":" + e.getMessage() + ")" ); |
getLogger().warning("Could not find ApiBukkit - web status is disabled (" + e.getClass().getName() + ":" + e.getMessage() + ")" ); |
140 |
|
}*/ |
141 |
|
|
142 |
|
try { |
143 |
|
InetSocketAddress adr = new InetSocketAddress("localhost", 9999); |
144 |
|
HttpServer.create(adr, 10); |
145 |
|
server.createContext("/bans", new BanListener(this, getServer()) ); |
146 |
|
server.createContext("/webstatus", new StatusListener(this, getServer(),logintimeHandler.getConfig(), home.getConfig()) ); |
147 |
|
|
148 |
|
|
149 |
|
} catch(Exception e) { |
150 |
|
getLogger().log(Level.SEVERE, "Error loading webserver", e); |
151 |
|
|
152 |
} |
} |
153 |
|
|
154 |
|
|
156 |
|
|
157 |
DoorBlockListener secretDoor = new DoorBlockListener(this); |
DoorBlockListener secretDoor = new DoorBlockListener(this); |
158 |
pm.registerEvents(secretDoor, this); |
pm.registerEvents(secretDoor, this); |
159 |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
|
|
|
160 |
} |
} |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
public MessageWrapper getMessageWrapper() { |
public MessageWrapper getMessageWrapper() { |
167 |
return messageWrapper; |
return messageWrapper; |
168 |
} |
} |