Skip to content

Commit e6dbb5b

Browse files
Continue internal GUI cleanup
1 parent ca4e1e3 commit e6dbb5b

8 files changed

Lines changed: 258 additions & 213 deletions

File tree

src/main/java/io/github/apickledwalrus/skriptgui/elements/conditions/CondIsLocked.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.skriptlang.skript.registration.SyntaxRegistry;
1414

1515
@Name("Is GUI Locked")
16-
@Description("Whether a GUI is locked or unlocked, which controls whether its items without actions can be removed.")
16+
@Description("Whether a GUI is locked or unlocked, which controls whether its items without actions can be removed or changed.")
1717
@Example("""
1818
if the player's gui is locked:
1919
send "You cannot remove items from this GUI!" to the player
@@ -31,8 +31,8 @@ public static void register(SyntaxRegistry syntaxRegistry) {
3131
syntaxRegistry.register(SyntaxRegistry.CONDITION, SyntaxInfo.builder(CondIsLocked.class)
3232
.supplier(CondIsLocked::new)
3333
.addPatterns(bePatterns)
34-
.addPatterns("%guis% allow[s] items to be removed",
35-
"%guis% (disallow|prevent)[s] items [from] being removed")
34+
.addPatterns("%guis% allow[s] items to be (removed|changed)",
35+
"%guis% (disallow|prevent)[s] items [from] being (removed|changed)")
3636
.build());
3737
}
3838

@@ -44,7 +44,7 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
4444

4545
@Override
4646
public boolean check(GUI gui) {
47-
return gui.isRemovable() != locked;
47+
return gui.isChangeable() != locked;
4848
}
4949

5050
@Override

src/main/java/io/github/apickledwalrus/skriptgui/elements/effects/EffCancelClose.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
5757
protected void execute(Event event) {
5858
GUI gui = SkriptGUI.getGUIManager().getGUI(event);
5959
if (gui != null) {
60-
gui.setCloseCancelled(event, cancel);
60+
gui.setCloseCanceled(event, cancel);
6161
}
6262
}
6363

src/main/java/io/github/apickledwalrus/skriptgui/elements/effects/EffLock.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import org.skriptlang.skript.registration.SyntaxRegistry;
1717

1818
@Name("Lock/Unlock GUI")
19-
@Description("Locks or unlocks a GUI, which controls whether its items without actions can be removed.")
19+
@Description("Locks or unlocks a GUI, which controls whether its items without actions can be removed or changed.")
2020
@Example("unlock the player's gui")
2121
@Since("1.4.0")
2222
public class EffLock extends Effect {
@@ -25,33 +25,33 @@ public static void register(SyntaxRegistry syntaxRegistry) {
2525
syntaxRegistry.register(SyntaxRegistry.EFFECT, SyntaxInfo.builder(EffLock.class)
2626
.supplier(EffLock::new)
2727
.addPatterns("(:unlock|:lock) [gui[s]] %guis%",
28-
"allow items to be removed from %guis%",
29-
"(disallow|prevent) items [from] being removed from %guis%")
28+
"allow items to be (removed|changed) from %guis%",
29+
"(disallow|prevent) items [from] being (removed|changed) from %guis%")
3030
.build());
3131
}
3232

3333
private Expression<GUI> guis;
34-
private boolean removable;
34+
private boolean changeable;
3535

3636
@Override
3737
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
3838
//noinspection unchecked
3939
this.guis = (Expression<GUI>) expressions[0];
40-
this.removable = parseResult.hasTag("unlock") || matchedPattern == 1;
40+
this.changeable = parseResult.hasTag("unlock") || matchedPattern == 1;
4141
return true;
4242
}
4343

4444
@Override
4545
protected void execute(Event event) {
4646
for (GUI gui : this.guis.getArray(event)) {
47-
gui.setRemovable(removable);
47+
gui.setChangeable(changeable);
4848
}
4949
}
5050

5151
@Override
5252
public String toString(@Nullable Event event, boolean debug) {
5353
return new SyntaxStringBuilder(event, debug)
54-
.append(removable ? "unlock" : "lock", guis)
54+
.append(changeable ? "unlock" : "lock", guis)
5555
.toString();
5656
}
5757

src/main/java/io/github/apickledwalrus/skriptgui/elements/expressions/ExprGlobalGUIs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
3737

3838
@Override
3939
protected GUI[] get(Event event) {
40-
return SkriptGUI.getGUIManager().getTrackedGUIs().toArray(new GUI[0]);
40+
return SkriptGUI.getGUIManager().getGlobalGUIs().toArray(new GUI[0]);
4141
}
4242

4343
@Override

src/main/java/io/github/apickledwalrus/skriptgui/elements/expressions/ExprLockStatus.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
4141

4242
@Override
4343
public @Nullable Boolean convert(GUI gui) {
44-
return !gui.isRemovable(); // Not removable = locked
44+
return !gui.isChangeable(); // Not changeable = locked
4545
}
4646

4747
@Override
@@ -54,9 +54,9 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
5454

5555
@Override
5656
public void change(Event event, Object @Nullable [] delta, ChangeMode mode) {
57-
boolean removable = delta != null && !((boolean) delta[0]);
57+
boolean changeable = delta != null && !((boolean) delta[0]);
5858
for (GUI gui : getExpr().getArray(event)) {
59-
gui.setRemovable(removable);
59+
gui.setChangeable(changeable);
6060
}
6161
}
6262

0 commit comments

Comments
 (0)