mirror of
https://github.com/rockyhawk64/CommandPanels.git
synced 2025-11-18 07:14:17 +01:00
fix spaces for conditions
This commit is contained in:
parent
76b3e122a2
commit
ada7d741a4
@ -29,10 +29,9 @@ public class ActionBuilder implements Listener {
|
||||
|
||||
public ActionButton buildButton(DialogButton button, DialogPanel panel) {
|
||||
Player player = builder.getPlayer();
|
||||
String conditions = ctx.text.parseTextToString(player, button.getConditions());
|
||||
|
||||
if (!conditions.trim().isEmpty()) {
|
||||
ConditionNode conditionNode = new ConditionParser().parse(conditions);
|
||||
if (!button.getConditions().trim().isEmpty()) {
|
||||
ConditionNode conditionNode = new ConditionParser().parse(button.getConditions());
|
||||
if (!conditionNode.evaluate(player, ctx)) return null;
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,6 @@ public class DialogPanelBuilder extends PanelBuilder {
|
||||
DialogComponent comp = panel.getComponents().get(id);
|
||||
|
||||
// Check conditions for which component to use
|
||||
String conditions = ctx.text.parseTextToString(player, comp.getConditions());
|
||||
if (!comp.getConditions().trim().isEmpty()) {
|
||||
ConditionNode conditionNode = new ConditionParser().parse(comp.getConditions());
|
||||
boolean result = conditionNode.evaluate(player, ctx);
|
||||
|
||||
@ -46,9 +46,8 @@ public class CustomForm {
|
||||
if (comp == null) continue;
|
||||
|
||||
// Evaluate conditions
|
||||
String conditions = ctx.text.parseTextToString(player, comp.getConditions());
|
||||
if (!conditions.trim().isEmpty()) {
|
||||
ConditionNode conditionNode = new ConditionParser().parse(conditions);
|
||||
if (!comp.getConditions().trim().isEmpty()) {
|
||||
ConditionNode conditionNode = new ConditionParser().parse(comp.getConditions());
|
||||
if (!conditionNode.evaluate(player, ctx)) continue;
|
||||
}
|
||||
|
||||
|
||||
@ -45,9 +45,8 @@ public class SimpleForm {
|
||||
if(!(panel.getComponents().get(key) instanceof FloodgateButton button)) continue;
|
||||
|
||||
// Check conditions for which button to use in the slot
|
||||
String conditions = ctx.text.parseTextToString(p, button.getConditions());
|
||||
if (!conditions.trim().isEmpty()) {
|
||||
ConditionNode conditionNode = new ConditionParser().parse(conditions);
|
||||
if (!button.getConditions().trim().isEmpty()) {
|
||||
ConditionNode conditionNode = new ConditionParser().parse(button.getConditions());
|
||||
boolean result = conditionNode.evaluate(p, ctx);
|
||||
if (!result) continue;
|
||||
}
|
||||
|
||||
@ -60,9 +60,8 @@ public class PanelFactory {
|
||||
if(item == null) continue;
|
||||
|
||||
// Check conditions for which item to use in the slot
|
||||
String conditions = ctx.text.parseTextToString(p, item.conditions());
|
||||
if (!conditions.trim().isEmpty()) {
|
||||
ConditionNode conditionNode = new ConditionParser().parse(conditions);
|
||||
if (!item.conditions().trim().isEmpty()) {
|
||||
ConditionNode conditionNode = new ConditionParser().parse(item.conditions());
|
||||
boolean result = conditionNode.evaluate(p, ctx);
|
||||
if (!result) continue;
|
||||
}
|
||||
|
||||
@ -35,6 +35,8 @@ public class ComparisonNode implements ConditionNode {
|
||||
parseTextToString will parse colour and placeholders
|
||||
After parsing strip colour, parsing and stripping will remove colour formatting
|
||||
*/
|
||||
player.sendMessage("l:"+parsedLeftRaw);
|
||||
player.sendMessage("r:"+parsedRightRaw);
|
||||
String parsedLeft = toPlainText(parsedLeftRaw);
|
||||
String parsedRight = toPlainText(parsedRightRaw);
|
||||
|
||||
|
||||
@ -29,10 +29,9 @@ public abstract class Panel {
|
||||
|
||||
public boolean canOpen(Player player, Context ctx) {
|
||||
// Check the panel condition
|
||||
String conditions = ctx.text.parseTextToString(player, this.conditions);
|
||||
if (conditions.trim().isEmpty()) return true;
|
||||
if (this.conditions.trim().isEmpty()) return true;
|
||||
try {
|
||||
ConditionNode node = new ConditionParser().parse(conditions);
|
||||
ConditionNode node = new ConditionParser().parse(this.conditions);
|
||||
return node.evaluate(player, ctx);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user