1 |
package dk.thoerup.bukkit.hoeruputils; |
package dk.thoerup.bukkit.hoeruputils; |
2 |
|
|
3 |
|
|
4 |
import java.lang.reflect.Method; |
import java.util.ArrayList; |
5 |
|
import java.util.List; |
6 |
|
|
|
import org.bukkit.configuration.Configuration; |
|
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 |
|
|
11 |
|
|
12 |
|
import dk.thoerup.bukkit.hoeruputils.chests.SnitchingChest; |
13 |
|
import dk.thoerup.bukkit.hoeruputils.chests.SnitchingChestBean; |
14 |
import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands; |
import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands; |
15 |
|
import dk.thoerup.bukkit.hoeruputils.message.MessageBean; |
16 |
|
import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper; |
17 |
import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener; |
import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener; |
18 |
|
import dk.thoerup.bukkit.hoeruputils.web.WebLoader; |
19 |
|
import dk.thoerup.bukkit.hoeruputils.web.WebUser; |
20 |
|
import dk.thoerup.bukkit.hoeruputils.web.WebUserCommand; |
21 |
|
|
22 |
public class HoerupUtilsPlugin extends JavaPlugin { |
public class HoerupUtilsPlugin extends JavaPlugin { |
23 |
|
|
25 |
public void onDisable() { |
public void onDisable() { |
26 |
// TODO Auto-generated method stub |
// TODO Auto-generated method stub |
27 |
} |
} |
28 |
|
|
29 |
|
MessageWrapper messageWrapper; |
30 |
|
|
31 |
|
|
32 |
@Override |
@Override |
36 |
//getCommand("mapgen").setExecutor(new MapgenCommand(this)); |
//getCommand("mapgen").setExecutor(new MapgenCommand(this)); |
37 |
getCommand("eternalday").setExecutor(new EternalDayCommand(this)); |
getCommand("eternalday").setExecutor(new EternalDayCommand(this)); |
38 |
getCommand("getpos").setExecutor( new GetposCommand() ); |
getCommand("getpos").setExecutor( new GetposCommand() ); |
39 |
getCommand("msg").setExecutor( new MsgCommand( getServer() ) ); |
getCommand("msg").setExecutor( new MsgCommand( this ) ); |
40 |
getCommand("tp").setExecutor( new TeleportCommand() ); |
getCommand("tp").setExecutor( new TeleportCommand() ); |
41 |
|
|
42 |
getCommand("wall").setExecutor( new WallCommand() ); |
getCommand("wall").setExecutor( new WallCommand() ); |
77 |
|
|
78 |
pm.registerEvents(diver, this); |
pm.registerEvents(diver, this); |
79 |
|
|
80 |
|
pm.registerEvents(new EndermanStopper(), this); |
81 |
pm.registerEvents(new EndermanStopper(), this); |
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
Runnable ddlInstaller = new Runnable() { |
88 |
|
@Override |
89 |
|
public void run() { |
90 |
|
System.out.println("installddl"); |
91 |
|
installDDL(); |
92 |
|
} |
93 |
|
}; |
94 |
|
messageWrapper = new MessageWrapper(this, ddlInstaller); |
95 |
|
pm.registerEvents( messageWrapper, this); |
96 |
|
|
97 |
|
SnitchingChest snitch = new SnitchingChest(this, ddlInstaller); |
98 |
|
getCommand("snitchingchest").setExecutor(snitch); |
99 |
|
pm.registerEvents( snitch, this); |
100 |
|
|
101 |
|
getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) ); |
102 |
|
|
103 |
|
|
104 |
//register web plugins |
//register web plugins |
105 |
//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); |
108 |
try { |
try { |
109 |
try { |
try { |
110 |
//først probes om klassen i det hele taget findes |
//først probes om klassen i det hele taget findes |
111 |
Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); |
Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception |
112 |
|
WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig()); |
113 |
Class<?>webloader = Class.forName("dk.thoerup.bukkit.hoeruputils.web.WebLoader"); |
|
114 |
Method load = webloader.getMethod("load", HoerupUtilsPlugin.class, Configuration.class, Configuration.class); |
getLogger().info("ApiBukkit found, status listener registered"); |
|
Object args[] = {this, logintimeHandler.getConfig(), home.getConfig() }; |
|
|
load.invoke(null, args); |
|
|
|
|
|
getLogger().warning("ApiBukkit found, status listener registered"); |
|
115 |
|
|
116 |
} catch (ClassNotFoundException e) { |
} catch (ClassNotFoundException e) { |
117 |
getLogger().warning("Could not find ApiBukkit - web status is disabled" ); |
getLogger().warning("Could not find ApiBukkit - web status is disabled" ); |
118 |
} |
} |
|
|
|
119 |
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
120 |
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() + ")" ); |
121 |
} |
} |
128 |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
129 |
|
|
130 |
} |
} |
131 |
|
|
132 |
|
public MessageWrapper getMessageWrapper() { |
133 |
|
return messageWrapper; |
134 |
|
} |
135 |
|
|
136 |
|
//@SuppressWarnings({ "unchecked", "rawtypes" }) |
137 |
|
@Override |
138 |
|
public List<Class<?>> getDatabaseClasses() { |
139 |
|
List<Class<?>> list = new ArrayList<Class<?>>(); |
140 |
|
|
141 |
|
list.add(MessageBean.class); |
142 |
|
list.add(SnitchingChestBean.class); |
143 |
|
list.add(WebUser.class); |
144 |
|
|
145 |
|
return list; |
146 |
|
} |
147 |
|
|
148 |
private void deprecated() { |
private void deprecated() { |
149 |
/* |
/* |