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,17 +108,14 @@ 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());
try { } else {
return Role.valueOf(name.toUpperCase());
} catch (Exception e) {
}
return null; return null;
} }
}
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {

View File

@ -45,10 +45,10 @@ 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 {
@ -56,6 +56,7 @@ public class CmdSethome extends FCommand {
return; return;
} }
} }
}
// Can the player set the faction home HERE? // Can the player set the faction home HERE?
if (!Permission.BYPASS.has(me) && if (!Permission.BYPASS.has(me) &&

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,17 +96,14 @@ 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());
try { } else {
return Role.valueOf(name.toUpperCase());
} catch (Exception e) {
}
return null; return null;
} }
}
private void buildItems() { private void buildItems() {
for (Map.Entry<Integer, Permissable> entry : relationSlots.entrySet()) { for (Map.Entry<Integer, Permissable> entry : relationSlots.entrySet()) {

View File

@ -419,8 +419,10 @@ 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()) {
if (relation != Relation.MEMBER) {
permissions.put(relation, new HashMap<>(freshMap)); permissions.put(relation, new HashMap<>(freshMap));
} }
}
// And each role. // And each role.
for (Role role : Role.values()) { for (Role role : Role.values()) {

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