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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SamplePlugin extends JavaPlugin {
public void onEnable() {
ViewFrame viewFrame = ViewFrame.create(this)
.install(AnvilInputFeature.AnvilInput)
.enableDebug()
.enableDebug()
.with(
new AnvilInputSample(),
new Failing(),
Expand All @@ -26,9 +26,9 @@ public void onEnable() {
new PaginationOrientation(),
new TimerSample(),
new RowColumnSample(),
new NavigatingBetweenViewsA(),
new NavigatingBetweenViewsB()
)
new NavigatingBetweenViewsA(),
new NavigatingBetweenViewsB(),
new AllowsEntityContainerInteractions())
.register();

IFExampleCommandExecutor command = new IFExampleCommandExecutor(viewFrame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class IFExampleCommandExecutor implements CommandExecutor, TabCompleter {
views.put("pagination", PaginationOrientation.class);
views.put("timer", TimerSample.class);
views.put("row-column", RowColumnSample.class);
views.put("navigation", NavigatingBetweenViewsA.class);
views.put("navigation", NavigatingBetweenViewsA.class);
views.put("entity-interactions", AllowsEntityContainerInteractions.class);
}

private final ViewFrame viewFrame;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package me.devnatan.inventoryframework.runtime.view;

import me.devnatan.inventoryframework.View;
import me.devnatan.inventoryframework.ViewConfigBuilder;
import me.devnatan.inventoryframework.context.OpenContext;
import me.devnatan.inventoryframework.context.RenderContext;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.NonNull;

public class AllowsEntityContainerInteractions extends View {

@Override
public void onInit(@NotNull ViewConfigBuilder config) {
config.title("Allows player inventory interactions")
.size(3)
.cancelOnClick()
.allowEntityContainerInteractions();
}

@Override
public void onOpen(@NonNull OpenContext open) {
open.getPlayer().getInventory().addItem(new ItemStack(Material.WOODEN_PICKAXE));
}

@Override
public void onFirstRender(@NotNull RenderContext render) {
render.firstSlot(new ItemStack(Material.GOLD_INGOT));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

public class NavigatingBetweenViewsA extends View {

@Override
public void onInit(ViewConfigBuilder config) {
config.title("A").size(3);
}
@Override
public void onInit(ViewConfigBuilder config) {
config.title("A").size(3);
}

@Override
public void onFirstRender(RenderContext render) {
// Moves player to "B" view on click
render.firstSlot(new ItemStack(Material.DIAMOND))
.onClick(click -> click.openForPlayer(NavigatingBetweenViewsB.class));
}
@Override
public void onFirstRender(RenderContext render) {
// Moves player to "B" view on click
render.firstSlot(new ItemStack(Material.DIAMOND))
.onClick(click -> click.openForPlayer(NavigatingBetweenViewsB.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

public class NavigatingBetweenViewsB extends View {

@Override
public void onInit(ViewConfigBuilder config) {
config.title("B").size(3);
}
@Override
public void onInit(ViewConfigBuilder config) {
config.title("B").size(3);
}

@Override
public void onFirstRender(RenderContext render) {
// Moves player to back to "A" view on click
render.firstSlot(new ItemStack(Material.REDSTONE))
.onClick(click -> click.openForPlayer(NavigatingBetweenViewsA.class));
}
@Override
public void onFirstRender(RenderContext render) {
// Moves player to back to "A" view on click
render.firstSlot(new ItemStack(Material.REDSTONE))
.onClick(click -> click.openForPlayer(NavigatingBetweenViewsA.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public void onFirstRender(@NotNull RenderContext render) {
? new ItemStack(Material.GOLD_INGOT)
: new ItemStack(Material.IRON_INGOT));

render.firstRow((pos, slot) -> slot.withItem(new ItemStack(Material.BLUE_STAINED_GLASS_PANE))
.onClick(click -> intState.increment(click)));
render.firstRow((pos, slot) ->
slot.withItem(new ItemStack(Material.BLUE_STAINED_GLASS_PANE)).onClick(intState::increment));

render.lastColumn((pos, slot) -> slot.withItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.devnatan.inventoryframework;

import java.util.function.Supplier;

import me.devnatan.inventoryframework.logging.Logger;
import org.intellij.lang.annotations.PrintFormat;
import org.jetbrains.annotations.ApiStatus;
Expand All @@ -17,19 +16,19 @@ public final class IFDebug {

private static Boolean DEBUG_ENABLED = null;

private static Logger logger;
private static Logger logger;

static {
DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty(SYSTEM_PROPERTY, "false"));
}
static {
DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty(SYSTEM_PROPERTY, "false"));
}

private IFDebug() {}

/** Enables InventoryFramework debug. */
public static void enable(Logger logger) {
IFDebug.logger = logger;
IFDebug.logger = logger;
DEBUG_ENABLED = true;
debug("Debug enabled");
debug("Debug enabled");
}

/**
Expand All @@ -51,6 +50,6 @@ public static void debug(Supplier<String> message, Object... args) {
*/
public static void debug(@PrintFormat String message, Object... args) {
if (!DEBUG_ENABLED) return;
logger.debug(String.format(message, args));
logger.debug(String.format(message, args));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public interface IFSlotRenderContext extends IFSlotContext, IFConfinedContext {

/**
* Sets the item that was rendered by the owning component in a previous render.
*
* <p><b><i>This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided.</i></b>
*
* <p><b><i>This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided.</i></b>
*/
@ApiStatus.Internal
void setResult(Object result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.List;
import java.util.Optional;
import java.util.function.BiFunction;

import me.devnatan.inventoryframework.VirtualView;
import me.devnatan.inventoryframework.component.ComponentFactory;
import me.devnatan.inventoryframework.component.ItemComponentBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ public final void openEndless(
public final ViewFrame register() {
if (isRegistered()) throw new IllegalStateException("This view frame is already registered");

if (debugEnabled) {
IFDebug.enable(new BukkitLogger(getOwner().getLogger(), "global", true));
}
if (debugEnabled) {
IFDebug.enable(new BukkitLogger(getOwner().getLogger(), "global", true));
}

PlatformUtils.setFactory(new BukkitElementFactory(getOwner()));
tryEnableMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

public class McVersion implements Comparable<McVersion> {

private static final Pattern LEADING_VERSION =
Pattern.compile("(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?");
private static final Pattern LEADING_VERSION = Pattern.compile("(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?");

private static final McVersion CURRENT_VERSION;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class IFViewFrame<S extends IFViewFrame<S, V>, V extends Platfor
protected final Map<String, Viewer> viewerById = new HashMap<>();
protected Consumer<ViewConfigBuilder> defaultConfig;

protected boolean debugEnabled;
protected boolean debugEnabled;

@SuppressWarnings("rawtypes")
private final Pipeline<IFViewFrame> pipeline = new Pipeline<>(FRAME_REGISTERED, FRAME_UNREGISTERED);
Expand Down
Loading