mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-23 04:47:34 +01:00
Added 'display' option to the perm crafting recipe condition
This commit is contained in:
parent
84370f3a3d
commit
a6f94d9c48
@ -9,11 +9,21 @@ import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
public class PermissionCondition extends Condition {
|
||||
private final List<String> permissions;
|
||||
|
||||
/**
|
||||
* Permissions are super ugly to display so MI uses a string instead.
|
||||
* This way 'Only for Mages' is used instead of 'class.mage'
|
||||
*
|
||||
* One string can also replace multiple permissions.
|
||||
* 'Magic Classes Only' instead of 'class.mage' and 'class.apprentice'
|
||||
*/
|
||||
private final String display;
|
||||
|
||||
public PermissionCondition(MMOLineConfig config) {
|
||||
super("permission");
|
||||
|
||||
config.validate("list");
|
||||
permissions = Arrays.asList(config.getString("list").split(","));
|
||||
display = config.contains("display") ? config.getString("display") : "?";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,7 +37,7 @@ public class PermissionCondition extends Condition {
|
||||
|
||||
@Override
|
||||
public String formatDisplay(String string) {
|
||||
return string.replace("#perms#", String.join(", ", permissions));
|
||||
return string.replace("#perms#", String.join(", ", permissions)).replace("#display#", display);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ public class CraftingManager implements Reloadable {
|
||||
|
||||
// Conditions
|
||||
registerCondition("level", LevelCondition::new, new ConditionalDisplay("&a" + AltChar.check + " Requires Level #level#", "&c" + AltChar.cross + " Requires Level #level#"));
|
||||
registerCondition("permission", PermissionCondition::new, null);
|
||||
registerCondition("permission", PermissionCondition::new, new ConditionalDisplay("&a" + AltChar.check + " #display#", "&c" + AltChar.cross + " #display#"));
|
||||
registerCondition("placeholder", PlaceholderCondition::new, null);
|
||||
registerCondition("mana", ManaCondition::new, new ConditionalDisplay("&a" + AltChar.check + " Requires #mana# Mana", "&c" + AltChar.cross + " Requires #mana# Mana"));
|
||||
registerCondition("stamina", StaminaCondition::new, new ConditionalDisplay("&a" + AltChar.check + " Requires #stamina# Stamina", "&c" + AltChar.cross + " Requires #stamina# Stamina"));
|
||||
|
Loading…
Reference in New Issue
Block a user