Skip to content

Commit

Permalink
Added BukkitContrib auto download and installation
Browse files Browse the repository at this point in the history
  • Loading branch information
DiddiZ committed Jul 9, 2011
1 parent 4cc4f87 commit bb0021f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/de/diddiz/LogBlock/LogBlock.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.diddiz.LogBlock;

import static de.diddiz.util.Utils.download;
import static de.diddiz.util.Utils.downloadIfNotExists;
import java.io.File;
import java.net.URL;
Expand Down Expand Up @@ -107,6 +108,14 @@ public void onEnable() {
final LBPlayerListener lbPlayerListener = new LBPlayerListener(this);
final LBEntityListener lbEntityListener = new LBEntityListener(this);
final PluginManager pm = getServer().getPluginManager();
if (config.logChestAccess && pm.getPlugin("BukkitContrib") == null)
try {
download(log, new URL("http://bit.ly/autoupdateBukkitContrib"), new File("plugins/BukkitContrib.jar"));
pm.loadPlugin(new File("plugins/BukkitContrib.jar"));
pm.enablePlugin(pm.getPlugin("BukkitContrib"));
} catch (final Exception ex) {
log.warning("[LogBlock] Failed to install BukkitContrib, you may have to restart your server or install it manually!");
}
pm.registerEvent(Type.PLAYER_INTERACT, new LBToolListener(this), Priority.Normal, this);
if (config.logBlockCreations) {
pm.registerEvent(Type.BLOCK_PLACE, lbBlockListener, Priority.Monitor, this);
Expand All @@ -125,8 +134,8 @@ public void onEnable() {
if (config.logLeavesDecay)
pm.registerEvent(Type.LEAVES_DECAY, lbBlockListener, Priority.Monitor, this);
if (config.logChestAccess)
if (getServer().getPluginManager().getPlugin("BukkitContrib") != null)
getServer().getPluginManager().registerEvent(Type.CUSTOM_EVENT, new LBChestAccessListener(this), Priority.Monitor, this);
if (pm.getPlugin("BukkitContrib") != null)
pm.registerEvent(Type.CUSTOM_EVENT, new LBChestAccessListener(this), Priority.Monitor, this);
else
log.warning("[LogBlock] BukkitContrib not found. Can't log chest accesses.");
if (config.logLavaFlow)
Expand Down

0 comments on commit bb0021f

Please sign in to comment.