Major f perm fix; Fix sethome permission check (#1079)

This commit is contained in:
Dariasc 2018-03-09 15:22:15 -03:00 committed by Trent Hensler
parent 693c831327
commit 819cb542cd
6 changed files with 28 additions and 32 deletions

View File

@ -108,16 +108,13 @@ public class CmdPerm extends FCommand {
} }
private Permissable getPermissable(String name) { private Permissable getPermissable(String name) {
try { if (Role.fromString(name.toUpperCase()) != null) {
return Relation.valueOf(name.toUpperCase()); return Role.fromString(name.toUpperCase());
} catch (Exception e) { } else if (Relation.fromString(name.toUpperCase()) != null) {
return Relation.fromString(name.toUpperCase());
} else {
return null;
} }
try {
return Role.valueOf(name.toUpperCase());
} catch (Exception e) {
}
return null;
} }
@Override @Override

View File

@ -45,15 +45,16 @@ public class CmdSethome extends FCommand {
return; return;
} }
// Can the player set the home for this faction? // If player does not have allow run extra permission checks
// Check for ALLOW access as well before we check for role. if (access != Access.ALLOW) {
if (faction == myFaction && access != Access.ALLOW) { if (faction == myFaction) {
if (!Permission.SETHOME_ANY.has(sender, true) || !assertMinRole(Role.MODERATOR)) { if (!assertMinRole(Role.MODERATOR)) {
return; return;
} }
} else { } else {
if (!Permission.SETHOME_ANY.has(sender, true)) { if (!Permission.SETHOME_ANY.has(sender, true)) {
return; return;
}
} }
} }

View File

@ -104,7 +104,6 @@ public enum Role implements Permissable {
return ""; return "";
} }
// Utility method to build items for F Perm GUI // Utility method to build items for F Perm GUI
@Override @Override
public ItemStack buildItem() { public ItemStack buildItem() {
@ -113,7 +112,7 @@ public enum Role implements Permissable {
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
Material material = Material.matchMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())); Material material = Material.matchMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY"));
if (material == null) { if (material == null) {
return null; return null;
} }

View File

@ -96,16 +96,13 @@ public class PermissableRelationGUI implements InventoryHolder, FactionGUI {
} }
private Permissable getPermissable(String name) { private Permissable getPermissable(String name) {
try { if (Role.fromString(name.toUpperCase()) != null) {
return Relation.valueOf(name.toUpperCase()); return Role.fromString(name.toUpperCase());
} catch (Exception e) { } else if (Relation.fromString(name.toUpperCase()) != null) {
return Relation.fromString(name.toUpperCase());
} else {
return null;
} }
try {
return Role.valueOf(name.toUpperCase());
} catch (Exception e) {
}
return null;
} }
private void buildItems() { private void buildItems() {

View File

@ -419,7 +419,9 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
// Put the map in there for each relation. // Put the map in there for each relation.
for (Relation relation : Relation.values()) { for (Relation relation : Relation.values()) {
permissions.put(relation, new HashMap<>(freshMap)); if (relation != Relation.MEMBER) {
permissions.put(relation, new HashMap<>(freshMap));
}
} }
// And each role. // And each role.

View File

@ -379,7 +379,7 @@ fperm-gui:
# Note: Slots start at 0 and end at one less that GUI size # Note: Slots start at 0 and end at one less that GUI size
slots: slots:
recruit: 10 recruit: 10
member: 11 normal: 11
moderator: 12 moderator: 12
truce: 13 truce: 13
ally: 14 ally: 14
@ -388,7 +388,7 @@ fperm-gui:
# Material to be displayed # Material to be displayed
materials: materials:
recruit: WOOD_SWORD recruit: WOOD_SWORD
member: STONE_SWORD normal: STONE_SWORD
moderator: IRON_SWORD moderator: IRON_SWORD
truce: IRON_AXE truce: IRON_AXE
ally: DIAMOND_SWORD ally: DIAMOND_SWORD