Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/infumia/frame
An inventory framework for Minecraft.
https://github.com/infumia/frame
Last synced: 7 days ago
JSON representation
An inventory framework for Minecraft.
- Host: GitHub
- URL: https://github.com/infumia/frame
- Owner: Infumia
- License: mit
- Created: 2024-09-29T17:34:19.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-10-17T18:50:20.000Z (2 months ago)
- Last Synced: 2024-10-20T22:42:03.256Z (2 months ago)
- Language: Java
- Homepage:
- Size: 230 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# frame
[![Maven Central Version](https://img.shields.io/maven-central/v/net.infumia/frame)](https://central.sonatype.com/artifact/net.infumia/frame)
## How to Use (Developers)
### Gradle
```groovy
repositories {
mavenCentral()
}dependencies {
// Base modules
implementation "net.infumia:frame:VERSION"
runtimeOnly "net.infumia:frame-core:VERSION"
}
```
### Code
```java
public final class Plugin extends JavaPlugin {
public static final TypedKey CONSOLE_KEY =
TypedKey.of(CommandSender.class, "console");
private final Frame frame = Frame.create(this)
.with(ViewExample.class);
@Override
public void onEnable() {
/*this.frame.register();*/
this.frame.register(builder ->
builder.add(Plugin.CONSOLE_KEY, Bukkit.getConsoleSender()));
}
}public final class ViewExample implements ViewHandler {
@Override
public void onInit(@NotNull final ContextInit ctx) {
ctx.configBuilder().type(InvType.CHEST).cancelOnClick();
}@Override
public void onOpen(@NotNull final ContextOpen ctx) {
final Viewer viewer = ctx.viewer();
ctx
.modifyConfig()
.layout(new String[] {
"xxxxxxxxx",
"xxxxaxxxx",
"xxxxxxxxx"
})
.title("Player: " + viewer.player().getName());
}@Override
public void onFirstRender(@NotNull final ContextRender ctx) {
final CommandSender sender = ctx.instances().getOrThrow(Plugin.CONSOLE_KEY);
ctx.layoutSlot('x', new ItemStack(Material.GRAY_STAINED_GLASS_PANE));ctx
.layoutSlot('a', new ItemStack(Material.DIAMOND))
.cancelOnClick()
.onClick(context -> {
context.closeForViewer();
sender.sendMessage("Player " + context.clicker().player() + " clicked to a diamond!");
});
}
}
```