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 |
92 |
pm.registerEvents(diver, this); |
pm.registerEvents(diver, this); |
93 |
|
|
94 |
pm.registerEvents(new EndermanStopper(), this); |
pm.registerEvents(new EndermanStopper(), this); |
95 |
|
|
96 |
|
Jail jail = new Jail(this); |
97 |
|
pm.registerEvents(jail, this); |
98 |
|
getCommand("jail").setExecutor( jail ); |
99 |
|
|
100 |
|
StickyChunk chunks = new StickyChunk(); |
101 |
|
pm.registerEvents(chunks, this); |
102 |
|
getCommand("stickychunk").setExecutor(chunks); |
103 |
|
|
104 |
|
|
105 |
|
|
125 |
//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); |
126 |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
127 |
|
|
128 |
try { |
/*try { |
129 |
try { |
try { |
130 |
//først probes om klassen i det hele taget findes |
//først probes om klassen i det hele taget findes |
131 |
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 |
138 |
} |
} |
139 |
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
140 |
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() + ")" ); |
141 |
|
}*/ |
142 |
|
|
143 |
|
try { |
144 |
|
InetSocketAddress adr = new InetSocketAddress("127.0.0.1", 9999); |
145 |
|
server = HttpServer.create(adr, 20); |
146 |
|
server.createContext("/bans", new BanListener(this, getServer()) ); |
147 |
|
server.createContext("/webstatus", new StatusListener(this, getServer(),logintimeHandler.getConfig(), home.getConfig()) ); |
148 |
|
server.start(); |
149 |
|
|
150 |
|
} catch(Exception e) { |
151 |
|
getLogger().log(Level.SEVERE, "Error loading webserver", e); |
152 |
|
|
153 |
} |
} |
154 |
|
|
155 |
|
|
157 |
|
|
158 |
DoorBlockListener secretDoor = new DoorBlockListener(this); |
DoorBlockListener secretDoor = new DoorBlockListener(this); |
159 |
pm.registerEvents(secretDoor, this); |
pm.registerEvents(secretDoor, this); |
160 |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
|
|
|
161 |
} |
} |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
public MessageWrapper getMessageWrapper() { |
public MessageWrapper getMessageWrapper() { |
168 |
return messageWrapper; |
return messageWrapper; |
169 |
} |
} |