mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-21 10:52:01 +00:00
Prevent adding inheritances to globalgroups. These are permissions
collections, not player groups.
This commit is contained in:
parent
9c68cbae72
commit
fa49fc91d2
|
@ -143,4 +143,5 @@ v 1.9:
|
||||||
This also means we no longer update permissions before we change worlds.
|
This also means we no longer update permissions before we change worlds.
|
||||||
- A command of '/manload' with no world arguments now performs a full reload of GM.
|
- A command of '/manload' with no world arguments now performs a full reload of GM.
|
||||||
- Update for Bukkit R5 compatability.
|
- Update for Bukkit R5 compatability.
|
||||||
- Removed BukkitPermsOverride as this is now the default with bukkit handling child nodes.
|
- Removed BukkitPermsOverride as this is now the default with bukkit handling child nodes.
|
||||||
|
- Prevent adding inheritances to globalgroups. These are permissions collections, not player groups.
|
|
@ -1019,6 +1019,11 @@ public class GroupManager extends JavaPlugin {
|
||||||
sender.sendMessage(ChatColor.RED + "Group 2 does not exists!");
|
sender.sendMessage(ChatColor.RED + "Group 2 does not exists!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (auxGroup.isGlobal()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support inheritance.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// VALIDANDO PERMISSAO
|
// VALIDANDO PERMISSAO
|
||||||
if (permissionHandler.searchGroupInInheritance(auxGroup, auxGroup2.getName(), null)) {
|
if (permissionHandler.searchGroupInInheritance(auxGroup, auxGroup2.getName(), null)) {
|
||||||
sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " already inherits " + auxGroup2.getName() + " (might not be directly)");
|
sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " already inherits " + auxGroup2.getName() + " (might not be directly)");
|
||||||
|
@ -1052,6 +1057,11 @@ public class GroupManager extends JavaPlugin {
|
||||||
sender.sendMessage(ChatColor.RED + "Group 2 does not exists!");
|
sender.sendMessage(ChatColor.RED + "Group 2 does not exists!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (auxGroup.isGlobal()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support inheritance.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// VALIDANDO PERMISSAO
|
// VALIDANDO PERMISSAO
|
||||||
if (!permissionHandler.searchGroupInInheritance(auxGroup, auxGroup2.getName(), null)) {
|
if (!permissionHandler.searchGroupInInheritance(auxGroup, auxGroup2.getName(), null)) {
|
||||||
sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " does not inherits " + auxGroup2.getName() + ".");
|
sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " does not inherits " + auxGroup2.getName() + ".");
|
||||||
|
|
|
@ -48,6 +48,15 @@ public class Group extends DataUnit implements Cloneable {
|
||||||
public Group(String name) {
|
public Group(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this a GlobalGroup
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isGlobal() {
|
||||||
|
return (getDataSource() == null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this group
|
* Clone this group
|
||||||
|
@ -57,7 +66,7 @@ public class Group extends DataUnit implements Cloneable {
|
||||||
public Group clone() {
|
public Group clone() {
|
||||||
Group clone;
|
Group clone;
|
||||||
|
|
||||||
if (getDataSource() == null) {
|
if (isGlobal()) {
|
||||||
clone = new Group(this.getName());
|
clone = new Group(this.getName());
|
||||||
} else {
|
} else {
|
||||||
clone = new Group(getDataSource(), this.getName());
|
clone = new Group(getDataSource(), this.getName());
|
||||||
|
@ -85,7 +94,7 @@ public class Group extends DataUnit implements Cloneable {
|
||||||
Group clone = dataSource.createGroup(this.getName());
|
Group clone = dataSource.createGroup(this.getName());
|
||||||
|
|
||||||
// Don't add inheritance for GlobalGroups
|
// Don't add inheritance for GlobalGroups
|
||||||
if (getDataSource() != null) {
|
if (!isGlobal()) {
|
||||||
clone.inherits = new ArrayList<String>(this.getInherits());
|
clone.inherits = new ArrayList<String>(this.getInherits());
|
||||||
}
|
}
|
||||||
for (String perm : this.getPermissionList()) {
|
for (String perm : this.getPermissionList()) {
|
||||||
|
@ -110,26 +119,30 @@ public class Group extends DataUnit implements Cloneable {
|
||||||
* @param inherit the inherits to set
|
* @param inherit the inherits to set
|
||||||
*/
|
*/
|
||||||
public void addInherits(Group inherit) {
|
public void addInherits(Group inherit) {
|
||||||
if (!this.getDataSource().groupExists(inherit.getName())) {
|
if (!isGlobal()) {
|
||||||
getDataSource().addGroup(inherit);
|
if (!this.getDataSource().groupExists(inherit.getName())) {
|
||||||
}
|
getDataSource().addGroup(inherit);
|
||||||
if (!inherits.contains(inherit.getName().toLowerCase())) {
|
}
|
||||||
inherits.add(inherit.getName().toLowerCase());
|
if (!inherits.contains(inherit.getName().toLowerCase())) {
|
||||||
}
|
inherits.add(inherit.getName().toLowerCase());
|
||||||
flagAsChanged();
|
}
|
||||||
if (GroupManager.isLoaded()) {
|
flagAsChanged();
|
||||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
if (GroupManager.isLoaded()) {
|
||||||
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
|
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||||
}
|
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeInherits(String inherit) {
|
public boolean removeInherits(String inherit) {
|
||||||
if (this.inherits.contains(inherit.toLowerCase())) {
|
if (!isGlobal()) {
|
||||||
this.inherits.remove(inherit.toLowerCase());
|
if (this.inherits.contains(inherit.toLowerCase())) {
|
||||||
flagAsChanged();
|
this.inherits.remove(inherit.toLowerCase());
|
||||||
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
|
flagAsChanged();
|
||||||
return true;
|
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,15 +158,17 @@ public class Group extends DataUnit implements Cloneable {
|
||||||
* @param varList
|
* @param varList
|
||||||
*/
|
*/
|
||||||
public void setVariables(Map<String, Object> varList) {
|
public void setVariables(Map<String, Object> varList) {
|
||||||
GroupVariables temp = new GroupVariables(this, varList);
|
if (!isGlobal()) {
|
||||||
variables.clearVars();
|
GroupVariables temp = new GroupVariables(this, varList);
|
||||||
for (String key : temp.getVarKeyList()) {
|
variables.clearVars();
|
||||||
variables.addVar(key, temp.getVarObject(key));
|
for (String key : temp.getVarKeyList()) {
|
||||||
}
|
variables.addVar(key, temp.getVarObject(key));
|
||||||
flagAsChanged();
|
}
|
||||||
if (GroupManager.isLoaded()) {
|
flagAsChanged();
|
||||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
if (GroupManager.isLoaded()) {
|
||||||
GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
|
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||||
}
|
GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue