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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1236  
changed lines
  Added in v.3207

  ViewVC Help
Powered by ViewVC 1.1.20