Fixed tests by fixing the default rank value.

Flag was marked as deprecated, which may be okay, but because it caused
a lot of warnings in the tests because they bypass the builder I removed
the deprecation but kept the warning in the JavaDoc.
This commit is contained in:
tastybento 2018-12-23 22:15:37 -08:00
parent cc15aa1956
commit 68d6b008f4
4 changed files with 55 additions and 27 deletions

View File

@ -49,9 +49,8 @@ public class Flag implements Comparable<Flag> {
private final boolean subPanel; private final boolean subPanel;
/** /**
* @deprecated {@link Flag.Builder} should be used instead. * {@link Flag.Builder} should be used instead. This is only used for testing.
*/ */
@Deprecated
Flag(String id, Material icon, Listener listener, Type type, int defaultRank, PanelItem.ClickHandler clickListener, boolean subPanel) { Flag(String id, Material icon, Listener listener, Type type, int defaultRank, PanelItem.ClickHandler clickListener, boolean subPanel) {
this.id = id; this.id = id;
this.icon = icon; this.icon = icon;
@ -282,7 +281,7 @@ public class Flag implements Comparable<Flag> {
// Default settings // Default settings
private boolean defaultSetting; private boolean defaultSetting;
private int defaultRank; private int defaultRank = RanksManager.MEMBER_RANK;
// ClickHandler - default depends on the type // ClickHandler - default depends on the type
private PanelItem.ClickHandler clickHandler; private PanelItem.ClickHandler clickHandler;

View File

@ -9,9 +9,42 @@ import org.bukkit.Material;
import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.api.flags.Flag.Type; import world.bentobox.bentobox.api.flags.Flag.Type;
import world.bentobox.bentobox.api.flags.FlagBuilder;
import world.bentobox.bentobox.api.flags.clicklisteners.CycleClick; import world.bentobox.bentobox.api.flags.clicklisteners.CycleClick;
import world.bentobox.bentobox.listeners.flags.*; import world.bentobox.bentobox.listeners.flags.BlockInteractionListener;
import world.bentobox.bentobox.listeners.flags.BreakBlocksListener;
import world.bentobox.bentobox.listeners.flags.BreedingListener;
import world.bentobox.bentobox.listeners.flags.BucketListener;
import world.bentobox.bentobox.listeners.flags.ChestDamageListener;
import world.bentobox.bentobox.listeners.flags.CleanSuperFlatListener;
import world.bentobox.bentobox.listeners.flags.CoarseDirtTillingListener;
import world.bentobox.bentobox.listeners.flags.CreeperListener;
import world.bentobox.bentobox.listeners.flags.EggListener;
import world.bentobox.bentobox.listeners.flags.EnderChestListener;
import world.bentobox.bentobox.listeners.flags.EndermanListener;
import world.bentobox.bentobox.listeners.flags.EnterExitListener;
import world.bentobox.bentobox.listeners.flags.EntityInteractListener;
import world.bentobox.bentobox.listeners.flags.ExperiencePickupListener;
import world.bentobox.bentobox.listeners.flags.FireListener;
import world.bentobox.bentobox.listeners.flags.GeoLimitMobsListener;
import world.bentobox.bentobox.listeners.flags.HurtingListener;
import world.bentobox.bentobox.listeners.flags.InventoryListener;
import world.bentobox.bentobox.listeners.flags.InvincibleVisitorsListener;
import world.bentobox.bentobox.listeners.flags.IslandRespawnListener;
import world.bentobox.bentobox.listeners.flags.ItemDropPickUpListener;
import world.bentobox.bentobox.listeners.flags.ItemFrameListener;
import world.bentobox.bentobox.listeners.flags.LeashListener;
import world.bentobox.bentobox.listeners.flags.LockAndBanListener;
import world.bentobox.bentobox.listeners.flags.MobSpawnListener;
import world.bentobox.bentobox.listeners.flags.OfflineRedstoneListener;
import world.bentobox.bentobox.listeners.flags.PVPListener;
import world.bentobox.bentobox.listeners.flags.PhysicalInteractionListener;
import world.bentobox.bentobox.listeners.flags.PistonPushListener;
import world.bentobox.bentobox.listeners.flags.PlaceBlocksListener;
import world.bentobox.bentobox.listeners.flags.PortalListener;
import world.bentobox.bentobox.listeners.flags.RemoveMobsListener;
import world.bentobox.bentobox.listeners.flags.ShearingListener;
import world.bentobox.bentobox.listeners.flags.TNTListener;
import world.bentobox.bentobox.listeners.flags.TeleportationListener;
import world.bentobox.bentobox.listeners.flags.clicklisteners.CommandRankClickListener; import world.bentobox.bentobox.listeners.flags.clicklisteners.CommandRankClickListener;
import world.bentobox.bentobox.listeners.flags.clicklisteners.GeoLimitClickListener; import world.bentobox.bentobox.listeners.flags.clicklisteners.GeoLimitClickListener;
import world.bentobox.bentobox.managers.RanksManager; import world.bentobox.bentobox.managers.RanksManager;

View File

@ -52,7 +52,6 @@ import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.api.events.team.TeamEvent; import world.bentobox.bentobox.api.events.team.TeamEvent;
import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.api.flags.FlagBuilder;
import world.bentobox.bentobox.api.flags.FlagListener; import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -500,7 +499,7 @@ public class TestBentoBox {
public void testCustomFlags() { public void testCustomFlags() {
// Custom // Custom
TestFlagListener fl = new TestFlagListener(plugin); TestFlagListener fl = new TestFlagListener(plugin);
Flag customFlag = new FlagBuilder().id("CUSTOM_FLAG").icon(Material.DIAMOND).listener(fl).build(); Flag customFlag = new Flag.Builder("CUSTOM_FLAG", Material.DIAMOND).listener(fl).build();
assertEquals("CUSTOM_FLAG", customFlag.getID()); assertEquals("CUSTOM_FLAG", customFlag.getID());
assertEquals(Material.DIAMOND, customFlag.getIcon()); assertEquals(Material.DIAMOND, customFlag.getIcon());
assertEquals(fl, customFlag.getListener().get()); assertEquals(fl, customFlag.getListener().get());

View File

@ -33,7 +33,6 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.api.flags.FlagBuilder;
import world.bentobox.bentobox.listeners.flags.BreakBlocksListener; import world.bentobox.bentobox.listeners.flags.BreakBlocksListener;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
@ -97,11 +96,9 @@ public class FlagsManagerTest {
public void testRegisterDuplicateFlagIcons() { public void testRegisterDuplicateFlagIcons() {
FlagsManager fm = new FlagsManager(plugin); FlagsManager fm = new FlagsManager(plugin);
// Change the ID to something random, but use every icon that is already used // Change the ID to something random, but use every icon that is already used
Flags.values().forEach(dupe -> assertFalse(fm.registerFlag(new FlagBuilder() Flags.values().forEach(dupe -> assertFalse(fm.registerFlag(
.id(UUID.randomUUID().toString()) new Flag.Builder(UUID.randomUUID().toString(), dupe.getIcon()).listener(new BreakBlocksListener()).build()
.icon(dupe.getIcon()) )));
.listener(new BreakBlocksListener())
.build())));
} }
@ -111,12 +108,12 @@ public class FlagsManagerTest {
FlagsManager fm = new FlagsManager(plugin); FlagsManager fm = new FlagsManager(plugin);
// This should pass // This should pass
OriginalListener ol = new OriginalListener(); OriginalListener ol = new OriginalListener();
Flag originalFlag = new FlagBuilder().id("ORIGINAL").icon(Material.EMERALD_BLOCK).listener(ol).build(); Flag originalFlag = new Flag.Builder("ORIGINAL", Material.EMERALD_BLOCK).listener(ol).build();
assertTrue(fm.registerFlag(originalFlag)); assertTrue(fm.registerFlag(originalFlag));
// Verify registered // Verify registered
Mockito.verify(server).getPluginManager(); Mockito.verify(server).getPluginManager();
// Register another flag with same listener // Register another flag with same listener
Flag originalFlag2 = new FlagBuilder().id("ORIGINAL2").icon(Material.COAL_ORE).listener(ol).build(); Flag originalFlag2 = new Flag.Builder("ORIGINAL2", Material.COAL_ORE).listener(ol).build();
assertTrue(fm.registerFlag(originalFlag2)); assertTrue(fm.registerFlag(originalFlag2));
// Verify registered only once // Verify registered only once
Mockito.verify(server).getPluginManager(); Mockito.verify(server).getPluginManager();