mirror of https://github.com/MilkBowl/Vault.git
cleanup bad formatting, and incorrect event handling.
This commit is contained in:
parent
90d5562d82
commit
376e9db6fc
|
@ -44,7 +44,7 @@ public class Chat_Privileges extends Chat {
|
|||
Plugin privsPlugin = plugin.getServer().getPluginManager().getPlugin(PLUGIN_NAME);
|
||||
if (privsPlugin != null && privsPlugin.isEnabled()) {
|
||||
this.privs = (Privileges) privsPlugin;
|
||||
plugin.getLogger().info(String.format("[Chat] %s hooked.", FRIENDLY_NAME));
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), FRIENDLY_NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,12 @@
|
|||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -24,188 +27,188 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import ru.simsonic.rscPermissions.MainPluginClass;
|
||||
|
||||
public class Chat_rscPermissions extends Chat
|
||||
{
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final Plugin vault;
|
||||
private ru.simsonic.rscPermissions.MainPluginClass rscp;
|
||||
private ru.simsonic.rscPermissions.rscpAPI API;
|
||||
public Chat_rscPermissions(Plugin plugin, Permission perm)
|
||||
{
|
||||
super(perm);
|
||||
this.vault = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ChatServerListener(this), vault);
|
||||
rscp = (ru.simsonic.rscPermissions.MainPluginClass)vault.getServer().getPluginManager().getPlugin("rscPermissions");
|
||||
}
|
||||
private class ChatServerListener implements Listener
|
||||
{
|
||||
private final Chat_rscPermissions bridge;
|
||||
public ChatServerListener(Chat_rscPermissions bridge)
|
||||
{
|
||||
this.bridge = bridge;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
private void onPluginEnable(PluginEnableEvent event)
|
||||
{
|
||||
if(bridge.rscp == null)
|
||||
{
|
||||
Plugin plugin = event.getPlugin();
|
||||
if(!"rscPermissions".equals(plugin.getName()))
|
||||
return;
|
||||
bridge.rscp = (MainPluginClass)plugin;
|
||||
}
|
||||
if(bridge.API == null)
|
||||
bridge.API = bridge.rscp.API;
|
||||
if(bridge.API.isEnabled())
|
||||
log.info(String.format("[%s][Chat] %s hooked.",
|
||||
vault.getDescription().getName(), bridge.API.getName()));
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event)
|
||||
{
|
||||
if(bridge.API != null)
|
||||
if(event.getPlugin().getDescription().getName().equals(bridge.API.getName()))
|
||||
{
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.",
|
||||
vault.getDescription().getName(), bridge.API.getName()));
|
||||
bridge.API = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return (API != null) ? API.getName() : "rscPermissions";
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return (API != null) ? API.isEnabled() : false;
|
||||
}
|
||||
@Override
|
||||
public String getPlayerPrefix(String string, String string1)
|
||||
{
|
||||
if(API != null)
|
||||
return API.getPlayerPrefix(string, string1);
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public String getPlayerSuffix(String string, String string1)
|
||||
{
|
||||
if(API != null)
|
||||
return API.getPlayerSuffix(string, string1);
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public String getGroupPrefix(String string, String string1)
|
||||
{
|
||||
if(API != null)
|
||||
return API.getGroupPrefix(string, string1);
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public String getGroupSuffix(String string, String string1)
|
||||
{
|
||||
if(API != null)
|
||||
return API.getGroupSuffix(string, string1);
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public void setPlayerPrefix(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
API.setPlayerPrefix(string, string1, string2);
|
||||
}
|
||||
@Override
|
||||
public void setPlayerSuffix(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
API.setPlayerSuffix(string, string1, string2);
|
||||
}
|
||||
@Override
|
||||
public void setGroupPrefix(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
API.setGroupPrefix(string, string1, string2);
|
||||
}
|
||||
@Override
|
||||
public void setGroupSuffix(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
API.setGroupSuffix(string, string1, string2);
|
||||
}
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String string, String string1, String string2, int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String string, String string1, String string2, int i)
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public int getGroupInfoInteger(String string, String string1, String string2, int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void setGroupInfoInteger(String string, String string1, String string2, int i)
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String string, String string1, String string2, double d)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String string, String string1, String string2, double d)
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public double getGroupInfoDouble(String string, String string1, String string2, double d)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public void setGroupInfoDouble(String string, String string1, String string2, double d)
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String string, String string1, String string2, boolean bln)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String string, String string1, String string2, boolean bln)
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String string, String string1, String string2, boolean bln)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String string, String string1, String string2, boolean bln)
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public String getPlayerInfoString(String string, String string1, String string2, String string3)
|
||||
{
|
||||
return "...";
|
||||
}
|
||||
@Override
|
||||
public void setPlayerInfoString(String string, String string1, String string2, String string3)
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public String getGroupInfoString(String string, String string1, String string2, String string3)
|
||||
{
|
||||
return "...";
|
||||
}
|
||||
@Override
|
||||
public void setGroupInfoString(String string, String string1, String string2, String string3)
|
||||
{
|
||||
}
|
||||
public class Chat_rscPermissions extends Chat {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final Plugin vault;
|
||||
private ru.simsonic.rscPermissions.MainPluginClass rscp;
|
||||
private ru.simsonic.rscPermissions.rscpAPI rscpAPI;
|
||||
|
||||
public Chat_rscPermissions(Plugin plugin, Permission perm) {
|
||||
super(perm);
|
||||
this.vault = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ChatServerListener(this), vault);
|
||||
if (rscp == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("rscPermissions");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
this.rscp = (MainPluginClass) perms;
|
||||
rscpAPI = rscp.API;
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ChatServerListener implements Listener {
|
||||
|
||||
private final Chat_rscPermissions bridge;
|
||||
public ChatServerListener(Chat_rscPermissions bridge) {
|
||||
this.bridge = bridge;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
private void onPluginEnable(PluginEnableEvent event) {
|
||||
if(bridge.rscp == null) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
if (plugin.getDescription().getName().equals("rscPermissions")) {
|
||||
bridge.rscp = (MainPluginClass) plugin;
|
||||
bridge.rscpAPI = bridge.rscp.API;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", vault.getDescription().getName(), bridge.rscpAPI.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(bridge.rscpAPI != null) {
|
||||
if(event.getPlugin().getDescription().getName().equals(bridge.rscpAPI.getName())) {
|
||||
bridge.rscpAPI = null;
|
||||
bridge.rscp = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", vault.getDescription().getName(), bridge.rscpAPI.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return rscpAPI.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return rscpAPI.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return rscpAPI.getPlayerPrefix(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return rscpAPI.getPlayerSuffix(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return rscpAPI.getGroupPrefix(world, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return rscpAPI.getGroupSuffix(world, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
rscpAPI.setPlayerPrefix(world, player, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
rscpAPI.setPlayerSuffix(world, player, suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
rscpAPI.setGroupPrefix(world, group, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
rscpAPI.setGroupSuffix(world, group, suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,20 +26,17 @@ public class Economy_Minefaconomy implements Economy {
|
|||
|
||||
public Economy_Minefaconomy(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.registerEvents(new EconomyServerListener(this), plugin);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
Plugin econ = null;
|
||||
// Load Plugin in case it was loaded before
|
||||
if (economy == null) {
|
||||
econ = plugin.getServer().getPluginManager()
|
||||
.getPlugin("Minefaconomy");
|
||||
econ = plugin.getServer().getPluginManager().getPlugin("Minefaconomy");
|
||||
log.info("Loading Minefaconomy");
|
||||
}
|
||||
if (econ != null && econ.isEnabled()) {
|
||||
economy = (Minefaconomy) econ;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin
|
||||
.getDescription().getName(), this.name));
|
||||
return;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), this.name));
|
||||
return;
|
||||
}
|
||||
log.info("Error Loading Minefaconomy");
|
||||
}
|
||||
|
@ -86,134 +83,134 @@ public class Economy_Minefaconomy implements Economy {
|
|||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return economy.vaultLayer.fractionalDigits();
|
||||
return Minefaconomy.vaultLayer.fractionalDigits();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return economy.vaultLayer.format(amount);
|
||||
return Minefaconomy.vaultLayer.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return economy.vaultLayer.currencyNamePlural();
|
||||
return Minefaconomy.vaultLayer.currencyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return economy.vaultLayer.currencyNameSingular();
|
||||
return Minefaconomy.vaultLayer.currencyNameSingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return economy.vaultLayer.hasAccount(playerName);
|
||||
return Minefaconomy.vaultLayer.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return economy.vaultLayer.hasAccount(playerName);
|
||||
return Minefaconomy.vaultLayer.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return economy.vaultLayer.getBalance(playerName);
|
||||
return Minefaconomy.vaultLayer.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return economy.vaultLayer.getBalance(playerName);
|
||||
return Minefaconomy.vaultLayer.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return economy.vaultLayer.has(playerName, amount);
|
||||
return Minefaconomy.vaultLayer.has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return economy.vaultLayer.has(playerName, amount);
|
||||
return Minefaconomy.vaultLayer.has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
return economy.vaultLayer.withdrawPlayer(playerName, amount);
|
||||
return Minefaconomy.vaultLayer.withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName,
|
||||
double amount) {
|
||||
return economy.vaultLayer.withdrawPlayer(playerName, amount);
|
||||
return Minefaconomy.vaultLayer.withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
return economy.vaultLayer.depositPlayer(playerName, amount);
|
||||
return Minefaconomy.vaultLayer.depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName,
|
||||
double amount) {
|
||||
return economy.vaultLayer.depositPlayer(playerName, amount);
|
||||
return Minefaconomy.vaultLayer.depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return economy.vaultLayer.createPlayerAccount(playerName);
|
||||
return Minefaconomy.vaultLayer.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return economy.vaultLayer.createPlayerAccount(playerName);
|
||||
return Minefaconomy.vaultLayer.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return economy.vaultLayer.hasBankSupport();
|
||||
return Minefaconomy.vaultLayer.hasBankSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return economy.vaultLayer.createBank(name, player);
|
||||
return Minefaconomy.vaultLayer.createBank(name, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return economy.vaultLayer.deleteBank(name);
|
||||
return Minefaconomy.vaultLayer.deleteBank(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return economy.vaultLayer.bankBalance(name);
|
||||
return Minefaconomy.vaultLayer.bankBalance(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return economy.vaultLayer.bankHas(name, amount);
|
||||
return Minefaconomy.vaultLayer.bankHas(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return economy.vaultLayer.bankWithdraw(name, amount);
|
||||
return Minefaconomy.vaultLayer.bankWithdraw(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return economy.vaultLayer.bankDeposit(name, amount);
|
||||
return Minefaconomy.vaultLayer.bankDeposit(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return economy.vaultLayer.isBankOwner(name, playerName);
|
||||
return Minefaconomy.vaultLayer.isBankOwner(name, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return economy.vaultLayer.isBankMember(name, playerName);
|
||||
return Minefaconomy.vaultLayer.isBankMember(name, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return economy.vaultLayer.getBanks();
|
||||
return Minefaconomy.vaultLayer.getBanks();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -22,157 +24,130 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import ru.simsonic.rscPermissions.MainPluginClass;
|
||||
|
||||
public class Permission_rscPermissions extends Permission
|
||||
{
|
||||
private final Plugin vault;
|
||||
private ru.simsonic.rscPermissions.MainPluginClass rscp = null;
|
||||
private ru.simsonic.rscPermissions.rscpAPI API = null;
|
||||
public Permission_rscPermissions(Plugin plugin)
|
||||
{
|
||||
super();
|
||||
this.vault = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), vault);
|
||||
rscp = (MainPluginClass)vault.getServer().getPluginManager().getPlugin("rscPermissions");
|
||||
}
|
||||
private class PermissionServerListener implements Listener
|
||||
{
|
||||
private final Permission_rscPermissions bridge;
|
||||
public PermissionServerListener(Permission_rscPermissions bridge)
|
||||
{
|
||||
this.bridge = bridge;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event)
|
||||
{
|
||||
if(bridge.rscp == null)
|
||||
{
|
||||
Plugin plugin = event.getPlugin();
|
||||
if(!"rscPermissions".equals(plugin.getName()))
|
||||
return;
|
||||
bridge.rscp = (MainPluginClass)plugin;
|
||||
}
|
||||
if(bridge.API == null)
|
||||
bridge.API = bridge.rscp.API;
|
||||
if(bridge.API.isEnabled())
|
||||
log.info(String.format("[%s][Permission] %s hooked.",
|
||||
vault.getDescription().getName(), bridge.API.getName()));
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event)
|
||||
{
|
||||
if(bridge.API != null)
|
||||
if(event.getPlugin().getDescription().getName().equals(bridge.API.getName()))
|
||||
{
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.",
|
||||
vault.getDescription().getName(), bridge.API.getName()));
|
||||
bridge.API = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return (API != null) ? API.getName() : "rscPermissions";
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return (API != null) ? API.isEnabled() : false;
|
||||
}
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat()
|
||||
{
|
||||
return (API != null) ? API.hasSuperPermsCompat() : true;
|
||||
}
|
||||
@Override
|
||||
public boolean hasGroupSupport()
|
||||
{
|
||||
return (API != null) ? API.hasGroupSupport() : true;
|
||||
}
|
||||
@Override
|
||||
public boolean playerHas(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
return API.playerHas(string, string1, string2);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean playerAdd(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
return API.playerAdd(string, string1, string2);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean playerRemove(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
return API.playerRemove(string, string1, string2);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean groupHas(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
return API.groupHas(string, string1, string2);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean groupAdd(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
return API.groupAdd(string, string1, string2);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean groupRemove(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
return API.groupRemove(string, string1, string2);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean playerInGroup(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
return API.playerInGroup(string, string1, string2);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean playerAddGroup(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
return API.playerAddGroup(string, string1, string2);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String string, String string1, String string2)
|
||||
{
|
||||
if(API != null)
|
||||
return API.playerRemoveGroup(string, string1, string2);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public String[] getPlayerGroups(String string, String string1)
|
||||
{
|
||||
if(API != null)
|
||||
return API.getPlayerGroups(string, string1);
|
||||
return new String[] { "Default" };
|
||||
}
|
||||
@Override
|
||||
public String getPrimaryGroup(String string, String string1)
|
||||
{
|
||||
if(API != null)
|
||||
return API.getPrimaryGroup(string, string1);
|
||||
return "Default";
|
||||
}
|
||||
@Override
|
||||
public String[] getGroups()
|
||||
{
|
||||
if(API != null)
|
||||
return API.getGroups();
|
||||
return new String[] { "Default" };
|
||||
}
|
||||
public class Permission_rscPermissions extends Permission {
|
||||
|
||||
private final Plugin vault;
|
||||
private ru.simsonic.rscPermissions.MainPluginClass rscp = null;
|
||||
private ru.simsonic.rscPermissions.rscpAPI rscpAPI = null;
|
||||
|
||||
public Permission_rscPermissions(Plugin plugin) {
|
||||
super();
|
||||
this.vault = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), vault);
|
||||
rscp = (MainPluginClass)vault.getServer().getPluginManager().getPlugin("rscPermissions");
|
||||
}
|
||||
|
||||
private class PermissionServerListener implements Listener {
|
||||
private final Permission_rscPermissions bridge;
|
||||
|
||||
public PermissionServerListener(Permission_rscPermissions bridge) {
|
||||
this.bridge = bridge;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if(bridge.rscp == null) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
if (plugin.getDescription().getName().equals("rscPermissions")) {
|
||||
bridge.rscp = (MainPluginClass) plugin;
|
||||
bridge.rscpAPI = bridge.rscp.API;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", vault.getDescription().getName(), bridge.rscpAPI.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(bridge.rscpAPI != null){
|
||||
if(event.getPlugin().getDescription().getName().equals(bridge.rscpAPI.getName())) {
|
||||
bridge.rscpAPI = null;
|
||||
bridge.rscp = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", vault.getDescription().getName(), bridge.rscpAPI.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "rscPermissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return rscpAPI.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return rscpAPI.hasSuperPermsCompat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return rscpAPI.hasGroupSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
return rscpAPI.playerHas(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return rscpAPI.playerAdd(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return rscpAPI.playerRemove(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return rscpAPI.groupHas(world, group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
return rscpAPI.groupAdd(world, group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
return rscpAPI.groupRemove(world, group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
return rscpAPI.playerInGroup(world, player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
return rscpAPI.playerAddGroup(world, player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
return rscpAPI.playerRemoveGroup(world, player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
return rscpAPI.getPlayerGroups(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
return rscpAPI.getPrimaryGroup(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return rscpAPI.getGroups();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue