1 |
package dk.thoerup.bukkit.hoeruputils; |
package dk.thoerup.bukkit.hoeruputils; |
2 |
|
|
3 |
|
|
4 |
|
import java.util.ArrayList; |
5 |
|
import java.util.List; |
6 |
|
|
7 |
import org.bukkit.plugin.PluginManager; |
import org.bukkit.plugin.PluginManager; |
8 |
import org.bukkit.plugin.java.JavaPlugin; |
import org.bukkit.plugin.java.JavaPlugin; |
9 |
|
|
10 |
import de.codeinfection.quickwango.ApiBukkit.ApiBukkit; |
import dk.thoerup.bukkit.hoeruputils.chests.AdvancedChest; |
11 |
import de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiManager; |
import dk.thoerup.bukkit.hoeruputils.chests.ChestBean; |
12 |
import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands; |
import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands; |
13 |
|
import dk.thoerup.bukkit.hoeruputils.message.MessageBean; |
14 |
|
import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper; |
15 |
import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener; |
import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener; |
16 |
import dk.thoerup.bukkit.hoeruputils.web.StatusListener; |
import dk.thoerup.bukkit.hoeruputils.web.WebLoader; |
17 |
|
import dk.thoerup.bukkit.hoeruputils.web.WebUser; |
18 |
|
import dk.thoerup.bukkit.hoeruputils.web.WebUserCommand; |
19 |
|
|
20 |
public class HoerupUtilsPlugin extends JavaPlugin { |
public class HoerupUtilsPlugin extends JavaPlugin { |
21 |
|
|
23 |
public void onDisable() { |
public void onDisable() { |
24 |
// TODO Auto-generated method stub |
// TODO Auto-generated method stub |
25 |
} |
} |
26 |
|
|
27 |
|
MessageWrapper messageWrapper; |
28 |
|
|
29 |
|
|
30 |
@Override |
@Override |
34 |
//getCommand("mapgen").setExecutor(new MapgenCommand(this)); |
//getCommand("mapgen").setExecutor(new MapgenCommand(this)); |
35 |
getCommand("eternalday").setExecutor(new EternalDayCommand(this)); |
getCommand("eternalday").setExecutor(new EternalDayCommand(this)); |
36 |
getCommand("getpos").setExecutor( new GetposCommand() ); |
getCommand("getpos").setExecutor( new GetposCommand() ); |
37 |
getCommand("msg").setExecutor( new MsgCommand( getServer() ) ); |
getCommand("msg").setExecutor( new MsgCommand( this ) ); |
38 |
getCommand("tp").setExecutor( new TeleportCommand() ); |
getCommand("tp").setExecutor( new TeleportCommand() ); |
39 |
|
|
40 |
getCommand("wall").setExecutor( new WallCommand() ); |
getCommand("wall").setExecutor( new WallCommand() ); |
46 |
HomeCommand home = new HomeCommand(this); |
HomeCommand home = new HomeCommand(this); |
47 |
getCommand("home").setExecutor( home ); |
getCommand("home").setExecutor( home ); |
48 |
getCommand("sethome").setExecutor( home ); |
getCommand("sethome").setExecutor( home ); |
49 |
|
getCommand("ophome").setExecutor( home ); |
50 |
|
|
51 |
DiverCommand diver = new DiverCommand(this ); |
DiverCommand diver = new DiverCommand(this ); |
52 |
getCommand("diver").setExecutor( diver ); |
getCommand("diver").setExecutor( diver ); |
59 |
getCommand("setsurface").setExecutor( generalContractor ); |
getCommand("setsurface").setExecutor( generalContractor ); |
60 |
getCommand("platform").setExecutor( generalContractor ); |
getCommand("platform").setExecutor( generalContractor ); |
61 |
getCommand("cylinder").setExecutor( generalContractor ); |
getCommand("cylinder").setExecutor( generalContractor ); |
62 |
|
getCommand("createcave").setExecutor( generalContractor ); |
63 |
|
getCommand("spawn").setExecutor( new SpawnCommand() ); |
64 |
|
|
65 |
|
getCommand("template").setExecutor( new TemplateCommand(this) ); |
66 |
|
|
67 |
LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() ); |
LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() ); |
68 |
|
|
70 |
PluginManager pm = getServer().getPluginManager(); |
PluginManager pm = getServer().getPluginManager(); |
71 |
|
|
72 |
|
|
73 |
|
MotdHandler motd = new MotdHandler(this); |
74 |
|
getCommand("motd").setExecutor( motd ); |
75 |
|
pm.registerEvents( motd, this); |
76 |
|
|
77 |
|
|
78 |
pm.registerEvents(logintimeHandler, this); |
pm.registerEvents(logintimeHandler, this); |
79 |
pm.registerEvents(logintimeHandler, this); |
pm.registerEvents(logintimeHandler, this); |
80 |
|
|
81 |
|
|
82 |
pm.registerEvents(diver, this); |
pm.registerEvents(diver, this); |
83 |
|
|
84 |
|
pm.registerEvents(new EndermanStopper(), this); |
85 |
pm.registerEvents(new EndermanStopper(), this); |
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
Runnable ddlInstaller = new Runnable() { |
92 |
|
@Override |
93 |
|
public void run() { |
94 |
|
System.out.println("installddl"); |
95 |
|
installDDL(); |
96 |
|
} |
97 |
|
}; |
98 |
|
messageWrapper = new MessageWrapper(this, ddlInstaller); |
99 |
|
pm.registerEvents( messageWrapper, this); |
100 |
|
|
101 |
|
AdvancedChest locked = new AdvancedChest(this, ddlInstaller); |
102 |
|
getCommand("chest").setExecutor(locked); |
103 |
|
pm.registerEvents( locked, this); |
104 |
|
|
105 |
|
|
106 |
|
getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) ); |
107 |
|
|
108 |
|
|
109 |
//register web plugins |
//register web plugins |
110 |
//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); |
111 |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
112 |
|
|
113 |
ApiBukkit api = (ApiBukkit) pm.getPlugin("ApiBukkit") ; |
try { |
114 |
if ( api != null) { |
try { |
115 |
StatusListener status = new StatusListener(this, getServer(), logintimeHandler.getConfig(), home.getConfig() ); |
//først probes om klassen i det hele taget findes |
116 |
//api.setRequestController("webstatus", status ); |
Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception |
117 |
ApiManager.getInstance().registerController( status ); |
WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig()); |
118 |
} else { |
|
119 |
System.out.println("Could not find ApiBukkit"); |
getLogger().info("ApiBukkit found, status listener registered"); |
120 |
|
|
121 |
|
} catch (ClassNotFoundException e) { |
122 |
|
getLogger().warning("Could not find ApiBukkit - web status is disabled" ); |
123 |
|
} |
124 |
|
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
125 |
|
getLogger().warning("Could not find ApiBukkit - web status is disabled (" + e.getClass().getName() + ":" + e.getMessage() + ")" ); |
126 |
} |
} |
127 |
|
|
128 |
|
|
133 |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
134 |
|
|
135 |
} |
} |
136 |
|
|
137 |
|
public MessageWrapper getMessageWrapper() { |
138 |
|
return messageWrapper; |
139 |
|
} |
140 |
|
|
141 |
|
//@SuppressWarnings({ "unchecked", "rawtypes" }) |
142 |
|
@Override |
143 |
|
public List<Class<?>> getDatabaseClasses() { |
144 |
|
List<Class<?>> list = new ArrayList<Class<?>>(); |
145 |
|
|
146 |
|
list.add(MessageBean.class); |
147 |
|
list.add(ChestBean.class); |
148 |
|
list.add(WebUser.class); |
149 |
|
|
150 |
|
return list; |
151 |
|
} |
152 |
|
|
153 |
private void deprecated() { |
private void deprecated() { |
154 |
/* |
/* |