/[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 1730 by torben, Tue Mar 13 08:30:39 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;
6    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 de.codeinfection.quickwango.ApiBukkit.ApiBukkit;  import com.sun.net.httpserver.HttpServer;
13  import de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiManager;  
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;
18    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.BanListener;
21  import dk.thoerup.bukkit.hoeruputils.web.StatusListener;  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    @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;  
36            HttpServer server = null;
37    
38                    
39          @Override          @Override
# Line 25  public class HoerupUtilsPlugin extends J Line 43  public class HoerupUtilsPlugin extends J
43                  //getCommand("mapgen").setExecutor(new MapgenCommand(this));                  //getCommand("mapgen").setExecutor(new MapgenCommand(this));
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( getServer() ) );                  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 37  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 );
75                    getCommand("createcave").setExecutor( generalContractor );
76                    getCommand("spawn").setExecutor( new SpawnCommand() );
77                    
78                    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() );
# Line 56  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    
101                                    
102                  pm.registerEvents(diver, this);                  pm.registerEvents(diver, this);
103    
104                    pm.registerEvents(new EndermanStopper(), this);
105    
106                  pm.registerEvents(new EndermanStopper(), this);                          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() {
121                            @Override
122                            public void run() {
123                                    System.out.println("installddl");
124                                    installDDL();
125                            }
126                    };
127                    messageWrapper = new MessageWrapper(this, ddlInstaller);
128                    pm.registerEvents( messageWrapper, this);
129                            
130                    AdvancedChest locked = new AdvancedChest(this, ddlInstaller);
131                    getCommand("chest").setExecutor(locked);
132                    pm.registerEvents( locked, this);
133                    
134                    
135                    getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) );                            
136    
137                    
138                  //register web plugins                  //register web plugins
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                  ApiBukkit api = (ApiBukkit) pm.getPlugin("ApiBukkit") ;                  /*try {
143                  if ( api != null) {                          try {
144                          StatusListener status = new StatusListener(this, getServer(), logintimeHandler.getConfig(), home.getConfig() );                                  //først probes om klassen i det hele taget findes
145                          //api.setRequestController("webstatus", status );                                  Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception
146                          //ApiManager.getInstance().registerController( status );                                  WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig());
147                  } else {                          
148                          System.out.println("Could not find ApiBukkit");                                  getLogger().info("ApiBukkit found, status listener registered");
149                                    
150                            } catch (ClassNotFoundException e) {
151                                    getLogger().warning("Could not find ApiBukkit - web status is disabled" );
152                            }                      
153                    } 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() + ")"  );
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 84  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() {
182                    return messageWrapper;
183            }
184    
185            //@SuppressWarnings({ "unchecked", "rawtypes" })
186            @Override
187            public List<Class<?>> getDatabaseClasses() {
188                    List<Class<?>> list = new ArrayList<Class<?>>();
189    
190                    list.add(MessageBean.class);
191                    list.add(ChestBean.class);
192                    list.add(WebUser.class);
193    
194                    return list;
195          }          }
196    
197          private void deprecated() {          private void deprecated() {

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

  ViewVC Help
Powered by ViewVC 1.1.20