mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-06 19:18:07 +01:00
Add missing permissions to plugin.yml
This commit is contained in:
parent
394ffc809d
commit
906fd41029
2
.gitignore
vendored
2
.gitignore
vendored
@ -49,6 +49,8 @@ Temporary Items
|
|||||||
*.tmp
|
*.tmp
|
||||||
|
|
||||||
|
|
||||||
|
*.sh
|
||||||
|
|
||||||
# =========================
|
# =========================
|
||||||
# IDE Project Files
|
# IDE Project Files
|
||||||
# =========================
|
# =========================
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
||||||
<timestamp>${maven.build.timestamp}</timestamp>
|
<timestamp>${maven.build.timestamp}</timestamp>
|
||||||
<version>${project.version}-T${timestamp}</version>
|
<version>${project.version}-T${timestamp}</version>
|
||||||
<dependencies>depend: [ PCGF_PluginLib ]</dependencies>
|
<dependencies>PCGF_PluginLib</dependencies>
|
||||||
|
<soft-dependencies/>
|
||||||
<mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}</mainClass>
|
<mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}</mainClass>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -43,10 +44,17 @@
|
|||||||
<artifactId>BadRabbit-Bukkit</artifactId>
|
<artifactId>BadRabbit-Bukkit</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Tests -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
<version>5.6.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package test</defaultGoal>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<testSourceDirectory>test/src</testSourceDirectory>
|
<testSourceDirectory>test/src</testSourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
@ -65,6 +73,10 @@
|
|||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.0.0-M4</version>
|
||||||
|
</plugin>
|
||||||
<!-- Bundle the API into the JAR -->
|
<!-- Bundle the API into the JAR -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@ -218,7 +230,8 @@
|
|||||||
</activation>
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<version>${project.version}-Release</version>
|
<version>${project.version}-Release</version>
|
||||||
<dependencies>softdepend: [ PCGF_PluginLib ]</dependencies>
|
<dependencies/>
|
||||||
|
<soft-dependencies>PCGF_PluginLib</soft-dependencies>
|
||||||
<mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}BadRabbit</mainClass>
|
<mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}BadRabbit</mainClass>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -5,7 +5,8 @@ main: "${mainClass}"
|
|||||||
description: "${project.description}"
|
description: "${project.description}"
|
||||||
version: "${version}"
|
version: "${version}"
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
${dependencies}
|
depend: [${dependencies}]
|
||||||
|
softdepend: [${soft-dependencies}]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
backpack.*:
|
backpack.*:
|
||||||
@ -32,12 +33,14 @@ permissions:
|
|||||||
backpack.use: true
|
backpack.use: true
|
||||||
backpack.size.1: true
|
backpack.size.1: true
|
||||||
backpack.clean: true
|
backpack.clean: true
|
||||||
|
backpack.sort: true
|
||||||
backpack.userBig:
|
backpack.userBig:
|
||||||
description: This permission can be used to give a user the biggest backpack size and allow him to use the backpack.
|
description: This permission can be used to give a user the biggest backpack size and allow him to use the backpack.
|
||||||
children:
|
children:
|
||||||
backpack.use: true
|
backpack.use: true
|
||||||
backpack.size.6: true
|
backpack.size.6: true
|
||||||
backpack.clean: true
|
backpack.clean: true
|
||||||
|
backpack.sort: true
|
||||||
backpack.bypass:
|
backpack.bypass:
|
||||||
children:
|
children:
|
||||||
backpack.ignoreGameMode: true
|
backpack.ignoreGameMode: true
|
||||||
@ -72,11 +75,14 @@ permissions:
|
|||||||
backpack.size.6:
|
backpack.size.6:
|
||||||
description: 6*9 backpack
|
description: 6*9 backpack
|
||||||
default: false
|
default: false
|
||||||
|
backpack.sort:
|
||||||
|
description: Allows the player to sort their own backpack.
|
||||||
|
default: false
|
||||||
backpack.clean:
|
backpack.clean:
|
||||||
description: Allows the player to clean their own backpack.
|
description: Allows the player to clean their own backpack.
|
||||||
default: false
|
default: false
|
||||||
backpack.fullpickup:
|
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
|
defaut: true
|
||||||
backpack.clean.other:
|
backpack.clean.other:
|
||||||
description: Allows the player to clean other players backpacks.
|
description: Allows the player to clean other players backpacks.
|
||||||
@ -120,4 +126,12 @@ permissions:
|
|||||||
default: op
|
default: op
|
||||||
backpack.version:
|
backpack.version:
|
||||||
description: Allows to print the version details of the plugin and it's dependencies.
|
description: Allows to print the version details of the plugin and it's dependencies.
|
||||||
default: op
|
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
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
The munge-maven-plugin requires a test source folder.
|
|
||||||
There currently are no tests so this file is here instead.
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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<String> 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<String> 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<String> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>2.3</revision>
|
<revision>2.3.1</revision>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
Loading…
Reference in New Issue
Block a user