Skip to content

Add blacklist for items and inventory types #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/buildtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ checkVersion () {
checkVersion "1.19" "17"
checkVersion "1.19.3" "17"
checkVersion "1.19.4" "17"
checkVersion "1.20" "17"
checkVersion "1.20.1" "17"
checkVersion "1.20.2" "17"
50 changes: 42 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.imprex</groupId>
Expand All @@ -13,7 +15,8 @@

<issueManagement>
<system>GitHub</system>
<url>https://github.com/Imprex-Development/zero-inventory-problems/issues</url>
<url>
https://github.com/Imprex-Development/zero-inventory-problems/issues</url>
</issueManagement>

<properties>
Expand All @@ -29,20 +32,51 @@
<plugin.flatten.version>1.2.7</plugin.flatten.version>
<plugin.specialsource.version>1.2.4</plugin.specialsource.version>

<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<java.version>17</java.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>spigot-repo</id>
<name>Spigot Repositories</name>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>minecraft-libraries</id>
<name>Minecraft Libraries</name>
<url>https://libraries.minecraft.net</url>
</repository>
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>brigadier</artifactId>
<version>1.0.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>4.1.68.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-base</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<resources>
<resource>
Expand Down Expand Up @@ -119,9 +153,9 @@
</build>

<modules>
<module>zip-plugin</module>
<module>zip-api</module>
<module>zip-base</module>
<module>zip-nms</module>
<module>zip-common</module>
<module>zip-bukkit</module>
</modules>
</project>
12 changes: 8 additions & 4 deletions zip-api/src/main/java/net/imprex/zip/api/ZIPHandler.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package net.imprex.zip.api;

import java.util.concurrent.CompletableFuture;

import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

public interface ZIPHandler {

void save(ZIPBackpack backpack);
CompletableFuture<Void> save(ZIPBackpack backpack);

CompletableFuture<ZIPBackpack> getBackpack(ZIPUniqueId id);

ZIPBackpack getBackpack(ZIPUniqueId id);
CompletableFuture<ZIPBackpack> getBackpack(ItemStack item);

ZIPBackpack getBackpack(Inventory inventory);
ZIPBackpack getLoadedBackpack(Inventory inventory);

ZIPBackpack getBackpack(ItemStack item);
ZIPUniqueId getBackpackId(ItemStack item);

boolean isBackpack(ItemStack item);
}
43 changes: 43 additions & 0 deletions zip-base/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>net.imprex</groupId>
<artifactId>zip</artifactId>
<version>${revision}</version>
</parent>

<artifactId>zip-base</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>net.imprex</groupId>
<artifactId>zip-api</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>brigadier</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-base</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
29 changes: 29 additions & 0 deletions zip-base/simple/example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 4
testBoolean: false # Just some testing
general:
# Change this value to true to enable update notifications.
checkForUpdates: true
# Change a test value to someting else
#
# Just added some space
#
testCountKey xD: 60
# Set your username
username: INGRIM
randomList:
- Just
- Some
- Random
- Input
exampleMap:
a:
- java
- html
- csharp
b:
- lua
- python
- scss
c:
- html
- css
29 changes: 29 additions & 0 deletions zip-base/src/main/java/net/imprex/command/ArgumentBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.imprex.command;

import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;

public class ArgumentBuilder {

public static final int RESULT_OK = 1;

public static LiteralArgumentBuilder<CommandSender> literal(String name) {
return LiteralArgumentBuilder.<CommandSender>literal(name);
}

public static <T> RequiredArgumentBuilder<CommandSender, T> argument(final String name,
final ArgumentType<T> type) {
return RequiredArgumentBuilder.<CommandSender, T>argument(name, type);
}

public static String getSafeStringArgument(CommandContext<?> context, String fieldName, String defaultValue) {
try {
return ArgumentTypes.getString(context, fieldName);
} catch (IllegalArgumentException e) {
// Ignore missing argument exception and return default value
return defaultValue;
}
}
}
165 changes: 165 additions & 0 deletions zip-base/src/main/java/net/imprex/command/ArgumentTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
package net.imprex.command;

import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.DoubleArgumentType;
import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.LongArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;

public class ArgumentTypes {

/**
* Converted into tick's
*
* Examples: "0d", "0s", "0t", "0"
*/
public static ArgumentType<?> time() {
return TimeArgumentType.time();
}

/**
* Converted into tick's
*/
public static Long getTime(CommandContext<?> context, String name) {
return TimeArgumentType.getTime(context, name);
}

/**
* Examples: "true", "false"
*/
public static BoolArgumentType bool() {
return BoolArgumentType.bool();
}

public static boolean getBoolean(CommandContext<?> context, String name) {
return BoolArgumentType.getBool(context, name);
}

/**
* Examples: "0", "1.2", ".5", "-1", "-.5", "-1234.56"
*/
public static DoubleArgumentType doubleArg() {
return DoubleArgumentType.doubleArg();
}

/**
* Examples: "0", "1.2", ".5", "-1", "-.5", "-1234.56"
*/
public static DoubleArgumentType doubleArg(double min) {
return DoubleArgumentType.doubleArg(min);
}

/**
* Examples: "0", "1.2", ".5", "-1", "-.5", "-1234.56"
*/
public static DoubleArgumentType doubleArg(double min, double max) {
return DoubleArgumentType.doubleArg(min, max);
}

public static double getDouble(CommandContext<?> context, String name) {
return DoubleArgumentType.getDouble(context, name);
}

/**
* Examples: "0", "1.2", ".5", "-1", "-.5", "-1234.56"
*/
public static FloatArgumentType floatArg() {
return FloatArgumentType.floatArg();
}

/**
* Examples: "0", "1.2", ".5", "-1", "-.5", "-1234.56"
*/
public static FloatArgumentType floatArg(float min) {
return FloatArgumentType.floatArg(min);
}

/**
* Examples: "0", "1.2", ".5", "-1", "-.5", "-1234.56"
*/
public static FloatArgumentType floatArg(float min, float max) {
return FloatArgumentType.floatArg(min, max);
}

public static float getFloat(CommandContext<?> context, String name) {
return FloatArgumentType.getFloat(context, name);
}

/**
* Examples: "0", "123", "-123"
*/
public static IntegerArgumentType integer() {
return IntegerArgumentType.integer();
}

/**
* Examples: "0", "123", "-123"
*/
public static IntegerArgumentType integer(int min) {
return IntegerArgumentType.integer(min);
}

/**
* Examples: "0", "123", "-123"
*/
public static IntegerArgumentType integer(int min, int max) {
return IntegerArgumentType.integer(min, max);
}

public static int getInteger(CommandContext<?> context, String name) {
return IntegerArgumentType.getInteger(context, name);
}

/**
* Examples: "0", "123", "-123"
*/
public static LongArgumentType longArg() {
return LongArgumentType.longArg();
}

/**
* Examples: "0", "123", "-123"
*/
public static LongArgumentType longArg(long min) {
return LongArgumentType.longArg(min);
}

/**
* Examples: "0", "123", "-123"
*/
public static LongArgumentType longArg(long min, long max) {
return LongArgumentType.longArg(min, max);
}

public static long getLong(CommandContext<?> context, String name) {
return LongArgumentType.getLong(context, name);
}

/**
* Examples: "word", "words with spaces", "\"and symbols\""
*/
public static StringArgumentType greedyString() {
return StringArgumentType.greedyString();
}

/**
* Examples: "\"quoted phrase\"", "word", "\"\""
*/
public static StringArgumentType string() {
return StringArgumentType.string();
}

/**
* Examples: "word", "words_with_underscores"
*/
public static StringArgumentType word() {
return StringArgumentType.word();
}

public static String getString(CommandContext<?> context, String name) {
return StringArgumentType.getString(context, name);
}
}
Loading