mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-12-28 20:07:55 +01:00
commit
4ae1bd67b7
BIN
lib/KPerms.jar
Normal file
BIN
lib/KPerms.jar
Normal file
Binary file not shown.
9
pom.xml
9
pom.xml
@ -10,7 +10,7 @@
|
||||
<url>http://dev.bukkit.org/server-mods/vault/</url>
|
||||
<description>Vault is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves.
|
||||
|
||||
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy, TAEcon</description>
|
||||
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, KPerms, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy, TAEcon</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -377,6 +377,13 @@ 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>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/KPerms.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -82,6 +82,7 @@ import net.milkbowl.vault.permission.plugins.Permission_bPermissions2;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_zPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_TotalPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_rscPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_KPerms;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -376,6 +377,9 @@ public class Vault extends JavaPlugin {
|
||||
// Try to load rscPermissions
|
||||
hookPermission("rscPermissions", Permission_rscPermissions.class, ServicePriority.Normal, "ru.simsonic.rscPermissions.MainPluginClass");
|
||||
|
||||
//Try to load KPerms
|
||||
hookPermission("KPerms", Permission_KPerms.class, ServicePriority.Normal, "com.lightniinja.kperms.KPermsPlugin");
|
||||
|
||||
Permission perms = new Permission_SuperPerms(this);
|
||||
sm.register(Permission.class, perms, this, ServicePriority.Lowest);
|
||||
log.info(String.format("[%s][Permission] SuperPermissions loaded as backup permission system.", getDescription().getName()));
|
||||
|
164
src/net/milkbowl/vault/permission/plugins/Permission_KPerms.java
Normal file
164
src/net/milkbowl/vault/permission/plugins/Permission_KPerms.java
Normal file
@ -0,0 +1,164 @@
|
||||
/* 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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user