Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions THIRDPARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

This document contains a list of third-party libraries that Inventory Framework uses.

* [ReflectionUtils](https://github.com/CryptoMorin/XSeries/blob/4e730e565b66cb648426c29c6cc58f923afbce1b/src/main/java/com/cryptomorin/xseries/ReflectionUtils.java). MIT license.
* [InventoryUpdate](https://github.com/aematsubara/InventoryUpdate). MIT license.
* [JetBrains Annotations](https://github.com/JetBrains/java-annotations). Apache 2.0 license.
* [Spigot-API](https://hub.spigotmc.org/stash/projects/SPIGOT). GPL-3.0 license.
* [Gradle Shadow](https://github.com/johnrengelman/shadow). Apache 2.0 license.
* [Kyori's Adventure](https://github.com/KyoriPowered/adventure). MIT license.
* [PaperSpigot](https://github.com/PaperMC/Paper). GPL-3.0 license.
* [ReflectionUtils](https://github.com/CryptoMorin/XSeries/blob/4e730e565b66cb648426c29c6cc58f923afbce1b/src/main/java/com/cryptomorin/xseries/ReflectionUtils.java). MIT License.
* [InventoryUpdate](https://github.com/aematsubara/InventoryUpdate). MIT License.
* [JetBrains Annotations](https://github.com/JetBrains/java-annotations). Apache License 2.0.
* [Spigot-API](https://hub.spigotmc.org/stash/projects/SPIGOT). GPL-3.0 License.
* [Gradle Shadow](https://github.com/johnrengelman/shadow). Apache License 2.0..
* [Kyori's Adventure](https://github.com/KyoriPowered/adventure). MIT License.
* [PaperSpigot](https://github.com/PaperMC/Paper). GPL-3.0 License.
* [FoliaLib](https://github.com/TechnicallyCoded/FoliaLib). MIT License.
* [Minestom](https://github.com/Minestom/Minestom). Apache License 2.0.
8 changes: 6 additions & 2 deletions examples/paper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id("me.devnatan.inventoryframework.library")
alias(libs.plugins.shadowjar)
alias(libs.plugins.bukkit)
alias(libs.plugins.run.paper)
alias(libs.plugins.runPaper)
}

dependencies {
Expand All @@ -23,9 +23,11 @@ tasks.shadowJar {
}
}

runPaper.folia.registerTask()

tasks.runServer {
jvmArgs("-Dme.devnatan.inventoryframework.debug=true")
minecraftVersion("1.21.7")
minecraftVersion("1.21.5")
}

bukkit {
Expand All @@ -36,6 +38,8 @@ bukkit {
website = "https://github.com/DevNatan/inventory-framework"
apiVersion = "1.20"
authors = listOf("SaiintBrisson", "DevNatan", "sasuked", "nicolube")
foliaSupported = true

commands {
register("ifexample") {
description = "This is a test command!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.devnatan.inventoryframework.ViewFrame;
import me.devnatan.inventoryframework.runtime.commands.IFExampleCommandExecutor;
import me.devnatan.inventoryframework.runtime.listener.PigListener;
import me.devnatan.inventoryframework.runtime.view.*;
import me.devnatan.inventoryframework.runtime.view.AnvilInputSample;
import me.devnatan.inventoryframework.runtime.view.AutoUpdate;
import me.devnatan.inventoryframework.runtime.view.Failing;
Expand All @@ -14,13 +15,14 @@ public class SamplePlugin extends JavaPlugin {

@Override
public void onEnable() {
System.out.println("ligoo");
ViewFrame viewFrame = ViewFrame.create(this)
.install(AnvilInputFeature.AnvilInput)
.with(new AnvilInputSample(), new Failing(), new SimplePagination(), new AutoUpdate())
.register();

getCommand("ifexample").setExecutor(new IFExampleCommandExecutor(viewFrame));
IFExampleCommandExecutor command = new IFExampleCommandExecutor(viewFrame);
getCommand("ifexample").setExecutor(command);
getCommand("ifexample").setTabCompleter(command);
getServer().getPluginManager().registerEvents(new PigListener(viewFrame), this);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package me.devnatan.inventoryframework.runtime.commands;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import me.devnatan.inventoryframework.View;
import me.devnatan.inventoryframework.ViewFrame;
import me.devnatan.inventoryframework.runtime.view.AnvilInputSample;
import me.devnatan.inventoryframework.runtime.view.AutoUpdate;
Expand All @@ -8,10 +12,18 @@
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class IFExampleCommandExecutor implements CommandExecutor {
public class IFExampleCommandExecutor implements CommandExecutor, TabCompleter {

private static final Map<String, Class<? extends View>> views = Map.of(
"anvil", AnvilInputSample.class,
"failing", Failing.class,
"simple-pagination", SimplePagination.class,
"auto-update", AutoUpdate.class);

private final ViewFrame viewFrame;

Expand All @@ -38,29 +50,22 @@ public boolean onCommand(
return false;
}

String view = strings[0].toLowerCase();

if (view.equalsIgnoreCase("anvil")) {
viewFrame.open(AnvilInputSample.class, player);
return true;
}

if (view.equalsIgnoreCase("failing")) {
viewFrame.open(Failing.class, player);
return true;
}

if (view.equalsIgnoreCase("simple-pagination")) {
viewFrame.open(SimplePagination.class, player);
return true;
}

if (view.equalsIgnoreCase("auto-update")) {
viewFrame.open(AutoUpdate.class, player);
Class<? extends View> viewClass = views.get(strings[0].toLowerCase());
if (viewClass != null) {
viewFrame.open(viewClass, player);
return true;
}

commandSender.sendMessage("Unknown view: " + view);
commandSender.sendMessage("Unknown view: " + strings[0]);
return true;
}

@Override
public @Nullable List<String> onTabComplete(
@NotNull CommandSender commandSender,
@NotNull Command command,
@NotNull String s,
@NotNull String[] strings) {
return new ArrayList<>(views.keySet());
}
}
7 changes: 6 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugin-shadowjar = "8.3.7"
plugin-spotless = "7.0.4"
plugin-bukkit = "0.7.1"
minestom = "b39badc77b"
folialib = "0.5.1"

[libraries.spigot]
module = "org.spigotmc:spigot-api"
Expand Down Expand Up @@ -52,10 +53,14 @@ version.ref = "adventure-api"
module = "net.minestom:minestom-snapshots"
version.ref = "minestom"

[libraries.folialib]
module = "com.tcoded:FoliaLib"
version.ref = "folialib"

[plugins]
shadowjar = { id = "com.gradleup.shadow", version.ref = "plugin-shadowjar" }
spotless = { id = "com.diffplug.spotless", version.ref = "plugin-spotless" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
bukkit = { id = "de.eldoria.plugin-yml.bukkit", version.ref = "plugin-bukkit" }
run-paper = { id = "xyz.jpenilla.run-paper", version = "2.3.1" }
runPaper = { id = "xyz.jpenilla.run-paper", version = "2.3.1" }
publish = { id = "com.vanniktech.maven.publish.base", version = "0.33.0" }
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Supplier;
import me.devnatan.inventoryframework.context.IFContext;
import me.devnatan.inventoryframework.internal.ElementFactory;
import me.devnatan.inventoryframework.internal.LayoutSlot;
Expand All @@ -11,7 +12,7 @@
public final class PaginationStateBuilder<
Context extends IFContext, Builder extends ItemComponentBuilder<Builder, Context> & ComponentFactory, V> {

private final ElementFactory internalElementFactory;
private final Supplier<ElementFactory> internalElementFactoryProvider;
private final Object sourceProvider;
private final Function<PaginationStateBuilder<Context, Builder, V>, State<Pagination>> internalStateFactory;
private char layoutTarget = LayoutSlot.FILLED_RESERVED_CHAR;
Expand All @@ -20,12 +21,12 @@ public final class PaginationStateBuilder<
private final boolean async, computed;

public PaginationStateBuilder(
ElementFactory internalElementFactory,
Supplier<ElementFactory> internalElementFactoryProvider,
Object sourceProvider,
Function<PaginationStateBuilder<Context, Builder, V>, State<Pagination>> internalStateFactory,
boolean async,
boolean computed) {
this.internalElementFactory = internalElementFactory;
this.internalElementFactoryProvider = internalElementFactoryProvider;
this.internalStateFactory = internalStateFactory;
this.sourceProvider = sourceProvider;
this.async = async;
Expand Down Expand Up @@ -65,7 +66,7 @@ public PaginationStateBuilder<Context, Builder, V> elementFactory(
@NotNull PaginationValueConsumer<Context, Builder, V> elementConsumer) {
this.paginationElementFactory = (pagination, index, slot, value) -> {
Context context = (Context) pagination.getRoot();
Builder builder = (Builder) internalElementFactory.createComponentBuilder(pagination);
Builder builder = (Builder) internalElementFactoryProvider.get().createComponentBuilder(pagination);
builder.withSlot(slot).withExternallyManaged(true);
elementConsumer.accept(context, builder, index, value);
return builder;
Expand Down
Loading
Loading