Skip to content

Commit

Permalink
Supporting WorldEdit as library, added WE auto download
Browse files Browse the repository at this point in the history
  • Loading branch information
DiddiZ committed Jul 9, 2011
1 parent bb0021f commit e174fc3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
Class-Path: ../lib/mysql-connector-java-bin.jar
Class-Path: ../lib/mysql-connector-java-bin.jar ../lib/WorldEdit.jar ../WorldEdit.jar

33 changes: 21 additions & 12 deletions src/de/diddiz/LogBlock/LogBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,32 @@ public void onLoad() {

@Override
public void onEnable() {
final PluginManager pm = getServer().getPluginManager();
if (errorAtLoading) {
getServer().getPluginManager().disablePlugin(this);
pm.disablePlugin(this);
return;
}
if (pm.getPlugin("WorldEdit") == null && !new File("lib/WorldEdit.jar").exists() && !new File("WorldEdit.jar").exists())
try {
download(log, new URL("http://diddiz.insane-architects.net/download/WorldEdit.jar"), new File("lib/WorldEdit.jar"));
log.info("[LogBlock] You've to restart/reload your server now.");
pm.disablePlugin(this);
return;
} catch (final Exception ex) {
log.warning("[LogBlock] Failed to download WorldEdit. You may have to download it manually. You don't have to install it, just place the jar in the lib folder.");
}
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.");
}
commandsHandler = new CommandsHandler(this);
getCommand("lb").setExecutor(commandsHandler);
if (getServer().getPluginManager().getPlugin("Permissions") != null) {
permissions = ((Permissions)getServer().getPluginManager().getPlugin("Permissions")).getHandler();
if (pm.getPlugin("Permissions") != null) {
permissions = ((Permissions)pm.getPlugin("Permissions")).getHandler();
log.info("[LogBlock] Permissions found.");
} else
log.info("[LogBlock] Permissions plugin not found. Using default permissions.");
Expand All @@ -107,15 +125,6 @@ public void onEnable() {
final LBBlockListener lbBlockListener = new LBBlockListener(this);
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 Down

0 comments on commit e174fc3

Please sign in to comment.