/[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 1760 by torben, Wed Mar 21 17:04:29 2012 UTC revision 1856 by torben, Sun Oct 14 11:36:45 2012 UTC
# Line 1  Line 1 
1  package dk.thoerup.bukkit.hoeruputils;  package dk.thoerup.bukkit.hoeruputils;
2    
3    
4  import java.lang.reflect.Method;  import java.util.ArrayList;
5    import java.util.List;
6    
 import org.bukkit.configuration.Configuration;  
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 dk.thoerup.bukkit.hoeruputils.chests.AdvancedChest;
11    import dk.thoerup.bukkit.hoeruputils.chests.ChestBean;
12  import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands;  import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands;
13    import dk.thoerup.bukkit.hoeruputils.message.MessageBean;
14    import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper;
15  import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;  import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;
16    import dk.thoerup.bukkit.hoeruputils.web.WebLoader;
17    import dk.thoerup.bukkit.hoeruputils.web.WebUser;
18    import dk.thoerup.bukkit.hoeruputils.web.WebUserCommand;
19    
20  public class HoerupUtilsPlugin extends JavaPlugin {  public class HoerupUtilsPlugin extends JavaPlugin {
21    
# Line 16  public class HoerupUtilsPlugin extends J Line 23  public class HoerupUtilsPlugin extends J
23          public void onDisable() {          public void onDisable() {
24                  // TODO Auto-generated method stub                  // TODO Auto-generated method stub
25          }          }
26            
27            MessageWrapper messageWrapper;
28    
29                    
30          @Override          @Override
# Line 25  public class HoerupUtilsPlugin extends J Line 34  public class HoerupUtilsPlugin extends J
34                  //getCommand("mapgen").setExecutor(new MapgenCommand(this));                  //getCommand("mapgen").setExecutor(new MapgenCommand(this));
35                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));
36                  getCommand("getpos").setExecutor( new GetposCommand() );                  getCommand("getpos").setExecutor( new GetposCommand() );
37                  getCommand("msg").setExecutor( new MsgCommand( getServer() ) );                  getCommand("msg").setExecutor( new MsgCommand( this ) );
38                  getCommand("tp").setExecutor( new TeleportCommand() );                  getCommand("tp").setExecutor( new TeleportCommand() );
39    
40                  getCommand("wall").setExecutor( new WallCommand() );                  getCommand("wall").setExecutor( new WallCommand() );
# Line 37  public class HoerupUtilsPlugin extends J Line 46  public class HoerupUtilsPlugin extends J
46                  HomeCommand home = new HomeCommand(this);                  HomeCommand home = new HomeCommand(this);
47                  getCommand("home").setExecutor( home );                  getCommand("home").setExecutor( home );
48                  getCommand("sethome").setExecutor( home );                  getCommand("sethome").setExecutor( home );
49                    getCommand("ophome").setExecutor( home );
50    
51                  DiverCommand diver = new DiverCommand(this );                  DiverCommand diver = new DiverCommand(this );
52                  getCommand("diver").setExecutor( diver );                  getCommand("diver").setExecutor( diver );
53    
54                    getCommand("opkill").setExecutor( new OpkillCommand() );
55                                    
56                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();                  GeneralContractorCommands generalContractor = new GeneralContractorCommands();
57                  getCommand("replay").setExecutor( generalContractor );                  getCommand("replay").setExecutor( generalContractor );
# Line 50  public class HoerupUtilsPlugin extends J Line 62  public class HoerupUtilsPlugin extends J
62                  getCommand("platform").setExecutor( generalContractor );                  getCommand("platform").setExecutor( generalContractor );
63                  getCommand("cylinder").setExecutor( generalContractor );                  getCommand("cylinder").setExecutor( generalContractor );
64                  getCommand("createcave").setExecutor( generalContractor );                  getCommand("createcave").setExecutor( generalContractor );
65                    getCommand("spawn").setExecutor( new SpawnCommand() );
66                                    
67                  getCommand("template").setExecutor( new TemplateCommand(this) );                  getCommand("template").setExecutor( new TemplateCommand(this) );
68    
# Line 60  public class HoerupUtilsPlugin extends J Line 72  public class HoerupUtilsPlugin extends J
72                  PluginManager pm = getServer().getPluginManager();                  PluginManager pm = getServer().getPluginManager();
73    
74    
75                    MotdHandler motd = new MotdHandler(this);
76                    getCommand("motd").setExecutor( motd );
77                    pm.registerEvents( motd, this);
78    
79    
80                  pm.registerEvents(logintimeHandler, this);                  pm.registerEvents(logintimeHandler, this);
81                  pm.registerEvents(logintimeHandler, this);                  pm.registerEvents(logintimeHandler, this);
82    
83                                    
84                  pm.registerEvents(diver, this);                  pm.registerEvents(diver, this);
85    
86                    pm.registerEvents(new EndermanStopper(), this);
87    
88                  pm.registerEvents(new EndermanStopper(), this);                          Jail jail = new Jail(this);
89                    pm.registerEvents(jail, this);
90                    getCommand("jail").setExecutor( jail );
91                    
92                    
93                    
94                    
95                    
96                    
97                    Runnable ddlInstaller = new Runnable() {
98                            @Override
99                            public void run() {
100                                    System.out.println("installddl");
101                                    installDDL();
102                            }
103                    };
104                    messageWrapper = new MessageWrapper(this, ddlInstaller);
105                    pm.registerEvents( messageWrapper, this);
106                            
107                    AdvancedChest locked = new AdvancedChest(this, ddlInstaller);
108                    getCommand("chest").setExecutor(locked);
109                    pm.registerEvents( locked, this);
110                    
111                    
112                    getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) );                            
113    
114                    
115                  //register web plugins                  //register web plugins
116                  //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);
# Line 77  public class HoerupUtilsPlugin extends J Line 119  public class HoerupUtilsPlugin extends J
119                  try {                  try {
120                          try {                          try {
121                                  //først probes om klassen i det hele taget findes                                  //først probes om klassen i det hele taget findes
122                                  Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController");                                  Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception
123                                                                    WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig());
124                                  Class<?>webloader = Class.forName("dk.thoerup.bukkit.hoeruputils.web.WebLoader");                                                
125                                  Method load = webloader.getMethod("load", HoerupUtilsPlugin.class, Configuration.class, Configuration.class);                                  getLogger().info("ApiBukkit found, status listener registered");
                                 Object args[] = {this, logintimeHandler.getConfig(), home.getConfig() };  
                                 load.invoke(null, args);  
                                   
                                 getLogger().warning("ApiBukkit found, status listener registered");  
126                                                                    
127                          } catch (ClassNotFoundException e) {                          } catch (ClassNotFoundException e) {
128                                  getLogger().warning("Could not find ApiBukkit - web status is disabled" );                                  getLogger().warning("Could not find ApiBukkit - web status is disabled" );
129                          }                          }                      
                           
130                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException
131                          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() + ")"  );
132                  }                  }
# Line 102  public class HoerupUtilsPlugin extends J Line 139  public class HoerupUtilsPlugin extends J
139                  pm.registerEvents(secretDoor.getPlayerListener(), this);                  pm.registerEvents(secretDoor.getPlayerListener(), this);
140                                    
141          }          }
142            
143            public MessageWrapper getMessageWrapper() {
144                    return messageWrapper;
145            }
146    
147            //@SuppressWarnings({ "unchecked", "rawtypes" })
148            @Override
149            public List<Class<?>> getDatabaseClasses() {
150                    List<Class<?>> list = new ArrayList<Class<?>>();
151    
152                    list.add(MessageBean.class);
153                    list.add(ChestBean.class);
154                    list.add(WebUser.class);
155    
156                    return list;
157            }
158    
159          private void deprecated() {          private void deprecated() {
160  /*  /*

Legend:
Removed from v.1760  
changed lines
  Added in v.1856

  ViewVC Help
Powered by ViewVC 1.1.20