Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kralverde committed Feb 17, 2025
1 parent 148ac38 commit 8ab28c6
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 82 deletions.
1 change: 1 addition & 0 deletions pumpkin-world/src/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl Level {
log::info!("Saving level...");

// chunks are automatically saved when all players get removed
// TODO: Await this ^

// then lets save the world info
self.world_info_writer
Expand Down
9 changes: 5 additions & 4 deletions pumpkin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rand = "0.8"
num-bigint = "0.4"

# Console line reading
rustyline = "15.0"
rustyline-async = "0.4.5"

# encryption
rsa = "0.9"
Expand All @@ -72,11 +72,12 @@ base64 = "0.22"
png = "0.17"

# logging
simple_logger = { version = "5.0", features = ["threads"] }
simplelog = "0.12.2"

# Remove time in favor of chrono?
time = "0.3"

chrono = { version = "0.4", features = ["serde"]}
chrono = { version = "0.4", features = ["serde"] }

# plugins
libloading = "0.8"
Expand All @@ -85,4 +86,4 @@ libloading = "0.8"
git-version = "0.3"
# This makes it so the entire project doesn't recompile on each build on linux.
[target.'cfg(target_os = "windows")'.build-dependencies]
tauri-winres= "0.3"
tauri-winres = "0.3"
14 changes: 4 additions & 10 deletions pumpkin/src/command/commands/stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use pumpkin_util::text::TextComponent;
use crate::command::args::ConsumedArgs;
use crate::command::tree::CommandTree;
use crate::command::{CommandError, CommandExecutor, CommandSender};
use crate::stop_server;

const NAMES: [&str; 1] = ["stop"];

Expand All @@ -17,23 +18,16 @@ impl CommandExecutor for StopExecutor {
async fn execute<'a>(
&self,
sender: &mut CommandSender<'a>,
server: &crate::server::Server,
_server: &crate::server::Server,
_args: &ConsumedArgs<'a>,
) -> Result<(), CommandError> {
sender
.send_message(
TextComponent::translate("commands.stop.stopping", []).color_named(NamedColor::Red),
)
.await;

// TODO: Gracefully stop

let kick_message = TextComponent::text("Server stopped");
for player in server.get_all_players().await {
player.kick(kick_message.clone()).await;
}
server.save().await;
std::process::exit(0)
stop_server();
Ok(())
}
}

Expand Down
10 changes: 6 additions & 4 deletions pumpkin/src/entity/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,17 +815,19 @@ impl Player {
return;
}

self.client
let _ = self
.client
.try_send_packet(&CPlayDisconnect::new(&reason))
.await
.unwrap_or_else(|_| self.client.close());
.await;

log::info!(
"Kicked Player {} ({}) for {}",
self.gameprofile.name,
self.client.id,
reason.to_pretty_console()
);
self.client.close();

self.client.close().await;
}

pub fn can_food_heal(&self) -> bool {
Expand Down
Loading

0 comments on commit 8ab28c6

Please sign in to comment.