Refactoring, Improved Window building

This commit is contained in:
NichtStudioCode 2023-01-28 12:30:36 +01:00
parent 19962dcc46
commit f8f2dfc95e
155 changed files with 2281 additions and 1775 deletions

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r1.inventory; package de.studiocode.inventoryaccess.r1;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r1.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.server.v1_14_R1.*; import net.minecraft.server.v1_14_R1.*;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
@ -18,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory { class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory {
private static final Field CONTAINER_ACCESS_FIELD = ReflectionUtils.getField(ContainerAnvil.class, true, "containerAccess"); private static final Field CONTAINER_ACCESS_FIELD = ReflectionUtils.getField(ContainerAnvil.class, true, "containerAccess");
private static final Field REPAIR_INVENTORY_FIELD = ReflectionUtils.getField(ContainerAnvil.class, true, "repairInventory"); private static final Field REPAIR_INVENTORY_FIELD = ReflectionUtils.getField(ContainerAnvil.class, true, "repairInventory");

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r1.inventory; package de.studiocode.inventoryaccess.r1;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r1.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.server.v1_14_R1.*; import net.minecraft.server.v1_14_R1.*;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory { class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory"); private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory");

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r1.util; package de.studiocode.inventoryaccess.r1;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -13,7 +13,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
private static Containers<?> getNotchInventoryType(Inventory inventory) { private static Containers<?> getNotchInventoryType(Inventory inventory) {
InventoryType type = inventory.getType(); InventoryType type = inventory.getType();

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r1.util; package de.studiocode.inventoryaccess.r1;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r1.util; package de.studiocode.inventoryaccess.r1;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.map.MapPatch; import de.studiocode.inventoryaccess.map.MapPatch;
@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = private static final Method REGISTER_LISTENERS_METHOD =
ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "d"); ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "d");

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r10.inventory; package de.studiocode.inventoryaccess.r10;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r10.util.InventoryUtilsImpl;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -28,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory { class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory {
private final Component title; private final Component title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r10.inventory; package de.studiocode.inventoryaccess.r10;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r10.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory { class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField( private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(
CartographyTableMenu.class, CartographyTableMenu.class,

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r10.util; package de.studiocode.inventoryaccess.r10;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -19,7 +19,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static Component createNMSComponent(ComponentWrapper component) { public static Component createNMSComponent(ComponentWrapper component) {
if (component == null) return null; if (component == null) return null;

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r10.util; package de.studiocode.inventoryaccess.r10;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r10.util; package de.studiocode.inventoryaccess.r10;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod( private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod(
PlayerAdvancements.class, PlayerAdvancements.class,

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r11.inventory; package de.studiocode.inventoryaccess.r11;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r11.util.InventoryUtilsImpl;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -28,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory { class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory {
private final Component title; private final Component title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r11.inventory; package de.studiocode.inventoryaccess.r11;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r11.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory { class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField( private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(
CartographyTableMenu.class, CartographyTableMenu.class,

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r11.util; package de.studiocode.inventoryaccess.r11;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -19,7 +19,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static Component createNMSComponent(ComponentWrapper component) { public static Component createNMSComponent(ComponentWrapper component) {
if (component == null) return null; if (component == null) return null;

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r11.util; package de.studiocode.inventoryaccess.r11;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r11.util; package de.studiocode.inventoryaccess.r11;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod( private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod(
PlayerAdvancements.class, PlayerAdvancements.class,

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r12.inventory; package de.studiocode.inventoryaccess.r12;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r12.util.InventoryUtilsImpl;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -28,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory { class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory {
private final Component title; private final Component title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r12.inventory; package de.studiocode.inventoryaccess.r12;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r12.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory { class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField( private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(
CartographyTableMenu.class, CartographyTableMenu.class,

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r12.util; package de.studiocode.inventoryaccess.r12;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -19,7 +19,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static Component createNMSComponent(ComponentWrapper component) { public static Component createNMSComponent(ComponentWrapper component) {
if (component == null) return null; if (component == null) return null;

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r12.util; package de.studiocode.inventoryaccess.r12;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r12.util; package de.studiocode.inventoryaccess.r12;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod( private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod(
PlayerAdvancements.class, PlayerAdvancements.class,

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r2.inventory; package de.studiocode.inventoryaccess.r2;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r2.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.server.v1_15_R1.*; import net.minecraft.server.v1_15_R1.*;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
@ -18,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory { class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory {
private static final Field CONTAINER_ACCESS_FIELD = ReflectionUtils.getField(ContainerAnvil.class, true, "containerAccess"); private static final Field CONTAINER_ACCESS_FIELD = ReflectionUtils.getField(ContainerAnvil.class, true, "containerAccess");
private static final Field REPAIR_INVENTORY_FIELD = ReflectionUtils.getField(ContainerAnvil.class, true, "repairInventory"); private static final Field REPAIR_INVENTORY_FIELD = ReflectionUtils.getField(ContainerAnvil.class, true, "repairInventory");

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r2.inventory; package de.studiocode.inventoryaccess.r2;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r2.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.server.v1_15_R1.*; import net.minecraft.server.v1_15_R1.*;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory { class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory"); private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory");

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r2.util; package de.studiocode.inventoryaccess.r2;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -12,7 +12,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static IChatBaseComponent createNMSComponent(ComponentWrapper component) { public static IChatBaseComponent createNMSComponent(ComponentWrapper component) {
return IChatBaseComponent.ChatSerializer.a(component.serializeToJson()); return IChatBaseComponent.ChatSerializer.a(component.serializeToJson());

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r2.util; package de.studiocode.inventoryaccess.r2;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r2.util; package de.studiocode.inventoryaccess.r2;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.map.MapPatch; import de.studiocode.inventoryaccess.map.MapPatch;
@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = private static final Method REGISTER_LISTENERS_METHOD =
ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "d"); ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "d");

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r3.inventory; package de.studiocode.inventoryaccess.r3;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r3.util.InventoryUtilsImpl;
import net.minecraft.server.v1_16_R1.*; import net.minecraft.server.v1_16_R1.*;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R1.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_16_R1.event.CraftEventFactory;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory { class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory {
private final IChatBaseComponent title; private final IChatBaseComponent title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r3.inventory; package de.studiocode.inventoryaccess.r3;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r3.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.server.v1_16_R1.*; import net.minecraft.server.v1_16_R1.*;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory { class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory"); private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory");

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r3.util; package de.studiocode.inventoryaccess.r3;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -13,7 +13,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static IChatBaseComponent createNMSComponent(ComponentWrapper component) { public static IChatBaseComponent createNMSComponent(ComponentWrapper component) {
return IChatBaseComponent.ChatSerializer.a(component.serializeToJson()); return IChatBaseComponent.ChatSerializer.a(component.serializeToJson());

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r3.util; package de.studiocode.inventoryaccess.r3;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r3.util; package de.studiocode.inventoryaccess.r3;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.map.MapPatch; import de.studiocode.inventoryaccess.map.MapPatch;
@ -16,7 +16,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = private static final Method REGISTER_LISTENERS_METHOD =
ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "b", AdvancementDataWorld.class); ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "b", AdvancementDataWorld.class);

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r4.inventory; package de.studiocode.inventoryaccess.r4;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r4.util.InventoryUtilsImpl;
import net.minecraft.server.v1_16_R2.*; import net.minecraft.server.v1_16_R2.*;
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R2.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_16_R2.event.CraftEventFactory;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory { class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory {
private final IChatBaseComponent title; private final IChatBaseComponent title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r4.inventory; package de.studiocode.inventoryaccess.r4;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r4.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.server.v1_16_R2.*; import net.minecraft.server.v1_16_R2.*;
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory { class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory"); private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory");

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r4.util; package de.studiocode.inventoryaccess.r4;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -13,7 +13,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static IChatBaseComponent createNMSComponent(ComponentWrapper component) { public static IChatBaseComponent createNMSComponent(ComponentWrapper component) {
return IChatBaseComponent.ChatSerializer.a(component.serializeToJson()); return IChatBaseComponent.ChatSerializer.a(component.serializeToJson());

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r4.util; package de.studiocode.inventoryaccess.r4;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r4.util; package de.studiocode.inventoryaccess.r4;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.map.MapPatch; import de.studiocode.inventoryaccess.map.MapPatch;
@ -16,7 +16,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = private static final Method REGISTER_LISTENERS_METHOD =
ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "b", AdvancementDataWorld.class); ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "b", AdvancementDataWorld.class);

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r5.inventory; package de.studiocode.inventoryaccess.r5;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r5.util.InventoryUtilsImpl;
import net.minecraft.server.v1_16_R3.*; import net.minecraft.server.v1_16_R3.*;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory { class AnvilInventoryImpl extends ContainerAnvil implements AnvilInventory {
private final IChatBaseComponent title; private final IChatBaseComponent title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r5.inventory; package de.studiocode.inventoryaccess.r5;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r5.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.server.v1_16_R3.*; import net.minecraft.server.v1_16_R3.*;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory { class CartographyInventoryImpl extends ContainerCartography implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory"); private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(ContainerCartography.class, true, "resultInventory");

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r5.util; package de.studiocode.inventoryaccess.r5;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -13,7 +13,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static IChatBaseComponent createNMSComponent(ComponentWrapper component) { public static IChatBaseComponent createNMSComponent(ComponentWrapper component) {
return IChatBaseComponent.ChatSerializer.a(component.serializeToJson()); return IChatBaseComponent.ChatSerializer.a(component.serializeToJson());

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r5.util; package de.studiocode.inventoryaccess.r5;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r5.util; package de.studiocode.inventoryaccess.r5;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.map.MapPatch; import de.studiocode.inventoryaccess.map.MapPatch;
@ -16,7 +16,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = private static final Method REGISTER_LISTENERS_METHOD =
ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "b", AdvancementDataWorld.class); ReflectionUtils.getMethod(AdvancementDataPlayer.class, true, "b", AdvancementDataWorld.class);

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r6.inventory; package de.studiocode.inventoryaccess.r6;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r6.util.InventoryUtilsImpl;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -27,7 +26,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory { class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory {
private final Component title; private final Component title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r6.inventory; package de.studiocode.inventoryaccess.r6;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r6.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory { class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField( private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(
CartographyTableMenu.class, CartographyTableMenu.class,

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r7.util; package de.studiocode.inventoryaccess.r6;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -19,7 +19,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static Component createNMSComponent(ComponentWrapper component) { public static Component createNMSComponent(ComponentWrapper component) {
if (component == null) return null; if (component == null) return null;

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r7.util; package de.studiocode.inventoryaccess.r6;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r6.util; package de.studiocode.inventoryaccess.r6;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod( private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod(
PlayerAdvancements.class, PlayerAdvancements.class,

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r7.inventory; package de.studiocode.inventoryaccess.r7;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r7.util.InventoryUtilsImpl;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -28,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory { class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory {
private final Component title; private final Component title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r7.inventory; package de.studiocode.inventoryaccess.r7;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r7.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory { class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField( private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(
CartographyTableMenu.class, CartographyTableMenu.class,

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r6.util; package de.studiocode.inventoryaccess.r7;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -19,7 +19,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static Component createNMSComponent(ComponentWrapper component) { public static Component createNMSComponent(ComponentWrapper component) {
if (component == null) return null; if (component == null) return null;

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r6.util; package de.studiocode.inventoryaccess.r7;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r7.util; package de.studiocode.inventoryaccess.r7;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod( private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod(
PlayerAdvancements.class, PlayerAdvancements.class,

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r8.inventory; package de.studiocode.inventoryaccess.r8;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r8.util.InventoryUtilsImpl;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -28,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory { class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory {
private final Component title; private final Component title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r8.inventory; package de.studiocode.inventoryaccess.r8;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r8.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory { class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField( private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(
CartographyTableMenu.class, CartographyTableMenu.class,

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r8.util; package de.studiocode.inventoryaccess.r8;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -19,7 +19,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static Component createNMSComponent(ComponentWrapper component) { public static Component createNMSComponent(ComponentWrapper component) {
if (component == null) return null; if (component == null) return null;

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r8.util; package de.studiocode.inventoryaccess.r8;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r8.util; package de.studiocode.inventoryaccess.r8;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod( private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod(
PlayerAdvancements.class, PlayerAdvancements.class,

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r9.inventory; package de.studiocode.inventoryaccess.r9;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r9.util.InventoryUtilsImpl;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -28,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory { class AnvilInventoryImpl extends AnvilMenu implements AnvilInventory {
private final Component title; private final Component title;
private final Consumer<String> renameHandler; private final Consumer<String> renameHandler;

@ -1,8 +1,7 @@
package de.studiocode.inventoryaccess.r9.inventory; package de.studiocode.inventoryaccess.r9;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.r9.util.InventoryUtilsImpl;
import de.studiocode.inventoryaccess.util.ReflectionUtils; import de.studiocode.inventoryaccess.util.ReflectionUtils;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory { class CartographyInventoryImpl extends CartographyTableMenu implements CartographyInventory {
private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField( private static final Field RESULT_CONTAINER_FIELD = ReflectionUtils.getField(
CartographyTableMenu.class, CartographyTableMenu.class,

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r9.util; package de.studiocode.inventoryaccess.r9;
import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils; import de.studiocode.inventoryaccess.abstraction.util.InventoryUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -19,7 +19,7 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class InventoryUtilsImpl implements InventoryUtils { class InventoryUtilsImpl implements InventoryUtils {
public static Component createNMSComponent(ComponentWrapper component) { public static Component createNMSComponent(ComponentWrapper component) {
if (component == null) return null; if (component == null) return null;

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r9.util; package de.studiocode.inventoryaccess.r9;
import de.studiocode.inventoryaccess.abstraction.util.ItemUtils; import de.studiocode.inventoryaccess.abstraction.util.ItemUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -15,7 +15,7 @@ import java.io.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ItemUtilsImpl implements ItemUtils { class ItemUtilsImpl implements ItemUtils {
@Override @Override
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) { public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.r9.util; package de.studiocode.inventoryaccess.r9;
import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils; import de.studiocode.inventoryaccess.abstraction.util.PlayerUtils;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerUtilsImpl implements PlayerUtils { class PlayerUtilsImpl implements PlayerUtils {
private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod( private static final Method REGISTER_LISTENERS_METHOD = ReflectionUtils.getMethod(
PlayerAdvancements.class, PlayerAdvancements.class,

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,4 +1,4 @@
package de.studiocode.inventoryaccess.version; package de.studiocode.inventoryaccess;
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory; import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory; import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
@ -15,11 +15,11 @@ import java.util.function.Consumer;
public class InventoryAccess { public class InventoryAccess {
private static final Class<InventoryUtils> INVENTORY_UTILS_CLASS = ReflectionUtils.getImplClass("util.InventoryUtilsImpl"); private static final Class<InventoryUtils> INVENTORY_UTILS_CLASS = ReflectionUtils.getImplClass("InventoryUtilsImpl");
private static final Class<ItemUtils> ITEM_UTILS_CLASS = ReflectionUtils.getImplClass("util.ItemUtilsImpl"); private static final Class<ItemUtils> ITEM_UTILS_CLASS = ReflectionUtils.getImplClass("ItemUtilsImpl");
private static final Class<PlayerUtils> PLAYER_UTILS_CLASS = ReflectionUtils.getImplClass("util.PlayerUtilsImpl"); private static final Class<PlayerUtils> PLAYER_UTILS_CLASS = ReflectionUtils.getImplClass("PlayerUtilsImpl");
private static final Class<AnvilInventory> ANVIL_INVENTORY_CLASS = ReflectionUtils.getImplClass("inventory.AnvilInventoryImpl"); private static final Class<AnvilInventory> ANVIL_INVENTORY_CLASS = ReflectionUtils.getImplClass("AnvilInventoryImpl");
private static final Class<CartographyInventory> CARTOGRAPHY_INVENTORY_CLASS = ReflectionUtils.getImplClass("inventory.CartographyInventoryImpl"); private static final Class<CartographyInventory> CARTOGRAPHY_INVENTORY_CLASS = ReflectionUtils.getImplClass("CartographyInventoryImpl");
private static final Constructor<AnvilInventory> ANVIL_INVENTORY_CONSTRUCTOR = private static final Constructor<AnvilInventory> ANVIL_INVENTORY_CONSTRUCTOR =
ReflectionUtils.getConstructor(ANVIL_INVENTORY_CLASS, false, Player.class, ComponentWrapper.class, Consumer.class); ReflectionUtils.getConstructor(ANVIL_INVENTORY_CLASS, false, Player.class, ComponentWrapper.class, Consumer.class);

@ -1,6 +1,5 @@
package de.studiocode.inventoryaccess.util; package de.studiocode.inventoryaccess.util;
import com.google.common.base.Preconditions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
public class VersionUtils { public class VersionUtils {
@ -54,7 +53,8 @@ public class VersionUtils {
* @throws IllegalArgumentException If the version array does not have a size of 3 * @throws IllegalArgumentException If the version array does not have a size of 3
*/ */
public static boolean isHigherOrEqualThanServer(int... version) { public static boolean isHigherOrEqualThanServer(int... version) {
Preconditions.checkArgument(version.length == 3); if (version.length != 3)
throw new IllegalArgumentException("Version array must have a size of 3");
return version[0] > major return version[0] > major
|| (version[0] == major && version[1] > minor) || (version[0] == major && version[1] > minor)
@ -79,7 +79,8 @@ public class VersionUtils {
* @throws IllegalArgumentException If the version array does not have a size of 3 * @throws IllegalArgumentException If the version array does not have a size of 3
*/ */
public static boolean isServerHigherOrEqual(int... version) { public static boolean isServerHigherOrEqual(int... version) {
Preconditions.checkArgument(version.length == 3); if (version.length != 3)
throw new IllegalArgumentException("Version array must have a size of 3");
return major > version[0] return major > version[0]
|| (major == version[0] && minor > version[1]) || (major == version[0] && minor > version[1])

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -1,10 +1,10 @@
package de.studiocode.invui.resourcepack; package de.studiocode.invui.resourcepack;
import de.studiocode.inventoryaccess.InventoryAccess;
import de.studiocode.inventoryaccess.component.BaseComponentWrapper; import de.studiocode.inventoryaccess.component.BaseComponentWrapper;
import de.studiocode.inventoryaccess.component.ComponentWrapper; import de.studiocode.inventoryaccess.component.ComponentWrapper;
import de.studiocode.inventoryaccess.util.ReflectionRegistry; import de.studiocode.inventoryaccess.util.ReflectionRegistry;
import de.studiocode.inventoryaccess.util.VersionUtils; import de.studiocode.inventoryaccess.util.VersionUtils;
import de.studiocode.inventoryaccess.version.InventoryAccess;
import de.studiocode.invui.InvUI; import de.studiocode.invui.InvUI;
import de.studiocode.invui.resourcepack.auth.AuthenticationServiceManager; import de.studiocode.invui.resourcepack.auth.AuthenticationServiceManager;
import de.studiocode.invui.util.DataUtils; import de.studiocode.invui.util.DataUtils;

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>de.studiocode.invui</groupId> <groupId>de.studiocode.invui</groupId>
<artifactId>InvUI-Parent</artifactId> <artifactId>InvUI-Parent</artifactId>
<version>0.10.2</version> <version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -1,10 +1,6 @@
package de.studiocode.invui.gui.impl; package de.studiocode.invui.gui;
import de.studiocode.invui.animation.Animation; import de.studiocode.invui.animation.Animation;
import de.studiocode.invui.gui.Controllable;
import de.studiocode.invui.gui.GUI;
import de.studiocode.invui.gui.GUIParent;
import de.studiocode.invui.gui.SlotElement;
import de.studiocode.invui.gui.SlotElement.ItemSlotElement; import de.studiocode.invui.gui.SlotElement.ItemSlotElement;
import de.studiocode.invui.gui.SlotElement.LinkedSlotElement; import de.studiocode.invui.gui.SlotElement.LinkedSlotElement;
import de.studiocode.invui.gui.SlotElement.VISlotElement; import de.studiocode.invui.gui.SlotElement.VISlotElement;
@ -12,18 +8,14 @@ import de.studiocode.invui.gui.structure.Structure;
import de.studiocode.invui.item.Item; import de.studiocode.invui.item.Item;
import de.studiocode.invui.item.ItemProvider; import de.studiocode.invui.item.ItemProvider;
import de.studiocode.invui.item.impl.controlitem.ControlItem; import de.studiocode.invui.item.impl.controlitem.ControlItem;
import de.studiocode.invui.util.ArrayUtils;
import de.studiocode.invui.util.InventoryUtils; import de.studiocode.invui.util.InventoryUtils;
import de.studiocode.invui.util.SlotUtils; import de.studiocode.invui.util.SlotUtils;
import de.studiocode.invui.util.ArrayUtils;
import de.studiocode.invui.virtualinventory.VirtualInventory; import de.studiocode.invui.virtualinventory.VirtualInventory;
import de.studiocode.invui.virtualinventory.event.ItemUpdateEvent; import de.studiocode.invui.virtualinventory.event.ItemUpdateEvent;
import de.studiocode.invui.virtualinventory.event.PlayerUpdateReason; import de.studiocode.invui.virtualinventory.event.PlayerUpdateReason;
import de.studiocode.invui.virtualinventory.event.UpdateReason; import de.studiocode.invui.virtualinventory.event.UpdateReason;
import de.studiocode.invui.window.Window; import de.studiocode.invui.window.*;
import de.studiocode.invui.window.WindowManager;
import de.studiocode.invui.window.impl.merged.MergedWindow;
import de.studiocode.invui.window.impl.merged.split.SplitWindow;
import de.studiocode.invui.window.impl.single.SingleWindow;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
@ -38,7 +30,7 @@ import java.util.*;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public abstract class BaseGUI implements GUI, Controllable { public abstract class AbstractGUI implements GUI, GUIParent {
private final int width; private final int width;
private final int height; private final int height;
@ -51,14 +43,13 @@ public abstract class BaseGUI implements GUI, Controllable {
private ItemProvider background; private ItemProvider background;
public BaseGUI(int width, int height) { public AbstractGUI(int width, int height) {
this.width = width; this.width = width;
this.height = height; this.height = height;
this.size = width * height; this.size = width * height;
slotElements = new SlotElement[size]; slotElements = new SlotElement[size];
} }
@Override
public void handleClick(int slotNumber, Player player, ClickType clickType, InventoryClickEvent event) { public void handleClick(int slotNumber, Player player, ClickType clickType, InventoryClickEvent event) {
if (animation != null) { if (animation != null) {
// cancel all clicks if an animation is running // cancel all clicks if an animation is running
@ -69,7 +60,8 @@ public abstract class BaseGUI implements GUI, Controllable {
SlotElement slotElement = slotElements[slotNumber]; SlotElement slotElement = slotElements[slotNumber];
if (slotElement instanceof LinkedSlotElement) { if (slotElement instanceof LinkedSlotElement) {
LinkedSlotElement linkedElement = (LinkedSlotElement) slotElement; LinkedSlotElement linkedElement = (LinkedSlotElement) slotElement;
linkedElement.getGui().handleClick(linkedElement.getSlotIndex(), player, clickType, event); AbstractGUI gui = (AbstractGUI) linkedElement.getGUI();
gui.handleClick(linkedElement.getSlotIndex(), player, clickType, event);
} else if (slotElement instanceof ItemSlotElement) { } else if (slotElement instanceof ItemSlotElement) {
event.setCancelled(true); // if it is an Item, don't let the player move it event.setCancelled(true); // if it is an Item, don't let the player move it
ItemSlotElement itemElement = (ItemSlotElement) slotElement; ItemSlotElement itemElement = (ItemSlotElement) slotElement;
@ -215,17 +207,17 @@ public abstract class BaseGUI implements GUI, Controllable {
if (!updateEvent.isCancelled()) { if (!updateEvent.isCancelled()) {
int leftOverAmount; int leftOverAmount;
if (window instanceof MergedWindow) { if (window instanceof AbstractDoubleWindow) {
GUI otherGui; GUI otherGui;
if (window instanceof SplitWindow) { if (window instanceof AbstractSplitWindow) {
SplitWindow splitWindow = (SplitWindow) window; AbstractSplitWindow splitWindow = (AbstractSplitWindow) window;
GUI[] guis = splitWindow.getGuis(); GUI[] guis = splitWindow.getGUIs();
otherGui = guis[0] == this ? guis[1] : guis[0]; otherGui = guis[0] == this ? guis[1] : guis[0];
} else { } else {
otherGui = this; otherGui = this;
} }
leftOverAmount = ((BaseGUI) otherGui).putIntoFirstVirtualInventory(updateReason, clicked, inventory); leftOverAmount = ((AbstractGUI) otherGui).putIntoFirstVirtualInventory(updateReason, clicked, inventory);
} else { } else {
leftOverAmount = InventoryUtils.addItemCorrectly(event.getWhoClicked().getInventory(), inventory.getItemStack(slot)); leftOverAmount = InventoryUtils.addItemCorrectly(event.getWhoClicked().getInventory(), inventory.getItemStack(slot));
} }
@ -240,7 +232,7 @@ public abstract class BaseGUI implements GUI, Controllable {
// TODO: add support for merged windows // TODO: add support for merged windows
protected void handleVINumberKey(InventoryClickEvent event, VirtualInventory inventory, int slot, Player player, ItemStack clicked) { protected void handleVINumberKey(InventoryClickEvent event, VirtualInventory inventory, int slot, Player player, ItemStack clicked) {
Window window = WindowManager.getInstance().getOpenWindow(player); Window window = WindowManager.getInstance().getOpenWindow(player);
if (window instanceof SingleWindow) { if (window instanceof AbstractSingleWindow) {
Inventory playerInventory = player.getInventory(); Inventory playerInventory = player.getInventory();
int hotbarButton = event.getHotbarButton(); int hotbarButton = event.getHotbarButton();
ItemStack hotbarItem = playerInventory.getItem(hotbarButton); ItemStack hotbarItem = playerInventory.getItem(hotbarButton);
@ -256,7 +248,7 @@ public abstract class BaseGUI implements GUI, Controllable {
// TODO: add support for merged windows // TODO: add support for merged windows
protected void handleVIOffHandKey(InventoryClickEvent event, VirtualInventory inventory, int slot, Player player, ItemStack clicked) { protected void handleVIOffHandKey(InventoryClickEvent event, VirtualInventory inventory, int slot, Player player, ItemStack clicked) {
Window window = WindowManager.getInstance().getOpenWindow(player); Window window = WindowManager.getInstance().getOpenWindow(player);
if (window instanceof SingleWindow) { if (window instanceof AbstractSingleWindow) {
PlayerInventory playerInventory = player.getInventory(); PlayerInventory playerInventory = player.getInventory();
ItemStack offhandItem = playerInventory.getItemInOffHand(); ItemStack offhandItem = playerInventory.getItemInOffHand();
if (offhandItem != null && offhandItem.getType().isAir()) offhandItem = null; if (offhandItem != null && offhandItem.getType().isAir()) offhandItem = null;
@ -289,11 +281,10 @@ public abstract class BaseGUI implements GUI, Controllable {
if (cursor == null) return; if (cursor == null) return;
UpdateReason updateReason = new PlayerUpdateReason(player, event); UpdateReason updateReason = new PlayerUpdateReason(player, event);
cursor.setAmount(inventory.collectToCursor(updateReason, cursor)); cursor.setAmount(inventory.collectSimilar(updateReason, cursor));
event.setCursor(cursor); event.setCursor(cursor);
} }
@Override
public boolean handleItemDrag(UpdateReason updateReason, int slot, ItemStack oldStack, ItemStack newStack) { public boolean handleItemDrag(UpdateReason updateReason, int slot, ItemStack oldStack, ItemStack newStack) {
SlotElement element = getSlotElement(slot); SlotElement element = getSlotElement(slot);
if (element != null) element = element.getHoldingElement(); if (element != null) element = element.getHoldingElement();
@ -309,7 +300,6 @@ public abstract class BaseGUI implements GUI, Controllable {
return false; return false;
} }
@Override
public void handleItemShift(InventoryClickEvent event) { public void handleItemShift(InventoryClickEvent event) {
event.setCancelled(true); event.setCancelled(true);
@ -361,23 +351,20 @@ public abstract class BaseGUI implements GUI, Controllable {
SlotElement element = slotElements[index]; SlotElement element = slotElements[index];
if (element instanceof LinkedSlotElement) { if (element instanceof LinkedSlotElement) {
LinkedSlotElement linkedSlotElement = (LinkedSlotElement) element; LinkedSlotElement linkedSlotElement = (LinkedSlotElement) element;
if (linkedSlotElement.getGui() == child && linkedSlotElement.getSlotIndex() == slotIndex) if (linkedSlotElement.getGUI() == child && linkedSlotElement.getSlotIndex() == slotIndex)
for (GUIParent parent : parents) parent.handleSlotElementUpdate(this, index); for (GUIParent parent : parents) parent.handleSlotElementUpdate(this, index);
} }
} }
} }
@Override
public void addParent(@NotNull GUIParent parent) { public void addParent(@NotNull GUIParent parent) {
parents.add(parent); parents.add(parent);
} }
@Override
public void removeParent(@NotNull GUIParent parent) { public void removeParent(@NotNull GUIParent parent) {
parents.remove(parent); parents.remove(parent);
} }
@Override
public Set<GUIParent> getParents() { public Set<GUIParent> getParents() {
return parents; return parents;
} }
@ -385,13 +372,13 @@ public abstract class BaseGUI implements GUI, Controllable {
@Override @Override
public List<Window> findAllWindows() { public List<Window> findAllWindows() {
List<Window> windows = new ArrayList<>(); List<Window> windows = new ArrayList<>();
List<GUIParent> parents = new ArrayList<>(this.parents); List<GUIParent> unexploredParents = new ArrayList<>(this.parents);
while (!parents.isEmpty()) { while (!unexploredParents.isEmpty()) {
List<GUIParent> parents1 = new ArrayList<>(parents); List<GUIParent> parents = new ArrayList<>(unexploredParents);
parents.clear(); unexploredParents.clear();
for (GUIParent parent : parents1) { for (GUIParent parent : parents) {
if (parent instanceof GUI) parents.addAll(((GUI) parent).getParents()); if (parent instanceof AbstractGUI) unexploredParents.addAll(((AbstractGUI) parent).getParents());
else if (parent instanceof Window) windows.add((Window) parent); else if (parent instanceof Window) windows.add((Window) parent);
} }
} }
@ -453,7 +440,6 @@ public abstract class BaseGUI implements GUI, Controllable {
} }
} }
@Override
public void updateControlItems() { public void updateControlItems() {
for (SlotElement element : slotElements) { for (SlotElement element : slotElements) {
if (element instanceof ItemSlotElement) { if (element instanceof ItemSlotElement) {
@ -475,14 +461,14 @@ public abstract class BaseGUI implements GUI, Controllable {
if (slotElement instanceof ItemSlotElement) { if (slotElement instanceof ItemSlotElement) {
Item item = ((ItemSlotElement) slotElement).getItem(); Item item = ((ItemSlotElement) slotElement).getItem();
if (item instanceof ControlItem<?>) if (item instanceof ControlItem<?>)
((ControlItem<?>) item).setGui(this); ((ControlItem<?>) item).setGUI(this);
} }
// notify parents that a SlotElement has been changed // notify parents that a SlotElement has been changed
parents.forEach(parent -> parent.handleSlotElementUpdate(this, index)); parents.forEach(parent -> parent.handleSlotElementUpdate(this, index));
GUI oldLink = oldElement instanceof LinkedSlotElement ? ((LinkedSlotElement) oldElement).getGui() : null; AbstractGUI oldLink = oldElement instanceof LinkedSlotElement ? (AbstractGUI) ((LinkedSlotElement) oldElement).getGUI() : null;
GUI newLink = slotElement instanceof LinkedSlotElement ? ((LinkedSlotElement) slotElement).getGui() : null; AbstractGUI newLink = slotElement instanceof LinkedSlotElement ? (AbstractGUI) ((LinkedSlotElement) slotElement).getGUI() : null;
// if newLink is the same as oldLink, there isn't anything to be done // if newLink is the same as oldLink, there isn't anything to be done
if (newLink == oldLink) return; if (newLink == oldLink) return;
@ -492,7 +478,7 @@ public abstract class BaseGUI implements GUI, Controllable {
// If no other slot still links to that GUI, remove this GUI from parents // If no other slot still links to that GUI, remove this GUI from parents
if (Arrays.stream(slotElements) if (Arrays.stream(slotElements)
.filter(element -> element instanceof LinkedSlotElement) .filter(element -> element instanceof LinkedSlotElement)
.map(element -> ((LinkedSlotElement) element).getGui()) .map(element -> ((LinkedSlotElement) element).getGUI())
.noneMatch(gui -> gui == oldLink)) oldLink.removeParent(this); .noneMatch(gui -> gui == oldLink)) oldLink.removeParent(this);
} }
@ -502,6 +488,15 @@ public abstract class BaseGUI implements GUI, Controllable {
} }
} }
@Override
public void addSlotElements(@NotNull SlotElement... slotElements) {
for (SlotElement element : slotElements) {
int emptyIndex = ArrayUtils.findFirstEmptyIndex(this.slotElements);
if (emptyIndex == -1) break;
setSlotElement(emptyIndex, element);
}
}
@Override @Override
public SlotElement getSlotElement(int index) { public SlotElement getSlotElement(int index) {
return slotElements[index]; return slotElements[index];
@ -513,12 +508,13 @@ public abstract class BaseGUI implements GUI, Controllable {
} }
@Override @Override
public SlotElement[] getSlotElements() { @Nullable
public SlotElement @NotNull[] getSlotElements() {
return slotElements.clone(); return slotElements.clone();
} }
@Override @Override
public void setItem(int index, Item item) { public void setItem(int index, @Nullable Item item) {
remove(index); remove(index);
if (item != null) setSlotElement(index, new ItemSlotElement(item)); if (item != null) setSlotElement(index, new ItemSlotElement(item));
} }
@ -533,7 +529,7 @@ public abstract class BaseGUI implements GUI, Controllable {
} }
@Override @Override
public Item getItem(int index) { public @Nullable Item getItem(int index) {
SlotElement slotElement = slotElements[index]; SlotElement slotElement = slotElements[index];
if (slotElement instanceof ItemSlotElement) { if (slotElement instanceof ItemSlotElement) {
@ -547,7 +543,7 @@ public abstract class BaseGUI implements GUI, Controllable {
} }
@Override @Override
public ItemProvider getBackground() { public @Nullable ItemProvider getBackground() {
return background; return background;
} }
@ -562,7 +558,7 @@ public abstract class BaseGUI implements GUI, Controllable {
} }
@Override @Override
public void applyStructure(Structure structure) { public void applyStructure(@NotNull Structure structure) {
structure.getIngredientList().insertIntoGUI(this); structure.getIngredientList().insertIntoGUI(this);
} }
@ -588,12 +584,12 @@ public abstract class BaseGUI implements GUI, Controllable {
} }
@Override @Override
public void setItem(int x, int y, Item item) { public void setItem(int x, int y, @Nullable Item item) {
setItem(convToIndex(x, y), item); setItem(convToIndex(x, y), item);
} }
@Override @Override
public Item getItem(int x, int y) { public @Nullable Item getItem(int x, int y) {
return getItem(convToIndex(x, y)); return getItem(convToIndex(x, y));
} }

@ -0,0 +1,138 @@
package de.studiocode.invui.gui;
import de.studiocode.invui.gui.builder.GUIBuilder;
import de.studiocode.invui.gui.impl.PageNestedGUIImpl;
import de.studiocode.invui.gui.impl.PagedItemsGUIImpl;
import de.studiocode.invui.gui.structure.Structure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
/**
* A {@link GUI} with pages.
*
* @see GUIBuilder
* @see PagedItemsGUIImpl
* @see PageNestedGUIImpl
*/
public abstract class AbstractPagedGUI<C> extends AbstractGUI implements PagedGUI<C> {
private final boolean infinitePages;
private final int[] contentListSlots;
private int currentPage;
private List<BiConsumer<Integer, Integer>> pageChangeHandlers;
public AbstractPagedGUI(int width, int height, boolean infinitePages, int... contentListSlots) {
super(width, height);
this.infinitePages = infinitePages;
this.contentListSlots = contentListSlots;
}
public AbstractPagedGUI(int width, int height, boolean infinitePages, Structure structure) {
this(width, height, infinitePages, structure.getIngredientList().findContentListSlots());
applyStructure(structure);
}
@Override
public void goForward() {
if (hasNextPage())
setPage(currentPage + 1);
}
@Override
public void goBack() {
if (hasPreviousPage())
setPage(currentPage - 1);
}
@Override
public void setPage(int page) {
int previous = currentPage;
currentPage = page;
update();
if (previous != currentPage) {
pageChangeHandlers.forEach(handler -> handler.accept(previous, page));
}
}
@Override
public boolean hasNextPage() {
return currentPage < getPageAmount() - 1 || infinitePages;
}
@Override
public boolean hasPreviousPage() {
return currentPage > 0;
}
protected void update() {
correctPage();
updateControlItems();
updatePageContent();
}
private void correctPage() {
if (currentPage == 0 || infinitePages) return;
int pageAmount = getPageAmount();
if (currentPage < 0 || pageAmount <= 0) currentPage = 0;
else if (currentPage >= pageAmount) currentPage = pageAmount - 1;
}
private void updatePageContent() {
List<SlotElement> slotElements = getPageElements(currentPage);
for (int i = 0; i < contentListSlots.length; i++) {
if (slotElements.size() > i) setSlotElement(contentListSlots[i], slotElements.get(i));
else remove(contentListSlots[i]);
}
}
@Override
public int getCurrentPage() {
return currentPage;
}
@Override
public boolean hasInfinitePages() {
return infinitePages;
}
@Override
public int[] getContentListSlots() {
return contentListSlots;
}
@Override
public void registerPageChangeHandler(@NotNull BiConsumer<Integer, Integer> pageChangeHandler) {
if (pageChangeHandlers == null) {
pageChangeHandlers = new ArrayList<>();
}
pageChangeHandlers.add(pageChangeHandler);
}
@Override
public void unregisterPageChangeHandler(@NotNull BiConsumer<Integer, Integer> pageChangeHandler) {
if (pageChangeHandlers != null) {
pageChangeHandlers.remove(pageChangeHandler);
}
}
@Override
public void setPageChangeHandlers(@Nullable List<BiConsumer<Integer, Integer>> handlers) {
this.pageChangeHandlers = handlers;
}
@Nullable
public List<BiConsumer<Integer, Integer>> getPageChangeHandlers() {
return pageChangeHandlers;
}
protected abstract List<SlotElement> getPageElements(int page);
}

@ -1,7 +1,7 @@
package de.studiocode.invui.gui.impl; package de.studiocode.invui.gui;
import de.studiocode.invui.gui.GUI; import de.studiocode.invui.gui.impl.ScrollItemsGUIImpl;
import de.studiocode.invui.gui.SlotElement; import de.studiocode.invui.gui.impl.ScrollNestedGUIImpl;
import de.studiocode.invui.gui.structure.Structure; import de.studiocode.invui.gui.structure.Structure;
import de.studiocode.invui.util.SlotUtils; import de.studiocode.invui.util.SlotUtils;
@ -10,35 +10,35 @@ import java.util.List;
/** /**
* A scrollable {@link GUI} * A scrollable {@link GUI}
* *
* @see SimpleScrollItemsGUI * @see ScrollItemsGUIImpl
* @see SimpleScrollNestedGUI * @see ScrollNestedGUIImpl
*/ */
public abstract class ScrollGUI extends BaseGUI { public abstract class AbstractScrollGUI<C> extends AbstractGUI implements ScrollGUI<C> {
private final boolean infiniteLines; private final boolean infiniteLines;
private final int lineLength; private final int lineLength;
private final int lineAmount; private final int lineAmount;
private final int[] itemListSlots; private final int[] contentListSlots;
protected int offset; protected int offset;
public ScrollGUI(int width, int height, boolean infiniteLines, int... itemListSlots) { public AbstractScrollGUI(int width, int height, boolean infiniteLines, int... contentListSlots) {
super(width, height); super(width, height);
this.infiniteLines = infiniteLines; this.infiniteLines = infiniteLines;
this.itemListSlots = itemListSlots; this.contentListSlots = contentListSlots;
this.lineLength = SlotUtils.getLongestLineLength(itemListSlots, width); this.lineLength = SlotUtils.getLongestLineLength(contentListSlots, width);
this.lineAmount = (int) Math.ceil((double) itemListSlots.length / (double) lineLength); this.lineAmount = (int) Math.ceil((double) contentListSlots.length / (double) lineLength);
if (itemListSlots.length == 0) if (contentListSlots.length == 0)
throw new IllegalArgumentException("No item list slots provided"); throw new IllegalArgumentException("No item list slots provided");
if (lineLength == 0) if (lineLength == 0)
throw new IllegalArgumentException("Line length can't be 0"); throw new IllegalArgumentException("Line length can't be 0");
if (itemListSlots.length % lineLength != 0) if (contentListSlots.length % lineLength != 0)
throw new IllegalArgumentException("itemListSlots has to be a multiple of lineLength"); throw new IllegalArgumentException("contentListSlots has to be a multiple of lineLength");
} }
public ScrollGUI(int width, int height, boolean infiniteLines, Structure structure) { public AbstractScrollGUI(int width, int height, boolean infiniteLines, Structure structure) {
this(width, height, infiniteLines, structure.getIngredientList().findItemListSlots()); this(width, height, infiniteLines, structure.getIngredientList().findContentListSlots());
applyStructure(structure); applyStructure(structure);
} }
@ -46,22 +46,26 @@ public abstract class ScrollGUI extends BaseGUI {
return lineLength; return lineLength;
} }
@Override
public int getCurrentLine() { public int getCurrentLine() {
return offset / lineLength; return offset / lineLength;
} }
@Override
public void setCurrentLine(int line) { public void setCurrentLine(int line) {
this.offset = line * lineLength; this.offset = line * lineLength;
} }
@Override
public boolean canScroll(int lines) { public boolean canScroll(int lines) {
if (lines == 0 || (infiniteLines && lines > 0) || (lines < 0 && getCurrentLine() > 0)) return true; if (lines == 0 || (infiniteLines && lines > 0) || (lines < 0 && getCurrentLine() > 0)) return true;
int line = getCurrentLine() + lines; int line = getCurrentLine() + lines;
int maxLineIndex = getMaxLineIndex(); int maxLineIndex = getMaxLine();
return line >= 0 && (line + lineAmount - 1) <= maxLineIndex; return line >= 0 && (line + lineAmount - 1) <= maxLineIndex;
} }
@Override
public void scroll(int lines) { public void scroll(int lines) {
if (lines == 0) return; if (lines == 0) return;
@ -69,7 +73,7 @@ public abstract class ScrollGUI extends BaseGUI {
setCurrentLine(getCurrentLine() + lines); setCurrentLine(getCurrentLine() + lines);
update(); update();
} else if (lines > 1) { } else if (lines > 1) {
setCurrentLine(getMaxLineIndex()); setCurrentLine(getMaxLine());
update(); update();
} else if (lines < -1) { } else if (lines < -1) {
setCurrentLine(0); setCurrentLine(0);
@ -91,22 +95,20 @@ public abstract class ScrollGUI extends BaseGUI {
offset = 0; offset = 0;
} else { } else {
int currentLine = getCurrentLine(); int currentLine = getCurrentLine();
int maxLineIndex = getMaxLineIndex(); int maxLineIndex = getMaxLine();
if (currentLine >= maxLineIndex) setCurrentLine(maxLineIndex); if (currentLine >= maxLineIndex) setCurrentLine(maxLineIndex);
} }
} }
private void updateContent() { private void updateContent() {
List<? extends SlotElement> slotElements = getElements(offset, itemListSlots.length + offset); List<? extends SlotElement> slotElements = getElements(offset, contentListSlots.length + offset);
for (int i = 0; i < itemListSlots.length; i++) { for (int i = 0; i < contentListSlots.length; i++) {
if (slotElements.size() > i) setSlotElement(itemListSlots[i], slotElements.get(i)); if (slotElements.size() > i) setSlotElement(contentListSlots[i], slotElements.get(i));
else remove(itemListSlots[i]); else remove(contentListSlots[i]);
} }
} }
protected abstract int getMaxLineIndex();
protected abstract List<? extends SlotElement> getElements(int from, int to); protected abstract List<? extends SlotElement> getElements(int from, int to);
} }

@ -1,26 +1,30 @@
package de.studiocode.invui.gui.impl; package de.studiocode.invui.gui;
import de.studiocode.invui.gui.Controllable;
import de.studiocode.invui.gui.SlotElement;
import de.studiocode.invui.gui.structure.Structure; import de.studiocode.invui.gui.structure.Structure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.BiConsumer;
public abstract class TabGUI extends BaseGUI implements Controllable { public abstract class AbstractTabGUI extends AbstractGUI implements TabGUI {
private final int tabAmount; private final int tabAmount;
private final int[] listSlots; private final int[] listSlots;
private int currentTab = -1; private int currentTab = -1;
public TabGUI(int width, int height, int tabAmount, int... listSlots) { private List<BiConsumer<Integer, Integer>> tabChangeHandlers;
public AbstractTabGUI(int width, int height, int tabAmount, int... listSlots) {
super(width, height); super(width, height);
this.tabAmount = tabAmount; this.tabAmount = tabAmount;
this.listSlots = listSlots; this.listSlots = listSlots;
} }
public TabGUI(int width, int height, int tabAmount, Structure structure) { public AbstractTabGUI(int width, int height, int tabAmount, Structure structure) {
this(width, height, tabAmount, structure.getIngredientList().findItemListSlots()); this(width, height, tabAmount, structure.getIngredientList().findContentListSlots());
applyStructure(structure); applyStructure(structure);
} }
@ -34,7 +38,9 @@ public abstract class TabGUI extends BaseGUI implements Controllable {
currentTab = tab; currentTab = tab;
update(); update();
handleTabChange(previous, currentTab); if (tabChangeHandlers != null) {
tabChangeHandlers.forEach(handler -> handler.accept(previous, tab));
}
} }
protected void update() { protected void update() {
@ -65,10 +71,31 @@ public abstract class TabGUI extends BaseGUI implements Controllable {
return currentTab; return currentTab;
} }
@Override
@Nullable
public List<BiConsumer<Integer, Integer>> getTabChangeHandlers() {
return tabChangeHandlers;
}
@Override
public void setTabChangeHandlers(@Nullable List<BiConsumer<Integer, Integer>> tabChangeHandlers) {
this.tabChangeHandlers = tabChangeHandlers;
}
public void registerTabChangeHandler(@NotNull BiConsumer<Integer, Integer> tabChangeHandler) {
if (tabChangeHandlers == null) tabChangeHandlers = new ArrayList<>();
tabChangeHandlers.add(tabChangeHandler);
}
@Override
public void unregisterTabChangeHandler(@NotNull BiConsumer<Integer, Integer> tabChangeHandler) {
if (tabChangeHandlers != null) tabChangeHandlers.remove(tabChangeHandler);
}
public abstract boolean isTabAvailable(int tab); public abstract boolean isTabAvailable(int tab);
protected abstract List<SlotElement> getSlotElements(int tab); protected abstract List<SlotElement> getSlotElements(int tab);
protected abstract void handleTabChange(int previous, int now);
} }

@ -1,7 +0,0 @@
package de.studiocode.invui.gui;
public interface Controllable {
void updateControlItems();
}

@ -7,14 +7,10 @@ import de.studiocode.invui.gui.structure.Structure;
import de.studiocode.invui.item.Item; import de.studiocode.invui.item.Item;
import de.studiocode.invui.item.ItemProvider; import de.studiocode.invui.item.ItemProvider;
import de.studiocode.invui.virtualinventory.VirtualInventory; import de.studiocode.invui.virtualinventory.VirtualInventory;
import de.studiocode.invui.virtualinventory.event.UpdateReason;
import de.studiocode.invui.window.Window; import de.studiocode.invui.window.Window;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -23,24 +19,29 @@ import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
/** /**
* A GUI is a container for width * height {@link SlotElement}s.<br> * A GUI is a container for width * height {@link SlotElement SlotElements}.<br>
* Each {@link SlotElement} can either be an {@link Item}, * Each {@link SlotElement} can either be an {@link Item},
* a reference to a {@link VirtualInventory}'s or another {@link GUI}'s * a reference to a {@link VirtualInventory}'s or another {@link GUI}'s
* slot index.<br> * slot index.<br>
* A {@link GUI} is not an {@link Inventory}, nor does * A {@link GUI} is not an {@link Inventory}, nor does
* it access one. It just contains {@link SlotElement}s and their positions.<br> * it access one. It just contains {@link SlotElement SlotElements} and their positions.<br>
* In order to create an {@link Inventory} which is visible * In order to create an {@link Inventory} which is visible
* to players, you will need to use a {@link Window}. * to players, you will need to use a {@link Window}.
* *
* @see BaseGUI
* @see PagedGUI
* @see SimpleGUI
* @see SimplePagedItemsGUI
* @see SimplePagedNestedGUI
* @see SimpleTabGUI
* @see GUIBuilder * @see GUIBuilder
* @see AbstractGUI
* @see AbstractPagedGUI
* @see AbstractScrollGUI
* @see AbstractTabGUI
* @see NormalGUIImpl
* @see PagedItemsGUIImpl
* @see PageNestedGUIImpl
* @see ScrollItemsGUIImpl
* @see ScrollNestedGUIImpl
* @see ScrollVIGUIImpl
* @see TabGUIImpl
*/ */
public interface GUI extends GUIParent { public interface GUI {
/** /**
* Gets the size of the {@link GUI}. * Gets the size of the {@link GUI}.
@ -82,6 +83,13 @@ public interface GUI extends GUIParent {
*/ */
void setSlotElement(int index, @Nullable SlotElement slotElement); void setSlotElement(int index, @Nullable SlotElement slotElement);
/**
* Adds {@link SlotElement SlotElements} to the {@link GUI}.
*
* @param slotElements The {@link SlotElement SlotElements} to add.
*/
void addSlotElements(@NotNull SlotElement... slotElements);
/** /**
* Gets the {@link SlotElement} on these coordinates. * Gets the {@link SlotElement} on these coordinates.
* *
@ -117,11 +125,12 @@ public interface GUI extends GUIParent {
boolean hasSlotElement(int index); boolean hasSlotElement(int index);
/** /**
* Gets all {@link SlotElement}s of this {@link GUI} in an Array. * Gets all {@link SlotElement SlotElements} of this {@link GUI} in an Array.
* *
* @return All {@link SlotElement}s of this {@link GUI} * @return All {@link SlotElement SlotElements} of this {@link GUI}
*/ */
SlotElement[] getSlotElements(); @Nullable
SlotElement @NotNull [] getSlotElements();
/** /**
* Sets the {@link Item} on these coordinates. * Sets the {@link Item} on these coordinates.
@ -131,7 +140,7 @@ public interface GUI extends GUIParent {
* @param item The {@link Item} that should be placed on these coordinates * @param item The {@link Item} that should be placed on these coordinates
* or null to remove the {@link Item} that is currently there. * or null to remove the {@link Item} that is currently there.
*/ */
void setItem(int x, int y, Item item); void setItem(int x, int y, @Nullable Item item);
/** /**
* Sets the {@link Item} on that slot * Sets the {@link Item} on that slot
@ -140,7 +149,14 @@ public interface GUI extends GUIParent {
* @param item The {@link Item} that should be placed on that slot or null * @param item The {@link Item} that should be placed on that slot or null
* to remove the {@link Item} that is currently there. * to remove the {@link Item} that is currently there.
*/ */
void setItem(int index, Item item); void setItem(int index, @Nullable Item item);
/**
* Adds {@link Item Items} to the gui.
*
* @param items The {@link Item Items} that should be added to the gui
*/
void addItems(@NotNull Item... items);
/** /**
* Gets the {@link Item} on these coordinates. * Gets the {@link Item} on these coordinates.
@ -149,6 +165,7 @@ public interface GUI extends GUIParent {
* @param y The y coordinate * @param y The y coordinate
* @return The {@link Item} which is placed on that slot or null if there isn't one * @return The {@link Item} which is placed on that slot or null if there isn't one
*/ */
@Nullable
Item getItem(int x, int y); Item getItem(int x, int y);
/** /**
@ -157,21 +174,16 @@ public interface GUI extends GUIParent {
* @param index The slot index * @param index The slot index
* @return The {@link Item} which is placed on that slot or null if there isn't one * @return The {@link Item} which is placed on that slot or null if there isn't one
*/ */
@Nullable
Item getItem(int index); Item getItem(int index);
/**
* Adds {@link Item}s to the gui.
*
* @param items The {@link Item}s that should be added to the gui
*/
void addItems(@NotNull Item... items);
/** /**
* Gets the {@link ItemProvider} that will be used if nothing else * Gets the {@link ItemProvider} that will be used if nothing else
* is placed on a slot. * is placed on a slot.
* *
* @return The {@link ItemProvider} * @return The {@link ItemProvider}
*/ */
@Nullable
ItemProvider getBackground(); ItemProvider getBackground();
/** /**
@ -193,7 +205,7 @@ public interface GUI extends GUIParent {
/** /**
* Remove the {@link Item} which are placed on these slots. * Remove the {@link Item} which are placed on these slots.
* *
* @param index The slot index of the {@link Item}s that should be removed * @param index The slot index of the {@link Item Items} that should be removed
*/ */
void remove(int index); void remove(int index);
@ -202,76 +214,26 @@ public interface GUI extends GUIParent {
* *
* @param structure The structure * @param structure The structure
*/ */
void applyStructure(Structure structure); void applyStructure(@NotNull Structure structure);
/** /**
* A method called if a slot in the {@link Inventory} has been clicked. * Finds all {@link Window Windows} that show this {@link GUI}.
*
* @param slot The slot that has been clicked
* @param player The {@link Player} that clicked
* @param clickType The {@link ClickType}
* @param event The {@link InventoryClickEvent}
*/
void handleClick(int slot, Player player, ClickType clickType, InventoryClickEvent event);
/**
* A method called when an {@link ItemStack} has been shift-clicked into this
* {@link GUI}.
*
* @param event The {@link InventoryClickEvent} associated with this action
*/
void handleItemShift(InventoryClickEvent event);
/**
* A method called when an {@link ItemStack} has been dragged over the {@link GUI}.
*
* @param updateReason The reason for this item update.
* @param slot The slot index
* @param oldStack The {@link ItemStack} that was previously on that slot
* @param newStack The new {@link ItemStack} that would be there if the action isn't cancelled
* @return If the action has been cancelled
*/
boolean handleItemDrag(UpdateReason updateReason, int slot, ItemStack oldStack, ItemStack newStack);
/**
* Adds a {@link GUIParent} to the set of {@link GUIParent}s.
*
* @param parent The {@link GUIParent} to add
*/
void addParent(@NotNull GUIParent parent);
/**
* Removes a {@link GUIParent} from the set of {@link GUIParent}s
*
* @param parent The {@link GUIParent} to remove
*/
void removeParent(@NotNull GUIParent parent);
/**
* Gets all {@link GUIParent}s.
*
* @return The {@link GUIParent}s of this {@link GUI}
*/
Set<GUIParent> getParents();
/**
* Finds all {@link Window}s that show this {@link GUI}.
* *
* @return The list of {@link Window} that show this {@link GUI} * @return The list of {@link Window} that show this {@link GUI}
*/ */
List<Window> findAllWindows(); List<Window> findAllWindows();
/** /**
* Finds all {@link Player}s that are currently seeing this {@link Window}. * Finds all {@link Player Players} that are currently seeing this {@link Window}.
* *
* @return The list of {@link Player}s that are currently seeing this {@link Window} * @return The list of {@link Player Players} that are currently seeing this {@link Window}
*/ */
Set<Player> findAllCurrentViewers(); Set<Player> findAllCurrentViewers();
/** /**
* Closes the open {@link Inventory} for all viewers of {@link Window}s * Closes the open {@link Inventory} for all viewers of {@link Window Windows}
* where this {@link GUI} is displayed. * where this {@link GUI} is displayed.
* Does not actually call the {@link Window#close(boolean)} method, which will * Does not actually call the {@link Window#remove(boolean)} method, which will
* be indirectly invoked by the {@link InventoryCloseEvent} if the {@link Window} * be indirectly invoked by the {@link InventoryCloseEvent} if the {@link Window}
* is set to close on that event. * is set to close on that event.
*/ */
@ -281,7 +243,7 @@ public interface GUI extends GUIParent {
* Plays an {@link Animation}. * Plays an {@link Animation}.
* *
* @param animation The {@link Animation} to play. * @param animation The {@link Animation} to play.
* @param filter The filter that selects which {@link SlotElement}s should be animated. * @param filter The filter that selects which {@link SlotElement SlotElements} should be animated.
*/ */
void playAnimation(@NotNull Animation animation, @Nullable Predicate<SlotElement> filter); void playAnimation(@NotNull Animation animation, @Nullable Predicate<SlotElement> filter);
@ -290,23 +252,23 @@ public interface GUI extends GUIParent {
*/ */
void cancelAnimation(); void cancelAnimation();
// ---- fill methods ---- //<editor-fold desc="fill methods">
/** /**
* Fills the {@link GUI} with {@link Item}s. * Fills the {@link GUI} with {@link Item Items}.
* *
* @param start The start index of the fill (inclusive) * @param start The start index of the fill (inclusive)
* @param end The end index of the fill (exclusive) * @param end The end index of the fill (exclusive)
* @param item The {@link Item} that should be used or null to remove an existing item. * @param item The {@link Item} that should be used or null to remove an existing item.
* @param replaceExisting If existing {@link Item}s should be replaced. * @param replaceExisting If existing {@link Item Items} should be replaced.
*/ */
void fill(int start, int end, @Nullable Item item, boolean replaceExisting); void fill(int start, int end, @Nullable Item item, boolean replaceExisting);
/** /**
* Fills the entire {@link GUI} with {@link Item}s. * Fills the entire {@link GUI} with {@link Item Items}.
* *
* @param item The {@link Item} that should be used or null to remove an existing item. * @param item The {@link Item} that should be used or null to remove an existing item.
* @param replaceExisting If existing {@link Item}s should be replaced. * @param replaceExisting If existing {@link Item Items} should be replaced.
*/ */
void fill(@Nullable Item item, boolean replaceExisting); void fill(@Nullable Item item, boolean replaceExisting);
@ -315,7 +277,7 @@ public interface GUI extends GUIParent {
* *
* @param row The row * @param row The row
* @param item The {@link Item} that should be used or null to remove an existing item. * @param item The {@link Item} that should be used or null to remove an existing item.
* @param replaceExisting If existing {@link Item}s should be replaced. * @param replaceExisting If existing {@link Item Items} should be replaced.
*/ */
void fillRow(int row, @Nullable Item item, boolean replaceExisting); void fillRow(int row, @Nullable Item item, boolean replaceExisting);
@ -324,7 +286,7 @@ public interface GUI extends GUIParent {
* *
* @param column The column * @param column The column
* @param item The {@link Item} that should be used or null to remove an existing item. * @param item The {@link Item} that should be used or null to remove an existing item.
* @param replaceExisting If existing {@link Item}s should be replaced. * @param replaceExisting If existing {@link Item Items} should be replaced.
*/ */
void fillColumn(int column, @Nullable Item item, boolean replaceExisting); void fillColumn(int column, @Nullable Item item, boolean replaceExisting);
@ -332,7 +294,7 @@ public interface GUI extends GUIParent {
* Fills the borders of this {@link GUI} with a specific {@link Item} * Fills the borders of this {@link GUI} with a specific {@link Item}
* *
* @param item The {@link Item} that should be used or null to remove an existing item. * @param item The {@link Item} that should be used or null to remove an existing item.
* @param replaceExisting If existing {@link Item}s should be replaced. * @param replaceExisting If existing {@link Item Items} should be replaced.
*/ */
void fillBorders(@Nullable Item item, boolean replaceExisting); void fillBorders(@Nullable Item item, boolean replaceExisting);
@ -344,41 +306,43 @@ public interface GUI extends GUIParent {
* @param width The width of the rectangle. * @param width The width of the rectangle.
* @param height The height of the rectangle * @param height The height of the rectangle
* @param item The {@link Item} that should be used or null to remove an existing item. * @param item The {@link Item} that should be used or null to remove an existing item.
* @param replaceExisting If existing {@link Item}s should be replaced. * @param replaceExisting If existing {@link Item Items} should be replaced.
*/ */
void fillRectangle(int x, int y, int width, int height, @Nullable Item item, boolean replaceExisting); void fillRectangle(int x, int y, int width, int height, @Nullable Item item, boolean replaceExisting);
/** /**
* Fills a rectangle of another {@link GUI} in this {@link GUI}. * Fills a rectangle with another {@link GUI} in this {@link GUI}.
* *
* @param x The x coordinate where the rectangle should start * @param x The x coordinate where the rectangle should start
* @param y The y coordinate where the rectangle should start * @param y The y coordinate where the rectangle should start
* @param gui The {@link GUI} to be put into this {@link GUI} * @param gui The {@link GUI} to be put into this {@link GUI}
* @param replaceExisting If existing {@link SlotElement}s should be replaced. * @param replaceExisting If existing {@link SlotElement SlotElements} should be replaced.
*/ */
void fillRectangle(int x, int y, @NotNull GUI gui, boolean replaceExisting); void fillRectangle(int x, int y, @NotNull GUI gui, boolean replaceExisting);
/** /**
* Fills a rectangle of a {@link VirtualInventory} in this {@link GUI}. * Fills a rectangle with a {@link VirtualInventory} in this {@link GUI}.
* *
* @param x The x coordinate where the rectangle should start * @param x The x coordinate where the rectangle should start
* @param y The y coordinate where the rectangle should start * @param y The y coordinate where the rectangle should start
* @param width The line length of the rectangle. (VirtualInventory does not define a width) * @param width The line length of the rectangle. (VirtualInventory does not define a width)
* @param virtualInventory The {@link VirtualInventory} to be put into this {@link GUI}. * @param virtualInventory The {@link VirtualInventory} to be put into this {@link GUI}.
* @param replaceExisting If existing {@link SlotElement}s should be replaced. * @param replaceExisting If existing {@link SlotElement SlotElements} should be replaced.
*/ */
void fillRectangle(int x, int y, int width, @NotNull VirtualInventory virtualInventory, boolean replaceExisting); void fillRectangle(int x, int y, int width, @NotNull VirtualInventory virtualInventory, boolean replaceExisting);
/** /**
* Fills a rectangle of a {@link VirtualInventory} in this {@link GUI}. * Fills a rectangle with a {@link VirtualInventory} in this {@link GUI}.
* *
* @param x The x coordinate where the rectangle should start * @param x The x coordinate where the rectangle should start
* @param y The y coordinate where the rectangle should start * @param y The y coordinate where the rectangle should start
* @param width The line length of the rectangle. (VirtualInventory does not define a width) * @param width The line length of the rectangle. (VirtualInventory does not define a width)
* @param virtualInventory The {@link VirtualInventory} to be put into this {@link GUI}. * @param virtualInventory The {@link VirtualInventory} to be put into this {@link GUI}.
* @param background The {@link ItemProvider} for empty slots of the {@link VirtualInventory} * @param background The {@link ItemProvider} for empty slots of the {@link VirtualInventory}
* @param replaceExisting If existing {@link SlotElement}s should be replaced. * @param replaceExisting If existing {@link SlotElement SlotElements} should be replaced.
*/ */
void fillRectangle(int x, int y, int width, @NotNull VirtualInventory virtualInventory, @Nullable ItemProvider background, boolean replaceExisting); void fillRectangle(int x, int y, int width, @NotNull VirtualInventory virtualInventory, @Nullable ItemProvider background, boolean replaceExisting);
//</editor-fold>
} }

@ -0,0 +1,106 @@
package de.studiocode.invui.gui;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.function.BiConsumer;
public interface PagedGUI<C> extends GUI {
/**
* Gets the amount of pages this {@link PagedGUI} has.
*
* @return The amount of pages this {@link PagedGUI} has.
*/
int getPageAmount();
/**
* Gets the current page of this {@link PagedGUI} as an index.
*
* @return Gets the current page of this {@link PagedGUI} as an index.
*/
int getCurrentPage();
/**
* Sets the current page of this {@link PagedGUI}.
*
* @param page The page to set.
*/
void setPage(int page);
/**
* Checks if there is a next page.
*
* @return Whether there is a next page.
*/
boolean hasNextPage();
/**
* Checks if there is a previous page.
*
* @return Whether there is a previous page.
*/
boolean hasPreviousPage();
/**
* Gets if there are infinite pages in this {@link PagedGUI}.
*
* @return Whether there are infinite pages in this {@link PagedGUI}.
*/
boolean hasInfinitePages();
/**
* Displays the next page if there is one.
*/
void goForward();
/**
* Displays the previous page if there is one.
*/
void goBack();
/**
* Gets the slot indices that are used to display content in this {@link PagedGUI}.
*
* @return The slot indices that are used to display content in this {@link PagedGUI}.
*/
int[] getContentListSlots();
/**
* Sets the content of this {@link PagedGUI} for all pages.
*
* @param content The content to set.
*/
void setContent(List<@Nullable C> content);
/**
* Gets the registered page change handlers.
*
* @return The registered page change handlers.
*/
@Nullable
List<BiConsumer<Integer, Integer>> getPageChangeHandlers();
/**
* Replaces the currently registered page change handlers with the given list.
*
* @param handlers The new page change handlers.
*/
void setPageChangeHandlers(@Nullable List<BiConsumer<Integer, Integer>> handlers);
/**
* Registers a page change handler.
*
* @param handler The handler to register.
*/
void registerPageChangeHandler(@NotNull BiConsumer<Integer, Integer> handler);
/**
* Unregisters a page change handler.
*
* @param handler The handler to unregister.
*/
void unregisterPageChangeHandler(@NotNull BiConsumer<Integer, Integer> handler);
}

@ -0,0 +1,49 @@
package de.studiocode.invui.gui;
import java.util.List;
public interface ScrollGUI<C> extends GUI {
/**
* Gets the current line of this {@link ScrollGUI}.
*
* @return The current line of this {@link ScrollGUI}.
*/
int getCurrentLine();
/**
* Gets the max line index of this {@link ScrollGUI}.
*
* @return The max line index of this {@link ScrollGUI}.
*/
int getMaxLine();
/**
* Sets the current line of this {@link ScrollGUI}.
*
* @param line The line to set.
*/
void setCurrentLine(int line);
/**
* Checks if it is possible to scroll the specified amount of lines.
*
* @return Whether it is possible to scroll the specified amount of lines.
*/
boolean canScroll(int lines);
/**
* Scrolls the specified amount of lines.
*
* @param lines The amount of lines to scroll.
*/
void scroll(int lines);
/**
* Sets the content of this {@link ScrollGUI} for all lines.
*
* @param content The content to set.
*/
void setContent(List<C> content);
}

@ -99,11 +99,14 @@ public interface SlotElement {
private final int slot; private final int slot;
public LinkedSlotElement(GUI gui, int slot) { public LinkedSlotElement(GUI gui, int slot) {
if (!(gui instanceof AbstractGUI))
throw new IllegalArgumentException("Illegal GUI implementation");
this.gui = gui; this.gui = gui;
this.slot = slot; this.slot = slot;
} }
public GUI getGui() { public GUI getGUI() {
return gui; return gui;
} }
@ -115,18 +118,18 @@ public interface SlotElement {
public SlotElement getHoldingElement() { public SlotElement getHoldingElement() {
LinkedSlotElement element = this; LinkedSlotElement element = this;
while (true) { while (true) {
SlotElement below = element.getGui().getSlotElement(element.getSlotIndex()); SlotElement below = element.getGUI().getSlotElement(element.getSlotIndex());
if (below instanceof LinkedSlotElement) element = (LinkedSlotElement) below; if (below instanceof LinkedSlotElement) element = (LinkedSlotElement) below;
else return below; else return below;
} }
} }
public List<GUI> getGuiList() { public List<GUI> getGUIList() {
ArrayList<GUI> guis = new ArrayList<>(); ArrayList<GUI> guis = new ArrayList<>();
LinkedSlotElement element = this; LinkedSlotElement element = this;
while (true) { while (true) {
guis.add(element.getGui()); guis.add(element.getGUI());
SlotElement below = element.getGui().getSlotElement(element.getSlotIndex()); SlotElement below = element.getGUI().getSlotElement(element.getSlotIndex());
if (below instanceof LinkedSlotElement) if (below instanceof LinkedSlotElement)
element = (LinkedSlotElement) below; element = (LinkedSlotElement) below;
else break; else break;

@ -0,0 +1,68 @@
package de.studiocode.invui.gui;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.function.BiConsumer;
public interface TabGUI extends GUI {
/**
* Gets the current tab index.
*
* @return The current tab index.
*/
int getCurrentTab();
/**
* Sets the current tab.
*
* @param tab The index of the tab to show.
*/
void showTab(int tab);
/**
* Checks if the given tab is available.
*
* @param tab The index of the tab to check.
* @return Whether the given tab is available.
*/
boolean isTabAvailable(int tab);
/**
* Gets the configured tabs.
* @return The configured tabs.
*/
List<GUI> getTabs();
/**
* Gets the registered tab change handlers.
*
* @return The registered tab change handlers.
*/
@Nullable
List<BiConsumer<Integer, Integer>> getTabChangeHandlers();
/**
* Replaces the currently registered tab change handlers with the given list.
*
* @param handlers The new page change handlers.
*/
void setTabChangeHandlers(@Nullable List<BiConsumer<Integer, Integer>> handlers);
/**
* Registers a page change handler.
*
* @param handler The handler to register.
*/
void registerTabChangeHandler(@NotNull BiConsumer<Integer, Integer> handler);
/**
* Unregisters a page change handler.
*
* @param handler The handler to unregister.
*/
void unregisterTabChangeHandler(@NotNull BiConsumer<Integer, Integer> handler);
}

@ -23,119 +23,92 @@ import java.util.function.Supplier;
* It provides similar functionality to Bukkit's {@link ShapedRecipe}, as it * It provides similar functionality to Bukkit's {@link ShapedRecipe}, as it
* allows for a structure String which defines the layout of the {@link GUI}. * allows for a structure String which defines the layout of the {@link GUI}.
*/ */
public class GUIBuilder<G extends GUI> { public class GUIBuilder<G extends GUI, C> {
private final GUIType<G> guiType; protected final GUIType<G, C> guiType;
private final GUIContext context; protected final GUIContext<C> context;
public GUIBuilder(@NotNull GUIType<G> guiType) { public GUIBuilder(@NotNull GUIType<G, C> guiType) {
this.guiType = guiType; this.guiType = guiType;
this.context = new GUIContext(); this.context = new GUIContext<>();
} }
public GUIBuilder<G> setStructure(int width, int height, @NotNull String structureData) { public GUIBuilder<G, C> setStructure(int width, int height, @NotNull String structureData) {
context.setStructure(new Structure(width, height, structureData)); context.setStructure(new Structure(width, height, structureData));
return this; return this;
} }
public GUIBuilder<G> setStructure(@NotNull String... structureData) { public GUIBuilder<G, C> setStructure(@NotNull String... structureData) {
return setStructure(new Structure(structureData)); return setStructure(new Structure(structureData));
} }
public GUIBuilder<G> setStructure(@NotNull Structure structure) { public GUIBuilder<G, C> setStructure(@NotNull Structure structure) {
context.setStructure(structure); context.setStructure(structure);
return this; return this;
} }
public GUIBuilder<G> addIngredient(char key, @NotNull ItemStack itemStack) { public GUIBuilder<G, C> addIngredient(char key, @NotNull ItemStack itemStack) {
context.getStructure().addIngredient(key, itemStack); context.getStructure().addIngredient(key, itemStack);
return this; return this;
} }
public GUIBuilder<G> addIngredient(char key, @NotNull ItemProvider itemProvider) { public GUIBuilder<G, C> addIngredient(char key, @NotNull ItemProvider itemProvider) {
context.getStructure().addIngredient(key, itemProvider); context.getStructure().addIngredient(key, itemProvider);
return this; return this;
} }
public GUIBuilder<G> addIngredient(char key, @NotNull Item item) { public GUIBuilder<G, C> addIngredient(char key, @NotNull Item item) {
context.getStructure().addIngredient(key, item); context.getStructure().addIngredient(key, item);
return this; return this;
} }
public GUIBuilder<G> addIngredient(char key, @NotNull VirtualInventory inventory) { public GUIBuilder<G, C> addIngredient(char key, @NotNull VirtualInventory inventory) {
context.getStructure().addIngredient(key, inventory); context.getStructure().addIngredient(key, inventory);
return this; return this;
} }
public GUIBuilder<G> addIngredient(char key, @NotNull VirtualInventory inventory, @Nullable ItemProvider background) { public GUIBuilder<G, C> addIngredient(char key, @NotNull VirtualInventory inventory, @Nullable ItemProvider background) {
context.getStructure().addIngredient(key, inventory, background); context.getStructure().addIngredient(key, inventory, background);
return this; return this;
} }
public GUIBuilder<G> addIngredient(char key, @NotNull SlotElement element) { public GUIBuilder<G, C> addIngredient(char key, @NotNull SlotElement element) {
context.getStructure().addIngredient(key, element); context.getStructure().addIngredient(key, element);
return this; return this;
} }
public GUIBuilder<G> addIngredient(char key, @NotNull Marker marker) { public GUIBuilder<G, C> addIngredient(char key, @NotNull Marker marker) {
context.getStructure().addIngredient(key, marker); context.getStructure().addIngredient(key, marker);
return this; return this;
} }
public GUIBuilder<G> addIngredient(char key, @NotNull Supplier<? extends Item> itemSupplier) { public GUIBuilder<G, C> addIngredient(char key, @NotNull Supplier<? extends Item> itemSupplier) {
context.getStructure().addIngredient(key, itemSupplier); context.getStructure().addIngredient(key, itemSupplier);
return this; return this;
} }
public GUIBuilder<G> addIngredientElementSupplier(char key, @NotNull Supplier<? extends SlotElement> elementSupplier) { public GUIBuilder<G, C> addIngredientElementSupplier(char key, @NotNull Supplier<? extends SlotElement> elementSupplier) {
context.getStructure().addIngredientElementSupplier(key, elementSupplier); context.getStructure().addIngredientElementSupplier(key, elementSupplier);
return this; return this;
} }
public GUIBuilder<G> setItems(@NotNull List<Item> items) { public GUIBuilder<G, C> setContent(@NotNull List<C> content) {
if (!guiType.acceptsItems()) context.setContent(content);
throw new UnsupportedOperationException("Items cannot be set in this gui type.");
context.setItems(items);
return this; return this;
} }
public GUIBuilder<G> addItem(@NotNull Item item) { public GUIBuilder<G, C> addContent(@NotNull C content) {
if (!guiType.acceptsItems()) if (context.getContent() == null)
throw new UnsupportedOperationException("Items cannot be set in this gui type."); context.setContent(new ArrayList<>());
if (context.getItems() == null) context.setItems(new ArrayList<>());
context.getItems().add(item);
return this;
}
public GUIBuilder<G> setGUIs(@NotNull List<GUI> guis) { context.getContent().add(content);
if (!guiType.acceptsGUIs())
throw new UnsupportedOperationException("GUIs cannot be set in this gui type.");
context.setGuis(guis);
return this;
}
public GUIBuilder<G> addGUI(@NotNull GUI gui) {
if (!guiType.acceptsGUIs())
throw new UnsupportedOperationException("GUIs cannot be set in this gui type.");
if (context.getGuis() == null) context.setGuis(new ArrayList<>());
context.getGuis().add(gui);
return this;
}
public GUIBuilder<G> setInventory(@NotNull VirtualInventory inventory) {
if (!guiType.acceptsInventory())
throw new UnsupportedOperationException("An inventory cannot be set in this gui type.");
context.setInventory(inventory);
return this;
}
public GUIBuilder<G> setBackground(@Nullable ItemProvider background) {
context.setBackground(background);
return this; return this;
} }
public G build() { public G build() {
if (context.getStructure() == null) throw new IllegalStateException("GUIContext has not been set yet."); if (context.getStructure() == null)
throw new IllegalStateException("GUIContext has not been set yet.");
return guiType.createGUI(context); return guiType.createGUI(context);
} }

@ -3,9 +3,7 @@ package de.studiocode.invui.gui.builder;
import de.studiocode.invui.gui.GUI; import de.studiocode.invui.gui.GUI;
import de.studiocode.invui.gui.builder.guitype.GUIType; import de.studiocode.invui.gui.builder.guitype.GUIType;
import de.studiocode.invui.gui.structure.Structure; import de.studiocode.invui.gui.structure.Structure;
import de.studiocode.invui.item.Item;
import de.studiocode.invui.item.ItemProvider; import de.studiocode.invui.item.ItemProvider;
import de.studiocode.invui.virtualinventory.VirtualInventory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
@ -14,13 +12,11 @@ import java.util.List;
* The {@link GUIContext} contains all information from the {@link GUIBuilder} to be passed to * The {@link GUIContext} contains all information from the {@link GUIBuilder} to be passed to
* an instance of {@link GUIType} to create a new {@link GUI}. * an instance of {@link GUIType} to create a new {@link GUI}.
*/ */
public class GUIContext { public class GUIContext<C> {
private Structure structure; private Structure structure;
private ItemProvider background; private ItemProvider background;
private List<GUI> guis; private List<C> content;
private List<Item> items;
private VirtualInventory inventory;
public Structure getStructure() { public Structure getStructure() {
return structure; return structure;
@ -38,28 +34,12 @@ public class GUIContext {
this.background = background; this.background = background;
} }
public List<GUI> getGuis() { public void setContent(@NotNull List<C> content) {
return guis; this.content = content;
} }
public void setGuis(@NotNull List<GUI> guis) { public List<C> getContent() {
this.guis = guis; return content;
}
public List<Item> getItems() {
return items;
}
public void setItems(@NotNull List<Item> items) {
this.items = items;
}
public VirtualInventory getInventory() {
return inventory;
}
public void setInventory(@NotNull VirtualInventory inventory) {
this.inventory = inventory;
} }
} }

@ -1,20 +1,22 @@
package de.studiocode.invui.gui.builder.guitype; package de.studiocode.invui.gui.builder.guitype;
import de.studiocode.invui.gui.GUI; import de.studiocode.invui.gui.GUI;
import de.studiocode.invui.gui.PagedGUI;
import de.studiocode.invui.gui.ScrollGUI;
import de.studiocode.invui.gui.TabGUI;
import de.studiocode.invui.gui.builder.GUIContext; import de.studiocode.invui.gui.builder.GUIContext;
import de.studiocode.invui.gui.impl.*;
import de.studiocode.invui.item.Item; import de.studiocode.invui.item.Item;
import de.studiocode.invui.virtualinventory.VirtualInventory; import de.studiocode.invui.virtualinventory.VirtualInventory;
public interface GUIType<G extends GUI> { public interface GUIType<G extends GUI, C> {
GUIType<SimpleGUI> NORMAL = new NormalGUIType(); GUIType<GUI, Void> NORMAL = new NormalGUIType();
GUIType<SimplePagedItemsGUI> PAGED_ITEMS = new PagedItemsGUIType(); GUIType<PagedGUI<Item>, Item> PAGED_ITEMS = new PagedItemsGUIType();
GUIType<SimplePagedNestedGUI> PAGED_GUIs = new PagedGUIsGUIType(); GUIType<PagedGUI<GUI>, GUI> PAGED_GUIs = new PagedGUIsGUIType();
GUIType<SimpleTabGUI> TAB = new TabGUIType(); GUIType<TabGUI, GUI> TAB = new TabGUIType();
GUIType<SimpleScrollItemsGUI> SCROLL_ITEMS = new ScrollItemsGUIType(); GUIType<ScrollGUI<Item>, Item> SCROLL_ITEMS = new ScrollItemsGUIType();
GUIType<SimpleScrollNestedGUI> SCROLL_GUIS = new ScrollGUIsGUIType(); GUIType<ScrollGUI<GUI>, GUI> SCROLL_GUIS = new ScrollGUIsGUIType();
GUIType<SimpleScrollVIGUI> SCROLL_INVENTORY = new ScrollVIGUIType(); GUIType<ScrollGUI<VirtualInventory>, VirtualInventory> SCROLL_INVENTORY = new ScrollVIGUIType();
/** /**
* Creates a {@link GUI} of type {@link G} with the given {@link GUIContext} * Creates a {@link GUI} of type {@link G} with the given {@link GUIContext}
@ -22,21 +24,6 @@ public interface GUIType<G extends GUI> {
* @param context The {@link GUIContext} to create the {@link G} from. * @param context The {@link GUIContext} to create the {@link G} from.
* @return The created {@link G} * @return The created {@link G}
*/ */
G createGUI(GUIContext context); G createGUI(GUIContext<C> context);
/**
* @return If this {@link GUIType} accepts {@link GUI GUIs} from the {@link GUIContext}.
*/
boolean acceptsGUIs();
/**
* @return If this {@link GUIType} accepts {@link Item Items} from the {@link GUIContext}.
*/
boolean acceptsItems();
/**
* @return If this {@link GUIType} accepts a {@link VirtualInventory} from the {@link GUIContext}
*/
boolean acceptsInventory();
} }

@ -1,30 +1,16 @@
package de.studiocode.invui.gui.builder.guitype; package de.studiocode.invui.gui.builder.guitype;
import de.studiocode.invui.gui.GUI;
import de.studiocode.invui.gui.builder.GUIContext; import de.studiocode.invui.gui.builder.GUIContext;
import de.studiocode.invui.gui.impl.SimpleGUI; import de.studiocode.invui.gui.impl.NormalGUIImpl;
class NormalGUIType implements GUIType<SimpleGUI> { class NormalGUIType implements GUIType<GUI, Void> {
@Override @Override
public SimpleGUI createGUI(GUIContext context) { public NormalGUIImpl createGUI(GUIContext<Void> context) {
SimpleGUI gui = new SimpleGUI(context.getStructure()); NormalGUIImpl gui = new NormalGUIImpl(context.getStructure());
gui.setBackground(context.getBackground()); gui.setBackground(context.getBackground());
return gui; return gui;
} }
@Override
public boolean acceptsGUIs() {
return false;
}
@Override
public boolean acceptsItems() {
return false;
}
@Override
public boolean acceptsInventory() {
return false;
}
} }

@ -1,30 +1,17 @@
package de.studiocode.invui.gui.builder.guitype; package de.studiocode.invui.gui.builder.guitype;
import de.studiocode.invui.gui.GUI;
import de.studiocode.invui.gui.PagedGUI;
import de.studiocode.invui.gui.builder.GUIContext; import de.studiocode.invui.gui.builder.GUIContext;
import de.studiocode.invui.gui.impl.SimplePagedNestedGUI; import de.studiocode.invui.gui.impl.PageNestedGUIImpl;
class PagedGUIsGUIType implements GUIType<SimplePagedNestedGUI> { class PagedGUIsGUIType implements GUIType<PagedGUI<GUI>, GUI> {
@Override @Override
public SimplePagedNestedGUI createGUI(GUIContext context) { public PageNestedGUIImpl createGUI(GUIContext<GUI> context) {
SimplePagedNestedGUI gui = new SimplePagedNestedGUI(context.getGuis(), context.getStructure()); PageNestedGUIImpl gui = new PageNestedGUIImpl(context.getContent(), context.getStructure());
gui.setBackground(context.getBackground()); gui.setBackground(context.getBackground());
return gui; return gui;
} }
@Override
public boolean acceptsGUIs() {
return true;
}
@Override
public boolean acceptsItems() {
return false;
}
@Override
public boolean acceptsInventory() {
return false;
}
} }

@ -1,30 +1,17 @@
package de.studiocode.invui.gui.builder.guitype; package de.studiocode.invui.gui.builder.guitype;
import de.studiocode.invui.gui.PagedGUI;
import de.studiocode.invui.gui.builder.GUIContext; import de.studiocode.invui.gui.builder.GUIContext;
import de.studiocode.invui.gui.impl.SimplePagedItemsGUI; import de.studiocode.invui.gui.impl.PagedItemsGUIImpl;
import de.studiocode.invui.item.Item;
class PagedItemsGUIType implements GUIType<SimplePagedItemsGUI> { class PagedItemsGUIType implements GUIType<PagedGUI<Item>, Item> {
@Override @Override
public SimplePagedItemsGUI createGUI(GUIContext context) { public PagedItemsGUIImpl createGUI(GUIContext<Item> context) {
SimplePagedItemsGUI gui = new SimplePagedItemsGUI(context.getItems(), context.getStructure()); PagedItemsGUIImpl gui = new PagedItemsGUIImpl(context.getContent(), context.getStructure());
gui.setBackground(context.getBackground()); gui.setBackground(context.getBackground());
return gui; return gui;
} }
@Override
public boolean acceptsGUIs() {
return false;
}
@Override
public boolean acceptsItems() {
return true;
}
@Override
public boolean acceptsInventory() {
return false;
}
} }

@ -1,30 +1,17 @@
package de.studiocode.invui.gui.builder.guitype; package de.studiocode.invui.gui.builder.guitype;
import de.studiocode.invui.gui.GUI;
import de.studiocode.invui.gui.ScrollGUI;
import de.studiocode.invui.gui.builder.GUIContext; import de.studiocode.invui.gui.builder.GUIContext;
import de.studiocode.invui.gui.impl.SimpleScrollNestedGUI; import de.studiocode.invui.gui.impl.ScrollNestedGUIImpl;
class ScrollGUIsGUIType implements GUIType<SimpleScrollNestedGUI> { class ScrollGUIsGUIType implements GUIType<ScrollGUI<GUI>, GUI> {
@Override @Override
public SimpleScrollNestedGUI createGUI(GUIContext context) { public ScrollNestedGUIImpl createGUI(GUIContext<GUI> context) {
SimpleScrollNestedGUI gui = new SimpleScrollNestedGUI(context.getGuis(), context.getStructure()); ScrollNestedGUIImpl gui = new ScrollNestedGUIImpl(context.getContent(), context.getStructure());
gui.setBackground(gui.getBackground()); gui.setBackground(gui.getBackground());
return gui; return gui;
} }
@Override
public boolean acceptsGUIs() {
return true;
}
@Override
public boolean acceptsItems() {
return false;
}
@Override
public boolean acceptsInventory() {
return false;
}
} }

@ -1,30 +1,17 @@
package de.studiocode.invui.gui.builder.guitype; package de.studiocode.invui.gui.builder.guitype;
import de.studiocode.invui.gui.ScrollGUI;
import de.studiocode.invui.gui.builder.GUIContext; import de.studiocode.invui.gui.builder.GUIContext;
import de.studiocode.invui.gui.impl.SimpleScrollItemsGUI; import de.studiocode.invui.gui.impl.ScrollItemsGUIImpl;
import de.studiocode.invui.item.Item;
class ScrollItemsGUIType implements GUIType<SimpleScrollItemsGUI> { class ScrollItemsGUIType implements GUIType<ScrollGUI<Item>, Item> {
@Override @Override
public SimpleScrollItemsGUI createGUI(GUIContext context) { public ScrollItemsGUIImpl createGUI(GUIContext<Item> context) {
SimpleScrollItemsGUI gui = new SimpleScrollItemsGUI(context.getItems(), context.getStructure()); ScrollItemsGUIImpl gui = new ScrollItemsGUIImpl(context.getContent(), context.getStructure());
gui.setBackground(context.getBackground()); gui.setBackground(context.getBackground());
return gui; return gui;
} }
@Override
public boolean acceptsGUIs() {
return false;
}
@Override
public boolean acceptsItems() {
return true;
}
@Override
public boolean acceptsInventory() {
return false;
}
} }

@ -1,30 +1,17 @@
package de.studiocode.invui.gui.builder.guitype; package de.studiocode.invui.gui.builder.guitype;
import de.studiocode.invui.gui.ScrollGUI;
import de.studiocode.invui.gui.builder.GUIContext; import de.studiocode.invui.gui.builder.GUIContext;
import de.studiocode.invui.gui.impl.SimpleScrollVIGUI; import de.studiocode.invui.gui.impl.ScrollVIGUIImpl;
import de.studiocode.invui.virtualinventory.VirtualInventory;
class ScrollVIGUIType implements GUIType<SimpleScrollVIGUI> { class ScrollVIGUIType implements GUIType<ScrollGUI<VirtualInventory>, VirtualInventory> {
@Override @Override
public SimpleScrollVIGUI createGUI(GUIContext context) { public ScrollVIGUIImpl createGUI(GUIContext<VirtualInventory> context) {
SimpleScrollVIGUI gui = new SimpleScrollVIGUI(context.getInventory(), context.getStructure()); ScrollVIGUIImpl gui = new ScrollVIGUIImpl(context.getContent(), context.getStructure());
gui.setBackground(context.getBackground()); gui.setBackground(context.getBackground());
return gui; return gui;
} }
@Override
public boolean acceptsGUIs() {
return true;
}
@Override
public boolean acceptsItems() {
return false;
}
@Override
public boolean acceptsInventory() {
return true;
}
} }

@ -1,30 +1,17 @@
package de.studiocode.invui.gui.builder.guitype; package de.studiocode.invui.gui.builder.guitype;
import de.studiocode.invui.gui.GUI;
import de.studiocode.invui.gui.TabGUI;
import de.studiocode.invui.gui.builder.GUIContext; import de.studiocode.invui.gui.builder.GUIContext;
import de.studiocode.invui.gui.impl.SimpleTabGUI; import de.studiocode.invui.gui.impl.TabGUIImpl;
class TabGUIType implements GUIType<SimpleTabGUI> { class TabGUIType implements GUIType<TabGUI, GUI> {
@Override @Override
public SimpleTabGUI createGUI(GUIContext context) { public TabGUIImpl createGUI(GUIContext<GUI> context) {
SimpleTabGUI gui = new SimpleTabGUI(context.getGuis(), context.getStructure()); TabGUIImpl gui = new TabGUIImpl(context.getContent(), context.getStructure());
gui.setBackground(context.getBackground()); gui.setBackground(context.getBackground());
return gui; return gui;
} }
@Override
public boolean acceptsGUIs() {
return true;
}
@Override
public boolean acceptsItems() {
return false;
}
@Override
public boolean acceptsInventory() {
return false;
}
} }

@ -1,5 +1,6 @@
package de.studiocode.invui.gui.impl; package de.studiocode.invui.gui.impl;
import de.studiocode.invui.gui.AbstractGUI;
import de.studiocode.invui.gui.GUI; import de.studiocode.invui.gui.GUI;
import de.studiocode.invui.gui.structure.Structure; import de.studiocode.invui.gui.structure.Structure;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -7,13 +8,13 @@ import org.jetbrains.annotations.NotNull;
/** /**
* A normal {@link GUI} without any special features. * A normal {@link GUI} without any special features.
*/ */
public class SimpleGUI extends BaseGUI { public final class NormalGUIImpl extends AbstractGUI {
public SimpleGUI(int width, int height) { public NormalGUIImpl(int width, int height) {
super(width, height); super(width, height);
} }
public SimpleGUI(@NotNull Structure structure) { public NormalGUIImpl(@NotNull Structure structure) {
super(structure.getWidth(), structure.getHeight()); super(structure.getWidth(), structure.getHeight());
applyStructure(structure); applyStructure(structure);
} }

@ -0,0 +1,59 @@
package de.studiocode.invui.gui.impl;
import de.studiocode.invui.gui.AbstractPagedGUI;
import de.studiocode.invui.gui.GUI;
import de.studiocode.invui.gui.SlotElement;
import de.studiocode.invui.gui.builder.GUIBuilder;
import de.studiocode.invui.gui.structure.Structure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* A {@link AbstractPagedGUI} where every page is its own {@link GUI}.
*
* @see GUIBuilder
* @see PagedItemsGUIImpl
*/
public final class PageNestedGUIImpl extends AbstractPagedGUI<GUI> {
private List<GUI> guis;
public PageNestedGUIImpl(int width, int height, @Nullable List<GUI> guis, int... contentListSlots) {
super(width, height, false, contentListSlots);
setContent(guis);
}
public PageNestedGUIImpl(@Nullable List<GUI> guis, @NotNull Structure structure) {
super(structure.getWidth(), structure.getHeight(), false, structure);
setContent(guis);
}
@Override
public int getPageAmount() {
return guis.size();
}
@Override
public void setContent(@Nullable List<GUI> guis) {
this.guis = guis == null ? new ArrayList<>() : guis;
update();
}
@Override
protected List<SlotElement> getPageElements(int page) {
if (guis.size() <= page) return new ArrayList<>();
GUI gui = guis.get(page);
int size = gui.getSize();
return IntStream.range(0, size)
.mapToObj(i -> new SlotElement.LinkedSlotElement(gui, i))
.collect(Collectors.toList());
}
}

Some files were not shown because too many files have changed in this diff Show More