/[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 3063 by torben, Tue Jul 12 14:23:02 2016 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 31  public class HoerupUtilsPlugin extends J Line 43  public class HoerupUtilsPlugin extends J
43                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));
44                  getCommand("getpos").setExecutor( new GetposCommand() );                  getCommand("getpos").setExecutor( new GetposCommand() );
45                  getCommand("msg").setExecutor( new MsgCommand( this ) );                  getCommand("msg").setExecutor( new MsgCommand( this ) );
46                  getCommand("tp").setExecutor( new TeleportCommand() );  //              getCommand("tp").setExecutor( new TeleportCommand() );
47    
48                  getCommand("wall").setExecutor( new WallCommand() );                  getCommand("wall").setExecutor( new WallCommand() );
49                  getCommand("weather").setExecutor( new WeatherCommand() );                  getCommand("weather").setExecutor( new WeatherCommand() );
# 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                    getCommand("regenerate").setExecutor( new RegenerateCommand() );
77    
78    
79                  LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );                  LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );
80                                    
# Line 65  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    
# Line 72  public class HoerupUtilsPlugin extends J Line 99  public class HoerupUtilsPlugin extends J
99                  pm.registerEvents(diver, this);                  pm.registerEvents(diver, this);
100    
101                  pm.registerEvents(new EndermanStopper(), this);                  pm.registerEvents(new EndermanStopper(), this);
102                    
103                                    Jail jail = new Jail(this);
104                                    pm.registerEvents(jail, this);
105                                    getCommand("jail").setExecutor( jail );
106                    
107                    StickyChunk chunks = new StickyChunk();
108                    pm.registerEvents(chunks, this);
109                    getCommand("stickychunk").setExecutor(chunks);          
110                    
111                    Mute mute = new Mute(this);
112                    pm.registerEvents(mute, this);
113                    getCommand("mute").setExecutor(mute);
114                    getCommand("unmute").setExecutor(mute);
115                                    
116                    
117                  Runnable ddlInstaller = new Runnable() {                  Runnable ddlInstaller = new Runnable() {
# Line 87  public class HoerupUtilsPlugin extends J Line 123  public class HoerupUtilsPlugin extends J
123                  };                  };
124                  messageWrapper = new MessageWrapper(this, ddlInstaller);                  messageWrapper = new MessageWrapper(this, ddlInstaller);
125                  pm.registerEvents( messageWrapper, this);                  pm.registerEvents( messageWrapper, this);
126                            
127                    AdvancedChest locked = new AdvancedChest(this, ddlInstaller);
128                    getCommand("chest").setExecutor(locked);
129                    pm.registerEvents( locked, this);
130                    
131                                    
132                  SnitchingChest snitch = new SnitchingChest(this, ddlInstaller);                  getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) );                            
                 getCommand("snitchingchest").setExecutor(snitch);  
                 pm.registerEvents( snitch, 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
143                                  WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig());                                  WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig());
144                                                    
145                                  getLogger().warning("ApiBukkit found, status listener registered");                                  getLogger().info("ApiBukkit found, status listener registered");
146                                                                    
147                          } catch (ClassNotFoundException e) {                          } catch (ClassNotFoundException e) {
148                                  getLogger().warning("Could not find ApiBukkit - web status is disabled" );                                  getLogger().warning("Could not find ApiBukkit - web status is disabled" );
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 117  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          public MessageWrapper getMessageWrapper() {          public MessageWrapper getMessageWrapper() {
179                  return messageWrapper;                  return messageWrapper;
180          }          }
# Line 128  public class HoerupUtilsPlugin extends J Line 182  public class HoerupUtilsPlugin extends J
182          //@SuppressWarnings({ "unchecked", "rawtypes" })          //@SuppressWarnings({ "unchecked", "rawtypes" })
183          @Override          @Override
184          public List<Class<?>> getDatabaseClasses() {          public List<Class<?>> getDatabaseClasses() {
                 System.out.println("getDatabaseClasses");  
185                  List<Class<?>> list = new ArrayList<Class<?>>();                  List<Class<?>> list = new ArrayList<Class<?>>();
186    
187                  list.add(MessageBean.class);                  list.add(MessageBean.class);
188                  list.add(SnitchingChestBean.class);                  list.add(ChestBean.class);
189                    list.add(WebUser.class);
190    
191                  return list;                  return list;
192          }          }

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

  ViewVC Help
Powered by ViewVC 1.1.20