This commit is contained in:
mung3r 2011-10-29 22:33:39 -07:00
commit af1a4b711f
21 changed files with 1530 additions and 1843 deletions

View File

@ -39,7 +39,7 @@
</target>
<target name="javadoc" description="Generate JavaDoc">
<javadoc packagenames="net.milkbowl.vault.economy,net.milkbowl.vault.permission"
<javadoc packagenames="net.milkbowl.vault.economy,net.milkbowl.vault.permission,net.milkbowl.vault.chat"
sourcepath="src"
destdir="javadoc"
access="public"

Binary file not shown.

Binary file not shown.

BIN
lib/bpermissions.jar Normal file

Binary file not shown.

Binary file not shown.

View File

@ -22,6 +22,12 @@ package net.milkbowl.vault;
import java.util.Collection;
import java.util.logging.Logger;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.chat.plugins.Chat_GroupManager;
import net.milkbowl.vault.chat.plugins.Chat_Permissions3;
import net.milkbowl.vault.chat.plugins.Chat_PermissionsEx;
import net.milkbowl.vault.chat.plugins.Chat_bPermissions;
import net.milkbowl.vault.chat.plugins.Chat_mChat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.plugins.Economy_3co;
import net.milkbowl.vault.economy.plugins.Economy_BOSE6;
@ -33,11 +39,11 @@ import net.milkbowl.vault.economy.plugins.Economy_iConomy5;
import net.milkbowl.vault.economy.plugins.Economy_iConomy6;
import net.milkbowl.vault.permission.Permission;
import net.milkbowl.vault.permission.plugins.Permission_GroupManager;
import net.milkbowl.vault.permission.plugins.Permission_Permissions2;
import net.milkbowl.vault.permission.plugins.Permission_Permissions3;
import net.milkbowl.vault.permission.plugins.Permission_PermissionsBukkit;
import net.milkbowl.vault.permission.plugins.Permission_PermissionsEx;
import net.milkbowl.vault.permission.plugins.Permission_SuperPerms;
import net.milkbowl.vault.permission.plugins.Permission_bPermissions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -64,12 +70,64 @@ public class Vault extends JavaPlugin {
// Load Vault Addons
loadEconomy();
loadPermission();
loadChat();
getCommand("vault-info").setExecutor(this);
getCommand("vault-reload").setExecutor(this);
log.info(String.format("[%s] Enabled Version %s", getDescription().getName(), getDescription().getVersion()));
}
/**
* Attempts to load Chat Addons
*/
private void loadChat() {
// Try to load PermissionsEx
if (packageExists(new String[] { "ru.tehkode.permissions.bukkit.PermissionsEx" })) {
Chat eChat = new Chat_PermissionsEx(this);
getServer().getServicesManager().register(Chat.class, eChat, this, ServicePriority.Highest);
log.info(String.format("[%s][Chat] PermissionsEx found: %s", getDescription().getName(), eChat.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] PermissionsEx not found.", getDescription().getName()));
}
//Try loading mChat
if (packageExists(new String[] {"net.D3GN.MiracleM4n.mChat"} )) {
Chat mChat = new Chat_mChat(this);
getServer().getServicesManager().register(Chat.class, mChat, this, ServicePriority.Highest);
log.info(String.format("[%s][Chat] mChat found: %s", getDescription().getName(), mChat.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] mChat not found.", getDescription().getName()));
}
//try loading bPermissions
if (packageExists(new String[] {"de.bananaco.permissions.worlds.WorldPermissionsManager"})) {
Chat bPerms = new Chat_bPermissions(this);
getServer().getServicesManager().register(Chat.class, bPerms, this, ServicePriority.High);
log.info(String.format("[%s][Chat] bPermissions found: %s", getDescription().getName(), bPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] bPermissions not found.", getDescription().getName()));
}
// Try to load GroupManager
if (packageExists(new String[] { "org.anjocaido.groupmanager.GroupManager" })) {
Chat gPerms = new Chat_GroupManager(this);
getServer().getServicesManager().register(Chat.class, gPerms, this, ServicePriority.High);
log.info(String.format("[%s][Chat] GroupManager found: %s", getDescription().getName(), gPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] GroupManager not found.", getDescription().getName()));
}
// Try to load Permissions 3 (Yeti)
if (packageExists(new String[] { "com.nijiko.permissions.ModularControl" })) {
Chat nPerms = new Chat_Permissions3(this);
getServer().getServicesManager().register(Chat.class, nPerms, this, ServicePriority.High);
log.info(String.format("[%s][Chat] Permissions 3 (Yeti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] Permissions 3 (Yeti) not found.", getDescription().getName()));
}
}
/**
* Attempts to load Economy Addons
*/
@ -77,7 +135,7 @@ public class Vault extends JavaPlugin {
// Try to load MultiCurrency
if (packageExists(new String[] { "me.ashtheking.currency.Currency", "me.ashtheking.currency.CurrencyList" })) {
Economy econ = new Economy_MultiCurrency(this);
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, econ, this, ServicePriority.Normal);
getServer().getServicesManager().register(Economy.class, econ, this, ServicePriority.Normal);
log.info(String.format("[%s][Economy] MultiCurrency found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Economy] MultiCurrency not found.", getDescription().getName()));
@ -86,7 +144,7 @@ public class Vault extends JavaPlugin {
// Try to load 3co
if (packageExists(new String[] { "me.ic3d.eco.ECO" })) {
Economy econ = new Economy_3co(this);
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, econ, this, ServicePriority.Normal);
getServer().getServicesManager().register(Economy.class, econ, this, ServicePriority.Normal);
log.info(String.format("[%s][Economy] 3co found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Economy] 3co not found.", getDescription().getName()));
@ -95,7 +153,7 @@ public class Vault extends JavaPlugin {
// Try to load BOSEconomy
if (packageExists(new String[] { "cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandManager" })) {
Economy bose6 = new Economy_BOSE6(this);
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, bose6, this, ServicePriority.Normal);
getServer().getServicesManager().register(Economy.class, bose6, this, ServicePriority.Normal);
log.info(String.format("[%s][Economy] BOSEconomy6 found: %s", getDescription().getName(), bose6.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Economy] BOSEconomy6 not found.", getDescription().getName()));
@ -138,7 +196,7 @@ public class Vault extends JavaPlugin {
// Try to load iConomy 6
if (packageExists(new String[] { "com.iCo6.iConomy" })) {
Economy icon6 = new Economy_iConomy6(this);
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, icon6, this, ServicePriority.High);
getServer().getServicesManager().register(Economy.class, icon6, this, ServicePriority.High);
log.info(String.format("[%s][Economy] iConomy 6 found: %s", getDescription().getName(), icon6.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Economy] iConomy 6 not found.", getDescription().getName()));
@ -152,7 +210,7 @@ public class Vault extends JavaPlugin {
// Try to load PermissionsEx
if (packageExists(new String[] { "ru.tehkode.permissions.bukkit.PermissionsEx" })) {
Permission ePerms = new Permission_PermissionsEx(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, ePerms, this, ServicePriority.Highest);
getServer().getServicesManager().register(Permission.class, ePerms, this, ServicePriority.Highest);
log.info(String.format("[%s][Permission] PermissionsEx found: %s", getDescription().getName(), ePerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Permission] PermissionsEx not found.", getDescription().getName()));
@ -161,15 +219,22 @@ public class Vault extends JavaPlugin {
//Try loading PermissionsBukkit
if (packageExists(new String[] {"com.platymuus.bukkit.permissions.PermissionsPlugin"} )) {
Permission pPerms = new Permission_PermissionsBukkit(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, pPerms, this, ServicePriority.Highest);
getServer().getServicesManager().register(Permission.class, pPerms, this, ServicePriority.Highest);
log.info(String.format("[%s][Permission] PermissionsBukkit found: %s", getDescription().getName(), pPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Permission] PermissionsBukkit not found.", getDescription().getName()));
}
if (packageExists(new String[] {"de.bananaco.permissions.worlds.WorldPermissionsManager"} )) {
Permission bPerms = new Permission_bPermissions(this);
getServer().getServicesManager().register(Permission.class, bPerms, this, ServicePriority.Highest);
log.info(String.format("[%s][Permission] bPermissions found: %s", getDescription().getName(), bPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Permission] bPermissions not found.", getDescription().getName()));
}
// Try to load GroupManager
if (packageExists(new String[] { "org.anjocaido.groupmanager.GroupManager" })) {
Permission gPerms = new Permission_GroupManager(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, gPerms, this, ServicePriority.High);
getServer().getServicesManager().register(Permission.class, gPerms, this, ServicePriority.High);
log.info(String.format("[%s][Permission] GroupManager found: %s", getDescription().getName(), gPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Permission] GroupManager not found.", getDescription().getName()));
@ -178,23 +243,14 @@ public class Vault extends JavaPlugin {
// Try to load Permissions 3 (Yeti)
if (packageExists(new String[] { "com.nijiko.permissions.ModularControl" })) {
Permission nPerms = new Permission_Permissions3(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, nPerms, this, ServicePriority.High);
getServer().getServicesManager().register(Permission.class, nPerms, this, ServicePriority.High);
log.info(String.format("[%s][Permission] Permissions 3 (Yeti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Permission] Permissions 3 (Yeti) not found.", getDescription().getName()));
}
// Try to load Permissions 2 (Phoenix)
if (packageExists(new String[] { "com.nijiko.permissions.Control" })) {
Permission oPerms = new Permission_Permissions2(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, oPerms, this, ServicePriority.Low);
log.info(String.format("[%s][Permission] Permissions 2 (Phoenix) found: %s", getDescription().getName(), oPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Permission] Permissions 2 (Phoenix) not found.", getDescription().getName()));
}
Permission perms = new Permission_SuperPerms(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, perms, this, ServicePriority.Lowest);
getServer().getServicesManager().register(Permission.class, perms, this, ServicePriority.Lowest);
log.info(String.format("[%s][Permission] SuperPermissions loaded as backup permission system.", getDescription().getName()));
}
@ -218,7 +274,7 @@ public class Vault extends JavaPlugin {
// Get String of Registered Economy Services
String registeredEcons = null;
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(net.milkbowl.vault.economy.Economy.class);
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(Economy.class);
for (RegisteredServiceProvider<Economy> econ : econs) {
Economy e = econ.getProvider();
if (registeredEcons == null) {
@ -230,7 +286,7 @@ public class Vault extends JavaPlugin {
// Get String of Registered Permission Services
String registeredPerms = null;
Collection<RegisteredServiceProvider<Permission>> perms = this.getServer().getServicesManager().getRegistrations(net.milkbowl.vault.permission.Permission.class);
Collection<RegisteredServiceProvider<Permission>> perms = this.getServer().getServicesManager().getRegistrations(Permission.class);
for (RegisteredServiceProvider<Permission> perm : perms) {
Permission p = perm.getProvider();
if (registeredPerms == null) {
@ -241,8 +297,8 @@ public class Vault extends JavaPlugin {
}
// Get Economy & Permission primary Services
Economy econ = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class).getProvider();
Permission perm = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class).getProvider();
Economy econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
Permission perm = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
// Send user some info!
sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion()));

View File

@ -1,5 +1,217 @@
package net.milkbowl.vault.chat.plugins;
public class Chat_GroupManager {
import java.util.logging.Logger;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import net.milkbowl.vault.chat.Chat;
@SuppressWarnings("deprecation")
public class Chat_GroupManager extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "GroupManager - Chat";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private GroupManager groupManager;
private AnjoPermissionsHandler perms;
private PermissionServerListener permissionServerListener = null;
public Chat_GroupManager(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (groupManager == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("GroupManager");
if (perms != null) {
if (perms.isEnabled()) {
groupManager = (GroupManager) perms;
this.perms = groupManager.getPermissionHandler();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
}
private class PermissionServerListener extends ServerListener {
Chat_GroupManager chat = null;
public PermissionServerListener(Chat_GroupManager chat) {
this.chat = chat;
}
public void onPluginEnable(PluginEnableEvent event) {
if (chat.groupManager == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("GroupManager");
if (perms != null) {
if (perms.isEnabled()) {
chat.groupManager = (GroupManager) perms;
chat.perms = groupManager.getPermissionHandler();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), chat.name));
}
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (chat.groupManager != null) {
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
chat.groupManager = null;
chat.perms = null;
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), chat.name));
}
}
}
}
@Override
public String getName() {
return this.name;
}
@Override
public boolean isEnabled() {
if (groupManager == null) {
return false;
} else {
return groupManager.isEnabled();
}
}
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
return perms.getPermissionInteger(playerName, node);
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
return perms.getGroupPermissionInteger(groupName, node);
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
return perms.getPermissionDouble(playerName, node);
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
return perms.getGroupPermissionDouble(groupName, node);
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
return perms.getPermissionBoolean(playerName, node);
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
return perms.getGroupPermissionBoolean(groupName, node);
}
@Override
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
return perms.getPermissionString(playerName, node);
}
@Override
public void setPlayerInfoString(String world, String playerName, String node, String value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
return perms.getGroupPermissionString(groupName, node);
}
@Override
public void setGroupInfoString(String world, String groupName, String node, String value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getPlayerPrefix(String world, String playerName) {
return perms.getGroupPrefix(getPrimaryGroup(world, playerName));
}
@Override
public String getPlayerSuffix(String world, String playerName) {
return perms.getGroupSuffix(getPrimaryGroup(world, playerName));
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getGroupPrefix(String world, String group) {
return perms.getGroupPrefix(group);
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getGroupSuffix(String world, String group) {
return perms.getGroupSuffix(group);
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
public String getPrimaryGroup(String world, String playerName) {
return perms.getGroup(playerName);
}
}

View File

@ -1,5 +0,0 @@
package net.milkbowl.vault.chat.plugins;
public class Chat_Permissions2 {
}

View File

@ -1,5 +1,233 @@
package net.milkbowl.vault.chat.plugins;
public class Chat_Permissions3 {
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import net.milkbowl.vault.chat.Chat;
public class Chat_Permissions3 extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "Permissions 3 (Yeti) - Chat";
private PermissionHandler perms;
private Plugin plugin = null;
private PluginManager pluginManager = null;
private Permissions chat = null;
private PermissionServerListener permissionServerListener = null;
public Chat_Permissions3(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener();
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (chat == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
if (perms != null) {
if (perms.isEnabled() && perms.getDescription().getVersion().startsWith("3")) {
chat = (Permissions) perms;
this.perms = chat.getHandler();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
}
private class PermissionServerListener extends ServerListener {
public void onPluginEnable(PluginEnableEvent event) {
if (chat == null) {
Plugin perms = event.getPlugin();
if(perms.getDescription().getName().equals("Permissions") && perms.getDescription().getVersion().startsWith("3")) {
if (perms.isEnabled()) {
chat = (Permissions) perms;
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (chat != null) {
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
chat = null;
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
}
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
if (chat == null) {
return false;
} else {
return chat.isEnabled();
}
}
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
Integer i = this.perms.getPermissionInteger(world, playerName, node);
return (i == null) ? defaultValue : i;
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
Double d = this.perms.getPermissionDouble(world, playerName, node);
return (d == null) ? defaultValue : d;
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
Boolean b = this.perms.getPermissionBoolean(world, playerName, node);
return (b == null) ? defaultValue : b;
}
@Override
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
String s = this.perms.getPermissionString(world, playerName, node);
return (s == null) ? defaultValue : s;
}
@Override
public String getPlayerPrefix(String world, String playerName) {
return getPlayerInfoString(world, playerName, "prefix", null);
}
@Override
public String getPlayerSuffix(String world, String playerName) {
return getPlayerInfoString(world, playerName, "suffix", null);
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
//this.perms.addUserInfo(world, player, "prefix", prefix);
}
public void setPlayerInfo(String world, String playerName, String node, Object value) {
//this.perms.addUserInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
setPlayerInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
setPlayerInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
setPlayerInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoString(String world, String playerName, String node, String value) {
setPlayerInfo(world, playerName, node, value);
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
//Integer i = this.perms.getInfoInteger(world, groupName, node, true);
//return (i == null) ? defaultValue : i;
return defaultValue;
}
public void setGroupInfo(String world, String groupName, String node, Object value) {
this.perms.addGroupInfo(world, groupName, node, value);
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
//Double d = this.perms.getInfoDouble(world, groupName, node, true);
//return (d == null) ? defaultValue : d;
return defaultValue;
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
//Boolean b = this.perms.getInfoBoolean(world, groupName, node, true);
//return (b == null) ? defaultValue : b;
return defaultValue;
}
@Override
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
//String s = this.perms.getInfoString(world, groupName, node, true);
//return (s == null) ? defaultValue : s;
return null;
}
@Override
public void setGroupInfoString(String world, String groupName, String node, String value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public String getGroupPrefix(String world, String group) {
//try {
// return perms.safeGetGroup(world, group).getPrefix();
//} catch(Exception e) {
return null;
//}
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
this.perms.addGroupInfo(world, group, "prefix", prefix);
}
@Override
public String getGroupSuffix(String world, String group) {
/*
try {
return perms.safeGetGroup(world, group).getSuffix();
} catch(Exception e) { */
return null;
//}
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
this.perms.addGroupInfo(world, group, "suffix", suffix);
}
}

View File

@ -1,5 +1,295 @@
package net.milkbowl.vault.chat.plugins;
public class Chat_PermissionsEx {
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import ru.tehkode.permissions.PermissionGroup;
import ru.tehkode.permissions.PermissionUser;
import ru.tehkode.permissions.bukkit.PermissionsEx;
import net.milkbowl.vault.chat.Chat;
public class Chat_PermissionsEx extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "PermissionsEx_Chat";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private PermissionsEx chat = null;
private PermissionServerListener permissionServerListener = null;
public Chat_PermissionsEx(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (chat == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("PermissionsEx");
if (perms != null) {
if (perms.isEnabled()) {
chat = (PermissionsEx) perms;
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
}
private class PermissionServerListener extends ServerListener {
Chat_PermissionsEx chat = null;
public PermissionServerListener(Chat_PermissionsEx chat) {
this.chat = chat;
}
public void onPluginEnable(PluginEnableEvent event) {
if (chat.chat == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("PermissionsEx");
if (perms != null) {
if (perms.isEnabled()) {
chat.chat = (PermissionsEx) perms;
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), chat.name));
}
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (chat.chat != null) {
if (event.getPlugin().getDescription().getName().equals("PermissionsEx")) {
chat.chat = null;
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), chat.name));
}
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
if (chat == null)
return false;
else
return chat.isEnabled();
}
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionInteger(node, world, defaultValue);
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionDouble(node, world, defaultValue);
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionBoolean(node, world, defaultValue);
}
@Override
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOption(node, world, defaultValue);
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
user.setOption(node, String.valueOf(value), world);
}
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
user.setOption(node, String.valueOf(value), world);
}
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
user.setOption(node, String.valueOf(value), world);
}
}
@Override
public void setPlayerInfoString(String world, String playerName, String node, String value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
user.setOption(node, String.valueOf(value), world);
}
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return defaultValue;
} else {
return group.getOptionInteger(node, world, defaultValue);
}
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return;
} else {
group.setOption(node, world, String.valueOf(value));
}
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return defaultValue;
} else {
return group.getOptionDouble(node, world, defaultValue);
}
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return;
} else {
group.setOption(node, world, String.valueOf(value));
}
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return defaultValue;
} else {
return group.getOptionBoolean(node, world, defaultValue);
}
}
@Override
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return;
} else {
group.setOption(node, world, String.valueOf(value));
}
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return defaultValue;
} else {
return group.getOption(node, world, defaultValue);
}
}
@Override
public void setGroupInfoString(String world, String groupName, String node, String value) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return;
} else {
group.setOption(node, world, value);
}
}
@Override
public String getPlayerPrefix(String world, String playerName) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
return user.getPrefix();
} else {
return null;
}
}
@Override
public String getPlayerSuffix(String world, String playerName) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
return user.getSuffix();
} else {
return null;
}
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(player);
if (user != null) {
user.setSuffix(suffix, world);
}
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(player);
if (user != null) {
user.setPrefix(prefix, world);
}
}
@Override
public String getGroupPrefix(String world, String group) {
PermissionGroup pGroup = PermissionsEx.getPermissionManager().getGroup(group);
if (group != null) {
return pGroup.getPrefix();
} else {
return null;
}
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
PermissionGroup pGroup = PermissionsEx.getPermissionManager().getGroup(group);
if (group != null) {
pGroup.setPrefix(prefix, world);
}
}
@Override
public String getGroupSuffix(String world, String group) {
PermissionGroup pGroup = PermissionsEx.getPermissionManager().getGroup(group);
if (group != null) {
return pGroup.getSuffix();
} else {
return null;
}
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
PermissionGroup pGroup = PermissionsEx.getPermissionManager().getGroup(group);
if (group != null) {
pGroup.setSuffix(suffix, world);
}
}
}

View File

@ -1,5 +1,277 @@
package net.milkbowl.vault.chat.plugins;
public class Chat_bPermissions {
import java.lang.reflect.Field;
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import de.bananaco.permissions.Permissions;
import de.bananaco.permissions.info.InfoReader;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.chat.Chat;
public class Chat_bPermissions extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "bInfo";
private Vault plugin = null;
InfoReader chat;
private PermissionServerListener permissionServerListener = null;
public Chat_bPermissions(Vault plugin) {
this.plugin = plugin;
permissionServerListener = new PermissionServerListener(this);
plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (chat == null) {
Plugin p = plugin.getServer().getPluginManager().getPlugin("bPermissions");
if (p != null) {
Permissions perms = (Permissions) p;
Field f;
try {
f = perms.getClass().getField(name);
f.setAccessible(true);
chat = (InfoReader) f.get(perms);
} catch (SecurityException e) {
return;
} catch (NoSuchFieldException e) {
return;
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "bPermissions"));
}
}
}
private class PermissionServerListener extends ServerListener {
Chat_bPermissions chat = null;
public PermissionServerListener(Chat_bPermissions chat) {
this.chat = chat;
}
public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.chat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("bPermissions");
if (chat != null) {
Permissions perms = (Permissions) chat;
Field f;
try {
f = perms.getClass().getField(name);
f.setAccessible(true);
this.chat.chat = (InfoReader) f.get(perms);
} catch (SecurityException e) {
return;
} catch (NoSuchFieldException e) {
return;
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "bPermissions"));
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.chat != null) {
if (event.getPlugin().getDescription().getName().equals("bPermissions")) {
this.chat.chat = null;
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "bPermissions"));
}
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
return chat != null;
}
@Override
public String getPlayerPrefix(String world, String player) {
return getPlayerInfoString(player, world, "prefix", null);
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public String getPlayerSuffix(String world, String player) {
return getPlayerInfoString(player, world, "suffix", null);
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public String getGroupPrefix(String world, String group) {
return getGroupInfoString(group, world, "prefix", null);
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public String getGroupSuffix(String world, String group) {
return getGroupInfoString(group, world, "suffix", null);
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
try {
int i = Integer.valueOf(s);
return i;
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setPlayerInfoInteger(String world, String player, String node, int value) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
String s = getGroupInfoString(world, group, node, null);
if (s == null)
return defaultValue;
try {
int i = Integer.valueOf(s);
return i;
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setGroupInfoInteger(String world, String group, String node, int value) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
try {
double d = Double.valueOf(s);
return d;
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setPlayerInfoDouble(String world, String player, String node, double value) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
String s = getGroupInfoString(world, group, node, null);
if (s == null)
return defaultValue;
try {
double d = Double.valueOf(s);
return d;
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setGroupInfoDouble(String world, String group, String node, double value) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
try {
boolean b = Boolean.valueOf(s);
return b;
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
String s = getGroupInfoString(world, group, node, null);
if (s == null)
return defaultValue;
try {
boolean b = Boolean.valueOf(s);
return b;
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
String val = chat.getValue(player, world, node);
return (val == null || val == "BLANKWORLD") ? defaultValue : val;
}
@Override
public void setPlayerInfoString(String world, String player, String node, String value) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
@Override
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
String val = chat.getGroupValue(group, world, node);
return (val == null || val == "BLANKWORLD") ? defaultValue : val;
}
@Override
public void setGroupInfoString(String world, String group, String node, String value) {
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
}
}

View File

@ -1,179 +1,237 @@
package net.milkbowl.vault.chat.plugins;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import net.D3GN.MiracleM4n.mChat.mChatAPI;
import net.milkbowl.vault.chat.Chat;
public class Chat_mChat extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "mChat";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private mChatAPI mChat = null;
private PermissionServerListener permissionServerListener = null;
public Chat_mChat(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (mChat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChat");
if (chat != null) {
mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
}
}
}
private class PermissionServerListener extends ServerListener {
Chat_mChat chat = null;
public PermissionServerListener(Chat_mChat chat) {
this.chat = chat;
}
public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.mChat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChat");
if (chat != null) {
this.chat.mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.mChat != null) {
if (event.getPlugin().getDescription().getName().equals("mChat")) {
this.chat.mChat = null;
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "mChat"));
}
}
}
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
return name;
}
@Override
public boolean isEnabled() {
// TODO Auto-generated method stub
return false;
return mChat != null;
}
@Override
public String getPlayerPrefix(String world, String player) {
// TODO Auto-generated method stub
return null;
Player p = Bukkit.getServer().getPlayer(player);
if (p ==null) {
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
}
return mChat.getPrefix(p);
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public String getPlayerSuffix(String world, String player) {
// TODO Auto-generated method stub
return null;
Player p = Bukkit.getServer().getPlayer(player);
if (p ==null) {
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
}
return mChat.getSuffix(p);
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public String getGroupPrefix(String world, String group) {
// TODO Auto-generated method stub
return null;
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public String getGroupSuffix(String world, String group) {
// TODO Auto-generated method stub
return null;
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
try {
return Integer.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public int getPlayerInfoInteger(String world, String player, String node,
int defaultValue) {
// TODO Auto-generated method stub
return 0;
public void setPlayerInfoInteger(String world, String player, String node, int value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public void setPlayerInfoInteger(String world, String player, String node,
int value) {
// TODO Auto-generated method stub
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoInteger(String world, String group, String node, int value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
try {
return Double.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public int getGroupInfoInteger(String world, String group, String node,
int defaultValue) {
// TODO Auto-generated method stub
return 0;
public void setPlayerInfoDouble(String world, String player, String node, double value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public void setGroupInfoInteger(String world, String group, String node,
int value) {
// TODO Auto-generated method stub
public double getGroupInfoDouble(String world, String group, String node,double defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoDouble(String world, String group, String node, double value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
try {
return Boolean.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public double getPlayerInfoDouble(String world, String player, String node,
double defaultValue) {
// TODO Auto-generated method stub
return 0;
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public void setPlayerInfoDouble(String world, String player, String node,
double value) {
// TODO Auto-generated method stub
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public double getGroupInfoDouble(String world, String group, String node,
double defaultValue) {
// TODO Auto-generated method stub
return 0;
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoDouble(String world, String group, String node,
double value) {
// TODO Auto-generated method stub
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
Player p = Bukkit.getServer().getPlayer(player);
if (p ==null) {
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
}
String s = mChat.getInfo(p, node);
return s == null ? defaultValue : s;
}
@Override
public boolean getPlayerInfoBoolean(String world, String player,
String node, boolean defaultValue) {
// TODO Auto-generated method stub
return false;
public void setPlayerInfoString(String world, String player, String node, String value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public void setPlayerInfoBoolean(String world, String player, String node,
boolean value) {
// TODO Auto-generated method stub
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public boolean getGroupInfoBoolean(String world, String group, String node,
boolean defaultValue) {
// TODO Auto-generated method stub
return false;
public void setGroupInfoString(String world, String group, String node, String value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoBoolean(String world, String group, String node,
boolean value) {
// TODO Auto-generated method stub
}
@Override
public String getPlayerInfoString(String world, String player, String node,
String defaultValue) {
// TODO Auto-generated method stub
return null;
}
@Override
public void setPlayerInfoString(String world, String player, String node,
String value) {
// TODO Auto-generated method stub
}
@Override
public String getGroupInfoString(String world, String group, String node,
String defaultValue) {
// TODO Auto-generated method stub
return null;
}
@Override
public void setGroupInfoString(String world, String group, String node,
String value) {
// TODO Auto-generated method stub
}
}

View File

@ -366,426 +366,6 @@ public abstract class Permission {
return playerRemoveGroup(player.getWorld().getName(), player.getName(), group);
}
/**
* Get a players informational node (Integer) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public int getPlayerInfoInteger(String world, String player, String node, int defaultValue);
/**
* Get a players informational node (Integer) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public int getPlayerInfoInteger(World world, String player, String node, int defaultValue) {
return getPlayerInfoInteger(world.getName(), player, node, defaultValue);
}
/**
* Get a players informational node (Integer) value
* @param player Player Object
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public int getPlayerInfoInteger(Player player, String node, int defaultValue) {
return getPlayerInfoInteger(player.getWorld().getName(), player.getName(), node, defaultValue);
}
/**
* Set a players informational node (Integer) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
abstract public void setPlayerInfoInteger(String world, String player, String node, int value);
/**
* Set a players informational node (Integer) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoInteger(World world, String player, String node, int value) {
setPlayerInfoInteger(world.getName(), player, node, value);
}
/**
* Set a players informational node (Integer) value
* @param player Player Object
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoInteger(Player player, String node, int value) {
setPlayerInfoInteger(player.getWorld().getName(), player.getName(), node, value);
}
/**
* Get a groups informational node (Integer) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public int getGroupInfoInteger(String world, String group, String node, int defaultValue);
/**
* Get a groups informational node (Integer) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public int getGroupInfoInteger(World world, String group, String node, int defaultValue) {
return getGroupInfoInteger(world.getName(), group, node, defaultValue);
}
/**
* Set a groups informational node (Integer) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setGroupInfoInteger(String world, String group, String node, int value);
/**
* Set a groups informational node (Integer) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoInteger(World world, String group, String node, int value) {
setGroupInfoInteger(world.getName(), group, node, value);
}
/**
* Get a players informational node (Double) value
* @param world World name
* @param player Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public double getPlayerInfoDouble(String world, String player, String node, double defaultValue);
/**
* Get a players informational node (Double) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public double getPlayerInfoDouble(World world, String player, String node, double defaultValue) {
return getPlayerInfoDouble(world.getName(), player, node, defaultValue);
}
/**
* Get a players informational node (Double) value
* @param player Player Object
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public double getPlayerInfoDouble(Player player, String node, double defaultValue) {
return getPlayerInfoDouble(player.getWorld().getName(), player.getName(), node, defaultValue);
}
/**
* Set a players informational node (Double) value
* @param world World name
* @param player Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setPlayerInfoDouble(String world, String player, String node, double value);
/**
* Set a players informational node (Double) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoDouble(World world, String player, String node, double value) {
setPlayerInfoDouble(world.getName(), player, node, value);
}
/**
* Set a players informational node (Double) value
* @param player Player Object
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoDouble(Player player, String node, double value) {
setPlayerInfoDouble(player.getWorld().getName(), player.getName(), node, value);
}
/**
* Get a groups informational node (Double) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public double getGroupInfoDouble(String world, String group, String node, double defaultValue);
/**
* Get a groups informational node (Double) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public double getGroupInfoDouble(World world, String group, String node, double defaultValue) {
return getGroupInfoDouble(world.getName(), group, node, defaultValue);
}
/**
* Set a groups informational node (Double) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setGroupInfoDouble(String world, String group, String node, double value);
/**
* Set a groups informational node (Double) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoDouble(World world, String group, String node, double value) {
setGroupInfoDouble(world.getName(), group, node, value);
}
/**
* Get a players informational node (Boolean) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue);
/**
* Get a players informational node (Boolean) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public boolean getPlayerInfoBoolean(World world, String player, String node, boolean defaultValue) {
return getPlayerInfoBoolean(world.getName(), player, node, defaultValue);
}
/**
* Get a players informational node (Boolean) value
* @param player Player Object
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public boolean getPlayerInfoBoolean(Player player, String node, boolean defaultValue) {
return getPlayerInfoBoolean(player.getWorld().getName(), player.getName(), node, defaultValue);
}
/**
* Set a players informational node (Boolean) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
abstract public void setPlayerInfoBoolean(String world, String player, String node, boolean value);
/**
* Set a players informational node (Boolean) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoBoolean(World world, String player, String node, boolean value) {
setPlayerInfoBoolean(world.getName(), player, node, value);
}
/**
* Set a players informational node (Boolean) value
* @param player Player Object
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoBoolean(Player player, String node, boolean value) {
setPlayerInfoBoolean(player.getWorld().getName(), player.getName(), node, value);
}
/**
* Get a groups informational node (Boolean) value
* @param world Name of World
* @param group Name of Group
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue);
/**
* Set a players informational node (Boolean) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public boolean getGroupInfoBoolean(World world, String group, String node, boolean defaultValue) {
return getGroupInfoBoolean(world.getName(), group, node, defaultValue);
}
/**
* Set a groups informational node (Boolean) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setGroupInfoBoolean(String world, String group, String node, boolean value);
/**
* Set a players informational node (Boolean) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoBoolean(World world, String group, String node, boolean value) {
setGroupInfoBoolean(world.getName(), group, node, value);
}
/**
* Get a players informational node (String) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public String getPlayerInfoString(String world, String player, String node, String defaultValue);
/**
* Get a players informational node (String) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public String getPlayerInfoString(World world, String player, String node, String defaultValue) {
return getPlayerInfoString(world.getName(), player, node, defaultValue);
}
/**
* Get a players informational node (String) value
* @param player Player Object
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public String getPlayerInfoString(Player player, String node, String defaultValue) {
return getPlayerInfoString(player.getWorld().getName(), player.getName(), node, defaultValue);
}
/**
* Set a players informational node (String) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
abstract public void setPlayerInfoString(String world, String player, String node, String value);
/**
* Set a players informational node (String) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoString(World world, String player, String node, String value) {
setPlayerInfoString(world.getName(), player, node, value);
}
/**
* Set a players informational node (String) value
* @param player Player Object
* @param node Permission node
* @param value Value ot set
*/
public void setPlayerInfoString(Player player, String node, String value) {
setPlayerInfoString(player.getWorld().getName(), player.getName(), node, value);
}
/**
* Get a groups informational node (String) value
* @param world Name of World
* @param group Name of Group
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public String getGroupInfoString(String world, String group, String node, String defaultValue);
/**
* Set a players informational node (String) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public String getGroupInfoString(World world, String group, String node, String defaultValue) {
return getGroupInfoString(world.getName(), group, node, defaultValue);
}
/**
* Set a groups informational node (String) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setGroupInfoString(String world, String group, String node, String value);
/**
* Set a groups informational node (String) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoString(World world, String group, String node, String value) {
setGroupInfoString(world.getName(), group, node, value);
}
/**
* Gets the list of groups that this player has
* @param world World name
@ -839,186 +419,6 @@ public abstract class Permission {
public String getPrimaryGroup(Player player) {
return getPrimaryGroup(player.getWorld().getName(), player.getName());
}
/**
* Get players prefix
* @param world World name
* @param player Player name
* @return Prefix
*/
abstract public String getPlayerPrefix(String world, String player);
/**
* Get players prefix
* @param world World Object
* @param player Player name
* @return Prefix
*/
public String getPlayerPrefix(World world, String player) {
return getPlayerPrefix(world.getName(), player);
}
/**
* Get players prefix
* @param player Player Object
* @return Prefix
*/
public String getPlayerPrefix(Player player) {
return getPlayerPrefix(player.getWorld().getName(), player.getName());
}
/**
* Set players prefix
* @param world World name
* @param player Player name
* @param prefix Prefix
*/
abstract public void setPlayerPrefix(String world, String player, String prefix);
/**
* Set players prefix
* @param world World Object
* @param player Player name
* @param prefix Prefix
*/
public void setPlayerPrefix(World world, String player, String prefix) {
setPlayerPrefix(world.getName(), player, prefix);
}
/**
* Set players prefix
* @param player Player Object
* @param prefix Prefix
*/
public void setPlayerPrefix(Player player, String prefix) {
setPlayerPrefix(player.getWorld().getName(), player.getName(), prefix);
}
/**
* Get players suffix
* @param world World name
* @param player Player name
* @return Suffix
*/
abstract public String getPlayerSuffix(String world, String player);
/**
* Get players suffix
* @param world World Object
* @param player Player name
* @return Suffix
*/
public String getPlayerSuffix(World world, String player) {
return getPlayerSuffix(world.getName(), player);
}
/**
* Get players suffix
* @param player Player Object
* @return Suffix
*/
public String getPlayerSuffix(Player player) {
return getPlayerSuffix(player.getWorld().getName(), player.getName());
}
/**
* Set players suffix
* @param world World name
* @param player Player name
* @param suffix Suffix
*/
abstract public void setPlayerSuffix(String world, String player, String suffix);
/**
* Set players suffix
* @param world World Object
* @param player Player name
* @param suffix Suffix
*/
public void setPlayerSuffix(World world, String player, String suffix) {
setPlayerSuffix(world.getName(), player, suffix);
}
/**
* Set players suffix
* @param player Player Object
* @param suffix Suffix
*/
public void setPlayerSuffix(Player player, String suffix) {
setPlayerSuffix(player.getWorld().getName(), player.getName(), suffix);
}
/**
* Get group prefix
* @param world World name
* @param group Group name
* @return Prefix
*/
abstract public String getGroupPrefix(String world, String group);
/**
* Get group prefix
* @param world World Object
* @param group Group name
* @return Prefix
*/
public String getGroupPrefix(World world, String group) {
return getGroupPrefix(world.getName(), group);
}
/**
* Set group prefix
* @param world World name
* @param group Group name
* @param prefix Prefix
*/
abstract public void setGroupPrefix(String world, String group, String prefix);
/**
* Set group prefix
* @param world World Object
* @param group Group name
* @param prefix Prefix
*/
public void setGroupPrefix(World world, String group, String prefix) {
setGroupPrefix(world.getName(), group, prefix);
}
/**
* Get group suffix
* @param world World name
* @param group Group name
* @return Suffix
*/
abstract public String getGroupSuffix(String world, String group);
/**
* Get group suffix
* @param world World Object
* @param group Group name
* @return Suffix
*/
public String getGroupSuffix(World world, String group) {
return getGroupSuffix(world.getName(), group);
}
/**
* Set group suffix
* @param world World name
* @param group Group name
* @param suffix Suffix
*/
abstract public void setGroupSuffix(String world, String group, String suffix);
/**
* Set group suffix
* @param world World Object
* @param group Group name
* @param suffix Suffix
*/
public void setGroupSuffix(World world, String group, String suffix) {
setGroupSuffix(world.getName(), group, suffix);
}
/**
* Returns a list of all known groups

View File

@ -158,86 +158,6 @@ public class Permission_GroupManager extends Permission {
return false;
}
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
return perms.getPermissionInteger(playerName, node);
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
return perms.getGroupPermissionInteger(groupName, node);
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
return perms.getPermissionDouble(playerName, node);
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
return perms.getGroupPermissionDouble(groupName, node);
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
return perms.getPermissionBoolean(playerName, node);
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
return perms.getGroupPermissionBoolean(groupName, node);
}
@Override
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
return perms.getPermissionString(playerName, node);
}
@Override
public void setPlayerInfoString(String world, String playerName, String node, String value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
return perms.getGroupPermissionString(groupName, node);
}
@Override
public void setGroupInfoString(String world, String groupName, String node, String value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String[] getPlayerGroups(String world, String playerName) {
return perms.getGroups(playerName);
@ -248,46 +168,6 @@ public class Permission_GroupManager extends Permission {
return perms.getGroup(playerName);
}
@Override
public String getPlayerPrefix(String world, String playerName) {
return perms.getGroupPrefix(getPrimaryGroup(world, playerName));
}
@Override
public String getPlayerSuffix(String world, String playerName) {
return perms.getGroupSuffix(getPrimaryGroup(world, playerName));
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getGroupPrefix(String world, String group) {
return perms.getGroupPrefix(group);
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getGroupSuffix(String world, String group) {
return perms.getGroupSuffix(group);
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean playerAddTransient(String world, String player, String permission) {
if (world != null) {

View File

@ -1,347 +0,0 @@
package net.milkbowl.vault.permission.plugins;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.nijiko.permissions.Group;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import net.milkbowl.vault.permission.Permission;
@SuppressWarnings("deprecation")
public class Permission_Permissions2 extends Permission {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "Permissions 2 (Phoenix)";
private PermissionHandler perms;
private Plugin plugin = null;
private PluginManager pluginManager = null;
private Permissions permission = null;
private PermissionServerListener permissionServerListener = null;
public Permission_Permissions2(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (permission == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
if (perms != null) {
if (perms.isEnabled() && perms.getDescription().getVersion().startsWith("2")) {
permission = (Permissions) perms;
this.perms = permission.getHandler();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
}
private class PermissionServerListener extends ServerListener {
Permission_Permissions2 permission = null;
public PermissionServerListener(Permission_Permissions2 permission) {
this.permission = permission;
}
public void onPluginEnable(PluginEnableEvent event) {
if (permission.permission == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
if (perms != null) {
if (perms.isEnabled()) {
permission.permission = (Permissions) perms;
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
}
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (permission.permission != null) {
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
permission.permission = null;
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
}
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
if (permission == null) {
return false;
} else {
return permission.isEnabled();
}
}
@Override
public boolean playerHas(String worldName, String playerName, String permission) {
Player p = plugin.getServer().getPlayer(playerName);
if (p != null) {
if (p.hasPermission(permission))
return true;
}
return this.perms.has(worldName, playerName, permission);
}
@Override
public boolean playerAdd(String worldName, String playerName, String permission) {
this.perms.addUserPermission(worldName, playerName, permission);
return true;
}
@Override
public boolean playerRemove(String worldName, String playerName, String permission) {
this.perms.removeUserPermission(worldName, playerName, permission);
return true;
}
@Override
public boolean groupHas(String worldName, String groupName, String permission) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean groupAdd(String worldName, String groupName, String permission) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean groupRemove(String worldName, String groupName, String permission) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean playerInGroup(String worldName, String playerName, String groupName) {
return this.perms.inGroup(worldName, playerName, groupName);
}
@Override
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
int i = this.perms.getPermissionInteger(world, playerName, node);
return (i == -1) ? defaultValue : i;
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
public void setGroupInfo(String world, String groupName, String node, Object value) {
this.perms.addGroupInfo(world, groupName, node, value);
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
int i = this.perms.getGroupPermissionInteger(world, groupName, node);
return (i == -1) ? defaultValue : i;
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
double d = this.perms.getPermissionDouble(world, playerName, node);
return (d == -1) ? defaultValue : d;
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
double d = this.perms.getGroupPermissionDouble(world, groupName, node);
return (d == -1) ? defaultValue : d;
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
// Warning does not support default value
return this.perms.getPermissionBoolean(world, playerName, node);
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
return this.perms.getGroupPermissionBoolean(world, groupName, node);
}
@Override
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
String s = this.perms.getPermissionString(world, playerName, node);
return (s == "" || s == null) ? defaultValue : s;
}
@Override
public void setPlayerInfoString(String world, String playerName, String node, String value) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
String s = this.perms.getGroupPermissionString(world, groupName, node);
return (s == "" || s == null) ? defaultValue : s;
}
@Override
public void setGroupInfoString(String world, String groupName, String node, String value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public String[] getPlayerGroups(String world, String playerName) {
return this.perms.getGroups(world, playerName);
}
@Override
public String getPrimaryGroup(String world, String playerName) {
return this.perms.getGroup(world, playerName);
}
@Override
public String getPlayerPrefix(String world, String playerName) {
return this.perms.getPermissionString(world, playerName, "prefix");
}
@Override
public String getPlayerSuffix(String world, String playerName) {
return this.perms.getPermissionString(world, playerName, "suffix");
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getGroupPrefix(String world, String group) {
return perms.getGroupPrefix(world, group);
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public String getGroupSuffix(String world, String group) {
return perms.getGroupSuffix(world, group);
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
}
@Override
public boolean playerAddTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
}
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
paInfo.getAttachment().setPermission(permission, true);
return true;
}
}
PermissionAttachment attach = p.addAttachment(plugin);
attach.setPermission(permission, true);
return true;
}
@Override
public boolean playerRemoveTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
}
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
return paInfo.getAttachment().getPermissions().remove(permission);
}
}
return false;
}
@Override
public String[] getGroups() {
Set<String> groupNames = new HashSet<String>();
for (World world : Bukkit.getServer().getWorlds()) {
for (Group group : perms.getGroups(world.getName())) {
groupNames.add(group.getName());
}
}
return groupNames.toArray(new String[0]);
}
}

View File

@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.logging.Logger;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
@ -45,12 +46,12 @@ public class Permission_Permissions3 extends Permission {
private String name = "Permissions 3 (Yeti)";
private PermissionHandler perms;
private Plugin plugin = null;
private Vault plugin = null;
private PluginManager pluginManager = null;
private Permissions permission = null;
private PermissionServerListener permissionServerListener = null;
public Permission_Permissions3(Plugin plugin) {
public Permission_Permissions3(Vault plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
@ -114,30 +115,6 @@ public class Permission_Permissions3 extends Permission {
return name;
}
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
Integer i = this.perms.getInfoInteger(world, playerName, node, false);
return (i == null) ? defaultValue : i;
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
Double d = this.perms.getInfoDouble(world, playerName, node, false);
return (d == null) ? defaultValue : d;
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
Boolean b = this.perms.getInfoBoolean(world, playerName, node, false);
return (b == null) ? defaultValue : b;
}
@Override
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
String s = this.perms.getInfoString(world, playerName, node, false);
return (s == null) ? defaultValue : s;
}
@Override
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
// Not certain if this is possible in P3
@ -164,97 +141,17 @@ public class Permission_Permissions3 extends Permission {
@Override
public boolean groupAdd(String worldName, String groupName, String permission) {
this.perms.addGroupPermission(worldName, groupName, permission);
return true;
return false;
}
@Override
public boolean groupRemove(String worldName, String groupName, String permission) {
this.perms.removeGroupPermission(worldName, groupName, permission);
return true;
}
public void setPlayerInfo(String world, String playerName, String node, Object value) {
this.perms.addUserInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
setPlayerInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
setPlayerInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
setPlayerInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoString(String world, String playerName, String node, String value) {
setPlayerInfo(world, playerName, node, value);
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
Integer i = this.perms.getInfoInteger(world, groupName, node, true);
return (i == null) ? defaultValue : i;
}
public void setGroupInfo(String world, String groupName, String node, Object value) {
this.perms.addGroupInfo(world, groupName, node, value);
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
Double d = this.perms.getInfoDouble(world, groupName, node, true);
return (d == null) ? defaultValue : d;
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
Boolean b = this.perms.getInfoBoolean(world, groupName, node, true);
return (b == null) ? defaultValue : b;
}
@Override
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
String s = this.permission.getHandler().getInfoString(world, groupName, node, true);
return (s == null) ? defaultValue : s;
}
@Override
public void setGroupInfoString(String world, String groupName, String node, String value) {
setGroupInfo(world, groupName, node, value);
return false;
}
@Override
public boolean groupHas(String worldName, String groupName, String permission) {
try {
Group group = this.perms.safeGetGroup(worldName, groupName);
return group.hasPermission(permission);
} catch (Exception e) {
// lowut?
return false;
}
return false;
}
@Override
@ -263,7 +160,7 @@ public class Permission_Permissions3 extends Permission {
}
public String getPrimaryGroup(String world, String playerName) {
return this.perms.getPrimaryGroup(world, playerName);
return getPlayerGroups(world, playerName)[0];
}
@Override
@ -276,82 +173,40 @@ public class Permission_Permissions3 extends Permission {
return this.perms.has(worldName, playerName, permission);
}
@Override
public String getPlayerPrefix(String world, String playerName) {
return this.perms.getUserPrefix(world, playerName);
}
@Override
public String getPlayerSuffix(String world, String playerName) {
return this.perms.getUserSuffix(world, playerName);
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
this.perms.addUserInfo(world, player, "suffix", suffix);
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
this.perms.addUserInfo(world, player, "prefix", prefix);
}
@Override
public String getGroupPrefix(String world, String group) {
try {
return perms.safeGetGroup(world, group).getPrefix();
} catch(Exception e) {
return null;
}
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
this.perms.addGroupInfo(world, group, "prefix", prefix);
}
@Override
public String getGroupSuffix(String world, String group) {
try {
return perms.safeGetGroup(world, group).getSuffix();
} catch(Exception e) {
return null;
}
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
this.perms.addGroupInfo(world, group, "suffix", suffix);
}
@Override
public boolean playerAddTransient(String world, String player, String permission) {
try {
/*try {
perms.safeGetUser(world, player).addTimedPermission(permission, 0);
return true;
} catch(Exception e) {
return false;
}
} */
return false;
}
@Override
public boolean playerRemoveTransient(String world, String player, String permission) {
/*
try {
perms.safeGetUser(world, player).removeTimedPermission(permission);
return true;
} catch (Exception e) {
return false;
}
*/
return false;
}
@Override
public String[] getGroups() {
Set<String> groupNames = new HashSet<String>();
Set<String> groupNames = new HashSet<String>();/*
for (World world : Bukkit.getServer().getWorlds()) {
for (Group group : perms.getGroups(world.getName())) {
groupNames.add(group.getName());
}
}
}*/
return groupNames.toArray(new String[0]);
}
}

View File

@ -26,7 +26,7 @@ import net.milkbowl.vault.permission.Permission;
public class Permission_PermissionsBukkit extends Permission {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "PermissionsBukkit";
private final String name = "PermissionsBukkit";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private PermissionsPlugin perms = null;
@ -138,9 +138,6 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean playerAddTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
@ -169,9 +166,6 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean playerRemoveTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
@ -242,88 +236,7 @@ public class Permission_PermissionsBukkit extends Permission {
}
return plugin.getServer().dispatchCommand(ccs, "permission player removegroup " + group + " " + player);
}
@Override
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public void setPlayerInfoInteger(String world, String player, String node, int value) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public void setGroupInfoInteger(String world, String group, String node,int value) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public void setPlayerInfoDouble(String world, String player, String node, double value) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public void setGroupInfoDouble(String world, String group, String node, double value) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
return this.groupHas(world, group, node);
}
@Override
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public void setPlayerInfoString(String world, String player, String node, String value) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public void setGroupInfoString(String world, String group, String node, String value) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
}
@Override
public String[] getPlayerGroups(String world, String player) {
List<String> groupList = new ArrayList<String>();
@ -351,59 +264,6 @@ public class Permission_PermissionsBukkit extends Permission {
return null;
}
@Override
public String getPlayerPrefix(String world, String player) {
if (mChat == null) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
} else if (plugin.getServer().getPlayer(player) == null){
throw new UnsupportedOperationException(getName() + " does not support offline node retrieval");
} else {
return mChat.getPrefix(plugin.getServer().getPlayer(player));
}
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
}
@Override
public String getPlayerSuffix(String world, String player) {
if (mChat == null) {
throw new UnsupportedOperationException(getName() + " does not support info nodes.");
} else if (plugin.getServer().getPlayer(player) == null){
throw new UnsupportedOperationException(getName() + " does not support offline node retrieval");
} else {
return mChat.getSuffix(plugin.getServer().getPlayer(player));
}
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
// TODO Auto-generated method stub
}
@Override
public String getGroupPrefix(String world, String group) {
throw new UnsupportedOperationException(getName() + " does not support group info nodes.");
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
// TODO Auto-generated method stub
}
@Override
public String getGroupSuffix(String world, String group) {
throw new UnsupportedOperationException(getName() + " does not support group info nodes.");
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
throw new UnsupportedOperationException(getName() + " does not support group info nodes.");
}
@Override
public String[] getGroups() {
List<String> groupNames = new ArrayList<String>();

View File

@ -21,6 +21,7 @@ package net.milkbowl.vault.permission.plugins;
import java.util.logging.Logger;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.entity.Player;
@ -39,13 +40,13 @@ import ru.tehkode.permissions.bukkit.PermissionsEx;
public class Permission_PermissionsEx extends Permission {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "PermissionsEx";
private Plugin plugin = null;
private final String name = "PermissionsEx";
private Vault plugin = null;
private PluginManager pluginManager = null;
private PermissionsEx permission = null;
private PermissionServerListener permissionServerListener = null;
public Permission_PermissionsEx(Plugin plugin) {
public Permission_PermissionsEx(Vault plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
@ -139,26 +140,6 @@ public class Permission_PermissionsEx extends Permission {
return name;
}
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionInteger(node, world, defaultValue);
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionDouble(node, world, defaultValue);
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionBoolean(node, world, defaultValue);
}
@Override
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOption(node, world, defaultValue);
}
@Override
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
@ -227,118 +208,6 @@ public class Permission_PermissionsEx extends Permission {
}
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
user.setOption(node, String.valueOf(value), world);
}
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
user.setOption(node, String.valueOf(value), world);
}
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
user.setOption(node, String.valueOf(value), world);
}
}
@Override
public void setPlayerInfoString(String world, String playerName, String node, String value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
user.setOption(node, String.valueOf(value), world);
}
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return defaultValue;
} else {
return group.getOptionInteger(node, world, defaultValue);
}
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return;
} else {
group.setOption(node, world, String.valueOf(value));
}
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return defaultValue;
} else {
return group.getOptionDouble(node, world, defaultValue);
}
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return;
} else {
group.setOption(node, world, String.valueOf(value));
}
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return defaultValue;
} else {
return group.getOptionBoolean(node, world, defaultValue);
}
}
@Override
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return;
} else {
group.setOption(node, world, String.valueOf(value));
}
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return defaultValue;
} else {
return group.getOption(node, world, defaultValue);
}
}
@Override
public void setGroupInfoString(String world, String groupName, String node, String value) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if (group == null) {
return;
} else {
group.setOption(node, world, value);
}
}
@Override
public boolean groupHas(String worldName, String groupName, String permission) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
@ -372,79 +241,6 @@ public class Permission_PermissionsEx extends Permission {
}
}
@Override
public String getPlayerPrefix(String world, String playerName) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
return user.getPrefix();
} else {
return null;
}
}
@Override
public String getPlayerSuffix(String world, String playerName) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if (user != null) {
return user.getSuffix();
} else {
return null;
}
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(player);
if (user != null) {
user.setSuffix(suffix, world);
}
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(player);
if (user != null) {
user.setPrefix(prefix, world);
}
}
@Override
public String getGroupPrefix(String world, String group) {
PermissionGroup pGroup = PermissionsEx.getPermissionManager().getGroup(group);
if (group != null) {
return pGroup.getPrefix();
} else {
return null;
}
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
PermissionGroup pGroup = PermissionsEx.getPermissionManager().getGroup(group);
if (group != null) {
pGroup.setPrefix(prefix, world);
}
}
@Override
public String getGroupSuffix(String world, String group) {
PermissionGroup pGroup = PermissionsEx.getPermissionManager().getGroup(group);
if (group != null) {
return pGroup.getSuffix();
} else {
return null;
}
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
PermissionGroup pGroup = PermissionsEx.getPermissionManager().getGroup(group);
if (group != null) {
pGroup.setSuffix(suffix, world);
}
}
@Override
public boolean playerAddTransient(String world, String player, String permission) {
PermissionUser pPlayer = PermissionsEx.getPermissionManager().getUser(player);
@ -478,4 +274,4 @@ public class Permission_PermissionsEx extends Permission {
}
return groupNames;
}
}
}

View File

@ -39,13 +39,9 @@ public class Permission_SuperPerms extends Permission {
@Override
public boolean playerAddTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
}
if (p == null)
return false;
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
@ -67,13 +63,10 @@ public class Permission_SuperPerms extends Permission {
@Override
public boolean playerRemoveTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
}
if (p == null)
return false;
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
return paInfo.getAttachment().getPermissions().remove(permission);
@ -112,87 +105,6 @@ public class Permission_SuperPerms extends Permission {
throw new UnsupportedOperationException(getName() + " no group permissions.");
}
@Override
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setPlayerInfoInteger(String world, String player, String node, int value) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setGroupInfoInteger(String world, String group, String node, int value) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setPlayerInfoDouble(String world, String player, String node, double value) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setGroupInfoDouble(String world, String group, String node,double value) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setPlayerInfoString(String world, String player, String node, String value) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setGroupInfoString(String world, String group, String node, String value) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public String[] getPlayerGroups(String world, String player) {
throw new UnsupportedOperationException(getName() + " no group permissions.");
@ -203,48 +115,8 @@ public class Permission_SuperPerms extends Permission {
throw new UnsupportedOperationException(getName() + " no group permissions.");
}
@Override
public String getPlayerPrefix(String world, String player) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public String getPlayerSuffix(String world, String player) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public String getGroupPrefix(String world, String group) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public String getGroupSuffix(String world, String group) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
throw new UnsupportedOperationException(getName() + " no data permissions.");
}
@Override
public String[] getGroups() {
throw new UnsupportedOperationException(getName() + " does not support group listing!");
return new String[0];
}
}

View File

@ -0,0 +1,260 @@
package net.milkbowl.vault.permission.plugins;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import de.bananaco.permissions.Permissions;
import de.bananaco.permissions.interfaces.PermissionSet;
import de.bananaco.permissions.worlds.WorldPermissionsManager;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.permission.Permission;
public class Permission_bPermissions extends Permission {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "bPermissions";
private Vault plugin = null;
private PluginManager pluginManager = null;
private WorldPermissionsManager perms;
private PermissionServerListener permissionServerListener = null;
public Permission_bPermissions(Vault plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener();
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (perms == null) {
Plugin p = plugin.getServer().getPluginManager().getPlugin("bPermissions");
if (p != null) {
perms = Permissions.getWorldPermissionsManager();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
private class PermissionServerListener extends ServerListener {
public void onPluginEnable(PluginEnableEvent event) {
if (perms == null) {
Plugin p = event.getPlugin();
if(p.getDescription().getName().equals("bPermissions")) {
if (p.isEnabled()) {
perms = Permissions.getWorldPermissionsManager();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (perms != null) {
if (event.getPlugin().getDescription().getName().equals("bPermissions")) {
perms = null;
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
}
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
return this.perms != null;
}
@Override
public boolean playerHas(String world, String player, String permission) {
Player p = plugin.getServer().getPlayer(player);
if (p == null)
throw new UnsupportedOperationException("Offline Permissions are not supported!");
return p.hasPermission(permission);
}
@Override
public boolean playerAdd(String world, String player, String permission) {
throw new UnsupportedOperationException("Player specific permissions are not supported!");
}
@Override
public boolean playerAddTransient(String world, String player, String permission) {
Player p = plugin.getServer().getPlayer(player);
if (p == null)
return false;
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
paInfo.getAttachment().setPermission(permission, true);
return true;
}
}
PermissionAttachment attach = p.addAttachment(plugin);
attach.setPermission(permission, true);
return true;
}
@Override
public boolean playerRemove(String world, String player, String permission) {
throw new UnsupportedOperationException("Player specific permissions are not supported!");
}
@Override
public boolean playerRemoveTransient(String world, String player, String permission) {
Player p = plugin.getServer().getPlayer(player);
if (p == null)
return false;
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
return paInfo.getAttachment().getPermissions().remove(permission);
}
}
return false;
}
@Override
public boolean groupHas(String world, String group, String permission) {
if (world == null)
return false;
PermissionSet set = perms.getPermissionSet(world);
if (set == null)
return false;
if (set.getGroupNodes(group) == null)
return false;
return set.getGroupNodes(group).contains(permission);
}
@Override
public boolean groupAdd(String world, String group, String permission) {
if (world == null)
return false;
PermissionSet set = perms.getPermissionSet(world);
if (set == null)
return false;
if (set.getGroupNodes(group) == null)
return false;
set.addNode(permission, group);
return true;
}
@Override
public boolean groupRemove(String world, String group, String permission) {
if (world == null)
return false;
PermissionSet set = perms.getPermissionSet(world);
if (set == null)
return false;
if (set.getGroupNodes(group) == null)
return false;
set.removeNode(permission, group);
return true;
}
@Override
public boolean playerInGroup(String world, String player, String group) {
if (world == null)
return false;
PermissionSet set = perms.getPermissionSet(world);
if (set == null)
return false;
if (set.getGroups(player) == null)
return false;
return set.getGroups(player).contains(group);
}
@Override
public boolean playerAddGroup(String world, String player, String group) {
if (world == null)
return false;
PermissionSet set = perms.getPermissionSet(world);
if (set == null)
return false;
if (set.getGroupNodes(group) == null)
return false;
set.addGroup(player, group);
return true;
}
@Override
public boolean playerRemoveGroup(String world, String player, String group) {
if (world == null)
return false;
PermissionSet set = perms.getPermissionSet(world);
if (set == null)
return false;
set.removeGroup(player, group);
return true;
}
@Override
public String[] getPlayerGroups(String world, String player) {
if (world == null)
return null;
PermissionSet set = perms.getPermissionSet(world);
if (set == null)
return null;
List<String> groups = set.getGroups(player);
return groups == null ? null : groups.toArray(new String[0]);
}
@Override
public String getPrimaryGroup(String world, String player) {
if (world == null)
return null;
PermissionSet set = perms.getPermissionSet(world);
if (set == null)
return null;
List<String> groups = set.getGroups(player);
if (groups == null || groups.isEmpty())
return null;
else
return groups.get(0);
}
@Override
public String[] getGroups() {
throw new UnsupportedOperationException("bPermissions does not support server-wide groups");
}
}