/[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 1778 by torben, Thu Apr 5 14:10:28 2012 UTC revision 3207 by torben, Sat Aug 19 14:06:42 2017 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.sun.net.httpserver.HttpServer;
11    
12  import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands;  import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands;
 import dk.thoerup.bukkit.hoeruputils.message.MessageBean;  
 import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper;  
13  import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;  import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;
14  import dk.thoerup.bukkit.hoeruputils.web.WebLoader;  import dk.thoerup.bukkit.hoeruputils.web.BanListener;
15    import dk.thoerup.bukkit.hoeruputils.web.StatusListener;
16    
17    @SuppressWarnings("restriction")
18  public class HoerupUtilsPlugin extends JavaPlugin {  public class HoerupUtilsPlugin extends JavaPlugin {
19    
20          @Override          @Override
21          public void onDisable() {          public void onDisable() {
22                  // TODO Auto-generated method stub                  if ( server != null ) {
23                            server.stop( 0 );
24                    }
25          }          }
26                    
27          MessageWrapper messageWrapper;          //MessageWrapper messageWrapper;        //TODO: RE-ENABLE
28            HttpServer server = null;
29    
30                    
31          @Override          @Override
32          public void onEnable() {          public void onEnable() {
33                  System.out.println("Loading HoerupUtils plugin");                  System.out.println("Loading HoerupUtils plugin");
34                    
35                    //Ebean.getDefaultServer(); //TODO: RE-ENABLE
36                    
37                  getCommand("whereis").setExecutor(new WhereisCommand(getServer()));                  getCommand("whereis").setExecutor(new WhereisCommand(getServer()));
38                  //getCommand("mapgen").setExecutor(new MapgenCommand(this));                  //getCommand("mapgen").setExecutor(new MapgenCommand(this));
39                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));
40                  getCommand("getpos").setExecutor( new GetposCommand() );                  getCommand("getpos").setExecutor( new GetposCommand() );
41                  getCommand("msg").setExecutor( new MsgCommand( this ) );                  getCommand("msg").setExecutor( new MsgCommand( this ) );
42                  getCommand("tp").setExecutor( new TeleportCommand() );  //              getCommand("tp").setExecutor( new TeleportCommand() );
43    
44                  getCommand("wall").setExecutor( new WallCommand() );                  getCommand("wall").setExecutor( new WallCommand() );
45                  getCommand("weather").setExecutor( new WeatherCommand() );                  getCommand("weather").setExecutor( new WeatherCommand() );
# Line 42  public class HoerupUtilsPlugin extends J Line 50  public class HoerupUtilsPlugin extends J
50                  HomeCommand home = new HomeCommand(this);                  HomeCommand home = new HomeCommand(this);
51                  getCommand("home").setExecutor( home );                  getCommand("home").setExecutor( home );
52                  getCommand("sethome").setExecutor( home );                  getCommand("sethome").setExecutor( home );
53                    getCommand("ophome").setExecutor( home );
54    
55                  DiverCommand diver = new DiverCommand(this );                  DiverCommand diver = new DiverCommand(this );
56                  getCommand("diver").setExecutor( diver );                  getCommand("diver").setExecutor( diver );
57    
58                    getCommand("opkill").setExecutor( new OpkillCommand() );
59                                    
60                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();
61                  getCommand("replay").setExecutor( generalContractor );                  getCommand("replay").setExecutor( generalContractor );
62                  getCommand("levelarea").setExecutor( generalContractor );                  getCommand("levelarea").setExecutor( generalContractor );
63                  getCommand("fillarea").setExecutor( generalContractor );                  getCommand("fillarea").setExecutor( generalContractor );
64                    getCommand("levelandfillarea").setExecutor( generalContractor );
65    
66                  getCommand("slopearea").setExecutor( generalContractor );                  getCommand("slopearea").setExecutor( generalContractor );
67                  getCommand("setsurface").setExecutor( generalContractor );                  getCommand("setsurface").setExecutor( generalContractor );
68                  getCommand("platform").setExecutor( generalContractor );                  getCommand("platform").setExecutor( generalContractor );
69                  getCommand("cylinder").setExecutor( generalContractor );                  getCommand("cylinder").setExecutor( generalContractor );
70                  getCommand("createcave").setExecutor( generalContractor );                  getCommand("createcave").setExecutor( generalContractor );
71                    getCommand("spawn").setExecutor( new SpawnCommand() );
72                                    
73                  getCommand("template").setExecutor( new TemplateCommand(this) );                  getCommand("template").setExecutor( new TemplateCommand(this) );
74                    getCommand("regenerate").setExecutor( new RegenerateCommand() );
75    
76    
77                  LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );                  LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );
78                                    
# 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                    WayPoint wp = new WayPoint(this);
88                    getCommand("waypoint").setExecutor( wp );
89                    getCommand("setwaypoint").setExecutor( wp );
90                    pm.registerEvents( wp, this);
91    
92    
93                  pm.registerEvents(logintimeHandler, this);                  pm.registerEvents(logintimeHandler, this);
94                  pm.registerEvents(logintimeHandler, this);                  pm.registerEvents(logintimeHandler, this);
95    
# Line 72  public class HoerupUtilsPlugin extends J Line 97  public class HoerupUtilsPlugin extends J
97                  pm.registerEvents(diver, this);                  pm.registerEvents(diver, this);
98    
99                  pm.registerEvents(new EndermanStopper(), this);                  pm.registerEvents(new EndermanStopper(), this);
100                    
101                                    Jail jail = new Jail(this);
102                                    pm.registerEvents(jail, this);
103                                    getCommand("jail").setExecutor( jail );
104                    
105                    StickyChunk chunks = new StickyChunk();
106                    pm.registerEvents(chunks, this);
107                    getCommand("stickychunk").setExecutor(chunks);          
108                    
109                    Mute mute = new Mute(this);
110                    pm.registerEvents(mute, this);
111                    getCommand("mute").setExecutor(mute);
112                    getCommand("unmute").setExecutor(mute);
113                                    
114                    
115                  Runnable ddlInstaller = new Runnable() {  /*
116                          @Override   * //TODO: RE-ENABLE
117                          public void run() {                  messageWrapper = new MessageWrapper(this);
                                 System.out.println("installddl");  
                                 installDDL();  
                         }  
                 };  
                 messageWrapper = new MessageWrapper(this, ddlInstaller);  
118                  pm.registerEvents( messageWrapper, this);                  pm.registerEvents( messageWrapper, this);
119                            
120                    AdvancedChest locked = new AdvancedChest(this);
121                    getCommand("chest").setExecutor(locked);
122                    pm.registerEvents( locked, this);
123                                    
124                  SnitchingChest snitch = new SnitchingChest(this, ddlInstaller);                  
125                  getCommand("snitchingchest").setExecutor(snitch);                  getCommand("webuser").setExecutor( new WebUserCommand(this) );                          
126                  pm.registerEvents( snitch, this);  */
   
127                    
128                  //register web plugins                  //register web plugins
129                  //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);
130                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);
131    
132                  try {                  /*try {
133                          try {                          try {
134                                  //først probes om klassen i det hele taget findes                                  //først probes om klassen i det hele taget findes
135                                  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 110  public class HoerupUtilsPlugin extends J Line 142  public class HoerupUtilsPlugin extends J
142                          }                                                }                      
143                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException
144                          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() + ")"  );
145                    }*/
146                    
147                    try  {
148                            InetSocketAddress adr = new InetSocketAddress("127.0.0.1", 9999);
149                            server = HttpServer.create(adr, 20);
150                            server.createContext("/bans", new BanListener(this, getServer()) );
151                            server.createContext("/webstatus", new StatusListener(this, getServer(),logintimeHandler.getConfig(), home.getConfig()) );
152                            server.start();
153                            
154                    } catch(Exception e) {
155                            getLogger().log(Level.SEVERE, "Error loading webserver", e);
156                            
157                  }                  }
158                                    
159                                    
# Line 117  public class HoerupUtilsPlugin extends J Line 161  public class HoerupUtilsPlugin extends J
161                                    
162                  DoorBlockListener secretDoor = new DoorBlockListener(this);                  DoorBlockListener secretDoor = new DoorBlockListener(this);
163                  pm.registerEvents(secretDoor, this);                  pm.registerEvents(secretDoor, this);
164                  pm.registerEvents(secretDoor.getPlayerListener(), this);                  pm.registerEvents(secretDoor.getPlayerListener(), this);                
                   
165          }          }
166                    
167            
168            
169            
170            /*
171             * //TODO: RE-ENABLE
172          public MessageWrapper getMessageWrapper() {          public MessageWrapper getMessageWrapper() {
173                  return messageWrapper;                  return messageWrapper;
174          }          }
175            */
176    
         //@SuppressWarnings({ "unchecked", "rawtypes" })  
         @Override  
         public List<Class<?>> getDatabaseClasses() {  
                 List<Class<?>> list = new ArrayList<Class<?>>();  
   
                 list.add(MessageBean.class);  
                 list.add(SnitchingChestBean.class);  
177    
178                  return list;          
         }  
179    
180            /*
181          private void deprecated() {          private void deprecated() {
182  /*  
183                  getCommand("stoner").setExecutor( new StonerCommand() );                  getCommand("stoner").setExecutor( new StonerCommand() );
184                  getCommand("spawn").setExecutor( new SpawnCommand() );                  getCommand("spawn").setExecutor( new SpawnCommand() );
185                  getCommand("boom").setExecutor( new BoomCommand(this) );                  getCommand("boom").setExecutor( new BoomCommand(this) );
# Line 163  public class HoerupUtilsPlugin extends J Line 205  public class HoerupUtilsPlugin extends J
205                  //pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this);                  //pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this);
206                  //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);              
207    
208  */  
209          }          }
210            */
211    
212  }  }

Legend:
Removed from v.1778  
changed lines
  Added in v.3207

  ViewVC Help
Powered by ViewVC 1.1.20