mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-23 11:05:48 +01:00
commit
343fa70880
@ -19,7 +19,7 @@ import java.util.ArrayList;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import com.github.sebc722.Xperms.Xmain;
|
||||
import com.github.sebc722.xperms.core.Main;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -32,13 +32,13 @@ import org.bukkit.plugin.Plugin;
|
||||
public class Permission_Xperms extends Permission {
|
||||
|
||||
private final String name = "Xperms";
|
||||
private Xmain perms = null;
|
||||
private Main permission = null;
|
||||
|
||||
public Permission_Xperms(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin)
|
||||
|
||||
if(perms == null){
|
||||
if(permission == null){
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Xperms");
|
||||
if(perms != null){
|
||||
if(perms.isEnabled()){
|
||||
@ -48,45 +48,49 @@ public class Permission_Xperms extends Permission {
|
||||
}
|
||||
} 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));
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatibe with vault! Please Update!", plugin.getDescription().getName(), name);
|
||||
}
|
||||
}
|
||||
perms = (Xmain) perms;
|
||||
permission = (Main) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_Xperms permission = null;
|
||||
Main permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_Xperms permission) {
|
||||
public PermissionServerListener(Permission_Xperms permission){
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Xperms")) {
|
||||
Plugin perms = event.getPlugin();
|
||||
try {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin)
|
||||
|
||||
if(permission == null){
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Xperms");
|
||||
if(perms != null){
|
||||
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));
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatibe with vault! Please Update!", plugin.getDescription().getName(), name);
|
||||
}
|
||||
permission.perms = (Xmain) perms;
|
||||
permission.permission = (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(permission.permission != null){
|
||||
if(event.getPlugin().getName().equals("Xperms")){
|
||||
permission.perms = null;
|
||||
permission.permission = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
@ -100,7 +104,7 @@ public class Permission_Xperms extends Permission {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return perms.isEnabled();
|
||||
return permission.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,76 +114,66 @@ public class Permission_Xperms extends Permission {
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
return perms.getXplayer().hasPermission(player, permission);
|
||||
return permission.getXplayer().hasPerm(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return perms.getXplayer().addPermission(player, permission);
|
||||
return permission.getXplayer().addNode(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return perms.getXplayer().removePermission(player, permission);
|
||||
return permission.getXplayer().removeNode(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return perms.getXgroup().hasPermission(group, permission);
|
||||
return permission.getXgroup().hasPerm(group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
return perms.getXgroup().addPermission(group, permission);
|
||||
permission.getXgroup().addNode(group, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
return perms.getXgroup().removePermission(group, permission);
|
||||
return permission.getXgroup().removeNode(group, permission)
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
String userGroup = perms.getXusers().getUserGroup(player);
|
||||
if(userGroup == group){
|
||||
String groupForWorld = permission.getXplayer().getGroupForWorld(player, world);
|
||||
if(groupForWorld.equals(group)){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
return perms.getXplayer().setGroup(player, group);
|
||||
return permission.getXplayer().setPlayerGroup(world, player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
return perms.getXplayer().setGroup(player, "def");
|
||||
return permission.getXplayer().setPlayerDefault(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
ArrayList<String> playerGroup = new ArrayList<String>();
|
||||
playerGroup.add(perms.getXusers().getUserGroup(player));
|
||||
String[] playerGroupArray = playerGroup.toArray(new String[0]);
|
||||
|
||||
return playerGroupArray;
|
||||
return permission.getXplayer().getPlayerGroups(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
return perms.getXusers().getUserGroup(player);
|
||||
return permission.getXplayer().getGroupForWorld(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return perms.getXperms().getGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
return permission.getXgroup().getGroups();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user