Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin Development Tutorial / API Docs #5

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vyPal
Copy link

@vyPal vyPal commented Jan 18, 2025

This PR aims to add docs and a development tutorial for the Pumpkin plugin system from Pumpkin-MC/Pumpkin#339

TODO

  • Plugin Development tutorial (~30% done)
  • API Docs

Comment on lines +10 to +22
pub struct MyPlugin {}

impl MyPlugin {
pub fn new() -> Self {
MyPlugin {}
}
}

impl Default for MyPlugin {
fn default() -> Self {
Self::new()
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pub struct MyPlugin; will be enough, no need for the other implementations

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhh i get an error when having non default, is there a way to prevent that ?

rustc: no function or associated item named `new` found for struct `MyPlugin` in the current scope
items from traits can only be used if the trait is implemented and in scope
the following traits define an item `new`, perhaps you need to implement one of them:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #[plugin_impl] proc macro uses the new() on the struct to construct it so that you can have your own fields in it

Comment on lines +83 to +95
pub struct MyPlugin {}

impl MyPlugin {
pub fn new() -> Self {
MyPlugin {}
}
}

impl Default for MyPlugin {
fn default() -> Self {
Self::new()
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here aswell

Comment on lines +7 to +15
Before we can get started, we need to have a folder to house our plugin's source code. Either create one using the file explorer, or from the command line using:
```bash
mkdir hello-pumpkin && cd hello-pumpkin
```

Next we need to initialize our crate, do so by running this command in the folder you created:
```bash
cargo init --lib
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would simpler to replace this with cargo new <name> --lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants