-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Add permissions check for SSetCreativeSlot #51
Conversation
You have a good commit message, Why you don't use that for the PR description. There are many people using "self explanatory commit" or something like this in PR and i really hate it. So would be cool if you could use good commit messages and good PR descriptions in the future 👍 |
updated my PR message :) |
pumpkin/src/client/player_packet.rs
Outdated
let gamemode = self.player.as_ref().unwrap().gamemode; | ||
if gamemode != GameMode::Creative { | ||
self.kick("CHEATER") | ||
} | ||
let inventory = &mut self.player.as_mut().unwrap().inventory; |
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 we should &mut self.player.as_mut()
twice when we also could just do it once ?
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.
because the borrow checker yells at me if i try to have a mut ref to player (that gets used later, so it can't be dropped) when doing self.kick (which requires &mut)
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.
let player = self.player.as_mut().unwrap();
if player.gamemode != GameMode::Creative {
self.kick("Invalid action, you can only do that if you are in creative");
return;
}
player
.inventory
.set_slot(packet.slot as usize, packet.clicked_item.to_item(), false);
that should be fixed now |
Looks good, Thanks |
make sure the players gamemode is creative when client sends SSetCreativeSlot