Use soft dependencies to request loading of Permissions and CraftIRC

before NoCheat
This commit is contained in:
Evenprime 2011-06-06 19:57:59 +02:00
parent 30622e9235
commit a039edcfaf
2 changed files with 33 additions and 33 deletions

View File

@ -5,6 +5,8 @@ author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 1.02 version: 1.02
softdepend: [ Permissions, CraftIRC ]
commands: commands:
nocheat: nocheat:
description: Provides information about the current status of the NoCheat plugin description: Provides information about the current status of the NoCheat plugin

View File

@ -123,10 +123,10 @@ public class NoCheat extends JavaPlugin implements CommandSender {
config.cleanup(); config.cleanup();
try { try {
teardownCleanupTask(); teardownCleanupTask();
teardownServerLagMeasureTask(); teardownServerLagMeasureTask();
NoCheatData.cancelPlayerDataTasks(); NoCheatData.cancelPlayerDataTasks();
} }
catch(Exception e) { /* Can't do much in case of error here... */ } catch(Exception e) { /* Can't do much in case of error here... */ }
Logger.getLogger("Minecraft").info( "[NoCheat] version [" + pdfFile.getVersion() + "] is disabled."); Logger.getLogger("Minecraft").info( "[NoCheat] version [" + pdfFile.getVersion() + "] is disabled.");
@ -168,13 +168,18 @@ public class NoCheat extends JavaPlugin implements CommandSender {
if(cleanUpTaskId != -1) return; if(cleanUpTaskId != -1) return;
cleanUpTaskId = Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() { try {
cleanUpTaskId = Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
@Override @Override
public void run() { public void run() {
NoCheatData.cleanPlayerDataCollection(); NoCheatData.cleanPlayerDataCollection();
} }
}, 5000, 5000); }, 5000, 5000);
}
catch(Exception e) {
// It's not THAT important, so if it fails for whatever reason, just let it be.
}
} }
private void teardownCleanupTask() { private void teardownCleanupTask() {
@ -207,24 +212,17 @@ public class NoCheat extends JavaPlugin implements CommandSender {
* Get, if available, a reference to the Permissions-plugin * Get, if available, a reference to the Permissions-plugin
*/ */
private void setupPermissions() { private void setupPermissions() {
PermissionHandler p = null;
Plugin test = this.getServer().getPluginManager().getPlugin("Permissions"); Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
if(test != null && test instanceof Permissions) { if (this.permissions == null) {
p = ((Permissions)test).getHandler(); if (permissionsPlugin != null) {
if(p == null) { this.permissions = ((Permissions) permissionsPlugin).getHandler();
this.getServer().getPluginManager().enablePlugin(test); } else {
PluginDescriptionFile pdfFile = this.getDescription();
Logger.getLogger("Minecraft").warning("[NoCheat] version [" + pdfFile.getVersion() + "] couldn't find Permissions plugin. Fallback to 'isOp()' equals 'nocheat.*'");
} }
p = ((Permissions)test).getHandler();
} }
if(p == null) {
PluginDescriptionFile pdfFile = this.getDescription();
Logger.getLogger("Minecraft").warning("[NoCheat] version [" + pdfFile.getVersion() + "] couldn't find Permissions plugin. Fallback to 'isOp()' equals 'nocheat.*'");
}
permissions = p;
} }
/** /**
@ -340,10 +338,10 @@ public class NoCheat extends JavaPlugin implements CommandSender {
} }
try { try {
BufferedReader reader = new BufferedReader(new FileReader(new File("server.properties"))); BufferedReader reader = new BufferedReader(new FileReader(new File("server.properties")));
allowFlightSet = true; allowFlightSet = true;
String s = null; String s = null;
while((s = reader.readLine()) != null) { while((s = reader.readLine()) != null) {
if(s.startsWith("allow-flight=false")) { if(s.startsWith("allow-flight=false")) {