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.web.MessageListener; |
import dk.thoerup.bukkit.hoeruputils.chests.LockedChest; |
11 |
import dk.thoerup.bukkit.hoeruputils.web.StatusListener; |
import dk.thoerup.bukkit.hoeruputils.chests.LockedChestBean; |
12 |
|
import dk.thoerup.bukkit.hoeruputils.chests.SnitchingChest; |
13 |
|
import dk.thoerup.bukkit.hoeruputils.chests.SnitchingChestBean; |
14 |
|
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; |
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 |
33 |
public void onEnable() { |
public void onEnable() { |
34 |
System.out.println("Loading HoerupUtils plugin"); |
System.out.println("Loading HoerupUtils plugin"); |
35 |
getCommand("whereis").setExecutor(new WhereisCommand(getServer())); |
getCommand("whereis").setExecutor(new WhereisCommand(getServer())); |
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("grass").setExecutor(new GrassCommand()); |
getCommand("getpos").setExecutor( new GetposCommand() ); |
39 |
|
getCommand("msg").setExecutor( new MsgCommand( this ) ); |
40 |
|
getCommand("tp").setExecutor( new TeleportCommand() ); |
41 |
|
|
42 |
|
getCommand("wall").setExecutor( new WallCommand() ); |
43 |
|
getCommand("weather").setExecutor( new WeatherCommand() ); |
44 |
|
|
45 |
|
getCommand("gc").setExecutor( new GcCommand() ); |
46 |
|
|
47 |
|
|
48 |
|
HomeCommand home = new HomeCommand(this); |
49 |
|
getCommand("home").setExecutor( home ); |
50 |
|
getCommand("sethome").setExecutor( home ); |
51 |
|
|
52 |
|
DiverCommand diver = new DiverCommand(this ); |
53 |
|
getCommand("diver").setExecutor( diver ); |
54 |
|
|
55 |
|
GeneralContractorCommands generalContractor = new GeneralContractorCommands(); |
56 |
|
getCommand("replay").setExecutor( generalContractor ); |
57 |
|
getCommand("levelarea").setExecutor( generalContractor ); |
58 |
|
getCommand("fillarea").setExecutor( generalContractor ); |
59 |
|
getCommand("slopearea").setExecutor( generalContractor ); |
60 |
|
getCommand("setsurface").setExecutor( generalContractor ); |
61 |
|
getCommand("platform").setExecutor( generalContractor ); |
62 |
|
getCommand("cylinder").setExecutor( generalContractor ); |
63 |
|
getCommand("createcave").setExecutor( generalContractor ); |
64 |
|
|
65 |
|
|
66 |
|
getCommand("template").setExecutor( new TemplateCommand(this) ); |
67 |
|
|
68 |
|
LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() ); |
69 |
|
|
70 |
|
|
71 |
PluginManager pm = getServer().getPluginManager(); |
PluginManager pm = getServer().getPluginManager(); |
72 |
pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this); |
|
73 |
pm.registerEvent(Event.Type.ENTITY_DEATH, new RespawnHandler.PlayerDeathListener(this.getDataFolder()), Priority.Normal, this); |
|
74 |
|
pm.registerEvents(logintimeHandler, this); |
75 |
|
pm.registerEvents(logintimeHandler, this); |
76 |
|
|
77 |
|
|
78 |
|
pm.registerEvents(diver, this); |
79 |
|
|
80 |
|
pm.registerEvents(new EndermanStopper(), this); |
81 |
|
|
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 |
|
LockedChest locked = new LockedChest(this, ddlInstaller); |
102 |
|
getCommand("lockedchest").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()), 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 |
|
try { |
114 |
|
try { |
115 |
|
//først probes om klassen i det hele taget findes |
116 |
|
Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception |
117 |
|
WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig()); |
118 |
|
|
119 |
|
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 |
|
|
129 |
|
|
130 |
|
|
131 |
|
DoorBlockListener secretDoor = new DoorBlockListener(this); |
132 |
|
pm.registerEvents(secretDoor, this); |
133 |
|
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(SnitchingChestBean.class); |
148 |
|
list.add(LockedChestBean.class); |
149 |
|
list.add(WebUser.class); |
150 |
|
|
151 |
|
return list; |
152 |
|
} |
153 |
|
|
154 |
|
private void deprecated() { |
155 |
|
/* |
156 |
|
getCommand("stoner").setExecutor( new StonerCommand() ); |
157 |
|
getCommand("spawn").setExecutor( new SpawnCommand() ); |
158 |
|
getCommand("boom").setExecutor( new BoomCommand(this) ); |
159 |
|
getCommand("grass").setExecutor(new GrassCommand()); |
160 |
|
|
161 |
|
getCommand("zapme").setExecutor( new ZapmeCommand() ); |
162 |
|
getCommand("zap").setExecutor( new ZapCommand() ); |
163 |
|
|
164 |
|
|
165 |
PowerMiner powerMiner = new PowerMiner(); |
PowerMiner powerMiner = new PowerMiner(); |
166 |
pm.registerEvent(Event.Type.BLOCK_DAMAGE, powerMiner, Priority.Normal, this); |
pm.registerEvent(Event.Type.BLOCK_DAMAGE, powerMiner, Priority.Normal, this); |
167 |
pm.registerEvent(Event.Type.PLAYER_QUIT, powerMiner.getPlayerQuitListener(), Priority.Normal, this); |
pm.registerEvent(Event.Type.PLAYER_QUIT, powerMiner.getPlayerQuitListener(), Priority.Normal, this); |
168 |
getCommand("powerminer").setExecutor(powerMiner); |
getCommand("powerminer").setExecutor(powerMiner); |
169 |
|
|
170 |
|
SuperMiner superMiner = new SuperMiner(); |
171 |
|
pm.registerEvent(Event.Type.BLOCK_DAMAGE, superMiner, Priority.Normal, this); |
172 |
|
pm.registerEvent(Event.Type.PLAYER_QUIT, superMiner.getPlayerQuitListener(), Priority.Normal, this); |
173 |
|
getCommand("superminer").setExecutor(superMiner); |
174 |
|
|
175 |
|
|
176 |
|
//pm.registerEvent(Event.Type.PROJECTILE_HIT, new ExplosiveSnowballs(), Priority.Normal, this); |
177 |
|
|
178 |
|
//pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this); |
179 |
|
//pm.registerEvent(Event.Type.ENTITY_DEATH, new RespawnHandler.PlayerDeathListener(this.getDataFolder()), Priority.Normal, this); |
180 |
|
|
181 |
|
*/ |
182 |
} |
} |
183 |
|
|
184 |
} |
} |