-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
feat: add whitelist command #446
Conversation
pumpkin-config/src/lib.rs
Outdated
/// Whether to enable the whitelist | ||
pub white_list: bool, | ||
/// Whether to enforce the whitelist | ||
pub enforce_whitelist: bool, |
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.
One boolean would be enough, If the white list is enabled it will be automatically enforced
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.
Both variables are used in the vanilla server.properties
file. You can enable the whitelist but not enforce it. If you enforce it, players will be kicked when you reload the whitelist if they are not whitelisted.
From the Minecraft wiki:
white-list
Whether the whitelist is enabled.
With a whitelist enabled, users not on the whitelist cannot connect. Intended for private servers, such as those for real-life friends or strangers carefully selected via an application process, for example.
false - No white list is used. true - The file whitelist.json is used to generate the white list.
Note: Ops are automatically whitelisted, and there is no need to add them to the whitelist.
enforce-whitelist
Whether to enforce changes to the whitelist.
When this option as well as the whitelist is enabled, players not present on the whitelist get kicked from the server after the server reloads the whitelist file.
false - Online players that are not on the whitelist are not kicked. true - Online players that are not on the whitelist are kicked.
pumpkin-config/src/player_profile.rs
Outdated
use uuid::Uuid; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Default, Debug)] | ||
pub struct PlayerProfile { |
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.
Why this is here in pumpkin-config
?
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.
I placed it where the op files were and moved both to the data folder.
pumpkin/src/main.rs
Outdated
|
||
// If the whitelist is enabled, check if the player is whitelisted | ||
if *server.white_list.read().await { | ||
let whitelist_config = WHITELIST_CONFIG.read().await; | ||
let is_whitelisted = whitelist_config | ||
.whitelist | ||
.iter() | ||
.any(|p| p.uuid == player.gameprofile.id); | ||
let is_op = player.permission_lvl.load() >= PermissionLvl::Three; | ||
if !is_whitelisted && !is_op { | ||
player | ||
.kick(TextComponent::text("You are not whitelisted!")) | ||
.await; | ||
} | ||
} |
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.
Lets not clutter our main (even more), A new method in the Server
which gets called in Server::add_player
would be probably ideal
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.
hat makes sense. Moved it
fb2b213
to
0fbc730
Compare
Description
whitelist
command and the correspondingwhitelist.json
file to keep track of the whitelisted users.Testing
Please follow our Coding Guidelines