-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathExampleAddon.java
More file actions
91 lines (76 loc) · 3.59 KB
/
ExampleAddon.java
File metadata and controls
91 lines (76 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package me.CHANGEME.slimefunaddon;
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.GitHubBuildsUpdater;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.libraries.dough.config.Config;
import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack;
import java.io.File;
public class ExampleAddon extends JavaPlugin implements SlimefunAddon {
@Override
public void onEnable() {
// Read something from your config.yml
Config cfg = new Config(this);
if (!new File(getDataFolder(), "config.yml").exists()) {
saveDefaultConfig();
}
//Auto updater for https://thebusybiscuit.github.io/builds/
if (getConfig().getBoolean("options.auto-update") && getDescription().getVersion().startsWith("DEV - ")) {
new GitHubBuildsUpdater(this, getFile(), "CHANGEME/ExampleAddon/master").start();
}
/*
* 1. Creating a new Category
* This Category will use the following ItemStack
*/
ItemStack itemGroupItem = new CustomItemStack(Material.DIAMOND, "&4Addon Category", "", "&a> Click to open");
// Give your Category a unique id.
NamespacedKey itemGroupId = new NamespacedKey(this, "addon_category");
ItemGroup itemGroup = new ItemGroup(itemGroupId, itemGroupItem);
/*
* 2. Create a new SlimefunItemStack
* This class has many constructors, it is very important
* that you give each item a unique id.
*/
SlimefunItemStack slimefunItem = new SlimefunItemStack("COOL_DIAMOND", Material.DIAMOND, "&4Cool Diamond", "&c+20% Coolness");
/*
* 3. Creating a Recipe
* The Recipe is an ItemStack Array with a length of 9.
* It represents a Shaped Recipe in a 3x3 crafting grid.
* The machine in which this recipe is crafted in is specified
* further down as the RecipeType.
*/
ItemStack[] recipe = { new ItemStack(Material.EMERALD), null, new ItemStack(Material.EMERALD), null, new ItemStack(Material.DIAMOND), null, new ItemStack(Material.EMERALD), null, new ItemStack(Material.EMERALD) };
/*
* 4. Registering the Item
* Now you just have to register the item.
* RecipeType.ENHANCED_CRAFTING_TABLE refers to the machine in
* which this item is crafted in.
* Recipe Types from Slimefun itself will automatically add the recipe to that machine.
*/
SlimefunItem item = new SlimefunItem(itemGroup, slimefunItem, RecipeType.ENHANCED_CRAFTING_TABLE, recipe);
item.register(this);
}
@Override
public void onDisable() {
// Logic for disabling the plugin...
}
@Override
public String getBugTrackerURL() {
//adds a link for people to report any bugs/errors/issues to your addon's github page
return "https://github.com/CHANGEME/ExampleAddon/issues";
}
@Override
public JavaPlugin getJavaPlugin() {
/*
* You will need to return a reference to your Plugin here.
* If you are using your main class for this, simply return "this".
*/
return this;
}
}