Skip to content

Conversation

NotSoDelayed
Copy link
Contributor

@NotSoDelayed NotSoDelayed commented Sep 25, 2025

Problem

Skript is lacking certain coverage on whitelist related APIs, especially whitelist events.

Solution

This PR focuses more on completing the whitelist module, such as:

  • Adds missing events: server and player whitelist events
  • Adds a condition to check the whitelist state for whitelist events
  • Optimizes on existing whitelist syntaxes for current Skript code standards
  • Migrates current (as of this PR) and existing whitelist syntaxes into Skript's registration API

Testing Completed

The current test coverage for whitelist only covers manipulating player list in whitelist and server whitelist state. Alongside with new additions added in this PR, JUnit tests were also added -- in EvtWhitelistTest.java and EvtWhitelistTest.sk, marking this a complete test coverage specifically for whitelist.

Supporting Information


Completes: none
Related: none

@NotSoDelayed NotSoDelayed requested review from a team as code owners September 25, 2025 05:19
@NotSoDelayed NotSoDelayed requested review from sovdeeth and cheeezburga and removed request for a team September 25, 2025 05:19
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Sep 25, 2025
@NotSoDelayed
Copy link
Contributor Author

NotSoDelayed commented Sep 25, 2025

PS. MC 1.19.4 tests are expected to fail due to classes doesn't exist in that version, but the next Skript release drops support of that version

"",
"on player whitelist:",
"\tsend "Whitelist of player % event - player % has been set to % whether server will be whitelisted%" to all ops"
""")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
""")
""")

Also gotta remove all the " and , in the block.


static {
Skript.registerEvent("Player Whitelist", EvtPlayerWhitelist.class, WhitelistStateUpdateEvent.class,
"player whitelist [state] (change[d]|toggle[d]|update[d])",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"player whitelist [state] (change[d]|toggle[d]|update[d])",
"player whitelist [state] (change[d]|update[d])",

the toggled syntax sounds like i'm turning the whitelist on or off, not updating a single player.

"",
"on player whitelist toggled:",
"\tsend \"Whitelist of player %event-offlineplayer% has been set to %whether server will be whitelisted%\" to all ops")
.since("");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.since("");
.since("");

?

EventValues.registerEventValue(WhitelistStateUpdateEvent.class, OfflinePlayer.class, WhitelistStateUpdateEvent::getPlayer);
}

private Kleenean state = Kleenean.UNKNOWN;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a proper enum for this, a Kleenean isn't the right tool for the job.

.since("");
}

private Kleenean state = Kleenean.UNKNOWN;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@sovdeeth sovdeeth moved this to In Review in 2.14 Releases Sep 28, 2025
@sovdeeth sovdeeth added enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature Pull request adding a new feature. labels Sep 28, 2025
Comment on lines +66 to +71
return new SyntaxStringBuilder(event, debug)
.append("the")
.append(isServer ? "server" : "player")
.append(isNegated() ? "will not" : "will")
.append("be whitelisted")
.toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use if statements instead of ternary to improve readability

SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug)
.append("player");
if (!state.isUnknown()) {
builder.append(state.isTrue() ? "added to" : "removed from")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statement

@skriptlang-automation skriptlang-automation bot removed the needs reviews A PR that needs additional reviews label Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature Pull request adding a new feature.
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants