Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review comments
  • Loading branch information
Efnilite committed Apr 1, 2025
commit 7e0603b1723d5d21bb3e8eb36672bab406e70675
6 changes: 5 additions & 1 deletion src/main/java/ch/njol/skript/config/SectionNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public void add(final Node n) {
public void add(int index, @NotNull Node node) {
Preconditions.checkArgument(index >= 0 && index <= size(), "index out of bounds: %s", index);

if (node.getParent() == this) { // this is not ideal. too bad!
// if a node is moved within the same section, and is at the end of that section,
// the index should be at most nodes.size() - 1
// since the node is removed before being added, the size of nodes is now one smaller.
// if this check wasn't present, adding node at index could cause an IndexOutOfBoundsException
if (node.getParent() == this) {
index = Math.min(index, nodes.size() - 1);
}
node.remove();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ch/njol/skript/config/VoidNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ public int hashCode() {
// at a different position
return Objects.hash(Arrays.hashCode(getPathSteps()), comment, getIndex());
}

}