mirror of
https://github.com/BentoBoxWorld/Warps.git
synced 2025-02-22 07:11:38 +01:00
Fixed bug where island level was not checked.
This commit is contained in:
parent
48c96cf3d3
commit
8bc438a6b7
@ -1,5 +1,5 @@
|
||||
name: BSkyBlock-WelcomeWarps
|
||||
main: bskyblock.addon.warps.Warp
|
||||
name: BentoBox-WelcomeWarps
|
||||
main: bentobox.addon.warps.Warp
|
||||
version: 0.1
|
||||
|
||||
authors: tastybento
|
||||
|
@ -1,14 +1,13 @@
|
||||
package bskyblock.addon.warps;
|
||||
package bentobox.addon.warps;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import bskyblock.addon.warps.commands.WarpCommand;
|
||||
import bskyblock.addon.warps.commands.WarpsCommand;
|
||||
import bskyblock.addon.warps.config.PluginConfig;
|
||||
import bentobox.addon.warps.commands.WarpCommand;
|
||||
import bentobox.addon.warps.commands.WarpsCommand;
|
||||
import bentobox.addon.warps.config.PluginConfig;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
@ -21,7 +20,8 @@ import world.bentobox.bentobox.util.Util;
|
||||
*/
|
||||
public class Warp extends Addon {
|
||||
|
||||
private static final String LEVEL_PLUGIN_NAME = "BSkyBlock-Level";
|
||||
private static final String BSKYBLOCK = "BSkyBlock";
|
||||
private static final String ACIDISLAND = "AcidIsland";
|
||||
|
||||
// The plugin instance.
|
||||
private BentoBox plugin;
|
||||
@ -32,9 +32,6 @@ public class Warp extends Addon {
|
||||
// Warps signs object
|
||||
private WarpSignsManager warpSignsManager;
|
||||
|
||||
// Level addon
|
||||
private Optional<Addon> levelAddon;
|
||||
|
||||
private Set<World> registeredWorlds;
|
||||
|
||||
private PluginConfig settings;
|
||||
@ -61,26 +58,24 @@ public class Warp extends Addon {
|
||||
// Register commands
|
||||
getServer().getScheduler().runTask(getPlugin(), () -> {
|
||||
// BSkyBlock hook in
|
||||
this.getPlugin().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(acidIsland -> {
|
||||
this.getPlugin().getAddonsManager().getAddonByName(BSKYBLOCK).ifPresent(acidIsland -> {
|
||||
CompositeCommand bsbIslandCmd = BentoBox.getInstance().getCommandsManager().getCommand("island");
|
||||
if (bsbIslandCmd != null) {
|
||||
new WarpCommand(this, bsbIslandCmd);
|
||||
new WarpsCommand(this, bsbIslandCmd);
|
||||
registeredWorlds.add(plugin.getIWM().getWorld("BSkyBlock"));
|
||||
registeredWorlds.add(plugin.getIWM().getWorld(BSKYBLOCK));
|
||||
}
|
||||
});
|
||||
// AcidIsland hook in
|
||||
this.getPlugin().getAddonsManager().getAddonByName("AcidIsland").ifPresent(acidIsland -> {
|
||||
this.getPlugin().getAddonsManager().getAddonByName(ACIDISLAND).ifPresent(acidIsland -> {
|
||||
CompositeCommand acidIslandCmd = getPlugin().getCommandsManager().getCommand("ai");
|
||||
if (acidIslandCmd != null) {
|
||||
new WarpCommand(this, acidIslandCmd);
|
||||
new WarpsCommand(this, acidIslandCmd);
|
||||
registeredWorlds.add(plugin.getIWM().getWorld("AcidIsland"));
|
||||
registeredWorlds.add(plugin.getIWM().getWorld(ACIDISLAND));
|
||||
}
|
||||
});
|
||||
});
|
||||
// Get the level addon if it exists
|
||||
setLevelAddon(getPlugin().getAddonsManager().getAddonByName(LEVEL_PLUGIN_NAME));
|
||||
});
|
||||
// Done
|
||||
}
|
||||
@ -104,14 +99,6 @@ public class Warp extends Addon {
|
||||
return warpSignsManager;
|
||||
}
|
||||
|
||||
public Optional<Addon> getLevelAddon() {
|
||||
return levelAddon;
|
||||
}
|
||||
|
||||
public void setLevelAddon(Optional<Addon> levelAddon) {
|
||||
this.levelAddon = levelAddon;
|
||||
}
|
||||
|
||||
public String getPermPrefix(World world) {
|
||||
this.getPlugin().getIWM().getPermissionPrefix(world);
|
||||
return null;
|
@ -1,4 +1,4 @@
|
||||
package bskyblock.addon.warps;
|
||||
package bentobox.addon.warps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
@ -1,4 +1,4 @@
|
||||
package bskyblock.addon.warps;
|
||||
package bentobox.addon.warps;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -15,8 +15,8 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import bskyblock.addon.level.Level;
|
||||
import bskyblock.addon.warps.event.WarpRemoveEvent;
|
||||
import bentobox.addon.level.Level;
|
||||
import bentobox.addon.warps.event.WarpRemoveEvent;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
||||
@ -27,6 +27,8 @@ import world.bentobox.bentobox.api.user.User;
|
||||
*
|
||||
*/
|
||||
public class WarpSignsListener implements Listener {
|
||||
private static final String LEVEL_PLUGIN_NAME = "BentoBox-Level";
|
||||
|
||||
private BentoBox plugin;
|
||||
|
||||
private Warp addon;
|
||||
@ -65,7 +67,7 @@ public class WarpSignsListener implements Listener {
|
||||
if (list.containsValue(s.getLocation())) {
|
||||
// Welcome sign detected - check to see if it is
|
||||
// this player's sign
|
||||
if ((list.containsKey(user.getUniqueId()) && list.get(user.getUniqueId()).equals(s.getLocation()))
|
||||
if ((list.containsKey(user.getUniqueId()) && list.get(user.getUniqueId()).equals(s.getLocation()))
|
||||
|| user.isOp() || user.hasPermission(addon.getPermPrefix(e.getBlock().getWorld()) + "mod.removesign")) {
|
||||
// Op or mod removed sign
|
||||
user.sendMessage("warps.removed");
|
||||
@ -101,18 +103,17 @@ public class WarpSignsListener implements Listener {
|
||||
user.sendMessage("general.errors.you-need", "[permission]", addon.getPermPrefix(b.getWorld()) + "island.addwarp");
|
||||
return;
|
||||
}
|
||||
if (addon.getLevelAddon().isPresent()) {
|
||||
Level lev = (Level) addon.getLevelAddon().get();
|
||||
if (lev.getIslandLevel(b.getWorld(), user.getUniqueId()) < addon.getSettings().getWarpLevelRestriction()) {
|
||||
user.sendMessage("warps.error.not-enough-level");
|
||||
user.sendMessage("warps.error.your-level-is",
|
||||
"[level]", String.valueOf(lev.getIslandLevel(b.getWorld(), user.getUniqueId())),
|
||||
"[required]", String.valueOf(addon.getSettings().getWarpLevelRestriction()));
|
||||
return;
|
||||
}
|
||||
long level = plugin.getAddonsManager().getAddonByName(LEVEL_PLUGIN_NAME).map(l -> (Level)l)
|
||||
.map(l -> l.getIslandLevel(b.getWorld(), user.getUniqueId()))
|
||||
.filter(l -> l < addon.getSettings().getWarpLevelRestriction()).orElse(0L);
|
||||
if (level > 0) {
|
||||
user.sendMessage("warps.error.not-enough-level");
|
||||
user.sendMessage("warps.error.your-level-is",
|
||||
"[level]", String.valueOf(level),
|
||||
"[required]", String.valueOf(addon.getSettings().getWarpLevelRestriction()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check that the player is on their island
|
||||
if (!(plugin.getIslands().userIsOnIsland(b.getWorld(), user))) {
|
||||
user.sendMessage("warps.error.not-on-island");
|
||||
@ -163,7 +164,7 @@ public class WarpSignsListener implements Listener {
|
||||
for (int i = 1; i<4; i++) {
|
||||
e.setLine(i, ChatColor.translateAlternateColorCodes('&', e.getLine(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package bskyblock.addon.warps;
|
||||
package bentobox.addon.warps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -24,9 +24,9 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import bskyblock.addon.warps.database.object.WarpsData;
|
||||
import bskyblock.addon.warps.event.WarpInitiateEvent;
|
||||
import bskyblock.addon.warps.event.WarpListEvent;
|
||||
import bentobox.addon.warps.database.object.WarpsData;
|
||||
import bentobox.addon.warps.event.WarpInitiateEvent;
|
||||
import bentobox.addon.warps.event.WarpListEvent;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.BSBDatabase;
|
@ -1,4 +1,4 @@
|
||||
package bskyblock.addon.warps.commands;
|
||||
package bentobox.addon.warps.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -6,7 +6,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import bskyblock.addon.warps.Warp;
|
||||
import bentobox.addon.warps.Warp;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
@ -1,11 +1,11 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.warps.commands;
|
||||
package bentobox.addon.warps.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import bskyblock.addon.warps.Warp;
|
||||
import bentobox.addon.warps.Warp;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package bskyblock.addon.warps.config;
|
||||
package bentobox.addon.warps.config;
|
||||
|
||||
import bskyblock.addon.warps.Warp;
|
||||
import bentobox.addon.warps.Warp;
|
||||
|
||||
public class PluginConfig {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package bskyblock.addon.warps.database.object;
|
||||
package bentobox.addon.warps.database.object;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
@ -1,4 +1,4 @@
|
||||
package bskyblock.addon.warps.event;
|
||||
package bentobox.addon.warps.event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -6,7 +6,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import bskyblock.addon.warps.Warp;
|
||||
import bentobox.addon.warps.Warp;
|
||||
|
||||
/**
|
||||
* This event is fired when a Warp is created
|
@ -1,4 +1,4 @@
|
||||
package bskyblock.addon.warps.event;
|
||||
package bentobox.addon.warps.event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -7,7 +7,7 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import bskyblock.addon.warps.Warp;
|
||||
import bentobox.addon.warps.Warp;
|
||||
|
||||
/**
|
||||
* This event is fired when a player tries to do a warp
|
@ -15,7 +15,7 @@
|
||||
* along with ASkyBlock. If not, see <http://www.gnu.org/licenses/>.
|
||||
*******************************************************************************/
|
||||
|
||||
package bskyblock.addon.warps.event;
|
||||
package bentobox.addon.warps.event;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -23,7 +23,7 @@ import java.util.UUID;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import bskyblock.addon.warps.Warp;
|
||||
import bentobox.addon.warps.Warp;
|
||||
|
||||
/**
|
||||
* This event is fired when request is made for a sorted list of warps or when
|
@ -1,4 +1,4 @@
|
||||
package bskyblock.addon.warps.event;
|
||||
package bentobox.addon.warps.event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -6,7 +6,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import bskyblock.addon.warps.Warp;
|
||||
import bentobox.addon.warps.Warp;
|
||||
|
||||
/**
|
||||
* This event is fired when a Warp is removed (when a warp sign is broken)
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.warps;
|
||||
package bentobox.addon.warps;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@ -27,6 +27,9 @@ import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import bentobox.addon.warps.Warp;
|
||||
import bentobox.addon.warps.WarpPanelManager;
|
||||
import bentobox.addon.warps.WarpSignsManager;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
@ -99,7 +102,7 @@ public class WarpPanelManagerTest {
|
||||
when(Bukkit.createInventory(Mockito.any(), Mockito.anyInt(), Mockito.any())).thenReturn(top); }
|
||||
|
||||
/**
|
||||
* Test method for {@link bskyblock.addon.warps.WarpPanelManager#showWarpPanel(org.bukkit.World, world.bentobox.bbox.api.user.User, int)}.
|
||||
* Test method for {@link bentobox.addon.warps.WarpPanelManager#showWarpPanel(org.bukkit.World, world.bentobox.bbox.api.user.User, int)}.
|
||||
*/
|
||||
@Test
|
||||
public void testShowWarpPanelFirst() {
|
||||
@ -111,7 +114,7 @@ public class WarpPanelManagerTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link bskyblock.addon.warps.WarpPanelManager#showWarpPanel(org.bukkit.World, world.bentobox.bbox.api.user.User, int)}.
|
||||
* Test method for {@link bentobox.addon.warps.WarpPanelManager#showWarpPanel(org.bukkit.World, world.bentobox.bbox.api.user.User, int)}.
|
||||
*/
|
||||
@Test
|
||||
public void testShowWarpPanelMiddle() {
|
||||
@ -123,7 +126,7 @@ public class WarpPanelManagerTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link bskyblock.addon.warps.WarpPanelManager#showWarpPanel(org.bukkit.World, world.bentobox.bbox.api.user.User, int)}.
|
||||
* Test method for {@link bentobox.addon.warps.WarpPanelManager#showWarpPanel(org.bukkit.World, world.bentobox.bbox.api.user.User, int)}.
|
||||
*/
|
||||
@Test
|
||||
public void testShowWarpPanelLast() {
|
||||
@ -135,7 +138,7 @@ public class WarpPanelManagerTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link bskyblock.addon.warps.WarpPanelManager#showWarpPanel(org.bukkit.World, world.bentobox.bbox.api.user.User, int)}.
|
||||
* Test method for {@link bentobox.addon.warps.WarpPanelManager#showWarpPanel(org.bukkit.World, world.bentobox.bbox.api.user.User, int)}.
|
||||
*/
|
||||
@Test
|
||||
public void testShowWarpPanelTestCache() {
|
||||
@ -150,7 +153,7 @@ public class WarpPanelManagerTest {
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link bskyblock.addon.warps.WarpPanelManager#removeWarp(org.bukkit.World, java.util.UUID)}.
|
||||
* Test method for {@link bentobox.addon.warps.WarpPanelManager#removeWarp(org.bukkit.World, java.util.UUID)}.
|
||||
*/
|
||||
@Test
|
||||
public void testRemoveWarp() {
|
@ -1,4 +1,4 @@
|
||||
package bskyblock.addon.warps;
|
||||
package bentobox.addon.warps;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@ -18,7 +18,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -35,11 +34,12 @@ import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import bskyblock.addon.level.Level;
|
||||
import bskyblock.addon.warps.config.PluginConfig;
|
||||
import bentobox.addon.level.Level;
|
||||
import bentobox.addon.warps.config.PluginConfig;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.managers.AddonsManager;
|
||||
import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
|
||||
@ -78,7 +78,7 @@ public class WarpSignsListenerTest {
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
s = mock(Sign.class);
|
||||
when(s.getLine(Mockito.anyInt())).thenReturn(ChatColor.GREEN + "[WELCOME]");
|
||||
when(block.getState()).thenReturn((BlockState)s);
|
||||
when(block.getState()).thenReturn(s);
|
||||
wsm = mock(WarpSignsManager.class);
|
||||
when(addon.getWarpSignsManager()).thenReturn(wsm);
|
||||
Map<UUID, Location> list = new HashMap<>();
|
||||
@ -109,19 +109,21 @@ public class WarpSignsListenerTest {
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
pm = mock(PluginManager.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pm);
|
||||
|
||||
|
||||
// Lines
|
||||
lines = new String[] {"[WELCOME]", "line2", "line3", "line4"};
|
||||
|
||||
|
||||
settings = mock(PluginConfig.class);
|
||||
when(settings.getWarpLevelRestriction()).thenReturn(10);
|
||||
when(addon.getSettings()).thenReturn(settings);
|
||||
|
||||
|
||||
level_addon = mock(Level.class);
|
||||
Optional<Addon> level = Optional.of(level_addon);
|
||||
when(addon.getLevelAddon()).thenReturn(level);
|
||||
AddonsManager am = mock(AddonsManager.class);
|
||||
when(plugin.getAddonsManager()).thenReturn(am);
|
||||
when(am.getAddonByName(Mockito.anyString())).thenReturn(level);
|
||||
when(level_addon.getIslandLevel(Mockito.any(), Mockito.any())).thenReturn(11L); // Higher than 10
|
||||
|
||||
|
||||
im = mock(IslandsManager.class);
|
||||
// On island
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
@ -152,7 +154,7 @@ public class WarpSignsListenerTest {
|
||||
assertFalse(e.isCancelled());
|
||||
Mockito.verify(addon).inRegisteredWorld(Mockito.eq(world));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnSignBreakNullState() {
|
||||
WarpSignsListener wsl = new WarpSignsListener(addon);
|
||||
@ -162,7 +164,7 @@ public class WarpSignsListenerTest {
|
||||
assertFalse(e.isCancelled());
|
||||
Mockito.verify(block).getState();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnSignNotWelcomeSign() {
|
||||
WarpSignsListener wsl = new WarpSignsListener(addon);
|
||||
@ -173,7 +175,7 @@ public class WarpSignsListenerTest {
|
||||
Mockito.verify(s).getLine(Mockito.eq(0));
|
||||
Mockito.verify(addon).getConfig();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnSignNotRealWelcomeSign() {
|
||||
// Right text, but not in the right position
|
||||
@ -185,7 +187,7 @@ public class WarpSignsListenerTest {
|
||||
Mockito.verify(wsm).getWarpMap(Mockito.eq(world));
|
||||
Mockito.verify(s).getLocation();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnSignRemovePlayerSignWrongPlayer() {
|
||||
when(player.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||
@ -195,7 +197,7 @@ public class WarpSignsListenerTest {
|
||||
assertTrue(e.isCancelled());
|
||||
Mockito.verify(player).sendMessage("warps.error.no-remove");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnSignRemovePlayerSignPlayerIsOp() {
|
||||
when(player.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||
@ -207,7 +209,7 @@ public class WarpSignsListenerTest {
|
||||
assertFalse(e.isCancelled());
|
||||
Mockito.verify(pm).callEvent(Mockito.any());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnSignRemovePlayerSignPlayerHasPerm() {
|
||||
when(player.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||
@ -219,7 +221,7 @@ public class WarpSignsListenerTest {
|
||||
assertFalse(e.isCancelled());
|
||||
Mockito.verify(pm).callEvent(Mockito.any());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnSignRemoveCorrectPlayer() {
|
||||
WarpSignsListener wsl = new WarpSignsListener(addon);
|
||||
@ -230,7 +232,7 @@ public class WarpSignsListenerTest {
|
||||
Mockito.verify(pm).callEvent(Mockito.any());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sign create
|
||||
@ -244,7 +246,7 @@ public class WarpSignsListenerTest {
|
||||
wsl.onSignWarpCreate(e);
|
||||
Mockito.verify(addon).inRegisteredWorld(Mockito.eq(world));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnCreateWrongText() {
|
||||
when(player.hasPermission(Mockito.anyString())).thenReturn(true);
|
||||
@ -256,7 +258,7 @@ public class WarpSignsListenerTest {
|
||||
Mockito.verify(config).getString(Mockito.anyString());
|
||||
Mockito.verify(player, Mockito.never()).sendMessage(Mockito.anyString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnCreateNoPerm() {
|
||||
when(player.hasPermission(Mockito.anyString())).thenReturn(false);
|
||||
@ -265,7 +267,7 @@ public class WarpSignsListenerTest {
|
||||
wsl.onSignWarpCreate(e);
|
||||
Mockito.verify(player).sendMessage("warps.error.no-permission");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOnLevelPresentNotHighEnough() {
|
||||
when(player.hasPermission(Mockito.anyString())).thenReturn(true);
|
||||
@ -286,7 +288,7 @@ public class WarpSignsListenerTest {
|
||||
Mockito.verify(player).sendMessage("warps.error.not-on-island");
|
||||
assertEquals(ChatColor.RED + "[WELCOME]", e.getLine(0));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateNoSignAlreadyUniqueSpot() {
|
||||
when(wsm.getWarp(Mockito.any(), Mockito.any())).thenReturn(null);
|
||||
@ -297,7 +299,7 @@ public class WarpSignsListenerTest {
|
||||
Mockito.verify(player).sendMessage("warps.success");
|
||||
assertEquals(ChatColor.GREEN + "[WELCOME]", e.getLine(0));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateNoSignAlreadyDuplicateSpot() {
|
||||
when(wsm.addWarp(Mockito.any(), Mockito.any())).thenReturn(false);
|
||||
@ -309,7 +311,7 @@ public class WarpSignsListenerTest {
|
||||
Mockito.verify(player).sendMessage("warps.error.duplicate");
|
||||
assertEquals(ChatColor.RED + "[WELCOME]", e.getLine(0));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateNoSignDeactivateOldSign() {
|
||||
when(player.hasPermission(Mockito.anyString())).thenReturn(true);
|
||||
@ -320,6 +322,6 @@ public class WarpSignsListenerTest {
|
||||
assertEquals(ChatColor.GREEN + "[WELCOME]", e.getLine(0));
|
||||
Mockito.verify(s).setLine(0, ChatColor.RED + "[WELCOME]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user