-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixs issues @Commandcracker found in review
- Move PermissionLvl to core and removed OpLevel - Move ops.json to /data/ops.json - Fix permissions issue with /op command - Shorten /op command description
- Loading branch information
1 parent
48ba281
commit fa59479
Showing
18 changed files
with
121 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,27 @@ | ||
use serde::{Deserialize, Deserializer, Serialize, Serializer}; | ||
use pumpkin_core::permission::PermissionLvl; | ||
use serde::{Deserialize, Serialize}; | ||
use uuid::Uuid; | ||
|
||
#[derive(Clone, Copy)] | ||
#[repr(u8)] | ||
pub enum OpLevel { | ||
None = 0, | ||
Basic = 1, | ||
Moderator = 2, | ||
Admin = 3, | ||
Owner = 4, | ||
} | ||
|
||
impl Serialize for OpLevel { | ||
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
serializer.serialize_u8(*self as u8) | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for OpLevel { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let value = u8::deserialize(deserializer)?; | ||
match value { | ||
0 => Ok(OpLevel::None), | ||
1 => Ok(OpLevel::Basic), | ||
2 => Ok(OpLevel::Moderator), | ||
3 => Ok(OpLevel::Admin), | ||
4 => Ok(OpLevel::Owner), | ||
_ => Err(serde::de::Error::custom(format!( | ||
"Invalid value for OpLevel: {}", | ||
value | ||
))), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
#[derive(Serialize, Deserialize, Clone, Default)] | ||
pub struct Op { | ||
pub uuid: Uuid, | ||
pub name: String, | ||
pub level: OpLevel, | ||
pub level: PermissionLvl, | ||
pub bypasses_player_limit: bool, | ||
} | ||
|
||
impl Op { | ||
pub fn new( | ||
uuid: Uuid, | ||
name: String, | ||
level: PermissionLvl, | ||
bypasses_player_limit: bool, | ||
) -> Self { | ||
Self { | ||
uuid, | ||
name, | ||
level, | ||
bypasses_player_limit, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod gamemode; | ||
pub mod math; | ||
pub mod permission; | ||
pub mod random; | ||
pub mod text; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use num_derive::{FromPrimitive, ToPrimitive}; | ||
use serde::{Deserialize, Deserializer, Serialize, Serializer}; | ||
|
||
/// Represents the player's permission level | ||
/// | ||
/// Permission levels determine the player's access to commands and server operations. | ||
/// Each numeric level corresponds to a specific role: | ||
/// - `Zero`: None | ||
/// - `One`: Basic | ||
/// - `Two`: Moderator | ||
/// - `Three`: Admin | ||
/// - `Four`: Owner | ||
#[derive(FromPrimitive, ToPrimitive, Clone, Copy, Default, PartialEq, Eq)] | ||
#[repr(i8)] | ||
pub enum PermissionLvl { | ||
#[default] | ||
Zero = 0, | ||
Two = 2, | ||
Three = 3, | ||
Four = 4, | ||
} | ||
|
||
impl PartialOrd for PermissionLvl { | ||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | ||
(*self as u8).partial_cmp(&(*other as u8)) | ||
} | ||
} | ||
|
||
impl Serialize for PermissionLvl { | ||
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
serializer.serialize_u8(*self as u8) | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for PermissionLvl { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let value = u8::deserialize(deserializer)?; | ||
match value { | ||
0 => Ok(PermissionLvl::Zero), | ||
2 => Ok(PermissionLvl::Two), | ||
3 => Ok(PermissionLvl::Three), | ||
4 => Ok(PermissionLvl::Four), | ||
_ => Err(serde::de::Error::custom(format!( | ||
"Invalid value for OpLevel: {}", | ||
value | ||
))), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.