Added 'display' option to the perm crafting recipe condition

This commit is contained in:
Indyuce 2021-11-13 13:21:30 +01:00
parent 84370f3a3d
commit a6f94d9c48
2 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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"));