Fix: Gamemode messages

Do not send them to target, send them to sender
This commit is contained in:
Snowiiii
2024-10-19 10:57:11 +02:00
parent 9d558967c1
commit 2945a6542e
8 changed files with 26 additions and 16 deletions

View File

@@ -36,7 +36,7 @@ rayon = "1.10.0"
parking_lot = "0.12.3"
crossbeam = "0.8.4"
uuid = { version = "1.10.0", features = ["serde", "v3", "v4"] }
uuid = { version = "1.11.0", features = ["serde", "v3", "v4"] }
derive_more = { version = "1.0.0", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }

View File

@@ -18,7 +18,7 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- **Performance**: Leveraging multi-threading for maximum speed and efficiency.
- **Compatibility**: Supports the latest Minecraft server version and adheres to vanilla game mechanics.
- **Security**: Prioritizes security by preventing known exploits.
- **Security**: Prioritizes security by preventing known security exploits.
- **Flexibility**: Highly configurable, with the ability to disable unnecessary features.
- **Extensibility**: Provides a foundation for plugin development.
@@ -48,6 +48,7 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- [x] Entity Spawning
- [x] Chunk Loading
- [x] Chunk Generation
- [x] Scoreboard
- [ ] World Borders
- [ ] World Saving
- Player

View File

@@ -9,7 +9,7 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- **Performance**: Leveraging multi-threading for maximum speed and efficiency.
- **Compatibility**: Supports the latest Minecraft server version and adheres to vanilla game mechanics.
- **Security**: Prioritizes security by preventing known exploits.
- **Security**: Prioritizes security by preventing known security exploits.
- **Flexibility**: Highly configurable, with the ability to disable unnecessary features.
- **Extensibility**: Provides a foundation for plugin development.
@@ -20,3 +20,13 @@ and customizable experience. It prioritizes performance and player enjoyment whi
> [!IMPORTANT]
> Pumpkin is currently under heavy development. Check out our [Github Project](https://github.com/users/Snowiiii/projects/12/views/3) to see current progress
## Vanilla
Pumpkin is designed to replicate vanilla Minecraft logic as closely as possible,
ensuring a familiar gameplay experience. However, we've also added new features to enhance your gameplay.
### Redstone
Unlike other forks that may compromise vanilla redstone mechanics, Pumpkin maintains the original redstone behavior.
If you're looking to experiment with redstone modifications or seek performance optimizations, you have the flexibility to do so through our configurable settings.

View File

@@ -5,12 +5,12 @@ use serde::Serialize;
#[derive(Serialize)]
#[packet(0x6C)]
pub struct CSystemChatMessage<'a> {
content: TextComponent<'a>,
content: &'a TextComponent<'a>,
overlay: bool,
}
impl<'a> CSystemChatMessage<'a> {
pub fn new(content: TextComponent<'a>, overlay: bool) -> Self {
pub fn new(content: &'a TextComponent<'a>, overlay: bool) -> Self {
Self { content, overlay }
}
}

View File

@@ -15,7 +15,6 @@ itertools.workspace = true
thiserror = "1.0"
futures = "0.3"
# Compression
flate2 = "1.0"
lz4 = "1.11.1"

View File

@@ -74,14 +74,14 @@ pub fn init_command_tree<'a>() -> CommandTree<'a> {
return if let Player(target) = sender {
if target.gamemode.load() == gamemode {
target.send_system_message(TextComponent::text(&format!(
target.send_system_message(&TextComponent::text(&format!(
"You already in {:?} gamemode",
gamemode
)));
} else {
// TODO
target.set_gamemode(gamemode);
target.send_system_message(TextComponent::text(&format!(
target.send_system_message(&TextComponent::text(&format!(
"Game mode was set to {:?}",
gamemode
)));
@@ -98,16 +98,16 @@ pub fn init_command_tree<'a>() -> CommandTree<'a> {
let target = parse_arg_player(sender, server, ARG_TARGET, args)?;
if target.gamemode.load() == gamemode {
target.send_system_message(TextComponent::text(&format!(
"You already in {:?} gamemode",
gamemode
sender.send_message(TextComponent::text(&format!(
"{} is already in {:?} gamemode",
target.gameprofile.name, gamemode
)));
} else {
// TODO
target.set_gamemode(gamemode);
target.send_system_message(TextComponent::text(&format!(
"Game mode was set to {:?}",
gamemode
sender.send_message(TextComponent::text(&format!(
"{}'s Game mode was set to {:?}",
target.gameprofile.name, gamemode
)));
}

View File

@@ -31,7 +31,7 @@ impl<'a> CommandSender<'a> {
match self {
// TODO: add color and stuff to console
CommandSender::Console => log::info!("{}", text.to_pretty_console()),
CommandSender::Player(c) => c.send_system_message(text),
CommandSender::Player(c) => c.send_system_message(&text),
CommandSender::Rcon(s) => s.push(text.to_pretty_console()),
}
}

View File

@@ -267,7 +267,7 @@ impl Player {
));
}
pub fn send_system_message(&self, text: TextComponent) {
pub fn send_system_message(&self, text: &TextComponent) {
self.client
.send_packet(&CSystemChatMessage::new(text, false));
}