Skip to content

Add an ability to change gamemode from plugins#521

Merged
Defman merged 9 commits into
feather-rs:mainfrom
Iaiao:change-gamemode
Jan 19, 2022
Merged

Add an ability to change gamemode from plugins#521
Defman merged 9 commits into
feather-rs:mainfrom
Iaiao:change-gamemode

Conversation

@Iaiao
Copy link
Copy Markdown
Contributor

@Iaiao Iaiao commented Jan 17, 2022

Add an ability to change gamemode from plugins

Status

  • Ready
  • Development
  • Hold

Description

Adds GamemodeEvent, InstabreakChangeEvent, FlyingAbilityChangeEvent, BuildingAbilityChangeEvent, and InvulnerabilityChangeEvent. This code was taken from #487 (I had to implement this for /gamemode command), but I think this change deserves a separate PR.

Related issues

Checklist

  • Ran cargo fmt, cargo clippy --all-targets, cargo build --release and cargo test and fixed any generated errors!
  • Removed unnecessary commented out code
  • Used specific traces (if you trace actions please specify the cause i.e. the player)

Note: if you locally don't get any errors, but GitHub Actions fails (especially at clippy) you might want to check your rust toolchain version. You can then feel free to fix these warnings/errors in your PR.

Comment thread feather/server/src/client.rs Outdated
pub fn change_gamemode(&self, gamemode: Gamemode) {
self.send_packet(ChangeGameState {
reason: StateReason::ChangeGameMode,
value: gamemode as u8 as f32,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we change the protocol to take Gamemode and implement write on game mode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ChangeGameState requires it to be f64, so I did it in a different way.

Comment thread feather/server/src/systems/gamemode.rs
Comment thread feather/server/src/systems/gamemode.rs Outdated
Comment thread feather/server/src/systems/gamemode.rs
Comment thread feather/server/src/systems/gamemode.rs Outdated
});
}
for (entity, flying) in fly_changes {
if flying {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This if statement is redundant, just create CreativeFlyingEvent with the value of flying?

@Defman Defman merged commit 77f1ace into feather-rs:main Jan 19, 2022
@Iaiao Iaiao mentioned this pull request Jan 20, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants