Fix for Ticket #102 (missing dependency -> NoClassDefFoundError)

This commit is contained in:
Jascha Starke 2013-03-25 17:51:01 +01:00
parent ee0a78a2fe
commit 071279ff02
5 changed files with 64 additions and 23 deletions

View file

@ -1,11 +1,8 @@
package de.jaschastarke.minecraft.limitedcreative;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.plugin.RegisteredServiceProvider;
import de.jaschastarke.bukkit.lib.CoreModule;
import de.jaschastarke.minecraft.limitedcreative.gmperm.GMPermConfig;
import de.jaschastarke.minecraft.limitedcreative.gmperm.PermissionInterface;
import de.jaschastarke.minecraft.limitedcreative.gmperm.PlayerListener;
import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry;
@ -13,8 +10,7 @@ import de.jaschastarke.modularize.ModuleEntry.ModuleState;
public class ModGameModePerm extends CoreModule<LimitedCreative> {
private GMPermConfig config;
private Permission permission = null;
private RegisteredServiceProvider<Permission> permissionProvider;
private PermissionInterface permission = null;
public ModGameModePerm(LimitedCreative plugin) {
super(plugin);
@ -31,15 +27,24 @@ public class ModGameModePerm extends CoreModule<LimitedCreative> {
config = new GMPermConfig(this, entry);
plugin.getPluginConfig().registerSection(config);
permissionProvider = plugin.getServer().getServicesManager().getRegistration(Permission.class);
if (!plugin.getServer().getPluginManager().isPluginEnabled("Vault")) {
if (config.getEnabled())
getLog().warn(plugin.getLocale().trans("gmperm.warning.vault_not_found", getName()));
entry.initialState = ModuleState.NOT_INITIALIZED;
return;
}
permission = new PermissionInterface(this);
if (config.getEnabled()) {
if (!plugin.getServer().getPluginManager().isPluginEnabled("Vault")) {
if (!permission.isPresent()) {
getLog().warn(plugin.getLocale().trans("gmperm.warning.vault_not_found", getName()));
entry.initialState = ModuleState.NOT_INITIALIZED;
return;
} /*else if (!getVaultPermission().hasGroupSupport()) {
getLog().warn(plugin.getLocale().trans("gmperm.warning.no_group_support", getName()));
entry.initialState = ModuleState.NOT_INITIALIZED;
return;
}*/
}
}
@ -52,15 +57,12 @@ public class ModGameModePerm extends CoreModule<LimitedCreative> {
@Override
public void onDisable() {
super.onDisable();
permission = null;
permission.clear();
}
public GMPermConfig getConfig() {
return config;
}
public Permission getVaultPermission() {
if (permissionProvider != null && permission == null) {
permission = permissionProvider.getProvider();
}
public PermissionInterface getPermissionInterface() {
return permission;
}
}

View file

@ -33,6 +33,10 @@ public class ModRegions extends CoreModule<LimitedCreative> {
public ModRegions(LimitedCreative plugin) {
super(plugin);
}
@Override
public String getName() {
return "Regions";
}
@Override
public void initialize(ModuleEntry<IModule> pEntry) {
@ -44,6 +48,13 @@ public class ModRegions extends CoreModule<LimitedCreative> {
config = plugin.getPluginConfig().registerSection(new RegionConfig(this, entry));
if (!plugin.getServer().getPluginManager().isPluginEnabled("WorldGuard")) {
if (config.getEnabled())
getLog().warn(plugin.getLocale().trans("region.warning.worldguard_not_found", getName()));
entry.initialState = ModuleState.NOT_INITIALIZED;
return;
}
command = new RegionsCommand(this);
listeners.addListener(new PlayerListener(this));
@ -52,11 +63,6 @@ public class ModRegions extends CoreModule<LimitedCreative> {
listeners.addListener(new PlayerRegionListener(this)); // Fires Custom-Events listen by RegionListener
FlagList.addFlags(Flags.getList());
if (config.getEnabled() && !plugin.getServer().getPluginManager().isPluginEnabled("WorldGuard")) {
getLog().warn(plugin.getLocale().trans("region.warning.worldguard_not_found", getName()));
entry.initialState = ModuleState.NOT_INITIALIZED;
}
}
@Override

View file

@ -0,0 +1,33 @@
package de.jaschastarke.minecraft.limitedcreative.gmperm;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.plugin.RegisteredServiceProvider;
import de.jaschastarke.bukkit.lib.CoreModule;
public class PermissionInterface {
//private CoreModule<?> mod;
private Permission permission = null;
private RegisteredServiceProvider<Permission> permissionProvider;
public PermissionInterface(CoreModule<?> mod) {
//this.mod = mod;
permissionProvider = mod.getPlugin().getServer().getServicesManager().getRegistration(Permission.class);
}
public boolean isPresent() {
return permissionProvider != null && permissionProvider.getProvider() != null;
}
public void clear() {
permission = null;
}
public Permission getPermission() {
if (permission == null)
permission = permissionProvider.getProvider();
return permission;
}
}

View file

@ -38,7 +38,7 @@ public class PlayerListener implements Listener {
}
protected Permission v() {
return mod.getVaultPermission();
return mod.getPermissionInterface().getPermission();
}
@EventHandler(priority = EventPriority.MONITOR)

View file

@ -1,9 +1,9 @@
basic.loaded.module: Module loaded.
inventory.warning.conflict: Due to conflict with the plugin {0}, the feature {1} is disabled
region.warning.worldguard_not_found: WorldGuard isn't found, the feature {0} is disabled
gmperm.warning.vault_not_found: Vault isn't found, the feature {0} is disabled
gmperm.warning.no_group_support: Your Permission-Plugin doesn't support groups, the feature {0} is disabled
region.warning.worldguard_not_found: WorldGuard isn''t found, the feature {0} is disabled
gmperm.warning.vault_not_found: Vault isn''t found, the feature {0} is disabled
gmperm.warning.no_group_support: "Your Permission-Plugin doesn''t support groups, the feature {0} is disabled"
command.general: LimitedCreative: GameMode-Switch, Creative-Regions, Config and more
command.regions: LimitedCreative-Region-Command: configure creative regions
@ -12,7 +12,7 @@ command.switch.creative: Changes the game mode of a player to creative
command.switch.adventure: Changes the game mode of a player to adventure
command.config.reload: Reloads configuration and re-initializes all active modules.
command.config.reload.success: The plugin was successfully reloaded.
command.gamemode.changed: {0}'s game mode has been changed
command.gamemode.changed: {0}''s game mode has been changed
command.gamemode.no_change: Already in that game mode.
command.worldguard.alias: Alias for //region-command