Skip to content

Commit

Permalink
Merge branch 'master' into biome-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
urisinger authored Jan 3, 2025
2 parents 01f5fa0 + 0fbc730 commit f3261db
Show file tree
Hide file tree
Showing 125 changed files with 1,214 additions and 669 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/config.yml

This file was deleted.

15 changes: 1 addition & 14 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
<!-- Empty or bad Descriptions are not welcome, Don't waste my time -->

<!-- A Detailed Description -->
## Description

<!-- A description of the tests performed to verify the changes -->
## Testing

<!-- Please use Markdown Checkboxes.
[ ] = not done
[x] = done
(or just click checkboxes to toggle them)
-->
## Checklist
Things need to be done before this Pull Request can be merged.

- [ ] Code is well-formatted and adheres to project style guidelines: `cargo fmt`
- [ ] Code does not produce any clippy warnings: `cargo clippy`
- [ ] All unit tests pass: `cargo test`
- [ ] I added new unit tests, so other people don't accidentally break my code by changing other parts of the codebase. [How?](https://doc.rust-lang.org/book/ch11-01-writing-tests.html)
Please follow our [Coding Guidelines](https://github.com/Pumpkin-MC/Pumpkin/blob/master/CONTRIBUTING.md#coding-guidelines)
23 changes: 17 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,27 @@ There are several ways you can contribute to Pumpkin:

The Documentation of Pumpkin can be found at <https://pumpkinmc.org/>

**Tip: [typos](https://github.com/crate-ci/typos) is a great Project to detect and automatically fix typos
**Tip: [typos](https://github.com/crate-ci/typos) is a great Project to detect and automatically fix typos**

### Coding Guidelines

Things need to be done before this Pull Request can be merged. Your CI also checks most of them automaticly and fill fail if something is not fulfilled
Note: Pumpkin's clippy settings are relativly strict, this can be may frustrating but is necesarry so the code says clean and conssistent
**Basic**

- **Code Formatting:** Code must be well-formatted and follow the project's style guidelines. You can achieve this by running `cargo fmt`.
- **No Clippy Warnings:** Code should not produce any warnings from the Clippy linter. You can check for warnings using `cargo clippy --all-targets`.
- **Passing Unit Tests:** All existing unit tests must pass successfully. You can run the tests with `cargo test`.

**Best Pratice**

- **Writing Unit Tests:** When adding new features or modifying existing code, consider adding unit tests to prevent regressions in the future. Refer to the Rust documentation for guidance on writing tests: https://doc.rust-lang.org/book/ch11-01-writing-tests.html
- **Benchmarking:** If your changes might impact performance, consider adding benchmarks to track performance regressions or improvements. We use the Criterion library for benchmarking. Refer to their Quick Start guide for more information: https://github.com/bheisler/criterion.rs#quickstart
- **Clear and Concise Commit Messages:** Use clear and concise commit messages that describe the changes you've made.
- **Code Style:** Adhere to consistent coding style throughout your contributions.
- **Documentation:** If your changes introduce new functionality, consider updating the relevant documentation.
- **Working with Tokio and Rayon:**
When invoking CPU intensive work, this work should be done in the Rayon thread pool via `rayon::spawn`, Rayon's
parallel iterators, or otherwise instead of from the Tokio runtime. However, it is important that the
Tokio runtime not block on these Rayon calls. Instead, the data should be passed to the Tokio runtime
via async means, for example: `tokio::sync::mpsc`. An example of how to properly do this can be found
in `pumpkin_world::level::Level::fetch_chunks`.
When dealing with CPU-intensive tasks, it's recommended to utilize Rayon's thread pool (`rayon::spawn`), parallel iterators, or similar mechanisms instead of the Tokio runtime. However, it's crucial to avoid blocking the Tokio runtime on Rayon calls. Instead, use asynchronous methods like `tokio::sync::mpsc` to transfer data between the two runtimes. Refer to `pumpkin_world::level::Level::fetch_chunks` for an example of this approach.

### Additional Information

Expand Down
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ debug = true
[workspace.dependencies]
log = "0.4"
tokio = { version = "1.42", features = [
"fs",
"io-util",
"macros",
"net",
"rt-multi-thread",
Expand All @@ -45,8 +43,6 @@ tokio = { version = "1.42", features = [
] }

thiserror = "2"
num-traits = "0.2"
num-derive = "0.4"

bytes = "1.9"

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Aleksander Medvedev
Copyright (c) 2025 Aleksander Medvedev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ and customizable experience. It prioritizes performance and player enjoyment whi

- [x] Configuration (toml)
- [x] Server Status/Ping
- Login
- Networking
- [x] Encryption
- [x] Packet Compression
- Player Configuration
Expand All @@ -52,10 +52,11 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- [x] Bossbar
- [x] Chunk Loading
- [x] Chunk Generation
- [ ] Chunk Saving
- [x] World Time
- [x] Scoreboard
- [x] World Borders
- [ ] World Saving
- [x] World Saving
- Player
- [x] Player Skins
- [x] Player Client brand
Expand All @@ -65,11 +66,11 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- [x] Player Inventory
- [x] Player Combat
- Entities
- [ ] Non-Living (Minecart, Eggs...)
- [x] Players
- [ ] Mobs
- [ ] Animals
- [x] Mobs
- [x] Animals
- [ ] Entity AI
- [ ] Minecart
- [ ] Boss
- Server
- [ ] Plugins
Expand All @@ -79,7 +80,7 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- [x] Particles
- [x] Chat
- [x] Commands
- [x] OP Permission
- [x] Permissions
- Proxy
- [x] Bungeecord
- [x] Velocity
Expand Down
29 changes: 10 additions & 19 deletions pumpkin-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use log::warn;
use logging::LoggingConfig;
use pumpkin_core::{Difficulty, GameMode, PermissionLvl};
use query::QueryConfig;
use serde::{de::DeserializeOwned, Deserialize, Serialize};

use std::{
Expand All @@ -12,29 +11,26 @@ use std::{
sync::LazyLock,
};

pub mod auth;
pub mod logging;
pub mod proxy;
pub mod query;
pub mod networking;

pub mod resource_pack;

pub use auth::AuthenticationConfig;
pub use commands::CommandsConfig;
pub use compression::CompressionConfig;
pub use lan_broadcast::LANBroadcastConfig;
pub use networking::auth::AuthenticationConfig;
pub use networking::compression::CompressionConfig;
pub use networking::lan_broadcast::LANBroadcastConfig;
pub use networking::rcon::RCONConfig;
pub use pvp::PVPConfig;
pub use rcon::RCONConfig;
pub use server_links::ServerLinksConfig;

mod commands;
pub mod compression;
mod lan_broadcast;

pub mod op;
mod pvp;
mod rcon;
mod server_links;

use proxy::ProxyConfig;
use networking::NetworkingConfig;
use resource_pack::ResourcePackConfig;

const CONFIG_ROOT_FOLDER: &str = "config/";
Expand All @@ -52,17 +48,12 @@ pub static BASIC_CONFIG: LazyLock<BasicConfiguration> = LazyLock::new(BasicConfi
#[derive(Deserialize, Serialize, Default)]
#[serde(default)]
pub struct AdvancedConfiguration {
pub proxy: ProxyConfig,
pub authentication: AuthenticationConfig,
pub packet_compression: CompressionConfig,
pub logging: LoggingConfig,
pub resource_pack: ResourcePackConfig,
pub networking: NetworkingConfig,
pub commands: CommandsConfig,
pub rcon: RCONConfig,
pub pvp: PVPConfig,
pub logging: LoggingConfig,
pub query: QueryConfig,
pub server_links: ServerLinksConfig,
pub lan_broadcast: LANBroadcastConfig,
}

#[derive(Serialize, Deserialize)]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions pumpkin-config/src/networking/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use auth::AuthenticationConfig;
use proxy::ProxyConfig;
use query::QueryConfig;
use rcon::RCONConfig;
use serde::{Deserialize, Serialize};

use crate::{CompressionConfig, LANBroadcastConfig};

pub mod auth;
pub mod compression;
pub mod lan_broadcast;
pub mod proxy;
pub mod query;
pub mod rcon;

#[derive(Deserialize, Serialize, Default)]
pub struct NetworkingConfig {
pub authentication: AuthenticationConfig,
pub query: QueryConfig,
pub rcon: RCONConfig,
pub proxy: ProxyConfig,
pub packet_compression: CompressionConfig,
pub lan_broadcast: LANBroadcastConfig,
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pumpkin-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pumpkin-nbt = { path = "../pumpkin-nbt" }
serde.workspace = true
bytes.workspace = true
uuid.workspace = true
num-traits.workspace = true
num-derive.workspace = true

num-traits = "0.2"

colored = "2"
md5 = "0.7.0"
16 changes: 14 additions & 2 deletions pumpkin-core/src/gamemode.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::str::FromStr;

use num_derive::FromPrimitive;
use serde::{Deserialize, Serialize};

#[derive(Debug, PartialEq, Eq)]
pub struct ParseGameModeError;

#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, FromPrimitive)]
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
#[repr(i8)]
pub enum GameMode {
Undefined = -1,
Expand All @@ -16,6 +15,19 @@ pub enum GameMode {
Spectator,
}

impl From<i8> for GameMode {
fn from(value: i8) -> Self {
match value {
-1 => Self::Undefined,
0 => Self::Survival,
1 => Self::Creative,
2 => Self::Adventure,
3 => Self::Spectator,
_ => Self::Undefined,
}
}
}

impl FromStr for GameMode {
type Err = ParseGameModeError;

Expand Down
11 changes: 8 additions & 3 deletions pumpkin-core/src/permission.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use num_derive::{FromPrimitive, ToPrimitive};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

/// Represents the player's permission level
Expand All @@ -10,7 +9,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
/// - `Two`: `gamemaster`: Player or executor can use more commands and player can use command blocks.
/// - `Three`: `admin`: Player or executor can use commands related to multiplayer management.
/// - `Four`: `owner`: Player or executor can use all of the commands, including commands related to server management.
#[derive(FromPrimitive, ToPrimitive, Clone, Copy, Default, PartialEq, Eq)]
#[derive(Clone, Copy, Default, PartialEq, Eq)]
#[repr(i8)]
pub enum PermissionLvl {
#[default]
Expand All @@ -23,7 +22,13 @@ pub enum PermissionLvl {

impl PartialOrd for PermissionLvl {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
(*self as u8).partial_cmp(&(*other as u8))
Some((*self as u8).cmp(&(*other as u8)))
}
}

impl Ord for PermissionLvl {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
(*self as u8).cmp(&(*other as u8))
}
}

Expand Down
12 changes: 6 additions & 6 deletions pumpkin-core/src/text/click.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ use serde::{Deserialize, Serialize};
/// Action to take on click of the text.
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, Eq, Hash)]
#[serde(tag = "action", content = "value", rename_all = "snake_case")]
pub enum ClickEvent<'a> {
pub enum ClickEvent {
/// Opens a URL
OpenUrl(Cow<'a, str>),
OpenUrl(Cow<'static, str>),
/// Opens a File
OpenFile(Cow<'a, str>),
OpenFile(Cow<'static, str>),
/// Works in signs, but only on the root text component
RunCommand(Cow<'a, str>),
RunCommand(Cow<'static, str>),
/// Replaces the contents of the chat box with the text, not necessarily a
/// command.
SuggestCommand(Cow<'a, str>),
SuggestCommand(Cow<'static, str>),
/// Only usable within written books. Changes the page of the book. Indexing
/// starts at 1.
ChangePage(i32),
/// Copies the given text to system clipboard
CopyToClipboard(Cow<'a, str>),
CopyToClipboard(Cow<'static, str>),
}
12 changes: 6 additions & 6 deletions pumpkin-core/src/text/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ use super::TextComponent;

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(tag = "action", content = "contents", rename_all = "snake_case")]
pub enum HoverEvent<'a> {
pub enum HoverEvent {
/// Displays a tooltip with the given text.
ShowText(Cow<'a, str>),
ShowText(Cow<'static, str>),
/// Shows an item.
ShowItem {
/// Resource identifier of the item
id: Cow<'a, str>,
id: Cow<'static, str>,
/// Number of the items in the stack
count: Option<i32>,
/// NBT information about the item (sNBT format)
tag: Cow<'a, str>,
tag: Cow<'static, str>,
},
/// Shows an entity.
ShowEntity {
Expand All @@ -25,9 +25,9 @@ pub enum HoverEvent<'a> {
/// Resource identifier of the entity
#[serde(rename = "type")]
#[serde(default, skip_serializing_if = "Option::is_none")]
kind: Option<Cow<'a, str>>,
kind: Option<Cow<'static, str>>,
/// Optional custom name for the entity
#[serde(default, skip_serializing_if = "Option::is_none")]
name: Option<Box<TextComponent<'a>>>,
name: Option<Box<TextComponent>>,
},
}
Loading

0 comments on commit f3261db

Please sign in to comment.