Compare commits
No commits in common. "2c498eabe36a760cddf200f14a03d2a9dc252c67" and "49b3a74fc7404c37c433153a32d52888bf60fceb" have entirely different histories.
2c498eabe3
...
49b3a74fc7
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 NichtStudioCode
|
||||
Copyright (c) 2021 NichtStudioCode
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -7,7 +7,7 @@
|
||||
# InvUI
|
||||
|
||||
An Inventory API for Minecraft Spigot servers.
|
||||
Supports all versions from 1.14.0 to 1.20.4.
|
||||
Supports all versions from 1.14.0 to 1.20.2.
|
||||
|
||||
[Documentation](https://xenondevs.xyz/docs/invui/)
|
||||
|
||||
@ -19,6 +19,7 @@ Supports all versions from 1.14.0 to 1.20.4.
|
||||
* Easily customizable (Create your own GUI types and Items)
|
||||
* VirtualInventory: Store real items inside GUIs, customize maximum stack size per slot, etc.
|
||||
* Easy way to add localization using the ItemProvider system and the built-in ItemBuilder
|
||||
* Supports custom textures (forced resource pack system, compatible with AuthMe)
|
||||
* Advanced ItemBuilder (Normal, Potion, Skull, Banner, Firework) with BaseComponent support
|
||||
* Support for BaseComponents in inventory titles
|
||||
* Uncloseable inventories
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -1,139 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>inventory-access-r18</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
<classifier>remapped-mojang</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>inventory-access</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>xyz.xenondevs.string-remapper</groupId>
|
||||
<artifactId>string-remapper-maven-plugin</artifactId>
|
||||
<version>1.2</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>remap-spigot</id>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<spigotVersion>${spigot.version}</spigotVersion>
|
||||
<goal>spigot</goal>
|
||||
<classesIn>${project.build.directory}/classes</classesIn>
|
||||
<classesOut>${project.build.directory}/classes-spigot</classesOut>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>remap-mojang</id>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<spigotVersion>${spigot.version}</spigotVersion>
|
||||
<goal>mojang</goal>
|
||||
<classesIn>${project.build.directory}/classes</classesIn>
|
||||
<classesOut>${project.build.directory}/classes-mojang</classesOut>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-jar</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>spigot</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classesDirectory>${project.build.directory}/classes-spigot</classesDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>mojang</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classesDirectory>${project.build.directory}/classes-mojang</classesDirectory>
|
||||
<classifier>remapped-mojang</classifier>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>specialsource-maven-plugin</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<id>remap-obf</id>
|
||||
<configuration>
|
||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang</srgIn>
|
||||
<reverse>true</reverse>
|
||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang</remappedDependencies>
|
||||
<remappedArtifactAttached>false</remappedArtifactAttached>
|
||||
<finalName>${project.artifactId}-${project.version}-remapped-obf</finalName>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<id>remap-spigot</id>
|
||||
<configuration>
|
||||
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
|
||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot</srgIn>
|
||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-obf</remappedDependencies>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -34,14 +34,14 @@ abstract class ComponentLocalizer<C> {
|
||||
var end = matcher.end();
|
||||
|
||||
// check for escaped %
|
||||
var matchedStr = formatString.substring(start, end);
|
||||
var matchedStr = formatString.substring(i, start);
|
||||
if ("%%".equals(matchedStr)) {
|
||||
sb.append('%');
|
||||
} else {
|
||||
// check for invalid format, only %s is supported
|
||||
var argType = matcher.group(2);
|
||||
if (!"s".equals(argType)) {
|
||||
throw new IllegalStateException("Unsupported placeholder format: '" + matchedStr + "'");
|
||||
throw new IllegalStateException("Unsupported format: '" + matchedStr + "'");
|
||||
}
|
||||
|
||||
// retrieve argument index
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class InvUI implements Listener {
|
||||
|
||||
public @NotNull Plugin getPlugin() {
|
||||
if (plugin == null) {
|
||||
setPlugin(tryFindPlugin());
|
||||
plugin = tryFindPlugin();
|
||||
|
||||
if (plugin == null)
|
||||
throw new IllegalStateException("Plugin is not set. Set it using InvUI.getInstance().setPlugin(plugin);");
|
||||
@ -60,9 +60,6 @@ public class InvUI implements Listener {
|
||||
if (this.plugin != null)
|
||||
throw new IllegalStateException("Plugin is already set");
|
||||
|
||||
if (plugin == null)
|
||||
return;
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -2,17 +2,16 @@ package xyz.xenondevs.invui.item;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface ItemProvider extends Supplier<@NotNull ItemStack>, Cloneable {
|
||||
public interface ItemProvider extends Supplier<ItemStack>, Cloneable {
|
||||
|
||||
/**
|
||||
* An {@link ItemProvider} for an {@link ItemStack}.
|
||||
*/
|
||||
@NotNull ItemProvider EMPTY = new ItemWrapper(new ItemStack(Material.AIR));
|
||||
ItemProvider EMPTY = new ItemWrapper(new ItemStack(Material.AIR));
|
||||
|
||||
/**
|
||||
* Gets the {@link ItemStack} translated in the specified language.
|
||||
@ -20,14 +19,14 @@ public interface ItemProvider extends Supplier<@NotNull ItemStack>, Cloneable {
|
||||
* @param lang The language to translate the item in.
|
||||
* @return The {@link ItemStack}
|
||||
*/
|
||||
@NotNull ItemStack get(@Nullable String lang);
|
||||
ItemStack get(@Nullable String lang);
|
||||
|
||||
/**
|
||||
* Gets the {@link ItemStack} without requesting a specific language.
|
||||
*
|
||||
* @return The {@link ItemStack}
|
||||
*/
|
||||
default @NotNull ItemStack get() {
|
||||
default ItemStack get() {
|
||||
return get(null);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package xyz.xenondevs.invui.item;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -18,7 +17,7 @@ public class ItemWrapper implements ItemProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ItemStack get(String lang) {
|
||||
public ItemStack get(String lang) {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@ public abstract class AbstractMergedWindow extends AbstractDoubleWindow {
|
||||
public AbstractMergedWindow(Player player, ComponentWrapper title, AbstractGui gui, Inventory upperInventory, boolean closeable) {
|
||||
super(player, title, gui.getSize(), upperInventory, closeable);
|
||||
this.gui = gui;
|
||||
|
||||
gui.addParent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,6 +32,8 @@ public abstract class AbstractSingleWindow extends AbstractWindow {
|
||||
this.gui = gui;
|
||||
this.size = gui.getSize();
|
||||
this.inventory = inventory;
|
||||
|
||||
gui.addParent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,9 @@ public abstract class AbstractSplitWindow extends AbstractDoubleWindow {
|
||||
super(player, title, upperGui.getSize() + lowerGui.getSize(), upperInventory, closeable);
|
||||
this.upperGui = upperGui;
|
||||
this.lowerGui = lowerGui;
|
||||
|
||||
upperGui.addParent(this);
|
||||
lowerGui.addParent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -261,7 +261,6 @@ public abstract class AbstractWindow implements Window, GuiParent {
|
||||
hasHandledClose = false;
|
||||
initItems();
|
||||
WindowManager.getInstance().addWindow(this);
|
||||
for (AbstractGui gui : getGuis()) gui.addParent(this);
|
||||
openInventory(viewer);
|
||||
}
|
||||
|
||||
@ -331,8 +330,9 @@ public abstract class AbstractWindow implements Window, GuiParent {
|
||||
((SlotElement.InventorySlotElement) slotElement).getInventory().removeWindow(this);
|
||||
}
|
||||
});
|
||||
|
||||
for (AbstractGui gui : getGuis()) gui.removeParent(this);
|
||||
|
||||
Arrays.stream(getGuis())
|
||||
.forEach(gui -> gui.removeParent(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>invui-kotlin</artifactId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>invui</artifactId>
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>xyz.xenondevs.invui</groupId>
|
||||
<artifactId>invui-parent</artifactId>
|
||||
<version>1.27</version>
|
||||
<version>1.23</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
|
Loading…
Reference in New Issue
Block a user