Skip to content

Loading Plugins

GUIDE EASY

Plugins 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

  1. 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.

    Trusted Publisher Badge
  2. 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.

  3. Once there, locate and click on the Releases tab.

    Find Releases Tab
  4. Now, download the latest version of the plugin.

    Download the Latest Release

    INFO

    Peanut Framework's plugin loader accepts .zip and .pfplugin as plugin file formats.

  5. Once your download has finished, open Visual Studio Code (or choice of compiler).

  6. Navigate to the /plugins/ folder in your project, and copy the plugin file into it.

    Copy plugin file
  7. Now navigate to the tabs in the top left, and click Terminal » New Terminal.

    Create new terminal
  8. In the new window at the bottom of your screen, run the command:
    peanut reload <path to project directory> or npm run peanut:reload

    Run peanut reload <path to project directory>
  9. You should see a result similar to what is shown above. If so, this means the plugin has been successfully loaded into your project!

Congratulations! 🥳
You've installed your first plugin.



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.

ts
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
ts
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();
Congratulations! 🎉
Now you're thinking with plugins!



Nice Job!

You have completed the Loading Plugins guide!

If you experience any issues or have a suggestion, please create an Issue.

What's Next?
If you're in need of a little more guidance, try one of our other guides!

If you're up to it, see Creating a Plugin to try making your own plugin!

Released under the MIT License.