mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-12-29 12:28:35 +01:00
hook vPerms in the P3 interface by checking alternative plugin names,
should work as long as they don't change package names.
This commit is contained in:
parent
c62879809c
commit
3e148ea58a
@ -12,7 +12,7 @@
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
@ -32,115 +32,119 @@ import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
public class Chat_Permissions3 extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "Permissions 3 (Yeti) - Chat";
|
||||
private PermissionHandler perms;
|
||||
private Plugin plugin = null;
|
||||
private Permissions chat = null;
|
||||
private String name = "Permissions 3 (Yeti) - Chat";
|
||||
private PermissionHandler perms;
|
||||
private Plugin plugin = null;
|
||||
private Permissions chat = null;
|
||||
|
||||
public Chat_Permissions3(Plugin plugin, Permission permissions) {
|
||||
super(permissions);
|
||||
this.plugin = plugin;
|
||||
public Chat_Permissions3(Plugin plugin, Permission permissions) {
|
||||
super(permissions);
|
||||
this.plugin = plugin;
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (chat == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
|
||||
if (perms != null) {
|
||||
if (perms.isEnabled() && perms.getDescription().getVersion().startsWith("3")) {
|
||||
chat = (Permissions) perms;
|
||||
this.perms = chat.getHandler();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat == null) {
|
||||
Plugin permChat = event.getPlugin();
|
||||
if(permChat.getDescription().getName().equals("Permissions") && permChat.getDescription().getVersion().startsWith("3")) {
|
||||
if (permChat.isEnabled()) {
|
||||
chat = (Permissions) permChat;
|
||||
perms = chat.getHandler();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Load Plugin in case it was loaded before
|
||||
if (chat == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
|
||||
if (perms == null) {
|
||||
plugin.getServer().getPluginManager().getPlugin("vPerms");
|
||||
name = "vPerms - Chat";
|
||||
}
|
||||
if (perms != null) {
|
||||
if (perms.isEnabled() && perms.getDescription().getVersion().startsWith("3")) {
|
||||
chat = (Permissions) perms;
|
||||
this.perms = chat.getHandler();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (chat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
|
||||
chat = null;
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat == null) {
|
||||
Plugin permChat = event.getPlugin();
|
||||
if((permChat.getDescription().getName().equals("Permissions") || permChat.getDescription().getName().equals("vPerms")) && permChat.getDescription().getVersion().startsWith("3")) {
|
||||
if (permChat.isEnabled()) {
|
||||
chat = (Permissions) permChat;
|
||||
perms = chat.getHandler();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (chat == null) {
|
||||
return false;
|
||||
} else {
|
||||
return chat.isEnabled();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
|
||||
Integer i = this.perms.getPermissionInteger(world, playerName, node);
|
||||
return (i == null) ? defaultValue : i;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (chat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions") || event.getPlugin().getDescription().getName().equals("vPerms")) {
|
||||
chat = null;
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
|
||||
Double d = this.perms.getPermissionDouble(world, playerName, node);
|
||||
return (d == null) ? defaultValue : d;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
|
||||
Boolean b = this.perms.getPermissionBoolean(world, playerName, node);
|
||||
return (b == null) ? defaultValue : b;
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (chat == null) {
|
||||
return false;
|
||||
} else {
|
||||
return chat.isEnabled();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
|
||||
Integer i = this.perms.getPermissionInteger(world, playerName, node);
|
||||
return (i == null) ? defaultValue : i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
|
||||
String s = this.perms.getPermissionString(world, playerName, node);
|
||||
return (s == null) ? defaultValue : s;
|
||||
}
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
|
||||
Double d = this.perms.getPermissionDouble(world, playerName, node);
|
||||
return (d == null) ? defaultValue : d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String playerName) {
|
||||
return getPlayerInfoString(world, playerName, "prefix", null);
|
||||
}
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
|
||||
Boolean b = this.perms.getPermissionBoolean(world, playerName, node);
|
||||
return (b == null) ? defaultValue : b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String playerName) {
|
||||
return getPlayerInfoString(world, playerName, "suffix", null);
|
||||
}
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
|
||||
String s = this.perms.getPermissionString(world, playerName, node);
|
||||
return (s == null) ? defaultValue : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
}
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String playerName) {
|
||||
return getPlayerInfoString(world, playerName, "prefix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
//this.perms.addUserInfo(world, player, "prefix", prefix);
|
||||
}
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String playerName) {
|
||||
return getPlayerInfoString(world, playerName, "suffix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
//this.perms.addUserInfo(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
public void setPlayerInfo(String world, String playerName, String node, Object value) {
|
||||
//this.perms.addUserInfo(world, playerName, node, value);
|
||||
@ -170,10 +174,10 @@ public class Chat_Permissions3 extends Chat {
|
||||
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
|
||||
//Integer i = this.perms.getInfoInteger(world, groupName, node, true);
|
||||
//return (i == null) ? defaultValue : i;
|
||||
return defaultValue;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setGroupInfo(String world, String groupName, String node, Object value) {
|
||||
this.perms.addGroupInfo(world, groupName, node, value);
|
||||
}
|
||||
@ -187,7 +191,7 @@ public class Chat_Permissions3 extends Chat {
|
||||
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
|
||||
//Double d = this.perms.getInfoDouble(world, groupName, node, true);
|
||||
//return (d == null) ? defaultValue : d;
|
||||
return defaultValue;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -199,7 +203,7 @@ public class Chat_Permissions3 extends Chat {
|
||||
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
|
||||
//Boolean b = this.perms.getInfoBoolean(world, groupName, node, true);
|
||||
//return (b == null) ? defaultValue : b;
|
||||
return defaultValue;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -211,40 +215,40 @@ public class Chat_Permissions3 extends Chat {
|
||||
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
|
||||
//String s = this.perms.getInfoString(world, groupName, node, true);
|
||||
//return (s == null) ? defaultValue : s;
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String groupName, String node, String value) {
|
||||
setGroupInfo(world, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
//try {
|
||||
// return perms.safeGetGroup(world, group).getPrefix();
|
||||
//} catch(Exception e) {
|
||||
return null;
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
this.perms.addGroupInfo(world, group, "prefix", prefix);
|
||||
}
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
//try {
|
||||
// return perms.safeGetGroup(world, group).getPrefix();
|
||||
//} catch(Exception e) {
|
||||
return null;
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
/*
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
this.perms.addGroupInfo(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
/*
|
||||
try {
|
||||
return perms.safeGetGroup(world, group).getSuffix();
|
||||
} catch(Exception e) { */
|
||||
return null;
|
||||
//}
|
||||
}
|
||||
return null;
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
this.perms.addGroupInfo(world, group, "suffix", suffix);
|
||||
}
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
this.perms.addGroupInfo(world, group, "suffix", suffix);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
public class Permission_Permissions3 extends Permission {
|
||||
|
||||
private final String name = "Permissions3";
|
||||
private String name = "Permissions3";
|
||||
private ModularControl perms;
|
||||
private Permissions permission = null;
|
||||
|
||||
@ -50,6 +50,10 @@ public class Permission_Permissions3 extends Permission {
|
||||
// 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;
|
||||
@ -81,7 +85,7 @@ public class Permission_Permissions3 extends Permission {
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission == null) {
|
||||
Plugin permi = event.getPlugin();
|
||||
if(permi.getDescription().getName().equals("Permissions") && permi.getDescription().getVersion().startsWith("3")) {
|
||||
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();
|
||||
@ -94,7 +98,7 @@ public class Permission_Permissions3 extends Permission {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user