Moved config into its own crate
This commit is contained in:
parent
a17ed23b00
commit
070a50833b
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -1906,6 +1906,7 @@ dependencies = [
|
|||||||
"num-bigint",
|
"num-bigint",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"pumpkin-config",
|
||||||
"pumpkin-core",
|
"pumpkin-core",
|
||||||
"pumpkin-entity",
|
"pumpkin-entity",
|
||||||
"pumpkin-inventory",
|
"pumpkin-inventory",
|
||||||
@ -1929,6 +1930,16 @@ dependencies = [
|
|||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pumpkin-config"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"pumpkin-core",
|
||||||
|
"serde",
|
||||||
|
"toml 0.8.19",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pumpkin-core"
|
name = "pumpkin-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = [ "pumpkin-core", "pumpkin-entity", "pumpkin-inventory", "pumpkin-macros/", "pumpkin-plugin", "pumpkin-protocol/", "pumpkin-registry/", "pumpkin-world", "pumpkin/"]
|
members = [ "pumpkin-config", "pumpkin-core", "pumpkin-entity", "pumpkin-inventory", "pumpkin-macros/", "pumpkin-plugin", "pumpkin-protocol/", "pumpkin-registry/", "pumpkin-world", "pumpkin/"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
12
pumpkin-config/Cargo.toml
Normal file
12
pumpkin-config/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "pumpkin-config"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
pumpkin-core = { path = "../pumpkin-core" }
|
||||||
|
|
||||||
|
serde = "1.0"
|
||||||
|
toml = "0.8"
|
||||||
|
|
||||||
|
log.workspace = true
|
||||||
@ -1,7 +1,6 @@
|
|||||||
|
use pumpkin_core::ProfileAction;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::client::authentication::ProfileAction;
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct AuthenticationConfig {
|
pub struct AuthenticationConfig {
|
||||||
/// Whether to use Mojang authentication.
|
/// Whether to use Mojang authentication.
|
||||||
@ -13,3 +13,10 @@ pub enum Difficulty {
|
|||||||
Normal,
|
Normal,
|
||||||
Hard,
|
Hard,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||||
|
pub enum ProfileAction {
|
||||||
|
ForcedNameChange,
|
||||||
|
UsingBannedSkin,
|
||||||
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ default = []
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
# pumpkin
|
# pumpkin
|
||||||
pumpkin-core = { path = "../pumpkin-core"}
|
pumpkin-core = { path = "../pumpkin-core"}
|
||||||
|
pumpkin-config = { path = "../pumpkin-config" }
|
||||||
pumpkin-plugin = { path = "../pumpkin-plugin"}
|
pumpkin-plugin = { path = "../pumpkin-plugin"}
|
||||||
pumpkin-inventory = { path = "../pumpkin-inventory"}
|
pumpkin-inventory = { path = "../pumpkin-inventory"}
|
||||||
pumpkin-world = { path = "../pumpkin-world"}
|
pumpkin-world = { path = "../pumpkin-world"}
|
||||||
|
|||||||
@ -2,16 +2,15 @@ use std::{collections::HashMap, net::IpAddr};
|
|||||||
|
|
||||||
use base64::{engine::general_purpose, Engine};
|
use base64::{engine::general_purpose, Engine};
|
||||||
use num_bigint::BigInt;
|
use num_bigint::BigInt;
|
||||||
|
use pumpkin_config::{auth::TextureConfig, ADVANCED_CONFIG};
|
||||||
|
use pumpkin_core::ProfileAction;
|
||||||
use pumpkin_protocol::Property;
|
use pumpkin_protocol::Property;
|
||||||
use reqwest::{StatusCode, Url};
|
use reqwest::{StatusCode, Url};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Deserialize;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::server::Server;
|
||||||
config::{auth::TextureConfig, ADVANCED_CONFIG},
|
|
||||||
server::Server,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Deserialize, Clone, Debug)]
|
#[derive(Deserialize, Clone, Debug)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
@ -32,14 +31,6 @@ pub struct Texture {
|
|||||||
metadata: Option<HashMap<String, String>>,
|
metadata: Option<HashMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq)]
|
|
||||||
pub enum ProfileAction {
|
|
||||||
#[serde(rename = "FORCED_NAME_CHANGE")]
|
|
||||||
ForcedNameChange,
|
|
||||||
#[serde(rename = "USING_BANNED_SKIN")]
|
|
||||||
UsingBannedSkin,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Clone, Debug)]
|
#[derive(Deserialize, Clone, Debug)]
|
||||||
pub struct GameProfile {
|
pub struct GameProfile {
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
|
use pumpkin_config::{ADVANCED_CONFIG, BASIC_CONFIG};
|
||||||
use pumpkin_core::text::TextComponent;
|
use pumpkin_core::text::TextComponent;
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
client::{
|
client::{
|
||||||
@ -19,7 +20,6 @@ use sha1::{Digest, Sha1};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::authentication::{self, GameProfile},
|
client::authentication::{self, GameProfile},
|
||||||
config::{ADVANCED_CONFIG, BASIC_CONFIG},
|
|
||||||
entity::player::{ChatMode, Hand},
|
entity::player::{ChatMode, Hand},
|
||||||
proxy::velocity::velocity_login,
|
proxy::velocity::velocity_login,
|
||||||
server::{Server, CURRENT_MC_VERSION},
|
server::{Server, CURRENT_MC_VERSION},
|
||||||
|
|||||||
@ -2,12 +2,12 @@ use std::f32::consts::PI;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{handle_command, CommandSender},
|
commands::{handle_command, CommandSender},
|
||||||
config::ADVANCED_CONFIG,
|
|
||||||
entity::player::{ChatMode, Hand, Player},
|
entity::player::{ChatMode, Hand, Player},
|
||||||
server::Server,
|
server::Server,
|
||||||
util::math::wrap_degrees,
|
util::math::wrap_degrees,
|
||||||
};
|
};
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
|
use pumpkin_config::ADVANCED_CONFIG;
|
||||||
use pumpkin_core::{text::TextComponent, GameMode};
|
use pumpkin_core::{text::TextComponent, GameMode};
|
||||||
use pumpkin_entity::EntityId;
|
use pumpkin_entity::EntityId;
|
||||||
use pumpkin_inventory::WindowType;
|
use pumpkin_inventory::WindowType;
|
||||||
|
|||||||
@ -18,7 +18,6 @@ use server::Server;
|
|||||||
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod config;
|
|
||||||
pub mod entity;
|
pub mod entity;
|
||||||
pub mod proxy;
|
pub mod proxy;
|
||||||
pub mod rcon;
|
pub mod rcon;
|
||||||
@ -29,8 +28,8 @@ pub mod world;
|
|||||||
fn main() -> io::Result<()> {
|
fn main() -> io::Result<()> {
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use config::{ADVANCED_CONFIG, BASIC_CONFIG};
|
|
||||||
use entity::player::Player;
|
use entity::player::Player;
|
||||||
|
use pumpkin_config::{ADVANCED_CONFIG, BASIC_CONFIG};
|
||||||
use pumpkin_core::text::{color::NamedColor, TextComponent};
|
use pumpkin_core::text::{color::NamedColor, TextComponent};
|
||||||
use rcon::RCONServer;
|
use rcon::RCONServer;
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,13 @@ use std::net::SocketAddr;
|
|||||||
|
|
||||||
use bytes::{BufMut, BytesMut};
|
use bytes::{BufMut, BytesMut};
|
||||||
use hmac::{Hmac, Mac};
|
use hmac::{Hmac, Mac};
|
||||||
|
use pumpkin_config::proxy::VelocityConfig;
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
bytebuf::ByteBuffer, client::login::CLoginPluginRequest, server::login::SLoginPluginResponse,
|
bytebuf::ByteBuffer, client::login::CLoginPluginRequest, server::login::SLoginPluginResponse,
|
||||||
};
|
};
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
|
|
||||||
use crate::{client::Client, config::proxy::VelocityConfig};
|
use crate::client::Client;
|
||||||
|
|
||||||
type HmacSha256 = Hmac<Sha256>;
|
type HmacSha256 = Hmac<Sha256>;
|
||||||
|
|
||||||
|
|||||||
@ -9,9 +9,10 @@ use mio::{
|
|||||||
Events, Interest, Poll, Token,
|
Events, Interest, Poll, Token,
|
||||||
};
|
};
|
||||||
use packet::{Packet, PacketError, PacketType};
|
use packet::{Packet, PacketError, PacketType};
|
||||||
|
use pumpkin_config::RCONConfig;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::{commands::handle_command, config::RCONConfig, server::Server};
|
use crate::{commands::handle_command, server::Server};
|
||||||
|
|
||||||
mod packet;
|
mod packet;
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ use std::{
|
|||||||
use base64::{engine::general_purpose, Engine};
|
use base64::{engine::general_purpose, Engine};
|
||||||
use image::GenericImageView;
|
use image::GenericImageView;
|
||||||
use mio::Token;
|
use mio::Token;
|
||||||
|
use pumpkin_config::{BasicConfiguration, BASIC_CONFIG};
|
||||||
use pumpkin_core::GameMode;
|
use pumpkin_core::GameMode;
|
||||||
use pumpkin_entity::EntityId;
|
use pumpkin_entity::EntityId;
|
||||||
use pumpkin_plugin::PluginLoader;
|
use pumpkin_plugin::PluginLoader;
|
||||||
@ -23,12 +24,7 @@ use pumpkin_world::dimension::Dimension;
|
|||||||
use pumpkin_registry::Registry;
|
use pumpkin_registry::Registry;
|
||||||
use rsa::{traits::PublicKeyParts, RsaPrivateKey, RsaPublicKey};
|
use rsa::{traits::PublicKeyParts, RsaPrivateKey, RsaPublicKey};
|
||||||
|
|
||||||
use crate::{
|
use crate::{client::Client, entity::player::Player, world::World};
|
||||||
client::Client,
|
|
||||||
config::{BasicConfiguration, BASIC_CONFIG},
|
|
||||||
entity::player::Player,
|
|
||||||
world::World,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const CURRENT_MC_VERSION: &str = "1.21.1";
|
pub const CURRENT_MC_VERSION: &str = "1.21.1";
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ use std::{
|
|||||||
|
|
||||||
use mio::Token;
|
use mio::Token;
|
||||||
use num_traits::ToPrimitive;
|
use num_traits::ToPrimitive;
|
||||||
|
use pumpkin_config::BasicConfiguration;
|
||||||
use pumpkin_entity::{entity_type::EntityType, EntityId};
|
use pumpkin_entity::{entity_type::EntityType, EntityId};
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
client::play::{
|
client::play::{
|
||||||
@ -19,7 +20,7 @@ use pumpkin_protocol::{
|
|||||||
use pumpkin_world::{level::Level, radial_chunk_iterator::RadialIterator};
|
use pumpkin_world::{level::Level, radial_chunk_iterator::RadialIterator};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use crate::{config::BasicConfiguration, entity::player::Player};
|
use crate::entity::player::Player;
|
||||||
|
|
||||||
pub struct World {
|
pub struct World {
|
||||||
pub level: Arc<Mutex<Level>>,
|
pub level: Arc<Mutex<Level>>,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user