mirror of https://github.com/MilkBowl/Vault.git
Remove native support for ancient chat and permissions plugins
This commit is contained in:
parent
5720e5393f
commit
38dad24f01
Binary file not shown.
BIN
lib/KPerms.jar
BIN
lib/KPerms.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/Xperms.jar
BIN
lib/Xperms.jar
Binary file not shown.
Binary file not shown.
BIN
lib/iChat.jar
BIN
lib/iChat.jar
Binary file not shown.
BIN
lib/mChat.jar
BIN
lib/mChat.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
120
pom.xml
120
pom.xml
|
@ -95,14 +95,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/MiConomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hydrox.bukkit</groupId>
|
||||
<artifactId>DroxPerms</artifactId>
|
||||
<version>0.5.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/DroxPerms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.coniin.plugins.minefaconomy</groupId>
|
||||
<artifactId>MineFaConomy</artifactId>
|
||||
|
@ -111,14 +103,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Minefaconomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.krinsoft</groupId>
|
||||
<artifactId>Privileges</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Privileges.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>is.currency</groupId>
|
||||
<artifactId>Currency</artifactId>
|
||||
|
@ -151,22 +135,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/BOSEconomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.bananaco.permissions.Permissions</groupId>
|
||||
<artifactId>bPermissions</artifactId>
|
||||
<version>2.0.9a</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/bpermissions.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.sebc722</groupId>
|
||||
<artifactId>xPerms</artifactId>
|
||||
<version>1.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Xperms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.agnate.EconXP.EconXP</groupId>
|
||||
<artifactId>EconXP</artifactId>
|
||||
|
@ -207,14 +175,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/McMoney.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.TheDgtl.iChat.iChat</groupId>
|
||||
<artifactId>iChat</artifactId>
|
||||
<version>2.5.7</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/iChat.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.iCo6.iConomy</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
|
@ -231,22 +191,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/XPBank.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.D3GN.MiracleM4n.mChat.mChat</groupId>
|
||||
<artifactId>mChat</artifactId>
|
||||
<version>1.8.5</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/mChat.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>in.mDev</groupId>
|
||||
<artifactId>mChatSuite</artifactId>
|
||||
<version>DEV-b275</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/mChatSuite.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.mjolnir.mineconomy.MineConomy</groupId>
|
||||
<artifactId>MineConomy</artifactId>
|
||||
|
@ -263,22 +207,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/MultiCurrency.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nijikokun.bukkit.Permissions.Permissions</groupId>
|
||||
<artifactId>Permissions</artifactId>
|
||||
<version>3.1.6</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Permissions.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platymuus.bukkit.permissions.PermissionsPlugin</groupId>
|
||||
<artifactId>PermissionsBukkit</artifactId>
|
||||
<version>2.3</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/PermissionsBukkit.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.tehkode</groupId>
|
||||
<artifactId>PermissionsEx</artifactId>
|
||||
|
@ -295,14 +223,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/bpermissions25.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dthielke.starburst</groupId>
|
||||
<artifactId>Starburst</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Starburst.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nijikokun.register</groupId>
|
||||
<artifactId>Register</artifactId>
|
||||
|
@ -325,14 +245,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<version>3.2.2-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crystalyx.bukkit.simplyperms</groupId>
|
||||
<artifactId>SimplyPerms</artifactId>
|
||||
<version>1.6.2</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/SimplyPerms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>Gringotts</groupId>
|
||||
<artifactId>Gringotts</artifactId>
|
||||
|
@ -365,22 +277,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/SDFEconomy-0.2.2.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ae97</groupId>
|
||||
<artifactId>TotalPermissions</artifactId>
|
||||
<version>0.3.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/TotalPermissions.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.simsonic</groupId>
|
||||
<artifactId>rscPermissions</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/rscPermissions.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.teamalpha.taecon</groupId>
|
||||
<artifactId>TAEcon</artifactId>
|
||||
|
@ -389,14 +285,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/TAEcon.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>KPerms</groupId>
|
||||
<artifactId>KPerms</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/KPerms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.uk.silvania.cities.digicoin</groupId>
|
||||
<artifactId>DigiCoin</artifactId>
|
||||
|
@ -405,14 +293,6 @@ 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>2.0.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/overpermissions-2.0.0.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -26,18 +26,10 @@ import java.util.concurrent.Callable;
|
|||
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;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_bPermissions;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_bPermissions2;
|
||||
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_rscPermissions;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_BOSE7;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_CommandsEX;
|
||||
|
@ -60,22 +52,10 @@ import net.milkbowl.vault.economy.plugins.Economy_iConomy6;
|
|||
import net.milkbowl.vault.economy.plugins.Economy_SDFEconomy;
|
||||
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;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_Privileges;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_SimplyPerms;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_Starburst;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_SuperPerms;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_Xperms;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_bPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_bPermissions2;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_TotalPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_rscPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_KPerms;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -100,7 +80,6 @@ import org.json.simple.JSONValue;
|
|||
|
||||
import com.nijikokun.register.payment.Methods;
|
||||
|
||||
import net.milkbowl.vault.chat.plugins.Chat_TotalPermissions;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_MiConomy;
|
||||
|
||||
public class Vault extends JavaPlugin {
|
||||
|
@ -198,41 +177,14 @@ public class Vault extends JavaPlugin {
|
|||
// Try to load PermissionsEx
|
||||
hookChat("PermissionsEx", Chat_PermissionsEx.class, ServicePriority.Highest, "ru.tehkode.permissions.bukkit.PermissionsEx");
|
||||
|
||||
// Try to load mChatSuite
|
||||
hookChat("mChatSuite", Chat_mChatSuite.class, ServicePriority.Highest, "in.mDev.MiracleM4n.mChatSuite.mChatSuite");
|
||||
|
||||
// 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.internal.OverPermissions");
|
||||
|
||||
// Try to load DroxPerms Chat
|
||||
hookChat("DroxPerms", Chat_DroxPerms.class, ServicePriority.Lowest, "de.hydrox.bukkit.DroxPerms.DroxPerms");
|
||||
|
||||
// Try to load bPermssions 2
|
||||
hookChat("bPermssions2", Chat_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.ApiLayer");
|
||||
|
||||
// Try to load bPermissions 1
|
||||
hookChat("bPermissions", Chat_bPermissions.class, ServicePriority.Normal, "de.bananaco.permissions.info.InfoReader");
|
||||
|
||||
// Try to load GroupManager
|
||||
hookChat("GroupManager", Chat_GroupManager.class, ServicePriority.Normal, "org.anjocaido.groupmanager.GroupManager");
|
||||
|
||||
// Try to load Permissions 3 (Yeti)
|
||||
hookChat("Permissions3", Chat_Permissions3.class, ServicePriority.Normal, "com.nijiko.permissions.ModularControl");
|
||||
|
||||
// Try to load iChat
|
||||
hookChat("iChat", Chat_iChat.class, ServicePriority.Low, "net.TheDgtl.iChat.iChat");
|
||||
|
||||
// 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");
|
||||
|
||||
//Try to load TotalPermissions
|
||||
hookChat("TotalPermissions", Chat_TotalPermissions.class, ServicePriority.Normal, "net.ar97.totalpermissions.TotalPermissions");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -307,51 +259,15 @@ public class Vault extends JavaPlugin {
|
|||
* Attempts to load Permission Addons
|
||||
*/
|
||||
private void loadPermission() {
|
||||
// Try to load Starburst
|
||||
hookPermission("Starburst", Permission_Starburst.class, ServicePriority.Highest, "com.dthielke.starburst.StarburstPlugin");
|
||||
|
||||
// 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.internal.OverPermissions");
|
||||
|
||||
// Try to load PermissionsBukkit
|
||||
hookPermission("PermissionsBukkit", Permission_PermissionsBukkit.class, ServicePriority.Normal, "com.platymuus.bukkit.permissions.PermissionsPlugin");
|
||||
|
||||
// Try to load DroxPerms
|
||||
hookPermission("DroxPerms", Permission_DroxPerms.class, ServicePriority.High, "de.hydrox.bukkit.DroxPerms.DroxPerms");
|
||||
|
||||
// Try to load SimplyPerms
|
||||
hookPermission("SimplyPerms", Permission_SimplyPerms.class, ServicePriority.Highest, "net.crystalyx.bukkit.simplyperms.SimplyPlugin");
|
||||
|
||||
// Try to load bPermissions2
|
||||
hookPermission("bPermissions 2", Permission_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.WorldManager");
|
||||
|
||||
// Try to load Privileges
|
||||
hookPermission("Privileges", Permission_Privileges.class, ServicePriority.Highest, "net.krinsoft.privileges.Privileges");
|
||||
|
||||
// Try to load bPermissions
|
||||
hookPermission("bPermissions", Permission_bPermissions.class, ServicePriority.High, "de.bananaco.permissions.SuperPermissionHandler");
|
||||
|
||||
// Try to load GroupManager
|
||||
hookPermission("GroupManager", Permission_GroupManager.class, ServicePriority.High, "org.anjocaido.groupmanager.GroupManager");
|
||||
|
||||
// Try to load Permissions 3 (Yeti)
|
||||
hookPermission("Permissions 3 (Yeti)", Permission_Permissions3.class, ServicePriority.Normal, "com.nijiko.permissions.ModularControl");
|
||||
|
||||
// Try to load Xperms
|
||||
hookPermission("Xperms", Permission_Xperms.class, ServicePriority.Low, "com.github.sebc722.Xperms");
|
||||
|
||||
//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");
|
||||
|
||||
// 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("[Permission] SuperPermissions loaded as backup permission system."));
|
||||
|
|
|
@ -1,239 +0,0 @@
|
|||
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.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPerms;
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPermsAPI;
|
||||
|
||||
public class Chat_DroxPerms extends Chat {
|
||||
|
||||
private final Logger log;
|
||||
private final String name = "DroxPerms";
|
||||
private Plugin plugin;
|
||||
private DroxPermsAPI API;
|
||||
|
||||
public Chat_DroxPerms(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (API == null) {
|
||||
DroxPerms p = (DroxPerms) plugin.getServer().getPluginManager().getPlugin("DroxPerms");
|
||||
if (p != null) {
|
||||
API = p.getAPI();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (API == null) {
|
||||
Plugin permPlugin = event.getPlugin();
|
||||
if (permPlugin.getDescription().getName().equals("DroxPerms")) {
|
||||
API = ((DroxPerms) permPlugin).getAPI();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
String prefix = API.getPlayerInfo(player, "prefix");
|
||||
if (prefix == null) {
|
||||
String prigroup = API.getPlayerGroup(player);
|
||||
prefix = API.getGroupInfo(prigroup, "prefix");
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
API.setPlayerInfo(player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return API.getPlayerInfo(player, "suffix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
API.setPlayerInfo(player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return API.getGroupInfo(group, "prefix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
API.setGroupInfo(group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return API.getGroupInfo(group, "suffix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
API.setGroupInfo(group, "suffix", 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);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
API.setPlayerInfo(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);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
API.setGroupInfo(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);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
API.setPlayerInfo(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);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
API.setGroupInfo(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;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
API.setPlayerInfo(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;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
API.setGroupInfo(group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
String val = API.getPlayerInfo(player, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
API.setPlayerInfo(player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
String val = API.getGroupInfo(group, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
API.setGroupInfo(group, node, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,317 +0,0 @@
|
|||
/* 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.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.api.GroupManager;
|
||||
import com.overmc.overpermissions.api.PermissionGroup;
|
||||
import com.overmc.overpermissions.api.PermissionUser;
|
||||
import com.overmc.overpermissions.api.UserManager;
|
||||
import com.overmc.overpermissions.internal.OverPermissions;
|
||||
|
||||
public class Chat_OverPermissions extends Chat {
|
||||
protected final Plugin plugin;
|
||||
private OverPermissions overPerms;
|
||||
private UserManager userManager;
|
||||
private GroupManager groupManager;
|
||||
|
||||
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;
|
||||
userManager = overPerms.getUserManager();
|
||||
groupManager = overPerms.getGroupManager();
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", new Object[] {plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName( ) {
|
||||
return "OverPermissions_Chat";
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val.booleanValue() : defaultValue;
|
||||
}
|
||||
|
||||
@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) {
|
||||
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 {
|
||||
if (!user.hasMeta(node, world)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return user.getMeta(node, world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String playerName, String node, String value) {
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
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.", new Object[] {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.", new Object[] {plugin.getDescription().getName(), getName()}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,231 +0,0 @@
|
|||
/* 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.krinsoft.privileges.Privileges;
|
||||
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;
|
||||
|
||||
public class Chat_Privileges extends Chat {
|
||||
private static final String FRIENDLY_NAME = "Privileges - Chat";
|
||||
private static final String PLUGIN_NAME = "Privileges";
|
||||
private static final String CHAT_PREFIX_KEY = "prefix";
|
||||
private static final String CHAT_SUFFIX_KEY = "suffix";
|
||||
|
||||
private Privileges privs;
|
||||
private final Plugin plugin;
|
||||
|
||||
public Chat_Privileges(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
// Load service in case it was loaded before
|
||||
if (privs == null) {
|
||||
Plugin privsPlugin = plugin.getServer().getPluginManager().getPlugin(PLUGIN_NAME);
|
||||
if (privsPlugin != null && privsPlugin.isEnabled()) {
|
||||
this.privs = (Privileges) privsPlugin;
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), FRIENDLY_NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return FRIENDLY_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return privs != null && privs.isEnabled();
|
||||
}
|
||||
|
||||
private String getPlayerOrGroupInfoString(String world, String player, String key, String defaultValue) {
|
||||
String value = getPlayerInfoString(world, player, key, null);
|
||||
if (value != null) return value;
|
||||
|
||||
value = getGroupInfoString(world, getPrimaryGroup(world, player), key, null);
|
||||
if (value != null) return value;
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private void worldCheck(String world) {
|
||||
if (world != null && !world.isEmpty()) {
|
||||
throw new UnsupportedOperationException("Privileges does not support multiple worlds for player/group metadata.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return getPlayerOrGroupInfoString(world, player, CHAT_PREFIX_KEY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
setPlayerInfoString(world, player, CHAT_PREFIX_KEY, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return getPlayerOrGroupInfoString(world, player, CHAT_SUFFIX_KEY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
setPlayerInfoString(world, player, CHAT_SUFFIX_KEY, suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return getGroupInfoString(world, group, CHAT_PREFIX_KEY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
setGroupInfoString(world, group, CHAT_PREFIX_KEY, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return getGroupInfoString(world, group, CHAT_SUFFIX_KEY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
setGroupInfoString(world, group, CHAT_SUFFIX_KEY, suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
return privs.getUserNode(player).getInt(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
worldCheck(world);
|
||||
privs.getUserNode(player).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
return privs.getGroupNode(group).getInt(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
worldCheck(world);
|
||||
privs.getGroupNode(group).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
return privs.getUserNode(player).getDouble(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
worldCheck(world);
|
||||
privs.getUserNode(player).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
return privs.getGroupNode(group).getDouble(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
worldCheck(world);
|
||||
privs.getGroupNode(group).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
return privs.getUserNode(player).getBoolean(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
worldCheck(world);
|
||||
privs.getUserNode(player).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
return privs.getGroupNode(group).getBoolean(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
worldCheck(world);
|
||||
privs.getGroupNode(group).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
return privs.getUserNode(player).getString(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
worldCheck(world);
|
||||
privs.getUserNode(player).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
return privs.getGroupNode(group).getString(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
worldCheck(world);
|
||||
privs.getGroupNode(group).set(node, value);
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (privs == null) {
|
||||
Plugin permChat = event.getPlugin();
|
||||
if (PLUGIN_NAME.equals(permChat.getDescription().getName())) {
|
||||
if (permChat.isEnabled()) {
|
||||
privs = (Privileges) permChat;
|
||||
plugin.getLogger().info(String.format("[Chat] %s hooked.", FRIENDLY_NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (privs != null) {
|
||||
if (PLUGIN_NAME.equals(event.getPlugin().getDescription().getName())) {
|
||||
privs = null;
|
||||
plugin.getLogger().info(String.format("[Chat] %s un-hooked.", FRIENDLY_NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,287 +0,0 @@
|
|||
/* 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.ae97.totalpermissions.PermissionManager;
|
||||
import net.ae97.totalpermissions.TotalPermissions;
|
||||
import net.ae97.totalpermissions.permission.PermissionBase;
|
||||
import net.ae97.totalpermissions.permission.PermissionGroup;
|
||||
import net.ae97.totalpermissions.permission.PermissionUser;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @author Lord_Ralex
|
||||
*/
|
||||
public class Chat_TotalPermissions extends Chat {
|
||||
|
||||
private final Plugin plugin;
|
||||
private TotalPermissions totalPermissions;
|
||||
private final String name = "TotalPermissions-Chat";
|
||||
|
||||
public Chat_TotalPermissions(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
if (totalPermissions == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("TotalPermissions");
|
||||
if (chat != null) {
|
||||
if (chat.isEnabled()) {
|
||||
totalPermissions = (TotalPermissions) chat;
|
||||
plugin.getLogger().info(String.format("[Chat] %s hooked.", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
Chat_TotalPermissions chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_TotalPermissions chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat.totalPermissions == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
|
||||
if (perms != null) {
|
||||
if (perms.getDescription().getName().equals("TotalPermissions")) {
|
||||
if (perms.isEnabled()) {
|
||||
chat.totalPermissions = (TotalPermissions) perms;
|
||||
plugin.getLogger().info(String.format("[Chat] %s hooked.", chat.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (chat.totalPermissions != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("TotalPermissions")) {
|
||||
chat.totalPermissions = null;
|
||||
plugin.getLogger().info(String.format("[Chat] %s un-hooked.", chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return (totalPermissions == null ? false : totalPermissions.isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return this.getPlayerInfoString(world, player, "prefix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
this.setPlayerInfoString(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return this.getPlayerInfoString(world, player, "suffix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
this.setPlayerInfoString(world, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return this.getGroupInfoString(world, group, "prefix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
this.setGroupInfoString(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return this.getGroupInfoString(world, group, "suffix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
this.setGroupInfoString(world, group, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
Object pre = getPlayerInfo(world, player, node);
|
||||
if (pre instanceof Integer) {
|
||||
return (Integer) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
setPlayerInfo(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
Object pre = getGroupInfo(world, group, node);
|
||||
if (pre instanceof Integer) {
|
||||
return (Integer) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
setGroupInfo(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
Object pre = getPlayerInfo(world, player, node);
|
||||
if (pre instanceof Double) {
|
||||
return (Double) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
setPlayerInfo(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
Object pre = getGroupInfo(world, group, node);
|
||||
if (pre instanceof Double) {
|
||||
return (Double) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
setGroupInfo(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
Object pre = getPlayerInfo(world, player, node);
|
||||
if (pre instanceof Boolean) {
|
||||
return (Boolean) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
setPlayerInfo(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
Object pre = getGroupInfo(world, group, node);
|
||||
if (pre instanceof Boolean) {
|
||||
return (Boolean) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
setGroupInfo(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
Object pre = getPlayerInfo(world, player, node);
|
||||
if (pre instanceof String) {
|
||||
return (String) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
setPlayerInfo(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
Object pre = getGroupInfo(world, group, node);
|
||||
if (pre instanceof String) {
|
||||
return (String) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
setGroupInfo(world, group, node, value);
|
||||
}
|
||||
|
||||
private PermissionUser getUser(String name) {
|
||||
PermissionManager manager = totalPermissions.getManager();
|
||||
PermissionUser user = manager.getUser(name);
|
||||
return user;
|
||||
}
|
||||
|
||||
private PermissionGroup getGroup(String name) {
|
||||
PermissionManager manager = totalPermissions.getManager();
|
||||
PermissionGroup group = manager.getGroup(name);
|
||||
return group;
|
||||
}
|
||||
|
||||
private void setPlayerInfo(String world, String player, String node, Object value) {
|
||||
PermissionBase base = getUser(player);
|
||||
base.setOption(node, value, world);
|
||||
}
|
||||
|
||||
private void setGroupInfo(String world, String group, String node, Object value) {
|
||||
PermissionBase base = getGroup(group);
|
||||
base.setOption(node, value, world);
|
||||
}
|
||||
|
||||
private Object getPlayerInfo(String world, String player, String node) {
|
||||
PermissionBase base = getUser(player);
|
||||
return base.getOption(node);
|
||||
}
|
||||
|
||||
private Object getGroupInfo(String world, String group, String node) {
|
||||
PermissionBase base = getUser(group);
|
||||
return base.getOption(node);
|
||||
}
|
||||
}
|
|
@ -1,264 +0,0 @@
|
|||
/* 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 de.bananaco.permissions.Permissions;
|
||||
import de.bananaco.permissions.info.InfoReader;
|
||||
|
||||
public class Chat_bPermissions extends Chat {
|
||||
private final String name = "bInfo";
|
||||
private final Logger log;
|
||||
private Plugin plugin = null;
|
||||
InfoReader chat;
|
||||
|
||||
public Chat_bPermissions(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (chat == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("bPermissions");
|
||||
if (p != null) {
|
||||
chat = Permissions.getInfoReader();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "bPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_bPermissions chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_bPermissions chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (this.chat.chat == null) {
|
||||
Plugin chat = event.getPlugin();
|
||||
if (chat.getDescription().getName().equals("bPermissions")) {
|
||||
this.chat.chat = Permissions.getInfoReader();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "bPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (this.chat.chat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("bPermissions")) {
|
||||
this.chat.chat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "bPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return chat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return chat.getPrefix(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return chat.getSuffix(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return chat.getGroupPrefix(group, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return chat.getGroupSuffix(group, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@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 {
|
||||
int i = Integer.valueOf(s);
|
||||
return i;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@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 {
|
||||
int i = Integer.valueOf(s);
|
||||
return i;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@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 {
|
||||
double d = Double.valueOf(s);
|
||||
return d;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@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 {
|
||||
double d = Double.valueOf(s);
|
||||
return d;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
String val = chat.getValue(player, world, node);
|
||||
return (val == null || val == "BLANKWORLD") ? defaultValue : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
String val = chat.getGroupValue(group, world, node);
|
||||
return (val == null || val == "BLANKWORLD") ? defaultValue : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
}
|
|
@ -1,274 +0,0 @@
|
|||
/* 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.TheDgtl.iChat.iChat;
|
||||
import net.TheDgtl.iChat.iChatAPI;
|
||||
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;
|
||||
|
||||
public class Chat_iChat extends Chat {
|
||||
|
||||
private final Logger log;
|
||||
private final String name = "iChat";
|
||||
private Plugin plugin = null;
|
||||
private iChatAPI iChat = null;
|
||||
|
||||
public Chat_iChat(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (iChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("iChat");
|
||||
if (chat != null) {
|
||||
iChat = ((iChat) chat).API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "iChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_iChat chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_iChat chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (this.chat.iChat == null) {
|
||||
Plugin chat = event.getPlugin();
|
||||
if (chat.getDescription().getName().equals("iChat")) {
|
||||
this.chat.iChat = ((iChat) chat).API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "iChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (this.chat.iChat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("iChat")) {
|
||||
this.chat.iChat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "iChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return iChat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
|
||||
}
|
||||
|
||||
if (!p.getWorld().getName().equals(world)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return iChat.getPrefix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
|
||||
}
|
||||
|
||||
if (!p.getWorld().getName().equals(world)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return iChat.getSuffix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
String val = getPlayerInfoString(world, player, node, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
Integer i = defaultValue;
|
||||
try {
|
||||
i = Integer.valueOf(val);
|
||||
return i;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
String val = getPlayerInfoString(world, player, node, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
double d = defaultValue;
|
||||
try {
|
||||
d = Double.valueOf(val);
|
||||
return d;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String val = getPlayerInfoString(world, player, node, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean v = Boolean.valueOf(val);
|
||||
return v != null ? v : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
|
||||
}
|
||||
|
||||
if (!p.getWorld().getName().equals(world)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String val = iChat.getInfo(p, node);
|
||||
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
}
|
|
@ -1,251 +0,0 @@
|
|||
/* 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.D3GN.MiracleM4n.mChat.mChatAPI;
|
||||
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;
|
||||
|
||||
public class Chat_mChat extends Chat {
|
||||
private final Logger log;
|
||||
private final String name = "mChat";
|
||||
private Plugin plugin = null;
|
||||
private mChatAPI mChat = null;
|
||||
|
||||
public Chat_mChat(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (mChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChat");
|
||||
if (chat != null) {
|
||||
mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_mChat chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_mChat chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (this.chat.mChat == null) {
|
||||
Plugin chat = event.getPlugin();
|
||||
if (chat.getDescription().getName().equals("mChat")) {
|
||||
this.chat.mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (this.chat.mChat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("mChat")) {
|
||||
this.chat.mChat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return mChat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
Player p = Bukkit.getServer().getPlayer(player);
|
||||
if (p ==null) {
|
||||
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
|
||||
}
|
||||
return mChat.getPrefix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
Player p = Bukkit.getServer().getPlayer(player);
|
||||
if (p ==null) {
|
||||
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
|
||||
}
|
||||
return mChat.getSuffix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@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);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@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);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node,double defaultValue) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
Player p = Bukkit.getServer().getPlayer(player);
|
||||
if (p ==null) {
|
||||
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
|
||||
}
|
||||
String s = mChat.getInfo(p, node);
|
||||
return s == null ? defaultValue : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
}
|
|
@ -1,285 +0,0 @@
|
|||
/* 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 com.miraclem4n.mchat.api.Reader;
|
||||
import com.miraclem4n.mchat.api.Writer;
|
||||
import com.miraclem4n.mchat.types.InfoType;
|
||||
import in.mDev.MiracleM4n.mChatSuite.mChatSuite;
|
||||
|
||||
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;
|
||||
|
||||
public class Chat_mChatSuite extends Chat {
|
||||
private final Logger log;
|
||||
private final String name = "mChatSuite";
|
||||
private Plugin plugin = null;
|
||||
private mChatSuite mChat = null;
|
||||
|
||||
public Chat_mChatSuite(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (mChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChatSuite");
|
||||
if (chat != null && chat.isEnabled()) {
|
||||
mChat = (mChatSuite) chat;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChatSuite"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (mChat == null) {
|
||||
Plugin chat = event.getPlugin();
|
||||
if (chat.getDescription().getName().equals("mChatSuite")) {
|
||||
mChat = (mChatSuite) chat;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChatSuite"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (mChat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("mChatSuite")) {
|
||||
mChat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "mChatSuite"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return mChat != null && mChat.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return Reader.getPrefix(player, InfoType.USER, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
setPlayerInfoValue(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return Reader.getSuffix(player, InfoType.USER, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
setPlayerInfoValue(world, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return Reader.getPrefix(group, InfoType.GROUP, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
setGroupInfoValue(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return Reader.getSuffix(group, InfoType.GROUP, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
setGroupInfoValue(world, group, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
String val = getPlayerInfoValue(world, player, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
setPlayerInfoValue(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
String val = getGroupInfoValue(world, group, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
setGroupInfoValue(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
String val = getPlayerInfoValue(world, player, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Double.parseDouble(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
setPlayerInfoValue(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node,double defaultValue) {
|
||||
String val = getGroupInfoValue(world, group, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Double.parseDouble(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
setGroupInfoValue(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String val = getPlayerInfoValue(world, player, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
return Boolean.parseBoolean(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
setPlayerInfoValue(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
String val = getGroupInfoValue(world, group, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
return Boolean.valueOf(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
setGroupInfoValue(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
String val = getPlayerInfoValue(world, player, node);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
setPlayerInfoValue(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
String val = getGroupInfoValue(world, group, node);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
setGroupInfoValue(world, group, node, value);
|
||||
}
|
||||
|
||||
private void setPlayerInfoValue(String world, String player, String node, Object value) {
|
||||
if (world != null) {
|
||||
Writer.setWorldVar(player, InfoType.USER, world, node, value.toString());
|
||||
} else {
|
||||
Writer.setInfoVar(player, InfoType.USER, node, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void setGroupInfoValue(String world, String group, String node, Object value) {
|
||||
if (world != null) {
|
||||
Writer.setWorldVar(group, InfoType.GROUP, world, node, value);
|
||||
} else {
|
||||
Writer.setInfoVar(group, InfoType.GROUP, node, value);
|
||||
}
|
||||
}
|
||||
private String getPlayerInfoValue(String world, String player, String node) {
|
||||
return Reader.getInfo(player, InfoType.USER, world, node);
|
||||
}
|
||||
|
||||
private String getGroupInfoValue(String world, String group, String node) {
|
||||
return Reader.getInfo(group, InfoType.GROUP, world, node);
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
/* 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 final Logger log;
|
||||
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;
|
||||
this.log = plugin.getLogger();
|
||||
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][Chat] %s hooked.", vault.getDescription().getName(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "rscPermissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return rscpAPI != null && 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");
|
||||
}
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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 de.hydrox.bukkit.DroxPerms.DroxPerms;
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPermsAPI;
|
||||
|
||||
public class Permission_DroxPerms extends Permission {
|
||||
|
||||
private final String name = "DroxPerms";
|
||||
private DroxPermsAPI API;
|
||||
private boolean useOnlySubgroups;
|
||||
|
||||
public Permission_DroxPerms(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (API == null) {
|
||||
DroxPerms p = (DroxPerms) plugin.getServer().getPluginManager().getPlugin("DroxPerms");
|
||||
if (p != null) {
|
||||
API = p.getAPI();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), "DroxPerms"));
|
||||
useOnlySubgroups = p.getConfig().getBoolean("Vault.useOnlySubgroups", true);
|
||||
log.info(String.format("[%s][Permission] Vault.useOnlySubgroups: %s", plugin.getDescription().getName(), useOnlySubgroups));
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (API == null) {
|
||||
Plugin permPlugin = event.getPlugin();
|
||||
if (permPlugin.getDescription().getName().equals("DroxPerms")) {
|
||||
API = ((DroxPerms) permPlugin).getAPI();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(API != null) {
|
||||
if(event.getPlugin().getDescription().getName().equals("DroxPerms")) {
|
||||
API = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
return p != null ? p.hasPermission(permission) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return API.addPlayerPermission(player, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return API.removePlayerPermission(player, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return false; //Droxperms doesn't support direct permission checking of groups
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
return API.addGroupPermission(group, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
return API.removeGroupPermission(group, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
return API.getPlayerGroup(player).equalsIgnoreCase(group) || API.getPlayerSubgroups(player).contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (useOnlySubgroups) {
|
||||
return API.addPlayerSubgroup(player, group);
|
||||
} else {
|
||||
if ("default".equalsIgnoreCase(API.getPlayerGroup(player))) {
|
||||
return API.setPlayerGroup(player, group);
|
||||
} else {
|
||||
return API.addPlayerSubgroup(player, group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (useOnlySubgroups) {
|
||||
return API.removePlayerSubgroup(player, group);
|
||||
} else {
|
||||
if (group.equalsIgnoreCase(API.getPlayerGroup(player))) {
|
||||
return API.setPlayerGroup(player, "default");
|
||||
} else {
|
||||
return API.removePlayerSubgroup(player, group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
ArrayList<String> array = API.getPlayerSubgroups(player);
|
||||
array.add(API.getPlayerGroup(player));
|
||||
return array.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
return API.getPlayerGroup(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return API.getGroupNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
/* 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 java.util.List;
|
||||
|
||||
import com.lightniinja.kperms.KPlayer;
|
||||
import com.lightniinja.kperms.KGroup;
|
||||
import com.lightniinja.kperms.Utilities;
|
||||
import com.lightniinja.kperms.KPermsPlugin;
|
||||
|
||||
public class Permission_KPerms extends Permission {
|
||||
|
||||
private final Plugin vault;
|
||||
private KPermsPlugin kperms = null;
|
||||
|
||||
public Permission_KPerms(Plugin plugin) {
|
||||
super();
|
||||
this.vault = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), vault);
|
||||
if (kperms == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("KPerms");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
this.kperms = (KPermsPlugin) perms;
|
||||
plugin.getLogger().info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), "KPerms"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionServerListener implements Listener {
|
||||
private final Permission_KPerms bridge;
|
||||
|
||||
public PermissionServerListener(Permission_KPerms bridge) {
|
||||
this.bridge = bridge;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if(bridge.kperms == null) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
if (plugin.getDescription().getName().equals("KPerms")) {
|
||||
bridge.kperms = (KPermsPlugin) plugin;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", vault.getDescription().getName(), "KPerms"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(bridge.kperms != null){
|
||||
if(event.getPlugin().getDescription().getName().equals(bridge.kperms.getName())) {
|
||||
bridge.kperms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", vault.getDescription().getName(), "KPerms"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "KPerms";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return kperms.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
return new KPlayer(player, kperms).hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return new KPlayer(player, kperms).addPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return new KPlayer(player, kperms).removePermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return new KGroup(group, kperms).hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
return new KGroup(group, kperms).addPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
return new KGroup(group, kperms).removePermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
return new KPlayer(player, kperms).isMemberOfGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
return new KPlayer(player, kperms).addGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
return new KPlayer(player, kperms).removeGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
List<String> groups = new KPlayer(player, kperms).getGroups();
|
||||
String[] gr = new String[groups.size()];
|
||||
gr = groups.toArray(gr);
|
||||
return gr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
return new KPlayer(player, kperms).getPrimaryGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return new Utilities(kperms).getGroups();
|
||||
}
|
||||
}
|
|
@ -1,224 +0,0 @@
|
|||
/* 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.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.overmc.overpermissions.api.GroupManager;
|
||||
import com.overmc.overpermissions.api.PermissionGroup;
|
||||
import com.overmc.overpermissions.api.PermissionUser;
|
||||
import com.overmc.overpermissions.api.UserManager;
|
||||
import com.overmc.overpermissions.internal.OverPermissions;
|
||||
|
||||
public class Permission_OverPermissions extends Permission {
|
||||
private OverPermissions overPerms;
|
||||
private UserManager userManager;
|
||||
private GroupManager groupManager;
|
||||
|
||||
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);
|
||||
userManager = overPerms.getUserManager();
|
||||
groupManager = overPerms.getGroupManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", new Object[] {plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName( ) {
|
||||
return "OverPermissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled( ) {
|
||||
return (overPerms != null) && (overPerms.isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).addPermissionNode(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
return groupManager.getGroup(groupName).getPermission(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
String[] playerGroups = getPlayerGroups(worldName, playerName);
|
||||
if (playerGroups.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return playerGroups[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
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( ) {
|
||||
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.", new Object[] {Permission_OverPermissions.this.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.", new Object[] {Permission_OverPermissions.this.plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,295 +0,0 @@
|
|||
/* 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.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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.nijiko.permissions.Group;
|
||||
import com.nijiko.permissions.ModularControl;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
public class Permission_Permissions3 extends Permission {
|
||||
|
||||
private String name = "Permissions3";
|
||||
private ModularControl perms;
|
||||
private Permissions permission = null;
|
||||
|
||||
public Permission_Permissions3(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (permission == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
|
||||
if (perms == null) {
|
||||
plugin.getServer().getPluginManager().getPlugin("vPerms");
|
||||
name = "vPerms";
|
||||
}
|
||||
if (perms != null) {
|
||||
if (perms.isEnabled() && perms.getDescription().getVersion().startsWith("3")) {
|
||||
permission = (Permissions) perms;
|
||||
this.perms = (ModularControl) permission.getHandler();
|
||||
log.severe("Your permission system is outdated and no longer fully supported! It is highly advised to update!");
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (permission == null) {
|
||||
return false;
|
||||
} else {
|
||||
return permission.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String worldName, String playerName, String groupName) {
|
||||
return this.permission.getHandler().inGroup(worldName, playerName, groupName);
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission == null) {
|
||||
Plugin permi = event.getPlugin();
|
||||
if((permi.getDescription().getName().equals("Permissions") || permi.getDescription().getName().equals("vPerms")) && permi.getDescription().getVersion().startsWith("3")) {
|
||||
if (permi.isEnabled()) {
|
||||
permission = (Permissions) permi;
|
||||
perms = (ModularControl) permission.getHandler();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions") || event.getPlugin().getDescription().getName().equals("vPerms")) {
|
||||
permission = null;
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
if (sender.isOp() || !(sender instanceof Player)) {
|
||||
return true;
|
||||
} else {
|
||||
return has(((Player) sender).getWorld().getName(), sender.getName(), permission);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(Player player, String permission) {
|
||||
return has(player.getWorld().getName(), player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
||||
Group g = perms.getGroupObject(worldName, groupName);
|
||||
if (g == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
perms.safeGetUser(worldName, playerName).addParent(g);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
||||
Group g = perms.getGroupObject(worldName, groupName);
|
||||
if (g == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
perms.safeGetUser(worldName, playerName).removeParent(g);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String worldName, String playerName, String permission) {
|
||||
this.perms.addUserPermission(worldName, playerName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String worldName, String playerName, String permission) {
|
||||
this.perms.removeUserPermission(worldName, playerName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
||||
perms.addGroupPermission(worldName, groupName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
perms.removeGroupPermission(worldName, groupName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String worldName, String groupName, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
try {
|
||||
return perms.safeGetGroup(worldName, groupName).hasPermission(permission);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String playerName) {
|
||||
return this.perms.getGroups(world, playerName);
|
||||
}
|
||||
|
||||
public String getPrimaryGroup(String world, String playerName) {
|
||||
return getPlayerGroups(world, playerName)[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String worldName, String playerName, String permission) {
|
||||
Player p = plugin.getServer().getPlayer(playerName);
|
||||
if (p != null) {
|
||||
if (p.hasPermission(permission))
|
||||
return true;
|
||||
}
|
||||
return this.perms.has(worldName, playerName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(Player player, String permission) {
|
||||
return playerAddTransient(null, player.getName(), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String worldName, Player player, String permission) {
|
||||
return playerAddTransient(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
private boolean playerAddTransient(String worldName, String player, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
try {
|
||||
perms.safeGetUser(worldName, player).addTransientPermission(permission);
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(Player player, String permission) {
|
||||
return pRemoveTransient(null, player.getName(), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String worldName, Player player, String permission) {
|
||||
return pRemoveTransient(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
|
||||
Set<String> groupNames = new HashSet<String>();
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
for (Group group : perms.getGroups(world.getName())) {
|
||||
groupNames.add(group.getName());
|
||||
}
|
||||
}
|
||||
return groupNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean pRemoveTransient(String worldName, String player, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
||||
try {
|
||||
perms.safeGetUser(worldName, player).removeTransientPermission(permission);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,237 +0,0 @@
|
|||
/* 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 java.util.List;
|
||||
|
||||
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.platymuus.bukkit.permissions.Group;
|
||||
import com.platymuus.bukkit.permissions.PermissionInfo;
|
||||
import com.platymuus.bukkit.permissions.PermissionsPlugin;
|
||||
|
||||
public class Permission_PermissionsBukkit extends Permission {
|
||||
|
||||
private final String name = "PermissionsBukkit";
|
||||
private PermissionsPlugin perms = null;
|
||||
|
||||
public Permission_PermissionsBukkit(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("PermissionsBukkit");
|
||||
if (perms != null) {
|
||||
this.perms = (PermissionsPlugin) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_PermissionsBukkit permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_PermissionsBukkit permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.perms == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
if (perms.getDescription().getName().equals("PermissionsBukkit")) {
|
||||
permission.perms = (PermissionsPlugin) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission.perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("PermissionsBukkit")) {
|
||||
permission.perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (perms == null) {
|
||||
return false;
|
||||
} else {
|
||||
return perms.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
if (Bukkit.getPlayer(player) != null) {
|
||||
return Bukkit.getPlayer(player).hasPermission(permission);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions player setperm " + player + " " + permission + " true");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions player unsetperm " + player + " " + permission);
|
||||
}
|
||||
|
||||
// use superclass implementation of playerAddTransient() and playerRemoveTransient()
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
if (world != null && !world.isEmpty()) {
|
||||
return perms.getGroup(group).getInfo().getWorldPermissions(world).get(permission) == null ? false : perms.getGroup(group).getInfo().getWorldPermissions(world).get(permission);
|
||||
}
|
||||
if (perms.getGroup(group) == null) {
|
||||
return false;
|
||||
} else if (perms.getGroup(group).getInfo() == null) {
|
||||
return false;
|
||||
} else if (perms.getGroup(group).getInfo().getPermissions() == null) {
|
||||
return false;
|
||||
}
|
||||
return perms.getGroup(group).getInfo().getPermissions().get(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions group setperm " + group + " " + permission + " true");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions group unsetperm " + group + " " + permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
for (Group g : perms.getPlayerInfo(player).getGroups()) {
|
||||
if (g.getName().equals(group)) {
|
||||
return g.getInfo().getWorlds().contains(world);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Group g = perms.getGroup(group);
|
||||
if (g == null) {
|
||||
return false;
|
||||
}
|
||||
return g.getPlayers().contains(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
return false;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions player addgroup " + player + " " + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
return false;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions player removegroup " + player + " " + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
List<String> groupList = new ArrayList<String>();
|
||||
PermissionInfo info = perms.getPlayerInfo(player);
|
||||
if (world != null && info != null) {
|
||||
for (Group group : perms.getPlayerInfo(player).getGroups()) {
|
||||
if (group.getInfo().getWorlds().contains(world)) {
|
||||
groupList.add(group.getName());
|
||||
}
|
||||
}
|
||||
return groupList.toArray(new String[0]);
|
||||
}
|
||||
if (info != null) {
|
||||
for (Group group : info.getGroups()) {
|
||||
groupList.add(group.getName());
|
||||
}
|
||||
}
|
||||
return groupList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
if (perms.getPlayerInfo(player) == null) {
|
||||
return null;
|
||||
} else if (perms.getPlayerInfo(player).getGroups() != null && !perms.getPlayerInfo(player).getGroups().isEmpty() ) {
|
||||
return perms.getPlayerInfo(player).getGroups().get(0).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
List<String> groupNames = new ArrayList<String>();
|
||||
for (Group group : perms.getAllGroups()) {
|
||||
groupNames.add(group.getName());
|
||||
}
|
||||
|
||||
return groupNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import net.krinsoft.privileges.Privileges;
|
||||
import net.krinsoft.privileges.groups.Group;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Permission_Privileges extends Permission {
|
||||
|
||||
private final String name = "Privileges";
|
||||
private Privileges privs;
|
||||
|
||||
public Permission_Privileges(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
// Load service in case it was loaded before
|
||||
if (privs == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Privileges");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
this.privs = (Privileges) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_Privileges permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_Privileges permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.privs == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
if (perms.getDescription().getName().equals("Privileges")) {
|
||||
permission.privs = (Privileges) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission.privs != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Privileges")) {
|
||||
permission.privs = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
return p != null && p.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// use superclass implementation of playerAddTransient() and playerRemoveTransient()
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
Group g = privs.getGroupManager().getGroup(group);
|
||||
return g != null && g.hasPermission(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
Group g = privs.getGroupManager().getGroup(group);
|
||||
return g != null && g.addPermission(world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
Group g = privs.getGroupManager().getGroup(group);
|
||||
return g != null && g.removePermission(world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
Group g = privs.getGroupManager().getGroup(p);
|
||||
return g != null && g.isMemberOf(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
Group g = privs.getGroupManager().setGroup(player, group);
|
||||
return g != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
Group g = privs.getGroupManager().getDefaultGroup();
|
||||
return g != null && playerAddGroup(world, player, g.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException("Privileges does not support offline players.");
|
||||
}
|
||||
Group g = privs.getGroupManager().getGroup(p);
|
||||
return g != null ? g.getGroupTree().toArray(new String[g.getGroupTree().size()]) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
Group g = privs.getGroupManager().getGroup(p);
|
||||
return g != null ? g.getName() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
List<String> groups = new ArrayList<String>();
|
||||
for (Group g : privs.getGroupManager().getGroups()) {
|
||||
groups.add(g.getName());
|
||||
}
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,226 +0,0 @@
|
|||
/* 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 java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
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;
|
||||
|
||||
public class Permission_SimplyPerms extends Permission{
|
||||
|
||||
private final String name = "SimplyPerms";
|
||||
private SimplyAPI perms;
|
||||
|
||||
public Permission_SimplyPerms(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
// Load service in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("SimplyPerms");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
this.perms = ((SimplyPlugin) perms).getAPI();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_SimplyPerms permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_SimplyPerms permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.perms == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
if (perms.getDescription().getName().equals("SimplyPerms")) {
|
||||
permission.perms = ((SimplyPlugin) perms).getAPI();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission.perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("SimplyPerms")) {
|
||||
permission.perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return perms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
Map<String, Boolean> playerPermissions = this.perms.getPlayerPermissions(player, world);
|
||||
return playerPermissions.containsKey(permission) && playerPermissions.get(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
if (world != null) {
|
||||
this.perms.addPlayerPermission(player, world, permission, true);
|
||||
} else {
|
||||
this.perms.addPlayerPermission(player, permission, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
if (world != null) {
|
||||
this.perms.removePlayerPermission(player, world, permission);
|
||||
} else {
|
||||
this.perms.removePlayerPermission(player, permission);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
Map<String, Boolean> groupPermissions = this.perms.getGroupPermissions(group, world);
|
||||
return groupPermissions.containsKey(permission) && groupPermissions.get(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
if (world != null) {
|
||||
this.perms.addGroupPermission(group, world, permission, true);
|
||||
} else {
|
||||
this.perms.addGroupPermission(group, permission, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
this.perms.removeGroupPermission(group, world, permission);
|
||||
} else {
|
||||
this.perms.removeGroupPermission(group, permission);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
for (String g : perms.getPlayerGroups(player)) {
|
||||
if (g.equals(group)) {
|
||||
return perms.getGroupWorlds(group).contains(world);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!perms.getAllGroups().contains(group)) {
|
||||
return false;
|
||||
}
|
||||
return perms.getPlayerGroups(player).contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
group = group.toLowerCase();
|
||||
this.perms.addPlayerGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
group = group.toLowerCase();
|
||||
this.perms.removePlayerGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
List<String> groupList = new ArrayList<String>();
|
||||
if (world != null && perms.isPlayerInDB(player)) {
|
||||
for (String group : perms.getPlayerGroups(player)) {
|
||||
if (perms.getGroupWorlds(group).contains(world)) {
|
||||
groupList.add(group);
|
||||
}
|
||||
}
|
||||
return groupList.toArray(new String[0]);
|
||||
}
|
||||
if (perms.isPlayerInDB(player)) {
|
||||
for (String group : perms.getPlayerGroups(player)) {
|
||||
groupList.add(group);
|
||||
}
|
||||
}
|
||||
return groupList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
if (!perms.isPlayerInDB(player)) {
|
||||
return null;
|
||||
} else if (perms.getPlayerGroups(player) != null && !perms.getPlayerGroups(player).isEmpty() ) {
|
||||
return perms.getPlayerGroups(player).get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return perms.getAllGroups().toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,307 +0,0 @@
|
|||
/* 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 java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
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.dthielke.starburst.Group;
|
||||
import com.dthielke.starburst.GroupManager;
|
||||
import com.dthielke.starburst.GroupSet;
|
||||
import com.dthielke.starburst.StarburstPlugin;
|
||||
import com.dthielke.starburst.User;
|
||||
|
||||
public class Permission_Starburst extends Permission {
|
||||
private StarburstPlugin perms;
|
||||
private final String name = "Starburst";
|
||||
|
||||
public Permission_Starburst(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("Starburst");
|
||||
if (p != null) {
|
||||
perms = (StarburstPlugin) p;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (perms == null) {
|
||||
Plugin p = event.getPlugin();
|
||||
if (p.getDescription().getName().equals("Starburst")) {
|
||||
perms = (StarburstPlugin) p;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Starburst")) {
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
String[] s = new String[perms.getGroupManager().getDefaultGroupSet().getGroups().size()];
|
||||
int i = 0;
|
||||
for (Group g : perms.getGroupManager().getDefaultGroupSet().getGroups()) {
|
||||
s[i] = g.getName();
|
||||
i++;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
Set<Group> children = user.getChildren(true);
|
||||
List<String> groups = new ArrayList<String>();
|
||||
for (Group child : children) {
|
||||
groups.add(child.getName());
|
||||
}
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
Set<Group> children = user.getChildren(false);
|
||||
if (!children.isEmpty()) {
|
||||
return children.iterator().next().getName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
GroupManager gm = perms.getGroupManager();
|
||||
GroupSet set = gm.getWorldSet(Bukkit.getWorld(world));
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
|
||||
boolean value = !permission.startsWith("^");
|
||||
permission = value ? permission : permission.substring(1);
|
||||
g.addPermission(permission, value, true, true);
|
||||
|
||||
for (User user : gm.getAffectedUsers(g)) {
|
||||
user.applyPermissions(gm.getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
return g.hasPermission(permission, true);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
GroupManager gm = perms.getGroupManager();
|
||||
GroupSet set = gm.getWorldSet(Bukkit.getWorld(world));
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
|
||||
boolean value = !permission.startsWith("^");
|
||||
permission = value ? permission : permission.substring(1);
|
||||
|
||||
if (g.hasPermission(permission, false)) {
|
||||
g.removePermission(permission, true);
|
||||
|
||||
for (User user : gm.getAffectedUsers(g)) {
|
||||
user.applyPermissions(gm.getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return perms != null && perms.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
boolean value = !permission.startsWith("^");
|
||||
permission = value ? permission : permission.substring(1);
|
||||
user.addPermission(permission, value, true, true);
|
||||
|
||||
if (user.isActive()) {
|
||||
user.applyPermissions(perms.getGroupManager().getFactory());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
if (!user.hasChild(g, false)) {
|
||||
user.addChild(g, true);
|
||||
|
||||
if (user.isActive()) {
|
||||
user.applyPermissions(perms.getGroupManager().getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
|
||||
if (op.isOnline()) {
|
||||
Player p = (Player) op;
|
||||
if (p.getWorld().getName().equalsIgnoreCase(world)) {
|
||||
return p.hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
Group user = set.getUser(op);
|
||||
return user.hasPermission(permission, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
return user.hasChild(g, true);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
boolean value = !permission.startsWith("^");
|
||||
permission = value ? permission : permission.substring(1);
|
||||
if (user.hasPermission(permission, false)) {
|
||||
user.removePermission(permission, true);
|
||||
if (user.isActive()) {
|
||||
user.applyPermissions(perms.getGroupManager().getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
if (user.hasChild(g, false)) {
|
||||
user.removeChild(g, true);
|
||||
|
||||
if (user.isActive()) {
|
||||
user.applyPermissions(perms.getGroupManager().getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,211 +0,0 @@
|
|||
/* 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.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import net.ae97.totalpermissions.PermissionManager;
|
||||
import net.ae97.totalpermissions.TotalPermissions;
|
||||
import net.ae97.totalpermissions.permission.PermissionBase;
|
||||
import net.ae97.totalpermissions.permission.PermissionUser;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
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;
|
||||
|
||||
public class Permission_TotalPermissions extends Permission {
|
||||
|
||||
private final String name = "TotalPermissions";
|
||||
private PermissionManager manager;
|
||||
private TotalPermissions totalperms;
|
||||
|
||||
public Permission_TotalPermissions(Plugin pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (manager == null || totalperms == null) {
|
||||
Plugin permPlugin = event.getPlugin();
|
||||
if (permPlugin.getDescription().getName().equals(name)) {
|
||||
totalperms = (TotalPermissions) permPlugin;
|
||||
manager = totalperms.getManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (manager != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals(name)) {
|
||||
totalperms = null;
|
||||
manager = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return plugin != null && plugin.isEnabled() && totalperms != null && totalperms.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
PermissionBase user = manager.getUser(player);
|
||||
return user.has(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
try {
|
||||
PermissionBase user = manager.getUser(player);
|
||||
user.addPerm(permission, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
try {
|
||||
PermissionBase user = manager.getUser(player);
|
||||
user.remPerm(permission, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
PermissionBase permGroup = manager.getGroup(group);
|
||||
return permGroup.has(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
try {
|
||||
PermissionBase permGroup = manager.getGroup(group);
|
||||
permGroup.addPerm(permission, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
try {
|
||||
PermissionBase permGroup = manager.getGroup(group);
|
||||
permGroup.remPerm(permission, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
PermissionUser user = manager.getUser(player);
|
||||
List<String> groups = user.getGroups(world);
|
||||
return groups.contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
try {
|
||||
PermissionUser user = manager.getUser(player);
|
||||
user.addGroup(group, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
try {
|
||||
PermissionUser user = manager.getUser(player);
|
||||
user.remGroup(group, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
PermissionUser user = manager.getUser(player);
|
||||
List<String> groups = user.getGroups(world);
|
||||
if (groups == null) {
|
||||
groups = new ArrayList<String>();
|
||||
}
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
String[] groups = getPlayerGroups(world, player);
|
||||
if (groups.length == 0) {
|
||||
return "";
|
||||
} else {
|
||||
return groups[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return manager.getGroups();
|
||||
}
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
/* 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 com.github.sebc722.xperms.core.Main;
|
||||
|
||||
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;
|
||||
|
||||
public class Permission_Xperms extends Permission {
|
||||
|
||||
private final String name = "Xperms";
|
||||
private Main perms = null;
|
||||
|
||||
public Permission_Xperms(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
if(perms == null){
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Xperms");
|
||||
if(this.perms != null){
|
||||
if(perms.isEnabled()){
|
||||
try{
|
||||
if(Double.valueOf(perms.getDescription().getVersion()) < 1.1){
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatible with vault! Please Update!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
} catch(NumberFormatException e){
|
||||
// version is first release, numbered 1.0.0
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatibe with vault! Please Update!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
this.perms = (Main) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_Xperms permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_Xperms permission){
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.perms == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
if(perms.getDescription().getName().equals("Xperms")){
|
||||
try{
|
||||
if(Double.valueOf(perms.getDescription().getVersion()) < 1.1){
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatible with vault! Please Update!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
} catch(NumberFormatException e){
|
||||
// version is first release, numbered 1.0.0
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatibe with vault! Please Update!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
permission.perms = (Main) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(permission.perms != null){
|
||||
if(event.getPlugin().getName().equals("Xperms")){
|
||||
permission.perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return perms.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
return perms.getXplayer().hasPerm(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return perms.getXplayer().addNode(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return perms.getXplayer().removeNode(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return perms.getXgroup().hasPerm(group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
perms.getXgroup().addNode(group, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
return perms.getXgroup().removeNode(group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
String groupForWorld = perms.getXplayer().getGroupForWorld(player, world);
|
||||
if(groupForWorld.equals(group)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
return perms.getXplayer().setPlayerGroup(world, player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
return perms.getXplayer().setPlayerDefault(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
return perms.getXplayer().getPlayerGroups(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
return perms.getXplayer().getGroupForWorld(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return perms.getXgroup().getGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,281 +0,0 @@
|
|||
/* 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.List;
|
||||
|
||||
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 de.bananaco.permissions.Permissions;
|
||||
import de.bananaco.permissions.interfaces.PermissionSet;
|
||||
import de.bananaco.permissions.worlds.HasPermission;
|
||||
import de.bananaco.permissions.worlds.WorldPermissionsManager;
|
||||
|
||||
public class Permission_bPermissions extends Permission {
|
||||
|
||||
private final String name = "bPermissions";
|
||||
private WorldPermissionsManager perms;
|
||||
|
||||
public Permission_bPermissions(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("bPermissions");
|
||||
if (p != null) {
|
||||
perms = Permissions.getWorldPermissionsManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (perms == null) {
|
||||
Plugin p = event.getPlugin();
|
||||
if(p.getDescription().getName().equals("bPermissions") && p.isEnabled()) {
|
||||
perms = Permissions.getWorldPermissionsManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("bPermissions")) {
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.perms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
return HasPermission.has(player, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.addPlayerNode(permission, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.removePlayerNode(permission, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
// use superclass implementation of playerAddTransient() and playerRemoveTransient()
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroupNodes(group) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return set.getGroupNodes(group).contains(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroupNodes(group) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.addNode(permission, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroupNodes(group) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.removeNode(permission, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroups(player) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return set.getGroups(player).contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroupNodes(group) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.addGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.removeGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> groups = set.getGroups(player);
|
||||
return groups == null ? null : groups.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> groups = set.getGroups(player);
|
||||
if (groups == null || groups.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return groups.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
throw new UnsupportedOperationException("bPermissions does not support server-wide groups");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
/* 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 rscpAPI = null;
|
||||
|
||||
public Permission_rscPermissions(Plugin plugin) {
|
||||
super();
|
||||
this.vault = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(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][Permission] %s hooked.", plugin.getDescription().getName(), "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(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "rscPermissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return rscpAPI != null && 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