/[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 1855 by torben, Sat Oct 13 20:55:30 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                  pm.registerEvents(new EndermanStopper(), this);                          
88                    
89                    
90                    
91                    
92                    
93                    Runnable ddlInstaller = new Runnable() {
94                            @Override
95                            public void run() {
96                                    System.out.println("installddl");
97                                    installDDL();
98                            }
99                    };
100                    messageWrapper = new MessageWrapper(this, ddlInstaller);
101                    pm.registerEvents( messageWrapper, this);
102                            
103                    AdvancedChest locked = new AdvancedChest(this, ddlInstaller);
104                    getCommand("chest").setExecutor(locked);
105                    pm.registerEvents( locked, this);
106                    
107                    
108                    getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) );                            
109    
110                    
111                  //register web plugins                  //register web plugins
112                  //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 115  public class HoerupUtilsPlugin extends J
115                  try {                  try {
116                          try {                          try {
117                                  //først probes om klassen i det hele taget findes                                  //først probes om klassen i det hele taget findes
118                                  Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController");                                  Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception
119                                                                    WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig());
120                                  Class<?>webloader = Class.forName("dk.thoerup.bukkit.hoeruputils.web.WebLoader");                                                
121                                  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");  
122                                                                    
123                          } catch (ClassNotFoundException e) {                          } catch (ClassNotFoundException e) {
124                                  getLogger().warning("Could not find ApiBukkit - web status is disabled" );                                  getLogger().warning("Could not find ApiBukkit - web status is disabled" );
125                          }                          }                      
                           
126                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException                  } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException
127                          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() + ")"  );
128                  }                  }
# Line 102  public class HoerupUtilsPlugin extends J Line 135  public class HoerupUtilsPlugin extends J
135                  pm.registerEvents(secretDoor.getPlayerListener(), this);                  pm.registerEvents(secretDoor.getPlayerListener(), this);
136                                    
137          }          }
138            
139            public MessageWrapper getMessageWrapper() {
140                    return messageWrapper;
141            }
142    
143            //@SuppressWarnings({ "unchecked", "rawtypes" })
144            @Override
145            public List<Class<?>> getDatabaseClasses() {
146                    List<Class<?>> list = new ArrayList<Class<?>>();
147    
148                    list.add(MessageBean.class);
149                    list.add(ChestBean.class);
150                    list.add(WebUser.class);
151    
152                    return list;
153            }
154    
155          private void deprecated() {          private void deprecated() {
156  /*  /*

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

  ViewVC Help
Powered by ViewVC 1.1.20