/[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

revision 1786 by torben, Fri Apr 6 15:06:46 2012 UTC revision 3220 by torben, Sat Jan 6 14:41:35 2018 UTC
# Line 1  Line 1 
1  package dk.thoerup.bukkit.hoeruputils;  package dk.thoerup.bukkit.hoeruputils;
2    
3    
4  import java.util.ArrayList;  import java.net.InetSocketAddress;
5  import java.util.List;  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.avaje.ebeaninternal.api.SpiEbeanServer;  import com.sun.net.httpserver.HttpServer;
 import com.avaje.ebeaninternal.server.ddl.DdlGenerator;  
11    
12  import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands;  import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands;
13  import dk.thoerup.bukkit.hoeruputils.message.MessageBean;  import dk.thoerup.bukkit.hoeruputils.deprecated.ExplosiveSnowballs;
14  import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper;  import dk.thoerup.bukkit.hoeruputils.deprecated.ZapCommand;
15  import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;  import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;
16  import dk.thoerup.bukkit.hoeruputils.web.WebLoader;  import dk.thoerup.bukkit.hoeruputils.web.BanListener;
17  import dk.thoerup.bukkit.hoeruputils.web.WebUser;  import dk.thoerup.bukkit.hoeruputils.web.StatusListener;
 import dk.thoerup.bukkit.hoeruputils.web.WebUserCommand;  
18    
19    @SuppressWarnings("restriction")
20  public class HoerupUtilsPlugin extends JavaPlugin {  public class HoerupUtilsPlugin extends JavaPlugin {
21    
22          @Override          @Override
23          public void onDisable() {          public void onDisable() {
24                  // TODO Auto-generated method stub                  if ( server != null ) {
25                            server.stop( 0 );
26                    }
27          }          }
28                    
29          MessageWrapper messageWrapper;          //MessageWrapper messageWrapper;        //TODO: RE-ENABLE
30            HttpServer server = null;
31    
32                    
33          @Override          @Override
34          public void onEnable() {          public void onEnable() {
35                  System.out.println("Loading HoerupUtils plugin");                  System.out.println("Loading HoerupUtils plugin");
36                    
37                    //Ebean.getDefaultServer(); //TODO: RE-ENABLE
38                    
39                  getCommand("whereis").setExecutor(new WhereisCommand(getServer()));                  getCommand("whereis").setExecutor(new WhereisCommand(getServer()));
40                  //getCommand("mapgen").setExecutor(new MapgenCommand(this));                  //getCommand("mapgen").setExecutor(new MapgenCommand(this));
41                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));
42                  getCommand("getpos").setExecutor( new GetposCommand() );                  getCommand("getpos").setExecutor( new GetposCommand() );
43                  getCommand("msg").setExecutor( new MsgCommand( this ) );                  getCommand("msg").setExecutor( new MsgCommand( this ) );
44                  getCommand("tp").setExecutor( new TeleportCommand() );  //              getCommand("tp").setExecutor( new TeleportCommand() );
45    
46                  getCommand("wall").setExecutor( new WallCommand() );                  getCommand("wall").setExecutor( new WallCommand() );
47                  getCommand("weather").setExecutor( new WeatherCommand() );                  getCommand("weather").setExecutor( new WeatherCommand() );
# Line 47  public class HoerupUtilsPlugin extends J Line 52  public class HoerupUtilsPlugin extends J
52                  HomeCommand home = new HomeCommand(this);                  HomeCommand home = new HomeCommand(this);
53                  getCommand("home").setExecutor( home );                  getCommand("home").setExecutor( home );
54                  getCommand("sethome").setExecutor( home );                  getCommand("sethome").setExecutor( home );
55                    getCommand("ophome").setExecutor( home );
56    
57                  DiverCommand diver = new DiverCommand(this );                  DiverCommand diver = new DiverCommand(this );
58                  getCommand("diver").setExecutor( diver );                  getCommand("diver").setExecutor( diver );
59    
60                    getCommand("opkill").setExecutor( new OpkillCommand() );
61                                    
62                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();
63                  getCommand("replay").setExecutor( generalContractor );                  getCommand("replay").setExecutor( generalContractor );
64                  getCommand("levelarea").setExecutor( generalContractor );                  getCommand("levelarea").setExecutor( generalContractor );
65                  getCommand("fillarea").setExecutor( generalContractor );                  getCommand("fillarea").setExecutor( generalContractor );
66                    getCommand("levelandfillarea").setExecutor( generalContractor );
67    
68                  getCommand("slopearea").setExecutor( generalContractor );                  getCommand("slopearea").setExecutor( generalContractor );
69                  getCommand("setsurface").setExecutor( generalContractor );                  getCommand("setsurface").setExecutor( generalContractor );
70                  getCommand("platform").setExecutor( generalContractor );                  getCommand("platform").setExecutor( generalContractor );
71                  getCommand("cylinder").setExecutor( generalContractor );                  getCommand("cylinder").setExecutor( generalContractor );
72                  getCommand("createcave").setExecutor( generalContractor );                  getCommand("createcave").setExecutor( generalContractor );
73                    getCommand("spawn").setExecutor( new SpawnCommand() );
74                                    
75                  getCommand("template").setExecutor( new TemplateCommand(this) );                  getCommand("template").setExecutor( new TemplateCommand(this) );
76                    getCommand("regenerate").setExecutor( new RegenerateCommand() );
77    
78    
79                  LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );                  LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );
80                                    
# Line 70  public class HoerupUtilsPlugin extends J Line 82  public class HoerupUtilsPlugin extends J
82                  PluginManager pm = getServer().getPluginManager();                  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);                  pm.registerEvents(logintimeHandler, this);
96                  pm.registerEvents(logintimeHandler, this);                  pm.registerEvents(logintimeHandler, this);
97    
98                                    
99                    
100                  pm.registerEvents(diver, this);                  pm.registerEvents(diver, this);
101    
102                  pm.registerEvents(new EndermanStopper(), this);                  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                                    // - fun/crazy/party elements
119                                    pm.registerEvents(new ExplosiveSnowballs(), this);
120                                    getCommand("zap").setExecutor( new ZapCommand() );
121                    
122                  Runnable ddlInstaller = new Runnable() {  /*
123                          @Override   * //TODO: RE-ENABLE
124                          public void run() {                  messageWrapper = new MessageWrapper(this);
                                 System.out.println("installddl");  
                                 installDDL();  
                         }  
                 };  
                 messageWrapper = new MessageWrapper(this, ddlInstaller);  
125                  pm.registerEvents( messageWrapper, this);                  pm.registerEvents( messageWrapper, this);
126                            
127                    AdvancedChest locked = new AdvancedChest(this);
128                    getCommand("chest").setExecutor(locked);
129                    pm.registerEvents( locked, this);
130                                    
                 SnitchingChest snitch = new SnitchingChest(this, ddlInstaller);  
                 getCommand("snitchingchest").setExecutor(snitch);  
                 pm.registerEvents( snitch, this);  
131                                    
132                  getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) );                                              getCommand("webuser").setExecutor( new WebUserCommand(this) );                          
133    */
134                    
135                  //register web plugins                  //register web plugins
136                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new StatusListener(getServer(), logintimeHandler.getConfig(), home.getConfig() ), Priority.Normal, this);                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new StatusListener(getServer(), logintimeHandler.getConfig(), home.getConfig() ), Priority.Normal, this);
137                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);
138    
139                  try {                  /*try {
140                          try {                          try {
141                                  //først probes om klassen i det hele taget findes                                  //først probes om klassen i det hele taget findes
142                                  Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception                                  Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception
# Line 117  public class HoerupUtilsPlugin extends J Line 149  public class HoerupUtilsPlugin extends J
149                          }                                                }                      
150                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException
151                          getLogger().warning("Could not find ApiBukkit - web status is disabled (" + e.getClass().getName() + ":" + e.getMessage() + ")"  );                          getLogger().warning("Could not find ApiBukkit - web status is disabled (" + e.getClass().getName() + ":" + e.getMessage() + ")"  );
152                    }*/
153                    
154                    try  {
155                            InetSocketAddress adr = new InetSocketAddress("127.0.0.1", 9999);
156                            server = HttpServer.create(adr, 20);
157                            server.createContext("/bans", new BanListener(this, getServer()) );
158                            server.createContext("/webstatus", new StatusListener(this, getServer(),logintimeHandler.getConfig(), home.getConfig()) );
159                            server.start();
160                            
161                    } catch(Exception e) {
162                            getLogger().log(Level.SEVERE, "Error loading webserver", e);
163                            
164                  }                  }
165                                    
166                                    
# Line 124  public class HoerupUtilsPlugin extends J Line 168  public class HoerupUtilsPlugin extends J
168                                    
169                  DoorBlockListener secretDoor = new DoorBlockListener(this);                  DoorBlockListener secretDoor = new DoorBlockListener(this);
170                  pm.registerEvents(secretDoor, this);                  pm.registerEvents(secretDoor, this);
171                  pm.registerEvents(secretDoor.getPlayerListener(), this);                  pm.registerEvents(secretDoor.getPlayerListener(), this);                
                   
172          }          }
173                    
174            
175            
176            
177            /*
178             * //TODO: RE-ENABLE
179          public MessageWrapper getMessageWrapper() {          public MessageWrapper getMessageWrapper() {
180                  return messageWrapper;                  return messageWrapper;
181          }          }
182            */
183    
         //@SuppressWarnings({ "unchecked", "rawtypes" })  
         @Override  
         public List<Class<?>> getDatabaseClasses() {  
                 List<Class<?>> list = new ArrayList<Class<?>>();  
   
                 list.add(MessageBean.class);  
                 list.add(SnitchingChestBean.class);  
                 list.add(WebUser.class);  
184    
185                  return list;          
         }  
186    
187            /*
188          private void deprecated() {          private void deprecated() {
189  /*  
190                  getCommand("stoner").setExecutor( new StonerCommand() );                  getCommand("stoner").setExecutor( new StonerCommand() );
191                  getCommand("spawn").setExecutor( new SpawnCommand() );                  getCommand("spawn").setExecutor( new SpawnCommand() );
192                  getCommand("boom").setExecutor( new BoomCommand(this) );                  getCommand("boom").setExecutor( new BoomCommand(this) );
# Line 171  public class HoerupUtilsPlugin extends J Line 212  public class HoerupUtilsPlugin extends J
212                  //pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this);                  //pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this);
213                  //pm.registerEvent(Event.Type.ENTITY_DEATH, new RespawnHandler.PlayerDeathListener(this.getDataFolder()), Priority.Normal, this);                                //pm.registerEvent(Event.Type.ENTITY_DEATH, new RespawnHandler.PlayerDeathListener(this.getDataFolder()), Priority.Normal, this);              
214    
215  */  
216          }          }
217            */
218    
219  }  }

Legend:
Removed from v.1786  
changed lines
  Added in v.3220

  ViewVC Help
Powered by ViewVC 1.1.20