/[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

miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/HoerupUtilsPlugin.java revision 1385 by torben, Sun Apr 24 10:23:02 2011 UTC miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/HoerupUtilsPlugin.java revision 1804 by torben, Mon May 28 15:06:26 2012 UTC
# Line 1  Line 1 
1  package dk.thoerup.bukkit.hoeruputils;  package dk.thoerup.bukkit.hoeruputils;
2    
3    
4  import org.bukkit.event.Event;  import java.util.ArrayList;
5  import org.bukkit.event.Event.Priority;  import java.util.List;
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 dk.thoerup.bukkit.hoeruputils.web.MessageListener;  
11  import dk.thoerup.bukkit.hoeruputils.web.StatusListener;  
12    import dk.thoerup.bukkit.hoeruputils.chests.SnitchingChest;
13    import dk.thoerup.bukkit.hoeruputils.chests.SnitchingChestBean;
14    import dk.thoerup.bukkit.hoeruputils.creative.GeneralContractorCommands;
15    import dk.thoerup.bukkit.hoeruputils.message.MessageBean;
16    import dk.thoerup.bukkit.hoeruputils.message.MessageWrapper;
17    import dk.thoerup.bukkit.hoeruputils.secretdoor.DoorBlockListener;
18    import dk.thoerup.bukkit.hoeruputils.web.WebLoader;
19    import dk.thoerup.bukkit.hoeruputils.web.WebUser;
20    import dk.thoerup.bukkit.hoeruputils.web.WebUserCommand;
21    
22  public class HoerupUtilsPlugin extends JavaPlugin {  public class HoerupUtilsPlugin extends JavaPlugin {
23    
# Line 15  public class HoerupUtilsPlugin extends J Line 25  public class HoerupUtilsPlugin extends J
25          public void onDisable() {          public void onDisable() {
26                  // TODO Auto-generated method stub                  // TODO Auto-generated method stub
27          }          }
28            
29            MessageWrapper messageWrapper;
30    
31                    
32          @Override          @Override
33          public void onEnable() {          public void onEnable() {
34                  System.out.println("Loading HoerupUtils plugin");                  System.out.println("Loading HoerupUtils plugin");
35                  getCommand("whereis").setExecutor(new WhereisCommand(getServer()));                  getCommand("whereis").setExecutor(new WhereisCommand(getServer()));
36                  getCommand("mapgen").setExecutor(new MapgenCommand(this));                  //getCommand("mapgen").setExecutor(new MapgenCommand(this));
37                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));                  getCommand("eternalday").setExecutor(new EternalDayCommand(this));
38                    getCommand("getpos").setExecutor( new GetposCommand() );
39                    getCommand("msg").setExecutor( new MsgCommand( this ) );
40                    getCommand("tp").setExecutor( new TeleportCommand() );
41    
42                    getCommand("wall").setExecutor( new WallCommand() );
43                    getCommand("weather").setExecutor( new WeatherCommand() );
44    
45                    getCommand("gc").setExecutor( new GcCommand() );
46    
47    
48                    HomeCommand home = new HomeCommand(this);
49                    getCommand("home").setExecutor( home );
50                    getCommand("sethome").setExecutor( home );
51    
52                    DiverCommand diver = new DiverCommand(this );
53                    getCommand("diver").setExecutor( diver );
54                    
55                    GeneralContractorCommands generalContractor = new GeneralContractorCommands();
56                    getCommand("replay").setExecutor( generalContractor );
57                    getCommand("levelarea").setExecutor( generalContractor );
58                    getCommand("fillarea").setExecutor( generalContractor );
59                    getCommand("slopearea").setExecutor( generalContractor );
60                    getCommand("setsurface").setExecutor( generalContractor );
61                    getCommand("platform").setExecutor( generalContractor );
62                    getCommand("cylinder").setExecutor( generalContractor );
63                    getCommand("createcave").setExecutor( generalContractor );
64    
65                    
66                    getCommand("template").setExecutor( new TemplateCommand(this) );
67    
68                    LogintimeHandler logintimeHandler = new LogintimeHandler( this.getDataFolder() );
69                    
70                                    
71                  PluginManager pm = getServer().getPluginManager();                  PluginManager pm = getServer().getPluginManager();
72                  pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this);  
73                  pm.registerEvent(Event.Type.ENTITY_DEATH, new RespawnHandler.PlayerDeathListener(this.getDataFolder()), Priority.Normal, this);          
74                    pm.registerEvents(logintimeHandler, this);
75                    pm.registerEvents(logintimeHandler, this);
76    
77                    
78                    pm.registerEvents(diver, this);
79    
80                    pm.registerEvents(new EndermanStopper(), this);
81                    
82                    
83                    
84                    
85                    
86            
87                    Runnable ddlInstaller = new Runnable() {
88                            @Override
89                            public void run() {
90                                    System.out.println("installddl");
91                                    installDDL();
92                            }
93                    };
94                    messageWrapper = new MessageWrapper(this, ddlInstaller);
95                    pm.registerEvents( messageWrapper, this);
96                                    
97                    SnitchingChest snitch = new SnitchingChest(this, ddlInstaller);
98                    getCommand("snitchingchest").setExecutor(snitch);
99                    pm.registerEvents( snitch, this);
100                    
101                    getCommand("webuser").setExecutor( new WebUserCommand(this,ddlInstaller) );                            
102    
103            
104                  //register web plugins                  //register web plugins
105                  pm.registerEvent(Event.Type.CUSTOM_EVENT, new StatusListener(getServer()), Priority.Normal, this);                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new StatusListener(getServer(), logintimeHandler.getConfig(), home.getConfig() ), Priority.Normal, this);
106                  pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);                  //pm.registerEvent(Event.Type.CUSTOM_EVENT, new MessageListener(getServer()), Priority.Normal, this);
107    
108                    try {
109                            try {
110                                    //først probes om klassen i det hele taget findes
111                                    Class.forName("de.codeinfection.quickwango.ApiBukkit.ApiServer.ApiController"); //if it fails it throws an exception
112                                    WebLoader.getInstance().load(this, logintimeHandler.getConfig(), home.getConfig());
113                            
114                                    getLogger().info("ApiBukkit found, status listener registered");
115                                    
116                            } catch (ClassNotFoundException e) {
117                                    getLogger().warning("Could not find ApiBukkit - web status is disabled" );
118                            }                      
119                    } catch (Throwable e) { //instead of ClassNotFoundException + NoSuchMethodException + InvocationTargetException + IllegalAccessException
120                            getLogger().warning("Could not find ApiBukkit - web status is disabled (" + e.getClass().getName() + ":" + e.getMessage() + ")"  );
121                    }
122                    
123                    
124    
125                                    
126                    DoorBlockListener secretDoor = new DoorBlockListener(this);
127                    pm.registerEvents(secretDoor, this);
128                    pm.registerEvents(secretDoor.getPlayerListener(), this);
129                                    
130            }
131            
132            public MessageWrapper getMessageWrapper() {
133                    return messageWrapper;
134            }
135    
136            //@SuppressWarnings({ "unchecked", "rawtypes" })
137            @Override
138            public List<Class<?>> getDatabaseClasses() {
139                    List<Class<?>> list = new ArrayList<Class<?>>();
140    
141                    list.add(MessageBean.class);
142                    list.add(SnitchingChestBean.class);
143                    list.add(WebUser.class);
144    
145                    return list;
146            }
147    
148            private void deprecated() {
149    /*
150                    getCommand("stoner").setExecutor( new StonerCommand() );
151                    getCommand("spawn").setExecutor( new SpawnCommand() );
152                    getCommand("boom").setExecutor( new BoomCommand(this) );
153                    getCommand("grass").setExecutor(new GrassCommand());
154    
155                    getCommand("zapme").setExecutor( new ZapmeCommand() );
156                    getCommand("zap").setExecutor( new ZapCommand() );
157    
158    
159                  PowerMiner powerMiner = new PowerMiner();                  PowerMiner powerMiner = new PowerMiner();
160                  pm.registerEvent(Event.Type.BLOCK_DAMAGE, powerMiner, Priority.Normal, this);                  pm.registerEvent(Event.Type.BLOCK_DAMAGE, powerMiner, Priority.Normal, this);
161                    pm.registerEvent(Event.Type.PLAYER_QUIT, powerMiner.getPlayerQuitListener(), Priority.Normal, this);
162                  getCommand("powerminer").setExecutor(powerMiner);                  getCommand("powerminer").setExecutor(powerMiner);
163    
164                    SuperMiner superMiner = new SuperMiner();
165                    pm.registerEvent(Event.Type.BLOCK_DAMAGE, superMiner, Priority.Normal, this);
166                    pm.registerEvent(Event.Type.PLAYER_QUIT, superMiner.getPlayerQuitListener(), Priority.Normal, this);
167                    getCommand("superminer").setExecutor(superMiner);
168    
169    
170                    //pm.registerEvent(Event.Type.PROJECTILE_HIT, new ExplosiveSnowballs(), Priority.Normal, this);
171    
172                    //pm.registerEvent(Event.Type.PLAYER_RESPAWN, new RespawnHandler(this), Priority.Normal, this);
173                    //pm.registerEvent(Event.Type.ENTITY_DEATH, new RespawnHandler.PlayerDeathListener(this.getDataFolder()), Priority.Normal, this);              
174    
175    */
176          }          }
177    
178  }  }

Legend:
Removed from v.1385  
changed lines
  Added in v.1804

  ViewVC Help
Powered by ViewVC 1.1.20