-
-
Notifications
You must be signed in to change notification settings - Fork 408
A Complete Whitelist Module #8205
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
base: dev/feature
Are you sure you want to change the base?
A Complete Whitelist Module #8205
Conversation
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 |
src/main/java/org/skriptlang/skript/bukkit/whitelist/WhitelistModule.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/whitelist/elements/CondWillBeWhitelisted.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/whitelist/elements/CondWillBeWhitelisted.java
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/whitelist/elements/EvtWhitelist.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/whitelist/elements/EvtWhitelist.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/whitelist/elements/EvtWhitelist.java
Outdated
Show resolved
Hide resolved
"", | ||
"on player whitelist:", | ||
"\tsend "Whitelist of player % event - player % has been set to % whether server will be whitelisted%" to all ops" | ||
""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""") | |
""") |
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])", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.since(""); | |
.since(""); |
?
EventValues.registerEventValue(WhitelistStateUpdateEvent.class, OfflinePlayer.class, WhitelistStateUpdateEvent::getPlayer); | ||
} | ||
|
||
private Kleenean state = Kleenean.UNKNOWN; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
return new SyntaxStringBuilder(event, debug) | ||
.append("the") | ||
.append(isServer ? "server" : "player") | ||
.append(isNegated() ? "will not" : "will") | ||
.append("be whitelisted") | ||
.toString(); |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if statement
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:
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