Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ExprHoverList's remove #7056

Merged
merged 4 commits into from
Sep 22, 2024
Merged
Changes from all commits
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
15 changes: 9 additions & 6 deletions src/main/java/ch/njol/skript/expressions/ExprHoverList.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {

if (HAS_NEW_LISTED_PLAYER_INFO) {
List<PaperServerListPingEvent.ListedPlayerInfo> values = new ArrayList<>();
if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET) {
if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET && mode != ChangeMode.REMOVE) {
for (Object object : delta) {
if (object instanceof Player) {
Player player = (Player) object;
Expand All @@ -124,7 +124,9 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
sample.addAll(values);
break;
case REMOVE:
sample.removeAll(values);
for (Object value : delta) {
sample.removeIf(profile -> profile.name().equals(value));
}
break;
case DELETE:
case RESET:
Expand All @@ -135,7 +137,7 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
}

List<PlayerProfile> values = new ArrayList<>();
if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET) {
if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET && mode != ChangeMode.REMOVE) {
for (Object object : delta) {
if (object instanceof Player) {
Player player = (Player) object;
Expand All @@ -150,13 +152,14 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
switch (mode) {
case SET:
sample.clear();
sample.addAll(values);
break;
// $FALL-THROUGH$
case ADD:
sample.addAll(values);
break;
case REMOVE:
sample.removeAll(values);
for (Object value : delta) {
sample.removeIf(profile -> profile.getName() != null && profile.getName().equals(value));
}
break;
case DELETE:
case RESET:
Expand Down