mirror of https://github.com/MilkBowl/Vault.git
P3 support seems messed up - hacked it together - please update
This commit is contained in:
parent
391fe80bdb
commit
fd7d804924
Binary file not shown.
|
@ -39,7 +39,6 @@ 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;
|
||||
|
@ -86,7 +85,7 @@ public class Vault extends JavaPlugin {
|
|||
// Try to load PermissionsEx
|
||||
if (packageExists(new String[] { "ru.tehkode.permissions.bukkit.PermissionsEx" })) {
|
||||
Chat eChat = new Chat_PermissionsEx(this);
|
||||
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, eChat, this, ServicePriority.Highest);
|
||||
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()));
|
||||
|
@ -95,7 +94,7 @@ public class Vault extends JavaPlugin {
|
|||
//Try loading mChat
|
||||
if (packageExists(new String[] {"net.D3GN.MiracleM4n.mChat"} )) {
|
||||
Chat mChat = new Chat_mChat(this);
|
||||
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, mChat, this, ServicePriority.Highest);
|
||||
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()));
|
||||
|
@ -104,7 +103,7 @@ public class Vault extends JavaPlugin {
|
|||
//try loading bPermissions
|
||||
if (packageExists(new String[] {"de.bananaco.permissions.worlds.WorldPermissionsManager"})) {
|
||||
Chat bPerms = new Chat_bPermissions(this);
|
||||
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, bPerms, this, ServicePriority.High);
|
||||
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()));
|
||||
|
@ -113,7 +112,7 @@ public class Vault extends JavaPlugin {
|
|||
// Try to load GroupManager
|
||||
if (packageExists(new String[] { "org.anjocaido.groupmanager.GroupManager" })) {
|
||||
Chat gPerms = new Chat_GroupManager(this);
|
||||
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, gPerms, this, ServicePriority.High);
|
||||
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()));
|
||||
|
@ -122,20 +121,11 @@ public class Vault extends JavaPlugin {
|
|||
// Try to load Permissions 3 (Yeti)
|
||||
if (packageExists(new String[] { "com.nijiko.permissions.ModularControl" })) {
|
||||
Chat nPerms = new Chat_Permissions3(this);
|
||||
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, nPerms, this, ServicePriority.High);
|
||||
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()));
|
||||
}
|
||||
|
||||
// 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][Chat] Permissions 2 (Phoenix) found: %s", getDescription().getName(), oPerms.isEnabled() ? "Loaded" : "Waiting"));
|
||||
} else {
|
||||
log.info(String.format("[%s][Chat] Permissions 2 (Phoenix) not found.", getDescription().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,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()));
|
||||
|
@ -154,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()));
|
||||
|
@ -163,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()));
|
||||
|
@ -206,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()));
|
||||
|
@ -220,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()));
|
||||
|
@ -229,14 +219,14 @@ 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(net.milkbowl.vault.permission.Permission.class, bPerms, this, ServicePriority.Highest);
|
||||
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()));
|
||||
|
@ -244,7 +234,7 @@ public class Vault extends JavaPlugin {
|
|||
// 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()));
|
||||
|
@ -253,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()));
|
||||
|
||||
}
|
||||
|
@ -293,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) {
|
||||
|
@ -305,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) {
|
||||
|
@ -316,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()));
|
||||
|
|
|
@ -1,228 +0,0 @@
|
|||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
|
||||
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.Control;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
public class Chat_Permissions2 extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private String name = "Permissions 2 (Phoenix) - Chat";
|
||||
private Control perms;
|
||||
private Plugin plugin = null;
|
||||
private PluginManager pluginManager = null;
|
||||
private Permissions chat = null;
|
||||
private PermissionServerListener permissionServerListener = null;
|
||||
|
||||
public Chat_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 (chat == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
|
||||
if (perms != null) {
|
||||
if (perms.isEnabled() && perms.getDescription().getVersion().startsWith("2")) {
|
||||
chat = (Permissions) perms;
|
||||
this.perms = (Control) chat.getHandler();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionServerListener extends ServerListener {
|
||||
Chat_Permissions2 permission = null;
|
||||
|
||||
public PermissionServerListener(Chat_Permissions2 permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.chat == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
|
||||
|
||||
if (perms != null) {
|
||||
if (perms.isEnabled()) {
|
||||
permission.chat = (Permissions) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission.chat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
|
||||
permission.chat = 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 (chat == null) {
|
||||
return false;
|
||||
} else {
|
||||
return chat.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
setPlayerInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
private void setPlayerInfo(String world, String playerName, String node, Object value) {
|
||||
this.perms.addUserInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
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) {
|
||||
setPlayerInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
@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) {
|
||||
setPlayerInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
@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) {
|
||||
setPlayerInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
@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 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) {
|
||||
setPlayerInfo(world, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
setPlayerInfo(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return perms.getGroupPrefix(world, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
setGroupInfo(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return perms.getGroupSuffix(world, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
setGroupInfo(world, group, "suffix", suffix);
|
||||
}
|
||||
}
|
|
@ -84,50 +84,49 @@ public class Chat_Permissions3 extends Chat {
|
|||
}
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
|
||||
Integer i = this.perms.getInfoInteger(world, playerName, node, false);
|
||||
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.getInfoDouble(world, playerName, node, false);
|
||||
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.getInfoBoolean(world, playerName, node, false);
|
||||
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.getInfoString(world, playerName, node, false);
|
||||
String s = this.perms.getPermissionString(world, playerName, node);
|
||||
return (s == null) ? defaultValue : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String playerName) {
|
||||
return this.perms.getUserPrefix(world, playerName);
|
||||
return getPlayerInfoString(world, playerName, "prefix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String playerName) {
|
||||
return this.perms.getUserSuffix(world, playerName);
|
||||
return getPlayerInfoString(world, playerName, "suffix", null);
|
||||
}
|
||||
|
||||
@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);
|
||||
//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);
|
||||
//this.perms.addUserInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,8 +151,9 @@ public class Chat_Permissions3 extends Chat {
|
|||
|
||||
@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;
|
||||
//Integer i = this.perms.getInfoInteger(world, groupName, node, true);
|
||||
//return (i == null) ? defaultValue : i;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,8 +168,9 @@ public class Chat_Permissions3 extends Chat {
|
|||
|
||||
@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;
|
||||
//Double d = this.perms.getInfoDouble(world, groupName, node, true);
|
||||
//return (d == null) ? defaultValue : d;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -179,8 +180,9 @@ public class Chat_Permissions3 extends Chat {
|
|||
|
||||
@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;
|
||||
//Boolean b = this.perms.getInfoBoolean(world, groupName, node, true);
|
||||
//return (b == null) ? defaultValue : b;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -190,8 +192,9 @@ public class Chat_Permissions3 extends Chat {
|
|||
|
||||
@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;
|
||||
//String s = this.perms.getInfoString(world, groupName, node, true);
|
||||
//return (s == null) ? defaultValue : s;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -201,11 +204,11 @@ public class Chat_Permissions3 extends Chat {
|
|||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
try {
|
||||
return perms.safeGetGroup(world, group).getPrefix();
|
||||
} catch(Exception e) {
|
||||
//try {
|
||||
// return perms.safeGetGroup(world, group).getPrefix();
|
||||
//} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -215,11 +218,12 @@ public class Chat_Permissions3 extends Chat {
|
|||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
/*
|
||||
try {
|
||||
return perms.safeGetGroup(world, group).getSuffix();
|
||||
} catch(Exception e) {
|
||||
} catch(Exception e) { */
|
||||
return null;
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,210 +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.Control;
|
||||
import com.nijiko.permissions.Group;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class Permission_Permissions2 extends Permission {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private String name = "Permissions 2 (Phoenix)";
|
||||
private Control 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 = (Control) 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 get group Permissions.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
||||
this.perms.addGroupPermission(worldName, groupName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
||||
this.perms.removeGroupPermission(worldName, groupName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@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 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 boolean playerAddTransient(String world, String player, String permission) {
|
||||
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) {
|
||||
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]);
|
||||
}
|
||||
}
|
|
@ -141,25 +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;
|
||||
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
|
||||
|
@ -168,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
|
||||
|
@ -184,32 +176,37 @@ public class Permission_Permissions3 extends Permission {
|
|||
|
||||
@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]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue