/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/HoerupUtilsPlugin.java
ViewVC logotype

Contents of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/HoerupUtilsPlugin.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3222 - (show annotations) (download)
Sat Jan 6 15:40:01 2018 UTC (6 years, 4 months ago) by torben
File size: 7319 byte(s)
Implement /fillchest
1 package dk.thoerup.bukkit.hoeruputils;
2
3
4 import java.net.InetSocketAddress;
5 import java.util.logging.Level;
6
7 import org.bukkit.plugin.PluginManager;
8 import org.bukkit.plugin.java.JavaPlugin;
9
10 import com.sun.net.httpserver.HttpServer;
11
12 import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands;
13 import dk.thoerup.bukkit.hoeruputils.deprecated.ExplosiveSnowballs;
14 import dk.thoerup.bukkit.hoeruputils.deprecated.ZapCommand;
15 import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;
16 import dk.thoerup.bukkit.hoeruputils.web.BanListener;
17 import dk.thoerup.bukkit.hoeruputils.web.StatusListener;
18
19 @SuppressWarnings("restriction")
20 public class HoerupUtilsPlugin extends JavaPlugin {
21
22 @Override
23 public void onDisable() {
24 if ( server != null ) {
25 server.stop( 0 );
26 }
27 }
28
29 //MessageWrapper messageWrapper; //TODO: RE-ENABLE
30 HttpServer server = null;
31
32
33 @Override
34 public void onEnable() {
35 System.out.println("Loading HoerupUtils plugin");
36
37 //Ebean.getDefaultServer(); //TODO: RE-ENABLE
38
39 getCommand("whereis").setExecutor(new WhereisCommand(getServer()));
40 //getCommand("mapgen").setExecutor(new MapgenCommand(this));
41 getCommand("eternalday").setExecutor(new EternalDayCommand(this));
42 getCommand("getpos").setExecutor( new GetposCommand() );
43 getCommand("msg").setExecutor( new MsgCommand( this ) );
44 // getCommand("tp").setExecutor( new TeleportCommand() );
45
46 getCommand("wall").setExecutor( new WallCommand() );
47 getCommand("weather").setExecutor( new WeatherCommand() );
48
49 getCommand("gc").setExecutor( new GcCommand() );
50
51
52 HomeCommand home = new HomeCommand(this);
53 getCommand("home").setExecutor( home );
54 getCommand("sethome").setExecutor( home );
55 getCommand("ophome").setExecutor( home );
56
57 DiverCommand diver = new DiverCommand(this );
58 getCommand("diver").setExecutor( diver );
59
60 getCommand("opkill").setExecutor( new OpkillCommand() );
61
62 GeneralContractorCommands generalContractor = new GeneralContractorCommands();
63 getCommand("replay").setExecutor( generalContractor );
64 getCommand("levelarea").setExecutor( generalContractor );
65 getCommand("fillarea").setExecutor( generalContractor );
66 getCommand("levelandfillarea").setExecutor( generalContractor );
67
68 getCommand("slopearea").setExecutor( generalContractor );
69 getCommand("setsurface").setExecutor( generalContractor );
70 getCommand("platform").setExecutor( generalContractor );
71 getCommand("cylinder").setExecutor( generalContractor );
72 getCommand("createcave").setExecutor( generalContractor );
73 getCommand("spawn").setExecutor( new SpawnCommand() );
74
75 getCommand("template").setExecutor( new TemplateCommand(this) );
76 getCommand("regenerate").setExecutor( new RegenerateCommand() );
77
78
79 LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );
80
81
82 PluginManager pm = getServer().getPluginManager();
83
84
85 MotdHandler motd = new MotdHandler(this);
86 getCommand("motd").setExecutor( motd );
87 pm.registerEvents( motd, this);
88
89 WayPoint wp = new WayPoint(this);
90 getCommand("waypoint").setExecutor( wp );
91 getCommand("setwaypoint").setExecutor( wp );
92 pm.registerEvents( wp, this);
93
94
95 pm.registerEvents(logintimeHandler, this);
96 pm.registerEvents(logintimeHandler, this);
97
98
99
100 pm.registerEvents(diver, this);
101
102 pm.registerEvents(new EndermanStopper(), this);
103
104 Jail jail = new Jail(this);
105 pm.registerEvents(jail, this);
106 getCommand("jail").setExecutor( jail );
107
108 StickyChunk chunks = new StickyChunk();
109 pm.registerEvents(chunks, this);
110 getCommand("stickychunk").setExecutor(chunks);
111
112 Mute mute = new Mute(this);
113 pm.registerEvents(mute, this);
114 getCommand("mute").setExecutor(mute);
115 getCommand("unmute").setExecutor(mute);
116
117
118
119 getCommand("fillchest").setExecutor( new ChestFiller() );
120
121
122 // - fun/crazy/party elements
123 pm.registerEvents(new ExplosiveSnowballs(), this);
124 getCommand("zap").setExecutor( new ZapCommand() );
125
126 /*
127 * //TODO: RE-ENABLE
128 messageWrapper = new MessageWrapper(this);
129 pm.registerEvents( messageWrapper, this);
130
131 AdvancedChest locked = new AdvancedChest(this);
132 getCommand("chest").setExecutor(locked);
133 pm.registerEvents( locked, this);
134
135
136 getCommand("webuser").setExecutor( new WebUserCommand(this) );
137 */
138
139 //register web plugins
140 //pm.registerEvent(Event.Type.CUSTOM_EVENT, new StatusListener(getServer(), logintimeHandler.getConfig(), home.getConfig() ), Priority.Normal, this);
141 //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);
142
143 /*try {
144 try {
145 //først probes om klassen i det hele taget findes
146 Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception
147 WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig());
148
149 getLogger().info("ApiBukkit found, status listener registered");
150
151 } catch (ClassNotFoundException e) {
152 getLogger().warning("Could not find ApiBukkit - web status is disabled" );
153 }
154 } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException
155 getLogger().warning("Could not find ApiBukkit - web status is disabled (" + e.getClass().getName() + ":" + e.getMessage() + ")" );
156 }*/
157
158 try {
159 InetSocketAddress adr = new InetSocketAddress("127.0.0.1", 9999);
160 server = HttpServer.create(adr, 20);
161 server.createContext("/bans", new BanListener(this, getServer()) );
162 server.createContext("/webstatus", new StatusListener(this, getServer(),logintimeHandler.getConfig(), home.getConfig()) );
163 server.start();
164
165 } catch(Exception e) {
166 getLogger().log(Level.SEVERE, "Error loading webserver", e);
167
168 }
169
170
171
172
173 DoorBlockListener secretDoor = new DoorBlockListener(this);
174 pm.registerEvents(secretDoor, this);
175 pm.registerEvents(secretDoor.getPlayerListener(), this);
176 }
177
178
179
180
181 /*
182 * //TODO: RE-ENABLE
183 public MessageWrapper getMessageWrapper() {
184 return messageWrapper;
185 }
186 */
187
188
189
190
191 /*
192 private void deprecated() {
193
194 getCommand("stoner").setExecutor( new StonerCommand() );
195 getCommand("spawn").setExecutor( new SpawnCommand() );
196 getCommand("boom").setExecutor( new BoomCommand(this) );
197 getCommand("grass").setExecutor(new GrassCommand());
198
199 getCommand("zapme").setExecutor( new ZapmeCommand() );
200 getCommand("zap").setExecutor( new ZapCommand() );
201
202
203 PowerMiner powerMiner = new PowerMiner();
204 pm.registerEvent(Event.Type.BLOCK_DAMAGE, powerMiner, Priority.Normal, this);
205 pm.registerEvent(Event.Type.PLAYER_QUIT, powerMiner.getPlayerQuitListener(), Priority.Normal, this);
206 getCommand("powerminer").setExecutor(powerMiner);
207
208 SuperMiner superMiner = new SuperMiner();
209 pm.registerEvent(Event.Type.BLOCK_DAMAGE, superMiner, Priority.Normal, this);
210 pm.registerEvent(Event.Type.PLAYER_QUIT, superMiner.getPlayerQuitListener(), Priority.Normal, this);
211 getCommand("superminer").setExecutor(superMiner);
212
213
214 //pm.registerEvent(Event.Type.PROJECTILE_HIT, new ExplosiveSnowballs(), Priority.Normal, this);
215
216 //pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this);
217 //pm.registerEvent(Event.Type.ENTITY_DEATH, new RespawnHandler.PlayerDeathListener(this.getDataFolder()), Priority.Normal, this);
218
219
220 }
221 */
222
223 }

  ViewVC Help
Powered by ViewVC 1.1.20