/[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 3201 by torben, Wed May 31 08:56:00 2017 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.avaje.ebeaninternal.api.SpiEbeanServer;  import com.sun.net.httpserver.HttpServer;
 import com.avaje.ebeaninternal.server.ddl.DdlGenerator;  
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;  import dk.thoerup.bukkit.hoeruputils.web.WebUser;
23  import dk.thoerup.bukkit.hoeruputils.web.WebUserCommand;  import dk.thoerup.bukkit.hoeruputils.web.WebUserCommand;
24    
25    @SuppressWarnings("restriction")
26  public class HoerupUtilsPlugin extends JavaPlugin {  public class HoerupUtilsPlugin extends JavaPlugin {
27    
28          @Override          @Override
29          public void onDisable() {          public void onDisable() {
30                  // TODO Auto-generated method stub                  if ( server != null ) {
31                            server.stop( 0 );
32                    }
33          }          }
34                    
35          MessageWrapper messageWrapper;          MessageWrapper messageWrapper;  
36            HttpServer server = null;
37    
38                    
39          @Override          @Override
# Line 36  public class HoerupUtilsPlugin extends J Line 44  public class HoerupUtilsPlugin extends J
44                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));
45                  getCommand("getpos").setExecutor( new GetposCommand() );                  getCommand("getpos").setExecutor( new GetposCommand() );
46                  getCommand("msg").setExecutor( new MsgCommand( this ) );                  getCommand("msg").setExecutor( new MsgCommand( this ) );
47                  getCommand("tp").setExecutor( new TeleportCommand() );  //              getCommand("tp").setExecutor( new TeleportCommand() );
48    
49                  getCommand("wall").setExecutor( new WallCommand() );                  getCommand("wall").setExecutor( new WallCommand() );
50                  getCommand("weather").setExecutor( new WeatherCommand() );                  getCommand("weather").setExecutor( new WeatherCommand() );
# Line 47  public class HoerupUtilsPlugin extends J Line 55  public class HoerupUtilsPlugin extends J
55                  HomeCommand home = new HomeCommand(this);                  HomeCommand home = new HomeCommand(this);
56                  getCommand("home").setExecutor( home );                  getCommand("home").setExecutor( home );
57                  getCommand("sethome").setExecutor( home );                  getCommand("sethome").setExecutor( home );
58                    getCommand("ophome").setExecutor( home );
59    
60                  DiverCommand diver = new DiverCommand(this );                  DiverCommand diver = new DiverCommand(this );
61                  getCommand("diver").setExecutor( diver );                  getCommand("diver").setExecutor( diver );
62    
63                    getCommand("opkill").setExecutor( new OpkillCommand() );
64                                    
65                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();
66                  getCommand("replay").setExecutor( generalContractor );                  getCommand("replay").setExecutor( generalContractor );
67                  getCommand("levelarea").setExecutor( generalContractor );                  getCommand("levelarea").setExecutor( generalContractor );
68                  getCommand("fillarea").setExecutor( generalContractor );                  getCommand("fillarea").setExecutor( generalContractor );
69                    getCommand("levelandfillarea").setExecutor( generalContractor );
70    
71                  getCommand("slopearea").setExecutor( generalContractor );                  getCommand("slopearea").setExecutor( generalContractor );
72                  getCommand("setsurface").setExecutor( generalContractor );                  getCommand("setsurface").setExecutor( generalContractor );
73                  getCommand("platform").setExecutor( generalContractor );                  getCommand("platform").setExecutor( generalContractor );
74                  getCommand("cylinder").setExecutor( generalContractor );                  getCommand("cylinder").setExecutor( generalContractor );
75                  getCommand("createcave").setExecutor( generalContractor );                  getCommand("createcave").setExecutor( generalContractor );
76                    getCommand("spawn").setExecutor( new SpawnCommand() );
77                                    
78                  getCommand("template").setExecutor( new TemplateCommand(this) );                  getCommand("template").setExecutor( new TemplateCommand(this) );
79                    getCommand("regenerate").setExecutor( new RegenerateCommand() );
80    
81    
82                  LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );                  LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );
83                                    
# Line 70  public class HoerupUtilsPlugin extends J Line 85  public class HoerupUtilsPlugin extends J
85                  PluginManager pm = getServer().getPluginManager();                  PluginManager pm = getServer().getPluginManager();
86    
87    
88                    MotdHandler motd = new MotdHandler(this);
89                    getCommand("motd").setExecutor( motd );
90                    pm.registerEvents( motd, this);
91                    
92                    WayPoint wp = new WayPoint(this);
93                    getCommand("waypoint").setExecutor( wp );
94                    getCommand("setwaypoint").setExecutor( wp );
95                    pm.registerEvents( wp, this);
96    
97    
98                  pm.registerEvents(logintimeHandler, this);                  pm.registerEvents(logintimeHandler, this);
99                  pm.registerEvents(logintimeHandler, this);                  pm.registerEvents(logintimeHandler, this);
100    
# Line 77  public class HoerupUtilsPlugin extends J Line 102  public class HoerupUtilsPlugin extends J
102                  pm.registerEvents(diver, this);                  pm.registerEvents(diver, this);
103    
104                  pm.registerEvents(new EndermanStopper(), this);                  pm.registerEvents(new EndermanStopper(), this);
105                    
106                                    Jail jail = new Jail(this);
107                                    pm.registerEvents(jail, this);
108                                    getCommand("jail").setExecutor( jail );
109                    
110                    StickyChunk chunks = new StickyChunk();
111                    pm.registerEvents(chunks, this);
112                    getCommand("stickychunk").setExecutor(chunks);          
113                    
114                    Mute mute = new Mute(this);
115                    pm.registerEvents(mute, this);
116                    getCommand("mute").setExecutor(mute);
117                    getCommand("unmute").setExecutor(mute);
118                                    
119                    
120                  Runnable ddlInstaller = new Runnable() {                  Runnable ddlInstaller = new Runnable() {
# Line 92  public class HoerupUtilsPlugin extends J Line 126  public class HoerupUtilsPlugin extends J
126                  };                  };
127                  messageWrapper = new MessageWrapper(this, ddlInstaller);                  messageWrapper = new MessageWrapper(this, ddlInstaller);
128                  pm.registerEvents( messageWrapper, this);                  pm.registerEvents( messageWrapper, this);
129                            
130                    AdvancedChest locked = new AdvancedChest(this, ddlInstaller);
131                    getCommand("chest").setExecutor(locked);
132                    pm.registerEvents( locked, this);
133                                    
                 SnitchingChest snitch = new SnitchingChest(this, ddlInstaller);  
                 getCommand("snitchingchest").setExecutor(snitch);  
                 pm.registerEvents( snitch, this);  
134                                    
135                  getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) );                                              getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) );                            
136    
# Line 104  public class HoerupUtilsPlugin extends J Line 139  public class HoerupUtilsPlugin extends J
139                  //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);
140                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);
141    
142                  try {                  /*try {
143                          try {                          try {
144                                  //først probes om klassen i det hele taget findes                                  //først probes om klassen i det hele taget findes
145                                  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 152  public class HoerupUtilsPlugin extends J
152                          }                                                }                      
153                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException
154                          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() + ")"  );
155                    }*/
156                    
157                    try  {
158                            InetSocketAddress adr = new InetSocketAddress("127.0.0.1", 9999);
159                            server = HttpServer.create(adr, 20);
160                            server.createContext("/bans", new BanListener(this, getServer()) );
161                            server.createContext("/webstatus", new StatusListener(this, getServer(),logintimeHandler.getConfig(), home.getConfig()) );
162                            server.start();
163                            
164                    } catch(Exception e) {
165                            getLogger().log(Level.SEVERE, "Error loading webserver", e);
166                            
167                  }                  }
168                                    
169                                    
# Line 124  public class HoerupUtilsPlugin extends J Line 171  public class HoerupUtilsPlugin extends J
171                                    
172                  DoorBlockListener secretDoor = new DoorBlockListener(this);                  DoorBlockListener secretDoor = new DoorBlockListener(this);
173                  pm.registerEvents(secretDoor, this);                  pm.registerEvents(secretDoor, this);
174                  pm.registerEvents(secretDoor.getPlayerListener(), this);                  pm.registerEvents(secretDoor.getPlayerListener(), this);                
                   
175          }          }
176                    
177            
178            
179            
180            
181          public MessageWrapper getMessageWrapper() {          public MessageWrapper getMessageWrapper() {
182                  return messageWrapper;                  return messageWrapper;
183          }          }
# Line 138  public class HoerupUtilsPlugin extends J Line 188  public class HoerupUtilsPlugin extends J
188                  List<Class<?>> list = new ArrayList<Class<?>>();                  List<Class<?>> list = new ArrayList<Class<?>>();
189    
190                  list.add(MessageBean.class);                  list.add(MessageBean.class);
191                  list.add(SnitchingChestBean.class);                  list.add(ChestBean.class);
192                  list.add(WebUser.class);                  list.add(WebUser.class);
193    
194                  return list;                  return list;

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

  ViewVC Help
Powered by ViewVC 1.1.20