mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-22 18:46:41 +01:00
Updated OverPermissions support to v2.0.0
This commit is contained in:
parent
064b8b7e1d
commit
eddd072f80
@ -108,6 +108,7 @@ Github and we'll get to it at our convenience.
|
||||
- bPermissions 2 (http://dev.bukkit.org/server-mods/bpermissions/)
|
||||
- DroxPerms
|
||||
- Group Manager (Essentials) (http://forums.bukkit.org/threads/15312/)
|
||||
- OverPermissions (http://dev.bukkit.org/bukkit-plugins/overpermissions/)
|
||||
- Permissions 3 (http://forums.bukkit.org/threads/18430/)
|
||||
- PermissionsBukkit
|
||||
- Permissions Ex (http://forums.bukkit.org/threads/18140/)
|
||||
@ -125,6 +126,7 @@ Github and we'll get to it at our convenience.
|
||||
- iChat
|
||||
- mChat
|
||||
- mChatSuite
|
||||
- OverPermissions
|
||||
- Permissions3
|
||||
- PEX
|
||||
- rscPermissions
|
||||
|
Binary file not shown.
BIN
lib/overpermissions.jar
Normal file
BIN
lib/overpermissions.jar
Normal file
Binary file not shown.
4
pom.xml
4
pom.xml
@ -17,7 +17,7 @@
|
||||
<url>http://dev.bukkit.org/server-mods/vault/</url>
|
||||
<description>Vault is a Permissions & 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, rscPermissions, KPerms, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy, TAEcon</description>
|
||||
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, KPerms, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy, TAEcon, and OverPermissions</description>
|
||||
|
||||
|
||||
|
||||
@ -410,7 +410,7 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
||||
<version>1.0.5</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/overpermissions-1.0.5.jar</systemPath>
|
||||
<systemPath>${project.basedir}/lib/overpermissions.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -1,45 +1,24 @@
|
||||
/* 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 net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.overmc.overpermissions.Group;
|
||||
import com.overmc.overpermissions.OverPermissions;
|
||||
import com.overmc.overpermissions.OverPermissionsAPI;
|
||||
|
||||
import com.overmc.overpermissions.api.*;
|
||||
import com.overmc.overpermissions.internal.OverPermissions;
|
||||
|
||||
public class Chat_OverPermissions extends Chat {
|
||||
|
||||
private static final String name = "OverPermissions_Chat";
|
||||
private Plugin plugin;
|
||||
protected final Plugin plugin;
|
||||
private OverPermissions overPerms;
|
||||
private OverPermissionsAPI api;
|
||||
private UserManager userManager;
|
||||
private GroupManager groupManager;
|
||||
|
||||
public Chat_OverPermissions(Plugin plugin, Permission perms) {
|
||||
public Chat_OverPermissions(Plugin plugin, Permission perms)
|
||||
{
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
@ -49,71 +28,82 @@ public class Chat_OverPermissions extends Chat {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("OverPermissions");
|
||||
if (p != null) {
|
||||
overPerms = (OverPermissions) p;
|
||||
userManager = overPerms.getUserManager();
|
||||
groupManager = overPerms.getGroupManager();
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", new Object[] {plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
if ((api == null) && (overPerms != null)) {
|
||||
api = overPerms.getAPI();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
public String getName( )
|
||||
{
|
||||
return "OverPermissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled( )
|
||||
{
|
||||
return overPerms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
public String getPlayerPrefix(String world, String player)
|
||||
{
|
||||
return getPlayerInfoString(world, player, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
public void setPlayerPrefix(String world, String player, String prefix)
|
||||
{
|
||||
setPlayerInfoString(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
public String getPlayerSuffix(String world, String player)
|
||||
{
|
||||
return getPlayerInfoString(world, player, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
public void setPlayerSuffix(String world, String player, String suffix)
|
||||
{
|
||||
setPlayerInfoString(world, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
public String getGroupPrefix(String world, String group)
|
||||
{
|
||||
return getGroupInfoString(world, group, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
public void setGroupPrefix(String world, String group, String prefix)
|
||||
{
|
||||
setGroupInfoString(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
public String getGroupSuffix(String world, String group)
|
||||
{
|
||||
return getGroupInfoString(world, group, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
public void setGroupSuffix(String world, String group, String suffix)
|
||||
{
|
||||
setGroupInfoString(world, group, "prefix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue)
|
||||
{
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
try
|
||||
{
|
||||
return Integer.valueOf(s).intValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
@ -121,17 +111,20 @@ public class Chat_OverPermissions extends Chat {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value)
|
||||
{
|
||||
setPlayerInfoString(world, player, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue)
|
||||
{
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
try
|
||||
{
|
||||
return Integer.valueOf(s).intValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
@ -139,17 +132,20 @@ public class Chat_OverPermissions extends Chat {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value)
|
||||
{
|
||||
setGroupInfoString(world, group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue)
|
||||
{
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
try
|
||||
{
|
||||
return Double.valueOf(s).doubleValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
@ -157,17 +153,20 @@ public class Chat_OverPermissions extends Chat {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value)
|
||||
{
|
||||
setPlayerInfoString(world, player, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue)
|
||||
{
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
try
|
||||
{
|
||||
return Double.valueOf(s).doubleValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
@ -175,12 +174,14 @@ public class Chat_OverPermissions extends Chat {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value)
|
||||
{
|
||||
setGroupInfoString(world, group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue)
|
||||
{
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
@ -190,80 +191,114 @@ public class Chat_OverPermissions extends Chat {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value)
|
||||
{
|
||||
setPlayerInfoString(world, player, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue)
|
||||
{
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return Boolean.valueOf(s);
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val.booleanValue() : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value)
|
||||
{
|
||||
setGroupInfoString(world, group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
|
||||
Player p = Bukkit.getPlayerExact(playerName);
|
||||
String ret = null;
|
||||
if (p != null) {
|
||||
ret = overPerms.getPlayerPermissions(p).getStringMeta(node, defaultValue);
|
||||
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue)
|
||||
{
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return defaultValue;
|
||||
}
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
if (world == null) { // Retrieve meta from the global store.
|
||||
if (!user.hasGlobalMeta(node)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return user.getGlobalMeta(node);
|
||||
} else {
|
||||
int playerId = overPerms.getSQLManager().getPlayerId(playerName);
|
||||
int worldId = overPerms.getSQLManager().getWorldId(world);
|
||||
ret = overPerms.getSQLManager().getPlayerMetaValue(playerId, worldId, node);
|
||||
}
|
||||
if (ret == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
Player p = Bukkit.getPlayerExact(player);
|
||||
int playerId = overPerms.getSQLManager().getPlayerId(player, true);
|
||||
int worldId = overPerms.getSQLManager().getWorldId(player, false);
|
||||
if (worldId < 0) {
|
||||
overPerms.getSQLManager().setGlobalPlayerMeta(playerId, node, value);
|
||||
} else {
|
||||
overPerms.getSQLManager().setPlayerMeta(playerId, worldId, node, value);
|
||||
}
|
||||
if (p != null) {
|
||||
overPerms.getPlayerPermissions(p).recalculateMeta();
|
||||
if (!user.hasMeta(node, world)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return user.getMeta(node, world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
|
||||
Group group = overPerms.getGroupManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
String value = group.getMeta(node);
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String groupName, String node, String value) {
|
||||
Group group = overPerms.getGroupManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
public void setPlayerInfoString(String world, String playerName, String node, String value)
|
||||
{
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return;
|
||||
}
|
||||
group.setMeta(node, value);
|
||||
group.recalculatePermissions();
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
if (world != null) {
|
||||
if (value == null) {
|
||||
user.removeMeta(node, world);
|
||||
} else {
|
||||
user.setMeta(node, value, world);
|
||||
}
|
||||
} else {
|
||||
if (value == null) {
|
||||
user.removeGlobalMeta(node);
|
||||
} else {
|
||||
user.setGlobalMeta(node, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String groupName, String node, String defaultValue)
|
||||
{
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return defaultValue;
|
||||
}
|
||||
PermissionGroup group = overPerms.getGroupManager().getGroup(groupName);
|
||||
if (world == null) { // Retrieve from the global store.
|
||||
if (!group.hasGlobalMeta(node)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return group.getGlobalMeta(node);
|
||||
} else {
|
||||
if (!group.hasMeta(node, world)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return group.getMeta(node, world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String groupName, String node, String value)
|
||||
{
|
||||
if (!overPerms.getGroupManager().doesGroupExist(groupName)) {
|
||||
return;
|
||||
}
|
||||
PermissionGroup group = overPerms.getGroupManager().getGroup(groupName);
|
||||
if (world != null) {
|
||||
if (value == null) {
|
||||
group.removeMeta(node, world);
|
||||
} else {
|
||||
group.setMeta(node, value, world);
|
||||
}
|
||||
} else {
|
||||
if (value == null) {
|
||||
group.removeGlobalMeta(node);
|
||||
} else {
|
||||
group.setGlobalMeta(node, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener
|
||||
{
|
||||
Chat_OverPermissions chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_OverPermissions chat) {
|
||||
@ -276,7 +311,7 @@ public class Chat_OverPermissions extends Chat {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("OverPermissions");
|
||||
if (chat != null) {
|
||||
this.chat.overPerms = (OverPermissions) chat;
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), getName()));
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", new Object[] {plugin.getDescription().getName(), getName()}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -286,7 +321,7 @@ public class Chat_OverPermissions extends Chat {
|
||||
if ((chat.overPerms != null) &&
|
||||
(event.getPlugin().getDescription().getName().equals("OverPermissions"))) {
|
||||
chat.overPerms = null;
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), getName()));
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s un-hooked.", new Object[] {plugin.getDescription().getName(), getName()}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,118 +1,168 @@
|
||||
/* 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 java.util.ArrayList;
|
||||
|
||||
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.*;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.overmc.overpermissions.OverPermissions;
|
||||
import com.overmc.overpermissions.OverPermissionsAPI;
|
||||
import com.overmc.overpermissions.api.*;
|
||||
import com.overmc.overpermissions.internal.OverPermissions;
|
||||
|
||||
public class Permission_OverPermissions extends Permission {
|
||||
|
||||
private final String name = "OverPermissions";
|
||||
private OverPermissions overPerms;
|
||||
private OverPermissionsAPI api;
|
||||
private UserManager userManager;
|
||||
private GroupManager groupManager;
|
||||
|
||||
public Permission_OverPermissions(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
public Permission_OverPermissions(Plugin plugin)
|
||||
{
|
||||
super.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
if (overPerms == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("OverPermissions");
|
||||
if ((perms != null) && (perms.isEnabled())) {
|
||||
overPerms = ((OverPermissions) perms);
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), "OverPermissions"));
|
||||
userManager = overPerms.getUserManager();
|
||||
groupManager = overPerms.getGroupManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", new Object[] {plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
|
||||
if ((api == null) && (overPerms != null)) {
|
||||
api = overPerms.getAPI();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getName( )
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled( )
|
||||
{
|
||||
return (overPerms != null) && (overPerms.isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String worldName, String playerName, String permission) {
|
||||
return api.playerHas(worldName, playerName, permission);
|
||||
public boolean playerHas(String worldName, String playerName, String permission)
|
||||
{
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).getPermission(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String worldName, String playerName, String permission) {
|
||||
return api.playerAdd(worldName, playerName, permission);
|
||||
public boolean playerAdd(String worldName, String playerName, String permission)
|
||||
{
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).addPermissionNode(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String worldName, String playerName, String permission) {
|
||||
return api.playerRemove(worldName, playerName, permission);
|
||||
public boolean playerRemove(String worldName, String playerName, String permission)
|
||||
{
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).removePermissionNode(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String worldName, String groupName, String permission) {
|
||||
return api.groupHas(groupName, permission);
|
||||
public boolean groupHas(String worldName, String groupName, String permission)
|
||||
{
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
return groupManager.getGroup(groupName).getPermission(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
||||
return api.groupAdd(groupName, permission);
|
||||
public boolean groupAdd(String worldName, String groupName, String permission)
|
||||
{
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (worldName == null) {
|
||||
return groupManager.getGroup(groupName).addGlobalPermissionNode(permission);
|
||||
} else {
|
||||
return groupManager.getGroup(groupName).addPermissionNode(permission, worldName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
||||
return api.groupRemove(groupName, permission);
|
||||
public boolean groupRemove(String worldName, String groupName, String permission)
|
||||
{
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (worldName == null) {
|
||||
return groupManager.getGroup(groupName).removeGlobalPermissionNode(permission);
|
||||
} else {
|
||||
return groupManager.getGroup(groupName).removePermissionNode(permission, worldName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String worldName, String playerName, String groupName) {
|
||||
return api.groupHasPlayer(playerName, groupName);
|
||||
public boolean playerInGroup(String worldName, String playerName, String groupName)
|
||||
{
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).getAllParents().contains(groupManager.getGroup(groupName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
|
||||
return api.playerAddGroup(playerName, groupName);
|
||||
public boolean playerAddGroup(String worldName, String playerName, String groupName)
|
||||
{
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).addParent(groupManager.getGroup(groupName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
|
||||
return api.playerRemoveGroup(playerName, groupName);
|
||||
public boolean playerRemoveGroup(String worldName, String playerName, String groupName)
|
||||
{
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).removeParent(groupManager.getGroup(groupName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String worldName, String playerName) {
|
||||
return api.getPlayerGroups(worldName, playerName);
|
||||
public String[] getPlayerGroups(String worldName, String playerName)
|
||||
{
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return new String[0];
|
||||
}
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
for (PermissionGroup parent : user.getAllParents()) {
|
||||
ret.add(parent.getName());
|
||||
}
|
||||
return ret.toArray(new String[ret.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String worldName, String playerName) {
|
||||
public String getPrimaryGroup(String worldName, String playerName)
|
||||
{
|
||||
String[] playerGroups = getPlayerGroups(worldName, playerName);
|
||||
if (playerGroups.length == 0) {
|
||||
return null;
|
||||
@ -121,31 +171,50 @@ public class Permission_OverPermissions extends Permission {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String world, String player, String permission) {
|
||||
return api.playerAddTransient(world, player, permission);
|
||||
public boolean playerAddTransient(String world, String playerName, String permission)
|
||||
{
|
||||
if (!userManager.doesUserExist(playerName)) { // Can't add transient permissions to an offline player.
|
||||
return false;
|
||||
}
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
return (world == null) ? user.addGlobalTransientPermissionNode(permission) : user.addTransientPermissionNode(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String world, String player, String permission) {
|
||||
return api.playerRemoveTransient(world, player, permission);
|
||||
public boolean playerRemoveTransient(String world, String playerName, String permission)
|
||||
{
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
return (world == null) ? user.removeGlobalTransientPermissionNode(permission) : user.removeTransientPermissionNode(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return api.getGroupsArray();
|
||||
public String[] getGroups( )
|
||||
{
|
||||
ArrayList<String> groupNames = new ArrayList<String>();
|
||||
for (PermissionGroup s : groupManager.getGroups()) {
|
||||
groupNames.add(s.getName());
|
||||
}
|
||||
return groupNames.toArray(new String[groupNames.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
public boolean hasSuperPermsCompat( )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
public boolean hasGroupSupport( )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
public class PermissionServerListener
|
||||
implements Listener
|
||||
{
|
||||
Permission_OverPermissions permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_OverPermissions permission) {
|
||||
@ -158,18 +227,21 @@ public class Permission_OverPermissions extends Permission {
|
||||
Plugin perms = Permission_OverPermissions.this.plugin.getServer().getPluginManager().getPlugin("OverPermissions");
|
||||
if (perms != null) {
|
||||
permission.overPerms = ((OverPermissions) perms);
|
||||
Permission_OverPermissions.log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), "OverPermissions"));
|
||||
Permission_OverPermissions.log.info(String
|
||||
.format("[%s][Permission] %s hooked.", new Object[] {Permission_OverPermissions.this.plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
public void onPluginDisable(PluginDisableEvent event)
|
||||
{
|
||||
if ((permission.overPerms != null) &&
|
||||
(event.getPlugin().getDescription().getName().equals("OverPermissions"))) {
|
||||
permission.overPerms = null;
|
||||
Permission_OverPermissions.log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), "OverPermissions"));
|
||||
Permission_OverPermissions.log.info(String
|
||||
.format("[%s][Permission] %s un-hooked.", new Object[] {Permission_OverPermissions.this.plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user