mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-27 13:07:23 +01:00
update GM hooking.
This commit is contained in:
parent
a56e4808b9
commit
7c23cb38d3
@ -30,7 +30,6 @@ public class Permission_GroupManager extends Permission {
|
||||
private GroupManager groupManager;
|
||||
private AnjoPermissionsHandler perms;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Permission_GroupManager(Vault plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
@ -41,7 +40,6 @@ public class Permission_GroupManager extends Permission {
|
||||
if (perms != null) {
|
||||
if (perms.isEnabled()) {
|
||||
groupManager = (GroupManager) perms;
|
||||
this.perms = groupManager.getPermissionHandler();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
@ -55,7 +53,6 @@ public class Permission_GroupManager extends Permission {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.groupManager == null) {
|
||||
@ -64,7 +61,6 @@ public class Permission_GroupManager extends Permission {
|
||||
if (perms != null) {
|
||||
if (perms.isEnabled()) {
|
||||
permission.groupManager = (GroupManager) perms;
|
||||
permission.perms = groupManager.getPermissionHandler();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
@ -76,7 +72,6 @@ public class Permission_GroupManager extends Permission {
|
||||
if (permission.groupManager != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
|
||||
permission.groupManager = null;
|
||||
permission.perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
@ -90,26 +85,37 @@ public class Permission_GroupManager extends Permission {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (groupManager == null) {
|
||||
return false;
|
||||
} else {
|
||||
return groupManager.isEnabled();
|
||||
}
|
||||
return groupManager != null && groupManager.isEnabled();
|
||||
}
|
||||
|
||||
@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;
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
}
|
||||
else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
} else {
|
||||
return user.hasSamePermissionNode(permission);
|
||||
}
|
||||
return perms.has(plugin.getServer().getPlayer(playerName), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String worldName, String playerName, String permission) {
|
||||
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
@ -125,7 +131,12 @@ public class Permission_GroupManager extends Permission {
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String worldName, String playerName, String permission) {
|
||||
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
@ -141,7 +152,12 @@ public class Permission_GroupManager extends Permission {
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String worldName, String groupName, String permission) {
|
||||
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
@ -156,7 +172,12 @@ public class Permission_GroupManager extends Permission {
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
||||
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
@ -172,7 +193,12 @@ public class Permission_GroupManager extends Permission {
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
||||
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
@ -188,7 +214,21 @@ public class Permission_GroupManager extends Permission {
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String worldName, String playerName, String groupName) {
|
||||
return perms.inGroup(playerName, groupName);
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
}
|
||||
else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
return user.getGroup().getName().equalsIgnoreCase(groupName) || user.subGroupListStringCopy().contains(groupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user