Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Mixelate/lwm
💨 Blazing fast, lightweight, and simple inventory menu library
https://github.com/Mixelate/lwm
Last synced: about 1 month ago
JSON representation
💨 Blazing fast, lightweight, and simple inventory menu library
- Host: GitHub
- URL: https://github.com/Mixelate/lwm
- Owner: Mixelate
- Created: 2021-12-21T18:56:34.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-21T20:19:27.000Z (almost 3 years ago)
- Last Synced: 2024-05-16T08:12:27.910Z (7 months ago)
- Language: Java
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-blazingly-fast - lwm - 💨 Blazing fast, lightweight, and simple inventory menu library (Java)
README
# LWM
A lightweight inventory menu library for the Spigot API.## Usage
### LightweightMenuHandler
1. To start using LWM, you'll need to create an instance of LightweightMenuHandler. You should do this in your plugins main class.```java
public class MyPlugin extends JavaPlugin {private LightweightMenuHandler lwmHandler;
@Override
public void onEnable() {
this.lwmHandler = new LightweightMenuHandler();
}
}
```2. After you have an instance of LightweightMenuHandler, you need to register it as an event listener. You can do this with the plugin manager or use the utility method 'registerListener'.
```java
@Override
public void onEnable() {
this.lwmHandler = new LightweightMenuHandler();
this.lwmHandler.registerListener(this);
}
```### LightweightMenu
1. Now you can create your first menu. You'll start by making a child class of LightweightMenu. The constructor takes a menu title as well as a row count.```java
public class MyMenu extends LightweightMenu {public MyMenu() {
super("My lightweight menu!", 3);
}}
```2. In the constructor you start customizing and adding components to your menu. Currently LWM supports toggleable dragging, buttons, slots, and static items.
```java
public class MyMenu extends LightweightMenu {public MyMenu() {
super("My lightweight menu!", 3);
setAllowDragging(false);
addMenuComponents(
// New button at inventory slot 20. Lambda parameters are the player who clicked the button and the menu that was clicked
new ClickComponent(this, 20, (player, menu) -> {
// Do something!!
}),
// New slot at inventory slot 20. Lambda parameters are the player who modified the slot, the inventory modified and the new stack in that slot
new SlotComponent(this, 21, (player, inventory, newStack) -> {
// Do something!
}),
// New static item at inventory slot 22
new ItemComponent(this, 22, Material.BLACK_STAINED_GLASS_PANE)
);
}
}
```