Skip to content

Commit 9553850

Browse files
illyrius666Illyriusrenovate[bot]
authored
Dev (#16)
* init Signed-off-by: Illyrius <fitimq@live.nl> * [ci-skip] Update actions/cache action to v5.0.3 (#3) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [ci-skip] Update actions/checkout action to v6.0.2 (#4) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * + Signed-off-by: Illyrius <fitimq@live.nl> * move to json instead of toml for config Signed-off-by: Illyrius <fitimq@live.nl> * + Signed-off-by: Illyrius <fitimq@live.nl> * blub Signed-off-by: Illyrius <fitimq@live.nl> * refactor: update MOTD module to use server configuration Signed-off-by: Illyrius <FitimQ@live.nl> * added Module trait Signed-off-by: Illyrius <fitimq@live.nl> * some fmt Signed-off-by: Illyrius <fitimq@live.nl> * adjusted text Signed-off-by: Illyrius <fitimq@live.nl> * added some rules Signed-off-by: Illyrius <fitimq@live.nl> * set some linting rules in the cargo.toml file instead of having it defined top-level for each file Signed-off-by: Illyrius <fitimq@live.nl> * [ci-skip] Update softprops/action-gh-release digest to e798e6a (#5) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * some small refactoring Signed-off-by: Illyrius <fitimq@live.nl> * fix docs Signed-off-by: Illyrius <fitimq@live.nl> * restructuring Signed-off-by: Illyrius <fitimq@live.nl> * reconstructing Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * added init locator module and its configuration and did some restructuring Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * trying to get the cmd and perms registration going Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * added the cmd arguments sort of Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * fix cmds for locator, start impl in executor, wait for locator bar api Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * [ci-skip] Update GitHub Artifact Actions (#6) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [ci-skip] Update actions-rust-lang/setup-rust-toolchain digest to a0b538f (#7) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * using wasm for plugins Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * some more changes Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * adjust readme Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * some more fixes * some more fixes Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * using plugin id const for perms Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * + Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * + Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * cleanup Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * added tablist.rs Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * rename Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * fix get_data_folder Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> * [ci-skip] Update actions/download-artifact action to v8.0.1 (#8) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [ci-skip] Update actions-rust-lang/setup-rust-toolchain digest to 150fca8 (#9) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [ci-skip] Update softprops/action-gh-release digest to 5284765 (#10) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [ci-skip] Update softprops/action-gh-release digest to 37819cb (#11) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [ci-skip] Update softprops/action-gh-release digest to 11f9176 (#12) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [ci-skip] Update softprops/action-gh-release digest to 26e8ad2 (#13) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [ci-skip] Update softprops/action-gh-release digest to 153bb8e (#14) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [ci-skip] Update actions/cache action to v5.0.4 (#15) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * + Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> --------- Signed-off-by: Illyrius <fitimq@live.nl> Signed-off-by: Illyrius <FitimQ@live.nl> Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com> Co-authored-by: Illyrius <fitimq@live.nl> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 20f2e3f commit 9553850

15 files changed

Lines changed: 455 additions & 99 deletions

File tree

.github/renovate.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"assignees": [
4-
"illyrius666"
5-
],
6-
"automerge": true,
7-
"baseBranchPatterns": [
8-
"dev"
9-
],
10-
"extends": [
11-
"config:recommended"
12-
],
13-
"prHeader": "Dependencies Updater",
14-
"commitMessagePrefix": "[ci-skip]"
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"assignees": [
4+
"illyrius666"
5+
],
6+
"automerge": true,
7+
"baseBranchPatterns": [
8+
"main"
9+
],
10+
"extends": [
11+
"config:recommended"
12+
],
13+
"prHeader": "Dependencies Updater",
14+
"commitMessagePrefix": "[ci-skip]"
1515
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Xodium CI/CD - Build Application
1+
name: Xodium CI/CD - Build | Test | Release
22

33
on:
44
push:
@@ -31,11 +31,11 @@ jobs:
3131
steps:
3232
- id: checkout
3333
name: Checkout
34-
uses: actions/checkout@v6.0.1
34+
uses: actions/checkout@v6.0.2
3535

3636
- id: cache_dependencies
3737
name: Cache dependencies
38-
uses: actions/cache@v5.0.2
38+
uses: actions/cache@v5.0.4
3939
with:
4040
path: |
4141
~/.cargo/registry
@@ -45,7 +45,7 @@ jobs:
4545

4646
- id: setup_rust
4747
name: Setup Rust
48-
uses: actions-rust-lang/setup-rust-toolchain@806aa7ddf5d59f36fb30048411f6bde29364a53f
48+
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606
4949
with:
5050
toolchain: stable
5151
components: rustfmt, clippy
@@ -63,7 +63,7 @@ jobs:
6363

6464
- id: upload_artifact
6565
name: Upload Artifact
66-
uses: actions/upload-artifact@v6.0.0
66+
uses: actions/upload-artifact@v7.0.0
6767
with:
6868
name: ${{ env.APP_NAME }}-${{ matrix.os }}
6969
path: target/release/${{ env.APP_NAME }}
@@ -81,11 +81,11 @@ jobs:
8181
steps:
8282
- id: checkout
8383
name: Checkout
84-
uses: actions/checkout@v6.0.1
84+
uses: actions/checkout@v6.0.2
8585

8686
- id: setup_rust
8787
name: Setup Rust
88-
uses: actions-rust-lang/setup-rust-toolchain@806aa7ddf5d59f36fb30048411f6bde29364a53f
88+
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606
8989
with:
9090
toolchain: stable
9191

@@ -107,7 +107,7 @@ jobs:
107107
steps:
108108
- id: download_artifact
109109
name: Download Artefact
110-
uses: actions/download-artifact@v7.0.0
110+
uses: actions/download-artifact@v8.0.1
111111
with:
112112
name: ${{ env.APP_NAME }}
113113

@@ -118,7 +118,7 @@ jobs:
118118

119119
- id: create_release
120120
name: Create Release
121-
uses: softprops/action-gh-release@78237c54eb15310cb292a15480c4be010be47aeb
121+
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe
122122
env:
123123
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
124124
with:

.github/workflows/enforce_branch.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ permissions:
1515
jobs:
1616
enforce-branch:
1717
runs-on: ubuntu-latest
18+
if: github.actor != 'renovate[bot]'
1819
steps:
1920
- id: enforce_branch
2021
name: Enforce and Auto-fix Target Branch
@@ -27,9 +28,9 @@ jobs:
2728
run: |
2829
if [ "$BASE_REF" == "main" ] && [ "$HEAD_REF" != "dev" ]; then
2930
echo "❌ PR is targeting 'main' but not from 'dev'. Changing target to 'dev'..."
30-
31+
3132
gh pr edit "$PR_NUMBER" --repo "$REPO" --base dev
32-
33+
3334
echo "changed=true" >> $GITHUB_OUTPUT
3435
echo "✅ Target branch automatically changed to 'dev'"
3536
echo "⚠️ To merge to 'main', please create a PR from 'dev' branch"

.github/workflows/enforce_pr_title.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ permissions:
1515
jobs:
1616
enforce-title:
1717
runs-on: ubuntu-latest
18+
if: github.actor != 'renovate[bot]'
1819
steps:
1920
- id: enforce_title
2021
name: Set PR title to branch name

.idea/dictionaries/project.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
[package]
2-
name = "illyriaplus"
2+
name = "vanillaplus"
33
version = "0.0.1"
44
edition = "2024"
5+
authors = ["Xodium"]
56

67
[lib]
78
crate-type = ["cdylib"]
89

910
[dependencies]
10-
pumpkin = { git = "https://github.com/Pumpkin-MC/Pumpkin.git", branch = "master" }
11-
pumpkin-util = { git = "https://github.com/Pumpkin-MC/Pumpkin.git", branch = "master", package = "pumpkin-util" }
12-
pumpkin-api-macros = { git = "https://github.com/Pumpkin-MC/Pumpkin.git", branch = "master" }
13-
14-
tokio = "1.49.0"
11+
pumpkin-plugin-api = { version = "0.1.0", git = "https://github.com/Pumpkin-MC/Pumpkin" }
12+
tracing = "0.1"
13+
serde = { version = "1.0.228", features = ["derive"] }
14+
serde_json = "1.0.149"
1515

1616
[profile.release]
1717
lto = true
18+
19+
[lints.rust]
20+
unsafe_code = "forbid"
21+
22+
[lints.clippy]
23+
all = "warn"

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<img src="https://gist.githubusercontent.com/illyrius666/a38f03b4fbe9b43faa2c5623137c1250/raw/3a1410e77807097bcfbcf963822b41fadd495d9f/xodium.svg" alt="Xodium Logo" width="200">
77
</a>
88
<br /><br />
9-
illyriaplus
9+
Vanilla+
1010
<br />
1111
<br />
1212
</h1>
@@ -38,14 +38,25 @@
3838
<p align="right"><a href="#readme-top">▲</a></p>
3939

4040
[built_with_shield_url]: https://skillicons.dev/icons?i=rust,github,githubactions
41+
4142
[built_with_url]: https://skillicons.dev
42-
[code_of_conduct_url]: https://github.com/XodiumSoftware/illyriaplus?tab=coc-ov-file
43-
[contributing_url]: https://github.com/XodiumSoftware/illyriaplus/blob/main/CONTRIBUTING.md
44-
[contributors_shield_url]: https://img.shields.io/github/contributors/XodiumSoftware/illyriaplus?style=for-the-badge&color=blue
45-
[contributors_url]: https://github.com/XodiumSoftware/illyriaplus/graphs/contributors
46-
[issues_shield_url]: https://img.shields.io/github/issues/XodiumSoftware/illyriaplus?style=for-the-badge&color=yellow
47-
[issues_url]: https://github.com/XodiumSoftware/illyriaplus/issues
48-
[license_url]: https://github.com/XodiumSoftware/illyriaplus?tab=AGPL-3.0-1-ov-file
43+
44+
[code_of_conduct_url]: https://github.com/XodiumSoftware/vanillaplus?tab=coc-ov-file
45+
46+
[contributing_url]: https://github.com/XodiumSoftware/vanillaplus/blob/main/CONTRIBUTING.md
47+
48+
[contributors_shield_url]: https://img.shields.io/github/contributors/XodiumSoftware/vanillaplus?style=for-the-badge&color=blue
49+
50+
[contributors_url]: https://github.com/XodiumSoftware/vanillaplus/graphs/contributors
51+
52+
[issues_shield_url]: https://img.shields.io/github/issues/XodiumSoftware/vanillaplus?style=for-the-badge&color=yellow
53+
54+
[issues_url]: https://github.com/XodiumSoftware/vanillaplus/issues
55+
56+
[license_url]: https://github.com/XodiumSoftware/vanillaplus?tab=AGPL-3.0-1-ov-file
57+
4958
[roadmap_shield_url]: https://img.shields.io/badge/Roadmap-Click%20Me!-purple.svg?style=for-the-badge
59+
5060
[roadmap_url]: https://github.com/orgs/XodiumSoftware/projects/4
51-
[security_url]: https://github.com/XodiumSoftware/illyriaplus?tab=security-ov-file
61+
62+
[security_url]: https://github.com/XodiumSoftware/vanillaplus?tab=security-ov-file

src/config.rs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
use crate::player::Config;
2+
use pumpkin_plugin_api::Context;
3+
use serde::{Deserialize, Serialize};
4+
use std::path::{Path, PathBuf};
5+
use std::{fs, io};
6+
7+
/// Manages plugin configuration, loading from and saving to disk.
8+
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
9+
pub struct ConfigManager {
10+
/// Configuration for the player mechanics module.
11+
pub player_module: Config,
12+
}
13+
14+
impl ConfigManager {
15+
/// Loads the configuration from disk, or writes and returns the default if not found.
16+
///
17+
/// # Errors
18+
/// Returns an [`io::Error`] if an I/O or deserialization error occurs.
19+
pub fn new(context: Context) -> Result<Self, io::Error> {
20+
let path = Self::path(context);
21+
22+
match Self::load(&path) {
23+
Ok(config) => Ok(config),
24+
Err(e) if e.kind() == io::ErrorKind::NotFound => {
25+
let default_config = ConfigManager::default();
26+
default_config.save(&path)?;
27+
Ok(default_config)
28+
}
29+
Err(e) => Err(e),
30+
}
31+
}
32+
33+
/// Returns the path to the configuration file within the plugin's data folder.
34+
fn path(context: Context) -> PathBuf {
35+
PathBuf::from(context.get_data_folder()).join("config.json")
36+
}
37+
38+
/// Reads and deserializes the configuration from `path`.
39+
///
40+
/// # Errors
41+
/// Returns [`io::ErrorKind::NotFound`] if the file does not exist, or
42+
/// [`io::ErrorKind::InvalidData`] if deserialization fails.
43+
fn load(path: &Path) -> Result<ConfigManager, io::Error> {
44+
if !path.exists() {
45+
return Err(io::Error::new(
46+
io::ErrorKind::NotFound,
47+
format!("Config file not found at: {}", path.display()),
48+
));
49+
}
50+
51+
let content = fs::read_to_string(path)?;
52+
let config: ConfigManager = serde_json::from_str(&content)
53+
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
54+
55+
Ok(config)
56+
}
57+
58+
/// Serializes and writes the configuration to `path`, creating parent directories if needed.
59+
///
60+
/// # Errors
61+
/// Returns an [`io::Error`] if serialization or any file operation fails.
62+
fn save(&self, path: &Path) -> Result<(), io::Error> {
63+
if let Some(parent) = path.parent() {
64+
fs::create_dir_all(parent)?;
65+
}
66+
67+
let content = serde_json::to_string_pretty(self)
68+
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
69+
70+
fs::write(path, content)?;
71+
Ok(())
72+
}
73+
}

src/lib.rs

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,53 @@
1+
mod config;
2+
13
mod modules {
2-
pub mod player;
4+
pub mod module;
5+
pub mod mechanics {
6+
pub mod locator;
7+
pub mod motd;
8+
pub mod player;
9+
pub mod tablist;
10+
}
311
}
412

5-
use pumpkin_api_macros::{plugin_impl, plugin_method};
6-
7-
#[plugin_method]
8-
async fn on_load(&mut self, server: Arc<Context>) -> Result<(), String> {
9-
server.init_log();
13+
pub use config::*;
14+
pub use mechanics::*;
15+
pub use modules::*;
1016

11-
log::info!("Hello, Pumpkin!");
17+
use crate::module::Module;
18+
use crate::motd::Motd;
19+
use crate::player::Player;
20+
use pumpkin_plugin_api::{Context, PluginMetadata};
21+
use tracing::info;
1222

13-
server
14-
.register_event(Arc::new(PlayerModule), EventPriority::Lowest, true)
15-
.await;
16-
17-
Ok(())
18-
}
23+
pub const PLUGIN_ID: &str = "vanillaplus";
1924

2025
/// IllyriaPlus plugin implementation.
21-
#[plugin_impl]
2226
pub struct IllyriaPlus {}
2327

2428
impl IllyriaPlus {
25-
pub fn new() -> Self {
29+
fn new() -> Self {
2630
IllyriaPlus {}
2731
}
28-
}
2932

30-
impl Default for IllyriaPlus {
31-
fn default() -> Self {
32-
Self::new()
33+
fn metadata(&self) -> PluginMetadata {
34+
PluginMetadata {
35+
name: "Vanilla+".into(),
36+
version: env!("CARGO_PKG_VERSION").into(),
37+
authors: vec!["Xodium".into()],
38+
description: "Minecraft plugin that enhances the base gameplay in Rust".into(),
39+
}
40+
}
41+
42+
fn on_load(&mut self, context: Context) -> pumpkin_plugin_api::Result<()> {
43+
Motd::default().register(&context);
44+
Player::default().register(&context);
45+
info!("IllyriaPlus loaded. NICE TO CYA!");
46+
Ok(())
47+
}
48+
49+
fn on_unload(&mut self, _context: Context) -> pumpkin_plugin_api::Result<()> {
50+
info!("IllyriaPlus unloaded. CYA NEXT TIME!");
51+
Ok(())
3352
}
3453
}

0 commit comments

Comments
 (0)