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 |
83 |
MotdHandler motd = new MotdHandler(this); |
MotdHandler motd = new MotdHandler(this); |
84 |
getCommand("motd").setExecutor( motd ); |
getCommand("motd").setExecutor( motd ); |
85 |
pm.registerEvents( motd, this); |
pm.registerEvents( motd, this); |
86 |
|
|
87 |
|
WayPoint wp = new WayPoint(this); |
88 |
|
getCommand("waypoint").setExecutor( wp ); |
89 |
|
getCommand("setwaypoint").setExecutor( wp ); |
90 |
|
pm.registerEvents( wp, this); |
91 |
|
|
92 |
|
|
93 |
pm.registerEvents(logintimeHandler, this); |
pm.registerEvents(logintimeHandler, this); |
97 |
pm.registerEvents(diver, this); |
pm.registerEvents(diver, this); |
98 |
|
|
99 |
pm.registerEvents(new EndermanStopper(), this); |
pm.registerEvents(new EndermanStopper(), this); |
100 |
|
|
101 |
|
Jail jail = new Jail(this); |
102 |
|
pm.registerEvents(jail, this); |
103 |
|
getCommand("jail").setExecutor( jail ); |
104 |
|
|
105 |
|
StickyChunk chunks = new StickyChunk(); |
106 |
|
pm.registerEvents(chunks, this); |
107 |
|
getCommand("stickychunk").setExecutor(chunks); |
108 |
|
|
109 |
|
Mute mute = new Mute(this); |
110 |
|
pm.registerEvents(mute, this); |
111 |
|
getCommand("mute").setExecutor(mute); |
112 |
|
getCommand("unmute").setExecutor(mute); |
113 |
|
|
114 |
|
|
115 |
Runnable ddlInstaller = new Runnable() { |
Runnable ddlInstaller = new Runnable() { |
134 |
//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); |
135 |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
136 |
|
|
137 |
try { |
/*try { |
138 |
try { |
try { |
139 |
//først probes om klassen i det hele taget findes |
//først probes om klassen i det hele taget findes |
140 |
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 |
147 |
} |
} |
148 |
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
149 |
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() + ")" ); |
150 |
|
}*/ |
151 |
|
|
152 |
|
try { |
153 |
|
InetSocketAddress adr = new InetSocketAddress("127.0.0.1", 9999); |
154 |
|
server = HttpServer.create(adr, 20); |
155 |
|
server.createContext("/bans", new BanListener(this, getServer()) ); |
156 |
|
server.createContext("/webstatus", new StatusListener(this, getServer(),logintimeHandler.getConfig(), home.getConfig()) ); |
157 |
|
server.start(); |
158 |
|
|
159 |
|
} catch(Exception e) { |
160 |
|
getLogger().log(Level.SEVERE, "Error loading webserver", e); |
161 |
|
|
162 |
} |
} |
163 |
|
|
164 |
|
|
166 |
|
|
167 |
DoorBlockListener secretDoor = new DoorBlockListener(this); |
DoorBlockListener secretDoor = new DoorBlockListener(this); |
168 |
pm.registerEvents(secretDoor, this); |
pm.registerEvents(secretDoor, this); |
169 |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
|
|
|
170 |
} |
} |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
public MessageWrapper getMessageWrapper() { |
public MessageWrapper getMessageWrapper() { |
177 |
return messageWrapper; |
return messageWrapper; |
178 |
} |
} |