/[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 1773 by torben, Thu Apr 5 12:37:13 2012 UTC revision 1936 by torben, Wed Mar 20 14:56:43 2013 UTC
# Line 1  Line 1 
1  package dk.thoerup.bukkit.hoeruputils;  package dk.thoerup.bukkit.hoeruputils;
2    
3    
4    import java.net.InetSocketAddress;
5  import java.util.ArrayList;  import java.util.ArrayList;
6  import java.util.List;  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;  import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands;
17  import dk.thoerup.bukkit.hoeruputils.message.MessageBean;  import dk.thoerup.bukkit.hoeruputils.message.MessageBean;
18  import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper;  import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper;
19  import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;  import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;
20  import dk.thoerup.bukkit.hoeruputils.web.WebLoader;  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;          MessageWrapper messageWrapper;
35            HttpServer server = null;
36    
37                    
38          @Override          @Override
# Line 42  public class HoerupUtilsPlugin extends J Line 54  public class HoerupUtilsPlugin extends J
54                  HomeCommand home = new HomeCommand(this);                  HomeCommand home = new HomeCommand(this);
55                  getCommand("home").setExecutor( home );                  getCommand("home").setExecutor( home );
56                  getCommand("sethome").setExecutor( home );                  getCommand("sethome").setExecutor( home );
57                    getCommand("ophome").setExecutor( home );
58    
59                  DiverCommand diver = new DiverCommand(this );                  DiverCommand diver = new DiverCommand(this );
60                  getCommand("diver").setExecutor( diver );                  getCommand("diver").setExecutor( diver );
61    
62                    getCommand("opkill").setExecutor( new OpkillCommand() );
63                                    
64                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();
65                  getCommand("replay").setExecutor( generalContractor );                  getCommand("replay").setExecutor( generalContractor );
# Line 55  public class HoerupUtilsPlugin extends J Line 70  public class HoerupUtilsPlugin extends J
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    
# Line 65  public class HoerupUtilsPlugin extends J Line 80  public class HoerupUtilsPlugin extends J
80                  PluginManager pm = getServer().getPluginManager();                  PluginManager pm = getServer().getPluginManager();
81    
82    
83                    MotdHandler motd = new MotdHandler(this);
84                    getCommand("motd").setExecutor( motd );
85                    pm.registerEvents( motd, this);
86    
87    
88                  pm.registerEvents(logintimeHandler, this);                  pm.registerEvents(logintimeHandler, this);
89                  pm.registerEvents(logintimeHandler, this);                  pm.registerEvents(logintimeHandler, this);
90    
# Line 72  public class HoerupUtilsPlugin extends J Line 92  public class HoerupUtilsPlugin extends J
92                  pm.registerEvents(diver, this);                  pm.registerEvents(diver, this);
93    
94                  pm.registerEvents(new EndermanStopper(), this);                  pm.registerEvents(new EndermanStopper(), this);
95    
96                    Jail jail = new Jail(this);
97                    pm.registerEvents(jail, this);
98                    getCommand("jail").setExecutor( jail );
99                                    
100                                    
101                                    
# Line 87  public class HoerupUtilsPlugin extends J Line 111  public class HoerupUtilsPlugin extends J
111                  };                  };
112                  messageWrapper = new MessageWrapper(this, ddlInstaller);                  messageWrapper = new MessageWrapper(this, ddlInstaller);
113                  pm.registerEvents( messageWrapper, this);                  pm.registerEvents( messageWrapper, this);
114                            
115                    AdvancedChest locked = new AdvancedChest(this, ddlInstaller);
116                    getCommand("chest").setExecutor(locked);
117                    pm.registerEvents( locked, this);
118                    
119                                    
120                  SnitchingChest snitch = new SnitchingChest(this, ddlInstaller);                  getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) );                            
                 getCommand("snitchingchest").setExecutor(snitch);  
                 pm.registerEvents( snitch, this);  
121    
122                    
123                  //register web plugins                  //register web plugins
124                  //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);
125                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);
126    
127                  try {                  /*try {
128                          try {                          try {
129                                  //først probes om klassen i det hele taget findes                                  //først probes om klassen i det hele taget findes
130                                  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
131                                  WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig());                                  WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig());
132                                                    
133                                  getLogger().warning("ApiBukkit found, status listener registered");                                  getLogger().info("ApiBukkit found, status listener registered");
134                                                                    
135                          } catch (ClassNotFoundException e) {                          } catch (ClassNotFoundException e) {
136                                  getLogger().warning("Could not find ApiBukkit - web status is disabled" );                                  getLogger().warning("Could not find ApiBukkit - web status is disabled" );
137                          }                                                }                      
138                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException
139                          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() + ")"  );
140                    }*/
141                    
142                    try  {
143                            InetSocketAddress adr = new InetSocketAddress("localhost", 9999);
144                            HttpServer.create(adr, 10);
145                            server.createContext("/bans", new BanListener(this, getServer()) );
146                            server.createContext("/webstatus", new StatusListener(this, getServer(),logintimeHandler.getConfig(), home.getConfig()) );
147                            server.start();
148                            
149                    } catch(Exception e) {
150                            getLogger().log(Level.SEVERE, "Error loading webserver", e);
151                            
152                  }                  }
153                                    
154                                    
# Line 117  public class HoerupUtilsPlugin extends J Line 156  public class HoerupUtilsPlugin extends J
156                                    
157                  DoorBlockListener secretDoor = new DoorBlockListener(this);                  DoorBlockListener secretDoor = new DoorBlockListener(this);
158                  pm.registerEvents(secretDoor, this);                  pm.registerEvents(secretDoor, this);
159                  pm.registerEvents(secretDoor.getPlayerListener(), this);                  pm.registerEvents(secretDoor.getPlayerListener(), this);                
                   
160          }          }
161                    
162            
163            
164            
165            
166          public MessageWrapper getMessageWrapper() {          public MessageWrapper getMessageWrapper() {
167                  return messageWrapper;                  return messageWrapper;
168          }          }
# Line 128  public class HoerupUtilsPlugin extends J Line 170  public class HoerupUtilsPlugin extends J
170          //@SuppressWarnings({ "unchecked", "rawtypes" })          //@SuppressWarnings({ "unchecked", "rawtypes" })
171          @Override          @Override
172          public List<Class<?>> getDatabaseClasses() {          public List<Class<?>> getDatabaseClasses() {
                 System.out.println("getDatabaseClasses");  
173                  List<Class<?>> list = new ArrayList<Class<?>>();                  List<Class<?>> list = new ArrayList<Class<?>>();
174    
175                  list.add(MessageBean.class);                  list.add(MessageBean.class);
176                  list.add(SnitchingChestBean.class);                  list.add(ChestBean.class);
177                    list.add(WebUser.class);
178    
179                  return list;                  return list;
180          }          }

Legend:
Removed from v.1773  
changed lines
  Added in v.1936

  ViewVC Help
Powered by ViewVC 1.1.20