mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
Test empty group and reformat style
This commit is contained in:
parent
101047a25b
commit
9458362453
4 changed files with 110 additions and 66 deletions
|
|
@ -19,7 +19,8 @@ import java.util.List;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class ConflictAPI {
|
public class ConflictAPI {
|
||||||
|
|
||||||
private ConflictAPI() {}
|
private ConflictAPI() {
|
||||||
|
}
|
||||||
|
|
||||||
private static Object saveChangeTask = null;
|
private static Object saveChangeTask = null;
|
||||||
private static Object reloadChangeTask = null;
|
private static Object reloadChangeTask = null;
|
||||||
|
|
@ -102,7 +103,8 @@ public class ConflictAPI {
|
||||||
List<String> excludedGroups = new ArrayList<>(builder.getExcludedGroupNames());
|
List<String> excludedGroups = new ArrayList<>(builder.getExcludedGroupNames());
|
||||||
if (!enchantments.isEmpty()) config.set(basePath + "enchantments", enchantments);
|
if (!enchantments.isEmpty()) config.set(basePath + "enchantments", enchantments);
|
||||||
if (!excludedGroups.isEmpty()) config.set(basePath + "notAffectedGroups", excludedGroups);
|
if (!excludedGroups.isEmpty()) config.set(basePath + "notAffectedGroups", excludedGroups);
|
||||||
if(builder.getMaxBeforeConflict() > 0) config.set(basePath + "maxEnchantmentBeforeConflict", builder.getMaxBeforeConflict());
|
if (builder.getMaxBeforeConflict() > 0)
|
||||||
|
config.set(basePath + "maxEnchantmentBeforeConflict", builder.getMaxBeforeConflict());
|
||||||
|
|
||||||
if (!config.isConfigurationSection(name)) return false;
|
if (!config.isConfigurationSection(name)) return false;
|
||||||
|
|
||||||
|
|
@ -114,6 +116,7 @@ public class ConflictAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract every enchantment names from a builder.
|
* Extract every enchantment names from a builder.
|
||||||
|
*
|
||||||
* @param builder The builder storing the enchantments
|
* @param builder The builder storing the enchantments
|
||||||
* @return Builder's stored enchantment.
|
* @return Builder's stored enchantment.
|
||||||
*/
|
*/
|
||||||
|
|
@ -183,6 +186,7 @@ public class ConflictAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get every registered conflict.
|
* Get every registered conflict.
|
||||||
|
*
|
||||||
* @return An immutable collection of conflict.
|
* @return An immutable collection of conflict.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ import java.util.*;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class MaterialGroupApi {
|
public class MaterialGroupApi {
|
||||||
|
|
||||||
private MaterialGroupApi(){}
|
private MaterialGroupApi() {
|
||||||
|
}
|
||||||
|
|
||||||
private static Object saveChangeTask = null;
|
private static Object saveChangeTask = null;
|
||||||
private static Object reloadChangeTask = null;
|
private static Object reloadChangeTask = null;
|
||||||
|
|
@ -225,6 +226,7 @@ public class MaterialGroupApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get every registered material groups.
|
* Get every registered material groups.
|
||||||
|
*
|
||||||
* @return An immutable map of group name as its key and group as mapped value.
|
* @return An immutable map of group name as its key and group as mapped value.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ public class ConflictApiTests extends ConfigResetCustomAnvilTest {
|
||||||
void writeGroup_Reload() {
|
void writeGroup_Reload() {
|
||||||
String conflictName = "conflict";
|
String conflictName = "conflict";
|
||||||
ConflictBuilder builder = new ConflictBuilder(conflictName);
|
ConflictBuilder builder = new ConflictBuilder(conflictName);
|
||||||
|
builder.addEnchantment("bane_of_arthropods");
|
||||||
|
|
||||||
// Group not being set should not exist
|
// Group not being set should not exist
|
||||||
assertFalse(doGroupExist(conflictName));
|
assertFalse(doGroupExist(conflictName));
|
||||||
|
|
@ -114,6 +115,24 @@ public class ConflictApiTests extends ConfigResetCustomAnvilTest {
|
||||||
assertTrue(doGroupExist(conflictName));
|
assertTrue(doGroupExist(conflictName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void writeGroup_Empty() {
|
||||||
|
String conflictName = "conflict";
|
||||||
|
ConflictBuilder builder = new ConflictBuilder(conflictName);
|
||||||
|
|
||||||
|
// Group not being set should not exist
|
||||||
|
assertFalse(doGroupExist(conflictName));
|
||||||
|
|
||||||
|
// Add group and reload
|
||||||
|
assertFalse(ConflictAPI.writeConflict(builder));
|
||||||
|
assertFalse(doGroupExist(conflictName));
|
||||||
|
|
||||||
|
// Tick so write get reloaded
|
||||||
|
server.getScheduler().performOneTick();
|
||||||
|
|
||||||
|
assertFalse(doGroupExist(conflictName));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void writeGroup_InvalidDot() {
|
void writeGroup_InvalidDot() {
|
||||||
String conflictName = "conflict.conflict";
|
String conflictName = "conflict.conflict";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package xyz.alexcrea.cuanvil.api;
|
package xyz.alexcrea.cuanvil.api;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
||||||
import xyz.alexcrea.cuanvil.group.IncludeGroup;
|
import xyz.alexcrea.cuanvil.group.IncludeGroup;
|
||||||
|
|
@ -14,6 +15,7 @@ public class MaterialGroupApiTests extends ConfigResetCustomAnvilTest {
|
||||||
void groupAddAndRemove() {
|
void groupAddAndRemove() {
|
||||||
String groupName = "group";
|
String groupName = "group";
|
||||||
IncludeGroup group = new IncludeGroup(groupName);
|
IncludeGroup group = new IncludeGroup(groupName);
|
||||||
|
group.addToPolicy(Material.DIAMOND_PICKAXE); // We do not want it to be empty
|
||||||
|
|
||||||
// Group not being set should not exist
|
// Group not being set should not exist
|
||||||
assertFalse(doGroupExist(groupName));
|
assertFalse(doGroupExist(groupName));
|
||||||
|
|
@ -46,6 +48,7 @@ public class MaterialGroupApiTests extends ConfigResetCustomAnvilTest {
|
||||||
void writeGroup_Reload() {
|
void writeGroup_Reload() {
|
||||||
String groupName = "group";
|
String groupName = "group";
|
||||||
IncludeGroup group = new IncludeGroup(groupName);
|
IncludeGroup group = new IncludeGroup(groupName);
|
||||||
|
group.addToPolicy(Material.DIAMOND_PICKAXE); // We do not want it to be empty
|
||||||
|
|
||||||
// Group not being set should not exist
|
// Group not being set should not exist
|
||||||
assertFalse(doGroupExist(groupName));
|
assertFalse(doGroupExist(groupName));
|
||||||
|
|
@ -63,6 +66,22 @@ public class MaterialGroupApiTests extends ConfigResetCustomAnvilTest {
|
||||||
assertTrue(doGroupCanBeFound(groupName));
|
assertTrue(doGroupCanBeFound(groupName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void writeGroup_Empty() {
|
||||||
|
String groupName = "group";
|
||||||
|
IncludeGroup group = new IncludeGroup(groupName);
|
||||||
|
|
||||||
|
// Add group and reload
|
||||||
|
assertFalse(MaterialGroupApi.writeMaterialGroup(group));
|
||||||
|
assertFalse(doGroupExist(groupName));
|
||||||
|
assertFalse(doGroupCanBeFound(groupName));
|
||||||
|
|
||||||
|
// Tick so write get reloaded
|
||||||
|
server.getScheduler().performOneTick();
|
||||||
|
|
||||||
|
assertFalse(doGroupExist(groupName));
|
||||||
|
assertFalse(doGroupCanBeFound(groupName));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void writeGroup_InvalidDot() {
|
void writeGroup_InvalidDot() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue