mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-12-02 15:33:29 +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 GroupManager groupManager;
|
||||||
private AnjoPermissionsHandler perms;
|
private AnjoPermissionsHandler perms;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public Permission_GroupManager(Vault plugin) {
|
public Permission_GroupManager(Vault plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||||
@ -41,7 +40,6 @@ public class Permission_GroupManager extends Permission {
|
|||||||
if (perms != null) {
|
if (perms != null) {
|
||||||
if (perms.isEnabled()) {
|
if (perms.isEnabled()) {
|
||||||
groupManager = (GroupManager) perms;
|
groupManager = (GroupManager) perms;
|
||||||
this.perms = groupManager.getPermissionHandler();
|
|
||||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
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;
|
this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPluginEnable(PluginEnableEvent event) {
|
public void onPluginEnable(PluginEnableEvent event) {
|
||||||
if (permission.groupManager == null) {
|
if (permission.groupManager == null) {
|
||||||
@ -64,7 +61,6 @@ public class Permission_GroupManager extends Permission {
|
|||||||
if (perms != null) {
|
if (perms != null) {
|
||||||
if (perms.isEnabled()) {
|
if (perms.isEnabled()) {
|
||||||
permission.groupManager = (GroupManager) perms;
|
permission.groupManager = (GroupManager) perms;
|
||||||
permission.perms = groupManager.getPermissionHandler();
|
|
||||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
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 (permission.groupManager != null) {
|
||||||
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
|
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
|
||||||
permission.groupManager = null;
|
permission.groupManager = null;
|
||||||
permission.perms = null;
|
|
||||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
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
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
if (groupManager == null) {
|
return groupManager != null && groupManager.isEnabled();
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return groupManager.isEnabled();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerHas(String worldName, String playerName, String permission) {
|
public boolean playerHas(String worldName, String playerName, String permission) {
|
||||||
Player p = plugin.getServer().getPlayer(playerName);
|
OverloadedWorldHolder owh;
|
||||||
if (p != null) {
|
if (worldName == null) {
|
||||||
if (p.hasPermission(permission))
|
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||||
return true;
|
}
|
||||||
|
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
|
@Override
|
||||||
public boolean playerAdd(String worldName, String playerName, String permission) {
|
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) {
|
if (owh == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -125,7 +131,12 @@ public class Permission_GroupManager extends Permission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerRemove(String worldName, String playerName, String permission) {
|
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) {
|
if (owh == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -141,7 +152,12 @@ public class Permission_GroupManager extends Permission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean groupHas(String worldName, String groupName, String permission) {
|
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) {
|
if (owh == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -156,7 +172,12 @@ public class Permission_GroupManager extends Permission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
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) {
|
if (owh == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -172,7 +193,12 @@ public class Permission_GroupManager extends Permission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
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) {
|
if (owh == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -188,7 +214,21 @@ public class Permission_GroupManager extends Permission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(String worldName, String playerName, String groupName) {
|
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
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user