Added rscPermissions support.

This commit is contained in:
SimSonic 2013-09-04 12:02:56 +07:00
parent ac1fd3e2e4
commit 39f58a6c79
5 changed files with 405 additions and 1 deletions

BIN
lib/rscPermissions.jar Normal file

Binary file not shown.

View File

@ -10,7 +10,7 @@
<url>http://dev.bukkit.org/server-mods/vault/</url>
<description>Vault is a Permissions &amp; Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves.
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy</description>
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -348,6 +348,13 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope>
<systemPath>${project.basedir}/lib/TotalPermissions.jar</systemPath>
</dependency>
<dependency>
<groupId>ru.simsonic</groupId>
<artifactId>rscPermissions</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/rscPermissions.jar</systemPath>
</dependency>
</dependencies>
<build>

View File

@ -36,6 +36,7 @@ import net.milkbowl.vault.chat.plugins.Chat_iChat;
import net.milkbowl.vault.chat.plugins.Chat_mChat;
import net.milkbowl.vault.chat.plugins.Chat_mChatSuite;
import net.milkbowl.vault.chat.plugins.Chat_zPermissions;
import net.milkbowl.vault.chat.plugins.Chat_rscPermissions;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.plugins.Economy_3co;
import net.milkbowl.vault.economy.plugins.Economy_AEco;
@ -76,6 +77,7 @@ import net.milkbowl.vault.permission.plugins.Permission_bPermissions;
import net.milkbowl.vault.permission.plugins.Permission_bPermissions2;
import net.milkbowl.vault.permission.plugins.Permission_zPermissions;
import net.milkbowl.vault.permission.plugins.Permission_TotalPermissions;
import net.milkbowl.vault.permission.plugins.Permission_rscPermissions;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -195,6 +197,9 @@ public class Vault extends JavaPlugin {
// Try to load Privileges
hookChat("Privileges", Chat_Privileges.class, ServicePriority.Normal, "net.krinsoft.privileges.Privileges");
// Try to load rscPermissions
hookChat("rscPermissions", Chat_rscPermissions.class, ServicePriority.Normal, "ru.simsonic.rscPermissions.MainPluginClass");
}
/**
@ -319,6 +324,9 @@ public class Vault extends JavaPlugin {
//Try to load TotalPermissions
hookPermission("TotalPermissions", Permission_TotalPermissions.class, ServicePriority.Normal, "net.ae97.totalpermissions.TotalPermissions");
// Try to load rscPermissions
hookPermission("rscPermissions", Permission_rscPermissions.class, ServicePriority.Normal, "ru.simsonic.rscPermissions.MainPluginClass");
Permission perms = new Permission_SuperPerms(this);
sm.register(Permission.class, perms, this, ServicePriority.Lowest);

View File

@ -0,0 +1,211 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
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;
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)
{
}
}

View File

@ -0,0 +1,178 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
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;
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" };
}
}