mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-10 21:01:03 +01:00
added support for DroxPerms - thanks Spyboticsguy
This commit is contained in:
parent
7a45547610
commit
4205aa5709
BIN
lib/DroxPerms.jar
Normal file
BIN
lib/DroxPerms.jar
Normal file
Binary file not shown.
7
pom.xml
7
pom.xml
@ -13,6 +13,13 @@
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.2.5-R3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hydrox.bukkit.DroxPerms</groupId>
|
||||
<artifactID>DroxPerms</artifactID>
|
||||
<version>0.3.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/DroxPerms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.krinsoft.privileges</groupId>
|
||||
<artifactId>Privileges</artifactId>
|
||||
|
@ -25,6 +25,7 @@ import java.util.logging.Logger;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
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_Permissions3;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_PermissionsEx;
|
||||
@ -51,6 +52,7 @@ import net.milkbowl.vault.economy.plugins.Economy_iConomy4;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy5;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy6;
|
||||
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_Permissions3;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_PermissionsBukkit;
|
||||
@ -165,6 +167,7 @@ public class Vault extends JavaPlugin {
|
||||
} catch (Exception e) {
|
||||
log.severe(String.format("There was an error hooking %s - check to make sure you're using a compatible version!", "PEX Chat"));
|
||||
}
|
||||
|
||||
try {
|
||||
//Try loading mChatSuite
|
||||
if (packageExists("in.mDev.MiracleM4n.mChatSuite.mChatSuite")) {
|
||||
@ -187,11 +190,22 @@ public class Vault extends JavaPlugin {
|
||||
log.severe(String.format("There was an error hooking %s - check to make sure you're using a compatible version!", "mChat"));
|
||||
}
|
||||
|
||||
try {
|
||||
//try to load DroxPerms Chat
|
||||
if (packageExists("de.hydrox.bukkit.DroxPerms.DroxPerms")) {
|
||||
Chat droxChat = new Chat_DroxPerms(this, perms);
|
||||
sm.register(Chat.class, droxChat, this, ServicePriority.Lowest);
|
||||
log.info(String.format("[%s][Chat] DroxPerms found: %s", getDescription().getName(), droxChat.isEnabled() ? "Loaded" : "Waiting"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.severe(String.format("There was an error hooking %s - check to make sure you're using a compatible version!", "DroxPerms"));
|
||||
}
|
||||
|
||||
try {
|
||||
//try loading bPermssions 2
|
||||
if (packageExists("de.bananaco.bpermissions.api.ApiLayer")) {
|
||||
Chat bPerms = new Chat_bPermissions2(this, perms);
|
||||
sm.register(Chat.class, bPerms, this, ServicePriority.High);
|
||||
sm.register(Chat.class, bPerms, this, ServicePriority.Highest);
|
||||
log.info(String.format("[%s][Chat] bPermissions2 found: %s", getDescription().getName(), bPerms.isEnabled() ? "Loaded" : "Waiting"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -462,6 +476,17 @@ public class Vault extends JavaPlugin {
|
||||
log.severe(String.format("There was an error hooking %s - check to make sure you're using a compatible version!", "PermissionsBukkit"));
|
||||
}
|
||||
|
||||
try {
|
||||
//Try to load DroxPerms
|
||||
if (packageExists("de.hydrox.bukkit.DroxPerms.DroxPerms")) {
|
||||
Permission dPerms = new Permission_DroxPerms(this);
|
||||
sm.register(Permission.class, dPerms, this, ServicePriority.High);
|
||||
log.info(String.format("[%s][Permission] DroxPerms found: %s", getDescription().getName(), dPerms.isEnabled() ? "Loaded" : "Waiting"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.severe(String.format("There was an error hooking %s - check to make sure you're using a compatible version!", "DroxPerms"));
|
||||
}
|
||||
|
||||
try {
|
||||
//Try loading SimplyPerms
|
||||
if (packageExists("net.crystalyx.bukkit.simplyperms.SimplyPlugin")) {
|
||||
@ -505,7 +530,7 @@ public class Vault extends JavaPlugin {
|
||||
} catch (Exception e) {
|
||||
log.severe(String.format("There was an error hooking %s - check to make sure you're using a compatible version!", "Privileges"));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
//Try to load bPermissions
|
||||
if (packageExists("de.bananaco.permissions.SuperPermissionHandler")) {
|
||||
|
235
src/net/milkbowl/vault/chat/plugins/Chat_DroxPerms.java
Normal file
235
src/net/milkbowl/vault/chat/plugins/Chat_DroxPerms.java
Normal file
@ -0,0 +1,235 @@
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.Vault;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPerms;
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPermsAPI;
|
||||
|
||||
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;
|
||||
|
||||
public class Chat_DroxPerms extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "DroxPerms";
|
||||
private Vault plugin;
|
||||
private DroxPermsAPI API;
|
||||
|
||||
public Chat_DroxPerms(Vault plugin, Permission perms) {
|
||||
super(perms);
|
||||
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][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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.milkbowl.vault.Vault;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPerms;
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPermsAPI;
|
||||
|
||||
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_DroxPerms extends Permission {
|
||||
|
||||
private final String name = "DroxPerms";
|
||||
private DroxPermsAPI API;
|
||||
|
||||
public Permission_DroxPerms(Vault 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"));
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
throw new UnsupportedOperationException(getName() + " no groupHas.");
|
||||
}
|
||||
|
||||
@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) {
|
||||
return API.addPlayerSubgroup(player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
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 null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user