mirror of https://github.com/MilkBowl/Vault.git
Add overpermissions support, fix missing licenses, and correct all the
formatting problems. Thanks @OverCaste
This commit is contained in:
parent
b7c7ca4cce
commit
f1b50edff6
Binary file not shown.
13
pom.xml
13
pom.xml
|
@ -391,11 +391,18 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/DigiCoin.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.overmc</groupId>
|
||||
<artifactId>overpermissions</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/overpermissions-1.0.5.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- Test Dependency -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.logging.Logger;
|
|||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_DroxPerms;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_GroupManager;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_OverPermissions;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_Permissions3;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_PermissionsEx;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_Privileges;
|
||||
|
@ -69,6 +70,7 @@ import net.milkbowl.vault.economy.plugins.Economy_Minefaconomy;
|
|||
import net.milkbowl.vault.permission.Permission;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_DroxPerms;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_GroupManager;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_OverPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_Permissions3;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_PermissionsBukkit;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_PermissionsEx;
|
||||
|
@ -139,7 +141,7 @@ public class Vault extends JavaPlugin {
|
|||
getConfig().addDefault("update-check", true);
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
|
||||
|
||||
// Load Vault Addons
|
||||
loadEconomy();
|
||||
loadPermission();
|
||||
|
@ -188,7 +190,7 @@ public class Vault extends JavaPlugin {
|
|||
}, 0, 432000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
// Load up the Plugin metrics
|
||||
|
@ -215,6 +217,9 @@ public class Vault extends JavaPlugin {
|
|||
// Try to load mChat
|
||||
hookChat("mChat", Chat_mChat.class, ServicePriority.Highest, "net.D3GN.MiracleM4n.mChat");
|
||||
|
||||
// Try to load OverPermissions
|
||||
hookChat("OverPermissions", Chat_OverPermissions.class, ServicePriority.Highest, "com.overmc.overpermissions.OverPermissions");
|
||||
|
||||
// Try to load DroxPerms Chat
|
||||
hookChat("DroxPerms", Chat_DroxPerms.class, ServicePriority.Lowest, "de.hydrox.bukkit.DroxPerms.DroxPerms");
|
||||
|
||||
|
@ -315,7 +320,7 @@ public class Vault extends JavaPlugin {
|
|||
|
||||
// Try to load GoldenChestEconomy
|
||||
hookEconomy("GoldenChestEconomy", Economy_GoldenChestEconomy.class, ServicePriority.Normal, "me.igwb.GoldenChest.GoldenChestEconomy");
|
||||
|
||||
|
||||
// Try to load Dosh
|
||||
hookEconomy("Dosh", Economy_Dosh.class, ServicePriority.Normal, "com.gravypod.Dosh.Dosh");
|
||||
|
||||
|
@ -330,7 +335,7 @@ public class Vault extends JavaPlugin {
|
|||
|
||||
// Try to load TAEcon
|
||||
hookEconomy("TAEcon", Economy_TAEcon.class, ServicePriority.Normal, "net.teamalpha.taecon.TAEcon");
|
||||
|
||||
|
||||
// Try to load DigiCoin
|
||||
hookEconomy("DigiCoin", Economy_DigiCoin.class, ServicePriority.Normal, "co.uk.silvania.cities.digicoin.DigiCoin");
|
||||
}
|
||||
|
@ -345,6 +350,9 @@ public class Vault extends JavaPlugin {
|
|||
// Try to load PermissionsEx
|
||||
hookPermission("PermissionsEx", Permission_PermissionsEx.class, ServicePriority.Highest, "ru.tehkode.permissions.bukkit.PermissionsEx");
|
||||
|
||||
// Try to load OverPermissions
|
||||
hookPermission("OverPermissions", Permission_OverPermissions.class, ServicePriority.Highest, "com.overmc.overpermissions.OverPermissions");
|
||||
|
||||
// Try to load PermissionsBukkit
|
||||
hookPermission("PermissionsBukkit", Permission_PermissionsBukkit.class, ServicePriority.Normal, "com.platymuus.bukkit.permissions.PermissionsPlugin");
|
||||
|
||||
|
@ -381,9 +389,9 @@ public class Vault extends JavaPlugin {
|
|||
// Try to load rscPermissions
|
||||
hookPermission("rscPermissions", Permission_rscPermissions.class, ServicePriority.Normal, "ru.simsonic.rscPermissions.MainPluginClass");
|
||||
|
||||
//Try to load KPerms
|
||||
// Try to load KPerms
|
||||
hookPermission("KPerms", Permission_KPerms.class, ServicePriority.Normal, "com.lightniinja.kperms.KPermsPlugin");
|
||||
|
||||
|
||||
Permission perms = new Permission_SuperPerms(this);
|
||||
sm.register(Permission.class, perms, this, ServicePriority.Lowest);
|
||||
log.info(String.format("[%s][Permission] SuperPermissions loaded as backup permission system.", getDescription().getName()));
|
||||
|
|
|
@ -0,0 +1,293 @@
|
|||
/* 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.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;
|
||||
|
||||
|
||||
public class Chat_OverPermissions extends Chat {
|
||||
|
||||
private static final String name = "OverPermissions_Chat";
|
||||
private Plugin plugin;
|
||||
private OverPermissions overPerms;
|
||||
private OverPermissionsAPI api;
|
||||
|
||||
public Chat_OverPermissions(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
if (overPerms == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("OverPermissions");
|
||||
if (p != null) {
|
||||
overPerms = (OverPermissions) p;
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return overPerms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return getPlayerInfoString(world, player, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
setPlayerInfoString(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return getPlayerInfoString(world, player, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
setPlayerInfoString(world, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return getGroupInfoString(world, group, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
setGroupInfoString(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return getGroupInfoString(world, group, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.valueOf(s).intValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.valueOf(s).intValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Double.valueOf(s).doubleValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Double.valueOf(s).doubleValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val.booleanValue() : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return Boolean.valueOf(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
return;
|
||||
}
|
||||
group.setMeta(node, value);
|
||||
group.recalculatePermissions();
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_OverPermissions chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_OverPermissions chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat.overPerms == null) {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
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;
|
||||
|
@ -33,14 +33,14 @@ import ru.tehkode.permissions.PermissionUser;
|
|||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||
|
||||
public class Chat_PermissionsEx extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final String name = "PermissionsEx_Chat";
|
||||
|
||||
|
||||
private Plugin plugin = null;
|
||||
private PermissionsEx chat = null;
|
||||
|
||||
public Chat_PermissionsEx(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
@ -56,14 +56,14 @@ public class Chat_PermissionsEx extends Chat {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_PermissionsEx chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_PermissionsEx chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat.chat == null) {
|
||||
|
@ -88,20 +88,20 @@ public class Chat_PermissionsEx extends Chat {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (chat == null)
|
||||
return false;
|
||||
else
|
||||
return chat.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (chat == null)
|
||||
return false;
|
||||
else
|
||||
return chat.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
|
||||
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionInteger(node, world, defaultValue);
|
||||
|
@ -121,7 +121,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
|
||||
return PermissionsEx.getPermissionManager().getUser(playerName).getOption(node, world, defaultValue);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
|
||||
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
|
||||
|
@ -233,7 +233,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
group.setOption(node, world, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String playerName) {
|
||||
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
/* 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 com.overmc.overpermissions.OverPermissions;
|
||||
import com.overmc.overpermissions.OverPermissionsAPI;
|
||||
|
||||
public class Permission_OverPermissions extends Permission {
|
||||
|
||||
private final String name = "OverPermissions";
|
||||
private OverPermissions overPerms;
|
||||
private OverPermissionsAPI api;
|
||||
|
||||
public Permission_OverPermissions(Plugin plugin) {
|
||||
this.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"));
|
||||
}
|
||||
}
|
||||
|
||||
if ((api == null) && (overPerms != null)) {
|
||||
api = overPerms.getAPI();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return (overPerms != null) && (overPerms.isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String worldName, String playerName, String permission) {
|
||||
return api.playerHas(worldName, playerName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String worldName, String playerName, String permission) {
|
||||
return api.playerAdd(worldName, playerName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String worldName, String playerName, String permission) {
|
||||
return api.playerRemove(worldName, playerName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String worldName, String groupName, String permission) {
|
||||
return api.groupHas(groupName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
||||
return api.groupAdd(groupName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
||||
return api.groupRemove(groupName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String worldName, String playerName, String groupName) {
|
||||
return api.groupHasPlayer(playerName, groupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
|
||||
return api.playerAddGroup(playerName, groupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
|
||||
return api.playerRemoveGroup(playerName, groupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String worldName, String playerName) {
|
||||
return api.getPlayerGroups(worldName, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String worldName, String playerName) {
|
||||
String[] playerGroups = getPlayerGroups(worldName, playerName);
|
||||
if (playerGroups.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return playerGroups[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String world, String player, String permission) {
|
||||
return api.playerAddTransient(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String world, String player, String permission) {
|
||||
return api.playerRemoveTransient(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return api.getGroupsArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_OverPermissions permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_OverPermissions permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.overPerms == null) {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue