Code smell reduction.
This commit is contained in:
parent
3cd93f39dd
commit
00938e67da
|
@ -18,8 +18,8 @@ public class SignCacheItem {
|
|||
@Expose
|
||||
private final Material type;
|
||||
/**
|
||||
* @param signText
|
||||
* @param type
|
||||
* @param signText sign text
|
||||
* @param type material of sign
|
||||
*/
|
||||
public SignCacheItem(List<String> signText, Material type) {
|
||||
this.signText = signText;
|
||||
|
|
|
@ -13,10 +13,10 @@ import world.bentobox.bentobox.database.Database;
|
|||
import world.bentobox.warps.objects.SignCache;
|
||||
|
||||
public class SignCacheManager {
|
||||
private Map<World, Map<UUID, SignCacheItem>> cachedSigns = new HashMap<>();
|
||||
private Warp addon;
|
||||
private final Map<World, Map<UUID, SignCacheItem>> cachedSigns = new HashMap<>();
|
||||
private final Warp addon;
|
||||
// Database handler for level data
|
||||
private Database<SignCache> handler;
|
||||
private final Database<SignCache> handler;
|
||||
|
||||
public SignCacheManager(Warp addon) {
|
||||
this.addon = addon;
|
||||
|
|
|
@ -248,20 +248,14 @@ public class Warp extends Addon {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
switch(requestLabel) {
|
||||
case "getSortedWarps":
|
||||
return getWarpSignsManager().getSortedWarps(world);
|
||||
case "getWarp":
|
||||
return uuid == null ? null : getWarpSignsManager().getWarp(world, uuid);
|
||||
case "getWarpMap":
|
||||
return getWarpSignsManager().getWarpMap(world);
|
||||
case "hasWarp":
|
||||
return uuid == null ? null : getWarpSignsManager().hasWarp(world, uuid);
|
||||
case "listWarps":
|
||||
return getWarpSignsManager().listWarps(world);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch (requestLabel) {
|
||||
case "getSortedWarps" -> getWarpSignsManager().getSortedWarps(world);
|
||||
case "getWarp" -> uuid == null ? null : getWarpSignsManager().getWarp(world, uuid);
|
||||
case "getWarpMap" -> getWarpSignsManager().getWarpMap(world);
|
||||
case "hasWarp" -> uuid == null ? null : getWarpSignsManager().hasWarp(world, uuid);
|
||||
case "listWarps" -> getWarpSignsManager().listWarps(world);
|
||||
default -> null;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.concurrent.CompletableFuture;
|
|||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
|
||||
|
@ -19,9 +20,9 @@ import world.bentobox.bentobox.api.user.User;
|
|||
public class WarpPanelManager {
|
||||
|
||||
private static final int PANEL_MAX_SIZE = 52;
|
||||
private Warp addon;
|
||||
private final Warp addon;
|
||||
// This is a cache of signs
|
||||
private SignCacheManager signCacheManager;
|
||||
private final SignCacheManager signCacheManager;
|
||||
|
||||
public WarpPanelManager(Warp addon) {
|
||||
this.addon = addon;
|
||||
|
@ -44,10 +45,9 @@ public class WarpPanelManager {
|
|||
|
||||
private boolean hander(World world, User clicker, UUID warpOwner) {
|
||||
clicker.closeInventory();
|
||||
String playerCommand = addon.getPlugin().getIWM().getAddon(world).map(gm -> gm.getPlayerCommand().map(c -> c.getLabel()).orElse("")).orElse("");
|
||||
String playerCommand = addon.getPlugin().getIWM().getAddon(world).map(gm -> gm.getPlayerCommand().map(Command::getLabel).orElse("")).orElse("");
|
||||
String command = addon.getSettings().getWarpCommand() + " " + addon.getPlayers().getName(warpOwner);
|
||||
clicker.getPlayer().performCommand((playerCommand.isEmpty() ? "" : playerCommand + " ") + command);
|
||||
//addon.getWarpSignsManager().warpPlayer(world, clicker, warpOwner);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class WarpPanelManager {
|
|||
.user(user)
|
||||
.name(user.getTranslation("warps.title") + " " + (index + 1));
|
||||
|
||||
buildPanel(panelBuilder, user, index, world).thenRun(() -> panelBuilder.build());
|
||||
buildPanel(panelBuilder, user, index, world).thenRun(panelBuilder::build);
|
||||
}
|
||||
|
||||
CompletableFuture<Void> buildPanel(PanelBuilder panelBuilder, User user, int index, World world) {
|
||||
|
@ -102,13 +102,11 @@ public class WarpPanelManager {
|
|||
});
|
||||
}
|
||||
|
||||
private boolean getRandomWarp(List<UUID> warps) {
|
||||
private void getRandomWarp(List<UUID> warps) {
|
||||
// Add random warp
|
||||
if (!warps.isEmpty() && addon.getSettings().isRandomAllowed()) {
|
||||
warps.add(0, warps.get(new Random().nextInt(warps.size())));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int buildMainBody(PanelBuilder panelBuilder, User user, int index, World world, List<UUID> warps) {
|
||||
|
|
|
@ -49,13 +49,13 @@ import world.bentobox.warps.objects.WarpsData;
|
|||
public class WarpSignsManager {
|
||||
private static final int MAX_WARPS = 600;
|
||||
private static final String WARPS = "warps";
|
||||
private BentoBox plugin;
|
||||
private final BentoBox plugin;
|
||||
// Map of all warps stored as player, warp sign Location
|
||||
private Map<World, Map<UUID, Location>> worldsWarpList;
|
||||
// Database handler for level data
|
||||
private Database<WarpsData> handler;
|
||||
private final Database<WarpsData> handler;
|
||||
|
||||
private Warp addon;
|
||||
private final Warp addon;
|
||||
private WarpsData warpsData = new WarpsData();
|
||||
|
||||
/**
|
||||
|
@ -155,8 +155,7 @@ public class WarpSignsManager {
|
|||
getWarpMap(world).values().removeIf(Objects::isNull);
|
||||
// Bigger value of time means a more recent login
|
||||
TreeMap<Long, UUID> map = new TreeMap<>();
|
||||
getWarpMap(world).entrySet().forEach(en -> {
|
||||
UUID uuid = en.getKey();
|
||||
getWarpMap(world).forEach((uuid, value) -> {
|
||||
// If never played, will be zero
|
||||
long lastPlayed = addon.getServer().getOfflinePlayer(uuid).getLastPlayed();
|
||||
// This aims to avoid the chance that players logged off at exactly the same time
|
||||
|
@ -185,7 +184,7 @@ public class WarpSignsManager {
|
|||
public Set<UUID> listWarps(@NonNull World world) {
|
||||
// Remove any null locations
|
||||
getWarpMap(world).values().removeIf(Objects::isNull);
|
||||
return getWarpMap(world).entrySet().stream().filter(e -> Util.sameWorld(world, e.getValue().getWorld())).map(Map.Entry::getKey).collect(Collectors.toSet());
|
||||
return getWarpMap(world).entrySet().stream().filter(e -> Util.sameWorld(world, Objects.requireNonNull(e.getValue().getWorld()))).map(Map.Entry::getKey).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,7 +216,7 @@ public class WarpSignsManager {
|
|||
|
||||
/**
|
||||
* Changes the sign to red if it exists
|
||||
* @param loc
|
||||
* @param loc location to pop
|
||||
*/
|
||||
private void popSign(Location loc) {
|
||||
Block b = loc.getBlock();
|
||||
|
@ -233,7 +232,7 @@ public class WarpSignsManager {
|
|||
/**
|
||||
* Removes a warp at a location.
|
||||
*
|
||||
* @param loc
|
||||
* @param loc location to remove
|
||||
*/
|
||||
public void removeWarp(Location loc) {
|
||||
popSign(loc);
|
||||
|
@ -258,7 +257,7 @@ public class WarpSignsManager {
|
|||
/**
|
||||
* Remove warp sign owned by UUID
|
||||
*
|
||||
* @param uuid
|
||||
* @param uuid UUID of owner to remove
|
||||
*/
|
||||
public void removeWarp(World world, UUID uuid) {
|
||||
if (getWarpMap(world).containsKey(uuid)) {
|
||||
|
@ -297,14 +296,13 @@ public class WarpSignsManager {
|
|||
*/
|
||||
@NonNull
|
||||
public SignCacheItem getSignInfo(@NonNull World world, @NonNull UUID uuid) {
|
||||
List<String> result = new ArrayList<>();
|
||||
//get the sign info
|
||||
Location signLocation = getWarp(world, uuid);
|
||||
if (signLocation == null || !signLocation.getBlock().getType().name().contains("SIGN")) {
|
||||
return new SignCacheItem();
|
||||
}
|
||||
Sign sign = (Sign)signLocation.getBlock().getState();
|
||||
result.addAll(Arrays.asList(sign.getLines()));
|
||||
List<String> result = new ArrayList<>(Arrays.asList(sign.getLines()));
|
||||
// Clean up - remove the [WELCOME] line
|
||||
result.remove(0);
|
||||
// Remove any trailing blank lines
|
||||
|
@ -359,9 +357,9 @@ public class WarpSignsManager {
|
|||
}
|
||||
if (pvp) {
|
||||
user.sendMessage("protection.flags.PVP_OVERWORLD.enabled");
|
||||
user.getWorld().playSound(user.getLocation(), Sound.ENTITY_ARROW_HIT, 1F, 1F);
|
||||
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_ARROW_HIT, 1F, 1F);
|
||||
} else {
|
||||
user.getWorld().playSound(user.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
|
||||
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
|
||||
}
|
||||
if (!warpOwner.equals(user)) {
|
||||
warpOwner.sendMessage("warps.player-warped", "[name]", user.getName());
|
||||
|
@ -396,7 +394,7 @@ public class WarpSignsManager {
|
|||
boolean pvp = false;
|
||||
if (island != null) {
|
||||
// Check for PVP
|
||||
switch (warpSpot.getWorld().getEnvironment()) {
|
||||
switch (Objects.requireNonNull(warpSpot.getWorld()).getEnvironment()) {
|
||||
case NETHER:
|
||||
pvp = island.isAllowed(Flags.PVP_NETHER);
|
||||
break;
|
||||
|
@ -447,9 +445,9 @@ public class WarpSignsManager {
|
|||
warpSpot.getBlockZ() + 0.5D);
|
||||
if (pvp) {
|
||||
user.sendMessage("protection.flags.PVP_OVERWORLD.enabled");
|
||||
user.getWorld().playSound(user.getLocation(), Sound.ENTITY_ARROW_HIT, 1F, 1F);
|
||||
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_ARROW_HIT, 1F, 1F);
|
||||
} else {
|
||||
user.getWorld().playSound(user.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
|
||||
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
|
||||
}
|
||||
Util.teleportAsync(user.getPlayer(), actualWarp, TeleportCause.COMMAND);
|
||||
}
|
||||
|
@ -489,10 +487,10 @@ public class WarpSignsManager {
|
|||
|
||||
String permPrefix = permissionPrefix + ".";
|
||||
|
||||
List<String> permissions = user.getEffectivePermissions().stream().
|
||||
map(PermissionAttachmentInfo::getPermission).
|
||||
filter(permission -> permission.startsWith(permPrefix)).
|
||||
collect(Collectors.toList());
|
||||
List<String> permissions = user.getEffectivePermissions().stream()
|
||||
.map(PermissionAttachmentInfo::getPermission)
|
||||
.filter(permission -> permission.startsWith(permPrefix))
|
||||
.toList();
|
||||
|
||||
for (String permission : permissions)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ import world.bentobox.warps.Warp;
|
|||
*/
|
||||
public class WarpCommand extends DelayedTeleportCommand {
|
||||
|
||||
private Warp addon;
|
||||
private final Warp addon;
|
||||
|
||||
public WarpCommand(Warp addon, CompositeCommand bsbIslandCmd) {
|
||||
super(bsbIslandCmd, addon.getSettings().getWarpCommand());
|
||||
|
|
|
@ -15,7 +15,7 @@ import world.bentobox.warps.Warp;
|
|||
*/
|
||||
public class WarpsCommand extends CompositeCommand {
|
||||
|
||||
private Warp addon;
|
||||
private final Warp addon;
|
||||
|
||||
public WarpsCommand(Warp addon, CompositeCommand bsbIslandCmd) {
|
||||
super(bsbIslandCmd, addon.getSettings().getWarpsCommand());
|
||||
|
|
|
@ -18,13 +18,13 @@ import world.bentobox.warps.Warp;
|
|||
public class WarpCreateEvent extends Event{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Location warpLoc;
|
||||
private UUID creator;
|
||||
private final Location warpLoc;
|
||||
private final UUID creator;
|
||||
|
||||
/**
|
||||
* @param plugin - BSkyBlock plugin objects
|
||||
* @param warpLoc
|
||||
* @param creator
|
||||
* @param warpLoc warp location
|
||||
* @param creator UUID of creator
|
||||
*/
|
||||
public WarpCreateEvent(Warp plugin, Location warpLoc, UUID creator){
|
||||
this.warpLoc = warpLoc;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class WarpInitiateEvent extends Event implements Cancellable {
|
|||
|
||||
/**
|
||||
* Set a different location to where the player will go
|
||||
* @param warpLoc
|
||||
* @param warpLoc warp location
|
||||
*/
|
||||
public void setWarpLoc(Location warpLoc) {
|
||||
this.warpLoc = warpLoc;
|
||||
|
|
|
@ -24,7 +24,7 @@ public class WarpListEvent extends Event {
|
|||
|
||||
/**
|
||||
* @param plugin - BSkyBlock plugin objects
|
||||
* @param warps
|
||||
* @param warps list of warp UUIDs
|
||||
*/
|
||||
public WarpListEvent(Warp plugin, List<UUID> warps) {
|
||||
this.warps = warps;
|
||||
|
|
|
@ -40,9 +40,9 @@ import world.bentobox.warps.event.WarpRemoveEvent;
|
|||
*/
|
||||
public class WarpSignsListener implements Listener {
|
||||
|
||||
private BentoBox plugin;
|
||||
private final BentoBox plugin;
|
||||
|
||||
private Warp addon;
|
||||
private final Warp addon;
|
||||
|
||||
/**
|
||||
* @param addon - addon
|
||||
|
@ -153,7 +153,7 @@ public class WarpSignsListener implements Listener {
|
|||
String title = e.getLine(0);
|
||||
User user = Objects.requireNonNull(User.getInstance(e.getPlayer()));
|
||||
// Check if someone is changing their own sign
|
||||
if (title.equalsIgnoreCase(addon.getSettings().getWelcomeLine())) {
|
||||
if (title != null && title.equalsIgnoreCase(addon.getSettings().getWelcomeLine())) {
|
||||
// Welcome sign detected - check permissions
|
||||
if (noPerms(user, b.getWorld(), inWorld)) {
|
||||
return;
|
||||
|
@ -164,11 +164,7 @@ public class WarpSignsListener implements Listener {
|
|||
}
|
||||
// Check if the player already has a sign
|
||||
final Location oldSignLoc = addon.getWarpSignsManager().getWarp(b.getWorld(), user.getUniqueId());
|
||||
if (oldSignLoc == null) {
|
||||
// First time the sign has been placed or this is a new
|
||||
// sign
|
||||
addSign(e, user, b);
|
||||
} else {
|
||||
if (oldSignLoc != null) {
|
||||
// A sign already exists. Check if it still there and if
|
||||
// so,
|
||||
// deactivate it
|
||||
|
@ -188,8 +184,8 @@ public class WarpSignsListener implements Listener {
|
|||
}
|
||||
}
|
||||
// Set up the new warp sign
|
||||
addSign(e, user, b);
|
||||
}
|
||||
addSign(e, user, b);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -235,7 +231,10 @@ public class WarpSignsListener implements Listener {
|
|||
user.sendMessage("warps.success");
|
||||
e.setLine(0, ChatColor.GREEN + addon.getSettings().getWelcomeLine());
|
||||
for (int i = 1; i<4; i++) {
|
||||
e.setLine(i, ChatColor.translateAlternateColorCodes('&', e.getLine(i)));
|
||||
String line = e.getLine(i);
|
||||
if (line != null) {
|
||||
e.setLine(i, ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> keyValues = new HashMap<>();
|
||||
|
|
|
@ -46,7 +46,7 @@ public class WarpsData implements DataObject {
|
|||
|
||||
/**
|
||||
* Puts all the data from the map into this objects ready for saving
|
||||
* @param worldsWarpList
|
||||
* @param worldsWarpList 2D map of warp locations by world vs UUID
|
||||
* @return this class filled with data
|
||||
*/
|
||||
public WarpsData save(Map<World, Map<UUID, Location>> worldsWarpList) {
|
||||
|
|
|
@ -26,11 +26,11 @@ disabled-gamemodes: []
|
|||
#
|
||||
# Warp panel name formatting.
|
||||
# Example: &c will make names red, &f is white
|
||||
name-format: &f
|
||||
name-format: "&f"
|
||||
#
|
||||
# Warp panel default lore formatting.
|
||||
# Example: &c will make lore red. &f is white
|
||||
lore-format: &f
|
||||
lore-format: "&f"
|
||||
#
|
||||
# Allow random teleport - adds a button to the warp panel that goes to a random warp sign
|
||||
random-allowed: true
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
@ -67,7 +66,6 @@ public class WarpPanelManagerTest {
|
|||
private World world;
|
||||
@Mock
|
||||
private Inventory top;
|
||||
private UUID uuid;
|
||||
@Mock
|
||||
private Settings settings;
|
||||
@Mock
|
||||
|
@ -92,10 +90,9 @@ public class WarpPanelManagerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
when(addon.getWarpSignsManager()).thenReturn(wsm);
|
||||
// Fill with 200 fake warps (I'm banking on them all being different, but there could be a clash)
|
||||
list = new ArrayList<>();
|
||||
|
@ -103,19 +100,14 @@ public class WarpPanelManagerTest {
|
|||
list.add(UUID.randomUUID());
|
||||
}
|
||||
// One final one
|
||||
uuid = UUID.randomUUID();
|
||||
UUID uuid = UUID.randomUUID();
|
||||
list.add(uuid);
|
||||
|
||||
when(wsm.getSortedWarps(any())).thenReturn(CompletableFuture.completedFuture(list));
|
||||
|
||||
// User and player
|
||||
when(user.getPlayer()).thenReturn(player);
|
||||
when(user.getTranslation(any())).thenAnswer(new Answer<String>() {
|
||||
|
||||
@Override
|
||||
public String answer(InvocationOnMock invocation) throws Throwable {
|
||||
return invocation.getArgument(0, String.class);
|
||||
}});
|
||||
when(user.getTranslation(any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
|
||||
|
||||
// BentoBox
|
||||
|
|
|
@ -13,14 +13,11 @@ import static org.mockito.Mockito.times;
|
|||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -89,7 +86,7 @@ public class WarpSignsManagerTest {
|
|||
private Logger logger;
|
||||
@Mock
|
||||
private WarpsData load;
|
||||
private UUID uuid = UUID.randomUUID();
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
@Mock
|
||||
private Location location;
|
||||
@Mock
|
||||
|
@ -129,7 +126,7 @@ public class WarpSignsManagerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
* @throws java.lang.Exception exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
@ -167,6 +164,7 @@ public class WarpSignsManagerTest {
|
|||
when(location.getBlockX()).thenReturn(23);
|
||||
when(location.getBlockY()).thenReturn(24);
|
||||
when(location.getBlockZ()).thenReturn(25);
|
||||
when(player.getLocation()).thenReturn(location);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
when(world.isChunkLoaded(anyInt(), anyInt())).thenReturn(true);
|
||||
|
||||
|
@ -224,10 +222,9 @@ public class WarpSignsManagerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
public void tearDown() {
|
||||
User.clearUsers();
|
||||
}
|
||||
|
||||
|
@ -272,7 +269,7 @@ public class WarpSignsManagerTest {
|
|||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.warps.WarpSignsManager#getWarpMap(org.bukkit.World)}.
|
||||
* @throws Exception
|
||||
* @throws Exception exception
|
||||
*/
|
||||
@Test
|
||||
public void testGetWarpMapNullDatabaseObject() throws Exception {
|
||||
|
@ -293,10 +290,9 @@ public class WarpSignsManagerTest {
|
|||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.warps.WarpSignsManager#WarpSignsManager(world.bentobox.warps.Warp, world.bentobox.bentobox.BentoBox)}.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testWarpSignsManager() throws Exception {
|
||||
public void testWarpSignsManager() {
|
||||
verify(addon).log("Loading warps...");
|
||||
verify(load).getWarpSigns();
|
||||
verify(block).getType();
|
||||
|
@ -372,11 +368,9 @@ public class WarpSignsManagerTest {
|
|||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.warps.WarpSignsManager#getSortedWarps(org.bukkit.World)}.
|
||||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Test
|
||||
public void testGetSortedWarps() throws InterruptedException, ExecutionException {
|
||||
public void testGetSortedWarps() {
|
||||
CompletableFuture<List<UUID>> r = new CompletableFuture<>();
|
||||
assertEquals(1, wsm.processWarpMap(r, world).size());
|
||||
}
|
||||
|
@ -410,9 +404,7 @@ public class WarpSignsManagerTest {
|
|||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.warps.WarpSignsManager#saveWarpList()}.
|
||||
* @throws IntrospectionException
|
||||
* @throws InvocationTargetException
|
||||
* @throws Exception
|
||||
* @throws Exception general exception
|
||||
*/
|
||||
@Test
|
||||
public void testSaveWarpList() throws Exception {
|
||||
|
@ -438,6 +430,7 @@ public class WarpSignsManagerTest {
|
|||
when(p.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||
when(p.getWorld()).thenReturn(world);
|
||||
when(p.getName()).thenReturn("tastybento");
|
||||
when(p.getLocation()).thenReturn(location);
|
||||
@Nullable
|
||||
User u = User.getInstance(p);
|
||||
wsm.warpPlayer(world, u, uuid);
|
||||
|
@ -473,7 +466,7 @@ public class WarpSignsManagerTest {
|
|||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.warps.WarpSignsManager#loadWarpList()}.
|
||||
* @throws Exception
|
||||
* @throws Exception exception
|
||||
*/
|
||||
@Test
|
||||
public void testLoadWarpListEmptyWarpTable() throws Exception {
|
||||
|
|
|
@ -53,7 +53,6 @@ public class WarpCommandTest {
|
|||
private static final String WELCOME_LINE = "[Welcome]";
|
||||
@Mock
|
||||
private CompositeCommand ic;
|
||||
private UUID uuid;
|
||||
@Mock
|
||||
private User user;
|
||||
@Mock
|
||||
|
@ -78,10 +77,9 @@ public class WarpCommandTest {
|
|||
private BukkitScheduler sch;
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -100,7 +98,7 @@ public class WarpCommandTest {
|
|||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Player
|
||||
uuid = UUID.randomUUID();
|
||||
UUID uuid = UUID.randomUUID();
|
||||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.getWorld()).thenReturn(world);
|
||||
|
||||
|
|
|
@ -66,10 +66,9 @@ public class WarpsCommandTest {
|
|||
private WarpPanelManager wpm;
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
|
|
@ -73,7 +73,6 @@ public class WarpSignsListenerTest {
|
|||
@Mock
|
||||
private WarpSignsManager wsm;
|
||||
private PluginManager pm;
|
||||
private UUID uuid;
|
||||
private String[] lines;
|
||||
@Mock
|
||||
private FileConfiguration config;
|
||||
|
@ -85,7 +84,7 @@ public class WarpSignsListenerTest {
|
|||
private IslandWorldManager iwm;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
// Bukkit
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
pm = mock(PluginManager.class);
|
||||
|
@ -114,7 +113,7 @@ public class WarpSignsListenerTest {
|
|||
when(block.getWorld()).thenReturn(world);
|
||||
// Player
|
||||
when(player.hasPermission(anyString())).thenReturn(false);
|
||||
uuid = UUID.randomUUID();
|
||||
UUID uuid = UUID.randomUUID();
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
s = mock(Sign.class);
|
||||
when(s.getLine(Mockito.anyInt())).thenReturn(ChatColor.GREEN + "[WELCOME]");
|
||||
|
|
Loading…
Reference in New Issue