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

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

  ViewVC Help
Powered by ViewVC 1.1.20