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 |
|
|
|
import de.codeinfection.quickwango.ApiBukkit.ApiBukkit; |
|
|
import de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiManager; |
|
10 |
import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands; |
import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands; |
11 |
|
import dk.thoerup.bukkit.hoeruputils.message.MessageBean; |
12 |
|
import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper; |
13 |
import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener; |
import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener; |
14 |
import dk.thoerup.bukkit.hoeruputils.web.StatusListener; |
import dk.thoerup.bukkit.hoeruputils.web.WebLoader; |
15 |
|
|
16 |
public class HoerupUtilsPlugin extends JavaPlugin { |
public class HoerupUtilsPlugin extends JavaPlugin { |
17 |
|
|
19 |
public void onDisable() { |
public void onDisable() { |
20 |
// TODO Auto-generated method stub |
// TODO Auto-generated method stub |
21 |
} |
} |
22 |
|
|
23 |
|
MessageWrapper messageWrapper; |
24 |
|
|
25 |
|
|
26 |
@Override |
@Override |
30 |
//getCommand("mapgen").setExecutor(new MapgenCommand(this)); |
//getCommand("mapgen").setExecutor(new MapgenCommand(this)); |
31 |
getCommand("eternalday").setExecutor(new EternalDayCommand(this)); |
getCommand("eternalday").setExecutor(new EternalDayCommand(this)); |
32 |
getCommand("getpos").setExecutor( new GetposCommand() ); |
getCommand("getpos").setExecutor( new GetposCommand() ); |
33 |
getCommand("msg").setExecutor( new MsgCommand( getServer() ) ); |
getCommand("msg").setExecutor( new MsgCommand( this ) ); |
34 |
getCommand("tp").setExecutor( new TeleportCommand() ); |
getCommand("tp").setExecutor( new TeleportCommand() ); |
35 |
|
|
36 |
getCommand("wall").setExecutor( new WallCommand() ); |
getCommand("wall").setExecutor( new WallCommand() ); |
54 |
getCommand("setsurface").setExecutor( generalContractor ); |
getCommand("setsurface").setExecutor( generalContractor ); |
55 |
getCommand("platform").setExecutor( generalContractor ); |
getCommand("platform").setExecutor( generalContractor ); |
56 |
getCommand("cylinder").setExecutor( generalContractor ); |
getCommand("cylinder").setExecutor( generalContractor ); |
57 |
|
getCommand("createcave").setExecutor( generalContractor ); |
58 |
|
|
59 |
|
|
60 |
getCommand("template").setExecutor( new TemplateCommand(this) ); |
getCommand("template").setExecutor( new TemplateCommand(this) ); |
71 |
|
|
72 |
pm.registerEvents(diver, this); |
pm.registerEvents(diver, this); |
73 |
|
|
74 |
|
pm.registerEvents(new EndermanStopper(), this); |
75 |
pm.registerEvents(new EndermanStopper(), this); |
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
Runnable ddlInstaller = new Runnable() { |
82 |
|
@Override |
83 |
|
public void run() { |
84 |
|
System.out.println("installddl"); |
85 |
|
installDDL(); |
86 |
|
} |
87 |
|
}; |
88 |
|
messageWrapper = new MessageWrapper(this, ddlInstaller); |
89 |
|
pm.registerEvents( messageWrapper, this); |
90 |
|
|
91 |
|
SnitchingChest snitch = new SnitchingChest(this, ddlInstaller); |
92 |
|
getCommand("snitchingchest").setExecutor(snitch); |
93 |
|
pm.registerEvents( snitch, this); |
94 |
|
|
95 |
|
|
96 |
//register web plugins |
//register web plugins |
97 |
//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); |
98 |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
//pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this); |
99 |
|
|
100 |
ApiBukkit api = (ApiBukkit) pm.getPlugin("ApiBukkit") ; |
try { |
101 |
if ( api != null) { |
try { |
102 |
StatusListener status = new StatusListener(this, getServer(), logintimeHandler.getConfig(), home.getConfig() ); |
//først probes om klassen i det hele taget findes |
103 |
//api.setRequestController("webstatus", status ); |
Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception |
104 |
ApiManager.getInstance().registerController( status ); |
WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig()); |
105 |
} else { |
|
106 |
System.out.println("Could not find ApiBukkit"); |
getLogger().warning("ApiBukkit found, status listener registered"); |
107 |
|
|
108 |
|
} catch (ClassNotFoundException e) { |
109 |
|
getLogger().warning("Could not find ApiBukkit - web status is disabled" ); |
110 |
|
} |
111 |
|
} catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException |
112 |
|
getLogger().warning("Could not find ApiBukkit - web status is disabled (" + e.getClass().getName() + ":" + e.getMessage() + ")" ); |
113 |
} |
} |
114 |
|
|
115 |
|
|
120 |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
pm.registerEvents(secretDoor.getPlayerListener(), this); |
121 |
|
|
122 |
} |
} |
123 |
|
|
124 |
|
public MessageWrapper getMessageWrapper() { |
125 |
|
return messageWrapper; |
126 |
|
} |
127 |
|
|
128 |
|
//@SuppressWarnings({ "unchecked", "rawtypes" }) |
129 |
|
@Override |
130 |
|
public List<Class<?>> getDatabaseClasses() { |
131 |
|
System.out.println("getDatabaseClasses"); |
132 |
|
List<Class<?>> list = new ArrayList<Class<?>>(); |
133 |
|
|
134 |
|
list.add(MessageBean.class); |
135 |
|
list.add(SnitchingChestBean.class); |
136 |
|
|
137 |
|
return list; |
138 |
|
} |
139 |
|
|
140 |
private void deprecated() { |
private void deprecated() { |
141 |
/* |
/* |