diff --git a/.gitignore b/.gitignore
index 1f229a3..44d5549 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,6 +49,8 @@ Temporary Items
*.tmp
+*.sh
+
# =========================
# IDE Project Files
# =========================
diff --git a/Minepacks/pom.xml b/Minepacks/pom.xml
index da445da..4add09c 100644
--- a/Minepacks/pom.xml
+++ b/Minepacks/pom.xml
@@ -20,7 +20,8 @@
yyyyMMddHHmmss
${maven.build.timestamp}
${project.version}-T${timestamp}
- depend: [ PCGF_PluginLib ]
+ PCGF_PluginLib
+
${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}
@@ -43,10 +44,17 @@
BadRabbit-Bukkit
1.4
+
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.6.0
+ test
+
- clean package
+ clean package test
src
test/src
@@ -65,6 +73,10 @@
+
+ maven-surefire-plugin
+ 3.0.0-M4
+
org.apache.maven.plugins
@@ -218,7 +230,8 @@
${project.version}-Release
- softdepend: [ PCGF_PluginLib ]
+
+ PCGF_PluginLib
${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}BadRabbit
diff --git a/Minepacks/resources/plugin.yml b/Minepacks/resources/plugin.yml
index c9712c0..fd7a201 100644
--- a/Minepacks/resources/plugin.yml
+++ b/Minepacks/resources/plugin.yml
@@ -5,7 +5,8 @@ main: "${mainClass}"
description: "${project.description}"
version: "${version}"
api-version: "1.13"
-${dependencies}
+depend: [${dependencies}]
+softdepend: [${soft-dependencies}]
permissions:
backpack.*:
@@ -32,12 +33,14 @@ permissions:
backpack.use: true
backpack.size.1: true
backpack.clean: true
+ backpack.sort: true
backpack.userBig:
description: This permission can be used to give a user the biggest backpack size and allow him to use the backpack.
children:
backpack.use: true
backpack.size.6: true
backpack.clean: true
+ backpack.sort: true
backpack.bypass:
children:
backpack.ignoreGameMode: true
@@ -72,11 +75,14 @@ permissions:
backpack.size.6:
description: 6*9 backpack
default: false
+ backpack.sort:
+ description: Allows the player to sort their own backpack.
+ default: false
backpack.clean:
description: Allows the player to clean their own backpack.
default: false
backpack.fullpickup:
- desctiption: Allows the player to automatically pick up items when their inventory is full (function needs to be enabled in the config)
+ description: Allows the player to automatically pick up items when their inventory is full (function needs to be enabled in the config)
defaut: true
backpack.clean.other:
description: Allows the player to clean other players backpacks.
@@ -120,4 +126,12 @@ permissions:
default: op
backpack.version:
description: Allows to print the version details of the plugin and it's dependencies.
- default: op
\ No newline at end of file
+ default: op
+ clearInventory:
+ description: Allows the player to clear their own inventory.
+ default: op
+ clearInventory.other:
+ description: Allows the player to clear the inventory of other players.
+ default: op
+ children:
+ clearInventory: true
diff --git a/Minepacks/test/src/.keep b/Minepacks/test/src/.keep
deleted file mode 100644
index 0962353..0000000
--- a/Minepacks/test/src/.keep
+++ /dev/null
@@ -1,2 +0,0 @@
-The munge-maven-plugin requires a test source folder.
-There currently are no tests so this file is here instead.
\ No newline at end of file
diff --git a/Minepacks/test/src/at/pcgamingfreaks/Minepacks/Bukkit/PermissionsTest.java b/Minepacks/test/src/at/pcgamingfreaks/Minepacks/Bukkit/PermissionsTest.java
new file mode 100644
index 0000000..8f7e300
--- /dev/null
+++ b/Minepacks/test/src/at/pcgamingfreaks/Minepacks/Bukkit/PermissionsTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2020 GeorgH93
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package at.pcgamingfreaks.Minepacks.Bukkit;
+
+import at.pcgamingfreaks.yaml.YAML;
+import at.pcgamingfreaks.yaml.YamlInvalidContentException;
+import at.pcgamingfreaks.yaml.YamlKeyNotFoundException;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.HashSet;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PermissionsTest
+{
+ private static Collection permissions;
+
+ @BeforeAll
+ public static void setup() throws IllegalAccessException
+ { // Collect all permissions defined in the Permissions class
+ permissions = new HashSet<>();
+ for(Field declaredField : Permissions.class.getDeclaredFields())
+ {
+ if(declaredField.getName().equals("BASE") || declaredField.getName().equals("SIZE_BASE")) continue;
+ permissions.add((String) declaredField.get(null));
+ }
+ }
+
+ private int countKeysStartingWith(Collection keys, String startsWith)
+ {
+ int count = 0;
+ for(String key : keys)
+ {
+ if(key.startsWith(startsWith)) count++;
+ }
+ return count;
+ }
+
+ @Test
+ public void testPermissionsInPluginYaml() throws IOException, YamlInvalidContentException, YamlKeyNotFoundException
+ {
+ YAML pluginYaml = new YAML(new File("resources/plugin.yml"));
+ YAML permissionsYaml = pluginYaml.getSection("permissions");
+ // Check if all permissions are defined in the plugin.yml
+ for(String permission : permissions)
+ {
+ assertTrue(permissionsYaml.isSet(permission + ".description"), "The plugin.yml should contain the permission " + permission);
+ }
+ // Check if all the permissions defined in the plugin.yml are also defined in the Permissions class
+ Collection keys = permissionsYaml.getKeys(true);
+ for(String key : keys)
+ {
+ if(!key.endsWith("description")) continue;
+ String perm = key.substring(0, key.length() - 12);
+ if(perm.contains(".size.")) continue; // Ignore size permissions
+ if(countKeysStartingWith(keys, perm + ".children") > 1) continue; // Skip all the permissions that are just for permission grouping
+ assertTrue(permissions.contains(perm), "The plugin.yml should not contain the permission " + perm);
+ }
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 0cfc32c..47f0f25 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
pom
- 2.3
+ 2.3.1
UTF-8
UTF-8