forked from LogBlock/LogBlock
Added BukkitContrib auto download and installation
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package de.diddiz.LogBlock;
|
package de.diddiz.LogBlock;
|
||||||
|
|
||||||
|
import static de.diddiz.util.Utils.download;
|
||||||
import static de.diddiz.util.Utils.downloadIfNotExists;
|
import static de.diddiz.util.Utils.downloadIfNotExists;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -107,6 +108,14 @@ public class LogBlock extends JavaPlugin
|
|||||||
final LBPlayerListener lbPlayerListener = new LBPlayerListener(this);
|
final LBPlayerListener lbPlayerListener = new LBPlayerListener(this);
|
||||||
final LBEntityListener lbEntityListener = new LBEntityListener(this);
|
final LBEntityListener lbEntityListener = new LBEntityListener(this);
|
||||||
final PluginManager pm = getServer().getPluginManager();
|
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);
|
pm.registerEvent(Type.PLAYER_INTERACT, new LBToolListener(this), Priority.Normal, this);
|
||||||
if (config.logBlockCreations) {
|
if (config.logBlockCreations) {
|
||||||
pm.registerEvent(Type.BLOCK_PLACE, lbBlockListener, Priority.Monitor, this);
|
pm.registerEvent(Type.BLOCK_PLACE, lbBlockListener, Priority.Monitor, this);
|
||||||
@@ -125,8 +134,8 @@ public class LogBlock extends JavaPlugin
|
|||||||
if (config.logLeavesDecay)
|
if (config.logLeavesDecay)
|
||||||
pm.registerEvent(Type.LEAVES_DECAY, lbBlockListener, Priority.Monitor, this);
|
pm.registerEvent(Type.LEAVES_DECAY, lbBlockListener, Priority.Monitor, this);
|
||||||
if (config.logChestAccess)
|
if (config.logChestAccess)
|
||||||
if (getServer().getPluginManager().getPlugin("BukkitContrib") != null)
|
if (pm.getPlugin("BukkitContrib") != null)
|
||||||
getServer().getPluginManager().registerEvent(Type.CUSTOM_EVENT, new LBChestAccessListener(this), Priority.Monitor, this);
|
pm.registerEvent(Type.CUSTOM_EVENT, new LBChestAccessListener(this), Priority.Monitor, this);
|
||||||
else
|
else
|
||||||
log.warning("[LogBlock] BukkitContrib not found. Can't log chest accesses.");
|
log.warning("[LogBlock] BukkitContrib not found. Can't log chest accesses.");
|
||||||
if (config.logLavaFlow)
|
if (config.logLavaFlow)
|
||||||
|
Reference in New Issue
Block a user