Skip to content

Commit

Permalink
Merge branch 'dev/patch' into patch/fix-invalid-equipment-slot
Browse files Browse the repository at this point in the history
  • Loading branch information
Burbulinis authored Jan 25, 2025
2 parents f1e1782 + 76cbae6 commit 88b784a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,11 @@ public boolean supportsNameChange() {
@Override
public void setName(String name) {
BlockState state = block.getState();
if (state instanceof Nameable nameable)
if (state instanceof Nameable nameable) {
//noinspection deprecation
nameable.setCustomName(name);
state.update(true, false);
}
}
},
//</editor-fold>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/njol/skript/expressions/ExprName.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public class ExprName extends SimplePropertyExpression<Object, String> {
serializer = BungeeComponentSerializer.get();

List<String> patterns = new ArrayList<>();
patterns.addAll(Arrays.asList(getPatterns("name[s]", "offlineplayers/entities/inventories/nameds")));
patterns.addAll(Arrays.asList(getPatterns("(display|nick|chat|custom)[ ]name[s]", "offlineplayers/entities/inventories/nameds")));
patterns.addAll(Arrays.asList(getPatterns("name[s]", "offlineplayers/entities/nameds/inventories")));
patterns.addAll(Arrays.asList(getPatterns("(display|nick|chat|custom)[ ]name[s]", "offlineplayers/entities/nameds/inventories")));
patterns.addAll(Arrays.asList(getPatterns("(player|tab)[ ]list name[s]", "players")));

Skript.registerExpression(ExprName.class, String.class, ExpressionType.COMBINED, patterns.toArray(new String[0]));
Expand Down
12 changes: 11 additions & 1 deletion src/test/skript/tests/syntaxes/expressions/ExprName.sk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ test "name of item":
set the name of {_thing} to "blob"
assert name of {_thing} is "blob" with "item name didn't change"

test "name of block":
set {_data} to blockdata of block at event-location
set block at event-location to a chest
assert name of block at event-location is not set with "The block shouldn't have a name yet"
set name of block at event-location to "Mr Chesty"
assert name of block at event-location = "Mr Chesty" with "The block should have a name now"
reset name of block at event-location
assert name of block at event-location is not set with "The block should no longer have a name"
set block at event-location to {_data}

using script reflection

test "config name (new)":
Expand All @@ -53,7 +63,7 @@ test "node name (new)":
assert name of {_node} is "test ""name of world""" with "first node name was wrong"

set {_node} to the current script
set {_node} to the 4th element of nodes of {_node} # Obviously, this changes if this file changes
set {_node} to the 5th element of nodes of {_node} # Obviously, this changes if this file changes
assert name of {_node} is "using script reflection" with "4th node name was wrong"

# root node
Expand Down

0 comments on commit 88b784a

Please sign in to comment.