-
Notifications
You must be signed in to change notification settings - Fork 2
How to use the API.
broken1arrow edited this page Jun 5, 2023
·
10 revisions
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.broken1arrow</groupId>
<artifactId>MenuLibrary</artifactId>
<version>typeRightVersion</version>
<scope>compile</scope>
</dependency>
</dependencies>
public class MenuMain extends JavaPlugin {
@Override
public void onEnable() {
// this = your main class.
//this will not work any more in 0.28
RegisterClass(this);
//use this.
new RegisterMenuAPI(this);
// own code here
}
@Override
public void onDisable() {
// own code here
}
public static MenuMain getInstance() {
return MenuMain.getPlugin(MenuMain.class);
}
}
You can also add getNbtApi() to get the instance of the nbt data you can set on items or entity's (or get the nbt data). Inside the new RegisterMenuAPI() class do you have a getter to access to methods to get metadata you has added on you item.
//so this code give you access to both get and set metadata.
//You need ether make instance if RegisterMenuAPI or of the getNbtApi() in your plugin to access CompMetadata class.
registerMenuAPIInstance.getNbtApi().getCompMetadata();
From the CheckItemsInsideInventory class. Override the messages with this methods (you can add this where it fits in your code).
SendMsgDuplicatedItems.setBlacklistMessage("This item is blacklisted");
SendMsgDuplicatedItems.setDublicatedMessage("This item already exist inside the inventory");
This api also contains class were you can check items player add inside the inventory. You can also specify slots to check or all slots.
final CheckItemsInsideInventory checkItemsInsideInventory = new CheckItemsInsideInventory();
// if you has blacklisted items players can't add to inventory
checkItemsInsideInventory.setBlacklistedItems(List)
// for set own slots to check
checkItemsInsideInventory.setSlotsToCheck(int...);
// or use this method
checkItemsInsideInventory.setSlotsToCheck(List);
final Map<Integer, ItemStack> map = checkItemsInsideInventory.getItemsOnSpecifiedSlots( Inventory, Player,boolean);