Loading Plugins
GUIDE EASYPlugins can be a powerful tool when creating addons; if a plugin exists for the specific type of feature you are trying to create, you can use their class template and save all that work of making it from scratch!
Installing a Plugin
First, find a plugin you like. You can find plugins in the Plugins Marketplace, which serves as a big list of plugins that have been tagged on Github.
INFO
You may notice that some plugins are tagged with a little check mark. This is an indication that the plugin was created by a Trusted Publisher, and is guaranteed to be safe to use.We do not guarantee the safety of third-party plugins created for Peanut Framework, and highly recommend that you vet plugins for malicious code before using them.
Once you choose a plugin, click the plugin entry to visit its Github repository.
TIP
If you already know how to download releases from Github, you can skip this step.
Once there, locate and click on the Releases tab.
Now, download the latest version of the plugin.
INFO
Peanut Framework's plugin loader accepts
.zip
and.pfplugin
as plugin file formats.Once your download has finished, open Visual Studio Code (or choice of compiler).
Navigate to the
/plugins/
folder in your project, and copy the plugin file into it.Now navigate to the tabs in the top left, and click Terminal » New Terminal.
In the new window at the bottom of your screen, run the command:
peanut reload <path to project directory>
ornpm run peanut:reload
You should see a result similar to what is shown above. If so, this means the plugin has been successfully loaded into your project!
Using the Plugin
TIP
If you are already an experienced programmer, you are welcome to skip to the end of this step.
Now that your plugin is installed, let's cover how you can use it!
In general, plugins are designed to create new classes or types that can be used along side Peanut Framework's ones in your project. As such, similarly to framework defintions, they need to be imported into the script you are using them in.
This is very simple to accomplish; all you need is a line of code like this.
import { Example } from "./plugins/ExamplePlugin/classes";
Make sure to replace 'ExamplePlugin
' with the folder name of the plugin you installed, and change '{ Example }'
to a list of every class and type you want to use.
Fantastic! With that out of the way, you can start using it like you would use any other typescript class!
Collapse code snippet
import { Block, Project } from "peanut-framework";
import { Pickaxe } from "./plugins/CustomPickaxe/classes";
const project = new Project("peanut_example");
project.manifest.properties({
header: {
name: "Peanut Example",
description: "Sample Project with Peanut Framework",
},
dependencies: {
server: {},
},
modules: {
scripts: {
entry: "main.js",
},
},
});
project.features = [
new Pickaxe(
"peanut:cosmium_pickaxe",
"items/cosmium_pickaxe",
"Cosmium Pickaxe",
{
destroySpeeds: 10,
durability: 100,
repairItems: [
{
items: ["minecraft:diamond"],
repair_amount: 25,
},
],
}
),
];
project.compile();
Nice Job!
You have completed the Loading Plugins guide!
If you experience any issues or have a suggestion, please create an Issue.
If you're up to it, see Creating a Plugin to try making your own plugin!