1 |
package dk.thoerup.bukkit.hoeruputils; |
package dk.thoerup.bukkit.hoeruputils; |
2 |
|
|
3 |
|
|
4 |
import org.bukkit.event.Event; |
import java.util.ArrayList; |
5 |
import org.bukkit.event.Event.Priority; |
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 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; |
14 |
|
import dk.thoerup.bukkit.hoeruputils.web.WebLoader; |
15 |
|
|
16 |
public class HoerupUtilsPlugin extends JavaPlugin { |
public class HoerupUtilsPlugin extends JavaPlugin { |
17 |
|
|
18 |
@Override |
@Override |
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 |
27 |
public void onEnable() { |
public void onEnable() { |
28 |
System.out.println("Loading HoerupUtils plugin"); |
System.out.println("Loading HoerupUtils plugin"); |
29 |
getCommand("whereis").setExecutor(new WhereisCommand(getServer())); |
getCommand("whereis").setExecutor(new WhereisCommand(getServer())); |
30 |
|
//getCommand("mapgen").setExecutor(new MapgenCommand(this)); |
31 |
|
getCommand("eternalday").setExecutor(new EternalDayCommand(this)); |
32 |
|
getCommand("getpos").setExecutor( new GetposCommand() ); |
33 |
|
getCommand("msg").setExecutor( new MsgCommand( this ) ); |
34 |
|
getCommand("tp").setExecutor( new TeleportCommand() ); |
35 |
|
|
36 |
|
getCommand("wall").setExecutor( new WallCommand() ); |
37 |
|
getCommand("weather").setExecutor( new WeatherCommand() ); |
38 |
|
|
39 |
|
getCommand("gc").setExecutor( new GcCommand() ); |
40 |
|
|
41 |
|
|
42 |
|
HomeCommand home = new HomeCommand(this); |
43 |
|
getCommand("home").setExecutor( home ); |
44 |
|
getCommand("sethome").setExecutor( home ); |
45 |
|
|
46 |
|
DiverCommand diver = new DiverCommand(this ); |
47 |
|
getCommand("diver").setExecutor( diver ); |
48 |
|
|
49 |
|
GeneralContractorCommands generalContractor = new GeneralContractorCommands(); |
50 |
|
getCommand("replay").setExecutor( generalContractor ); |
51 |
|
getCommand("levelarea").setExecutor( generalContractor ); |
52 |
|
getCommand("fillarea").setExecutor( generalContractor ); |
53 |
|
getCommand("slopearea").setExecutor( generalContractor ); |
54 |
|
getCommand("setsurface").setExecutor( generalContractor ); |
55 |
|
getCommand("platform").setExecutor( generalContractor ); |
56 |
|
getCommand("cylinder").setExecutor( generalContractor ); |
57 |
|
getCommand("createcave").setExecutor( generalContractor ); |
58 |
|
|
59 |
|
|
60 |
|
getCommand("template").setExecutor( new TemplateCommand(this) ); |
61 |
|
|
62 |
|
LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() ); |
63 |
|
|
64 |
|
|
65 |
PluginManager pm = getServer().getPluginManager(); |
PluginManager pm = getServer().getPluginManager(); |
66 |
pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this); |
|
67 |
pm.registerEvent(Event.Type.ENTITY_DEATH, new RespawnHandler.PlayerDeathListener(this.getDataFolder()), Priority.Normal, this); |
|
68 |
|
pm.registerEvents(logintimeHandler, this); |
69 |
|
pm.registerEvents(logintimeHandler, this); |
70 |
|
|
71 |
|
|
72 |
|
pm.registerEvents(diver, this); |
73 |
|
|
74 |
|
pm.registerEvents(new EndermanStopper(), this); |
75 |
|
|
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 |
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new PeriodicStatusSaver(getServer()), 10*20, 2*60*20); |
SnitchingChest snitch = new SnitchingChest(this, ddlInstaller); |
92 |
|
getCommand("snitchingchest").setExecutor(snitch); |
93 |
|
pm.registerEvents( snitch, this); |
94 |
|
|
95 |
|
|
96 |
|
//register web plugins |
97 |
|
//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); |
99 |
|
|
100 |
|
try { |
101 |
|
try { |
102 |
|
//først probes om klassen i det hele taget findes |
103 |
|
Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception |
104 |
|
WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig()); |
105 |
|
|
106 |
|
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 |
|
|
116 |
|
|
117 |
|
|
118 |
|
DoorBlockListener secretDoor = new DoorBlockListener(this); |
119 |
|
pm.registerEvents(secretDoor, this); |
120 |
|
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() { |
141 |
|
/* |
142 |
|
getCommand("stoner").setExecutor( new StonerCommand() ); |
143 |
|
getCommand("spawn").setExecutor( new SpawnCommand() ); |
144 |
|
getCommand("boom").setExecutor( new BoomCommand(this) ); |
145 |
|
getCommand("grass").setExecutor(new GrassCommand()); |
146 |
|
|
147 |
|
getCommand("zapme").setExecutor( new ZapmeCommand() ); |
148 |
|
getCommand("zap").setExecutor( new ZapCommand() ); |
149 |
|
|
150 |
|
|
151 |
|
PowerMiner powerMiner = new PowerMiner(); |
152 |
|
pm.registerEvent(Event.Type.BLOCK_DAMAGE, powerMiner, Priority.Normal, this); |
153 |
|
pm.registerEvent(Event.Type.PLAYER_QUIT, powerMiner.getPlayerQuitListener(), Priority.Normal, this); |
154 |
|
getCommand("powerminer").setExecutor(powerMiner); |
155 |
|
|
156 |
|
SuperMiner superMiner = new SuperMiner(); |
157 |
|
pm.registerEvent(Event.Type.BLOCK_DAMAGE, superMiner, Priority.Normal, this); |
158 |
|
pm.registerEvent(Event.Type.PLAYER_QUIT, superMiner.getPlayerQuitListener(), Priority.Normal, this); |
159 |
|
getCommand("superminer").setExecutor(superMiner); |
160 |
|
|
161 |
|
|
162 |
|
//pm.registerEvent(Event.Type.PROJECTILE_HIT, new ExplosiveSnowballs(), Priority.Normal, this); |
163 |
|
|
164 |
|
//pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this); |
165 |
|
//pm.registerEvent(Event.Type.ENTITY_DEATH, new RespawnHandler.PlayerDeathListener(this.getDataFolder()), Priority.Normal, this); |
166 |
|
|
167 |
|
*/ |
168 |
} |
} |
169 |
|
|
170 |
} |
} |