Added an Island World Manager that handles worlds

Still a WIP but it's gradually coming along.
This commit is contained in:
tastybento 2018-05-20 16:09:57 -07:00
parent 576d9ff314
commit 82ee6d746e
28 changed files with 216 additions and 134 deletions

View File

@ -136,6 +136,7 @@ commands:
description: "create an island"
unable-create-island: "Your island could not be generated, please contact an administrator."
creating-island: "Creating your island..."
pick-world: "&cPick a world from [worlds]"
info:
description: "display info about your island"
reset:

View File

@ -9,7 +9,6 @@ import us.tastybento.bskyblock.api.user.Notifier;
import us.tastybento.bskyblock.commands.AdminCommand;
import us.tastybento.bskyblock.commands.IslandCommand;
import us.tastybento.bskyblock.database.BSBDbSetup;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.listeners.JoinLeaveListener;
import us.tastybento.bskyblock.listeners.NetherPortals;
import us.tastybento.bskyblock.listeners.ObsidianToLava;
@ -18,6 +17,7 @@ import us.tastybento.bskyblock.listeners.protection.FlyingMobEvents;
import us.tastybento.bskyblock.managers.AddonsManager;
import us.tastybento.bskyblock.managers.CommandsManager;
import us.tastybento.bskyblock.managers.FlagsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -45,7 +45,7 @@ public class BSkyBlock extends JavaPlugin {
private LocalesManager localesManager;
private AddonsManager addonsManager;
private FlagsManager flagsManager;
private IslandWorld islandWorldManager;
private IslandWorldManager islandWorldManager;
private RanksManager ranksManager;
// Settings
@ -106,7 +106,7 @@ public class BSkyBlock extends JavaPlugin {
// at this point. Therefore, the 1 tick scheduler is required.
getServer().getScheduler().runTask(this, () -> {
// Create the world if it does not exist
islandWorldManager = new IslandWorld(instance);
islandWorldManager = new IslandWorldManager(instance);
getServer().getScheduler().runTask(instance, () -> {
@ -269,7 +269,7 @@ public class BSkyBlock extends JavaPlugin {
/**
* @return the Island World Manager
*/
public IslandWorld getIslandWorldManager() {
public IslandWorldManager getIslandWorldManager() {
return islandWorldManager;
}
@ -312,8 +312,8 @@ public class BSkyBlock extends JavaPlugin {
* Registers a world as a world to be covered by this plugin
* @param world - world
*/
public void registerWorld(World world) {
islandWorldManager.addWorld(world);
public void registerWorld(String name, World world) {
islandWorldManager.addWorld(name, world);
}
}

View File

@ -3,6 +3,8 @@ package us.tastybento.bskyblock.commands;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.World;
import us.tastybento.bskyblock.Constants;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
@ -63,19 +65,27 @@ public class IslandCommand extends CompositeCommand {
if (user == null) {
return false;
}
// TODO: set up different games
if (args.isEmpty()) {
// If this player does not have an island, create one
if (!getPlugin().getIslands().hasIsland(user.getWorld(), user.getUniqueId())) {
return getSubCommand("create").map(createCmd -> createCmd.execute(user, new ArrayList<>())).orElse(false);
} else {
// Otherwise, currently, just go home
// If in world, go
if (getPlugin().getIslands().hasIsland(user.getWorld(), user.getUniqueId())) {
return getSubCommand("go").map(goCmd -> goCmd.execute(user, new ArrayList<>())).orElse(false);
}
} else {
user.sendMessage("general.errors.unknown-command", "[label]", Constants.ISLANDCOMMAND);
return false;
}
// No islands currently
return getSubCommand("create").map(createCmd -> createCmd.execute(user, new ArrayList<>())).orElse(false);
} else if (args.size() == 1) {
// Argument should be a world
if (getPlugin().getIslandWorldManager().isOverWorld(args.get(0))) {
World world = getPlugin().getIslandWorldManager().getWorld(args.get(0));
if (getPlugin().getIslands().hasIsland(world, user.getUniqueId())) {
return getSubCommand("go").map(goCmd -> goCmd.execute(user, args)).orElse(false);
}
// No islands currently
return getSubCommand("create").map(createCmd -> createCmd.execute(user, args)).orElse(false);
}
}
user.sendMessage("general.errors.unknown-command", "[label]", Constants.ISLANDCOMMAND);
return false;
}

View File

@ -5,6 +5,7 @@ package us.tastybento.bskyblock.commands.island;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import org.bukkit.World;
@ -38,17 +39,36 @@ public class IslandCreateCommand extends CompositeCommand {
*/
@Override
public boolean execute(User user, List<String> args) {
// TODO: fix world
World world = getPlugin().getIslandWorldManager().getIslandWorld();
if (!args.isEmpty()) {
// Get game types
// TODO
World world = null;
if (args.size() == 1 && getPlugin().getIslandWorldManager().isOverWorld(args.get(0))) {
world = getPlugin().getIslandWorldManager().getWorld(args.get(0));
}
if (world == null) {
// See which worlds are available
Set<String> worldNames = getPlugin().getIslandWorldManager().getFreeOverWorldNames(user);
if (!worldNames.isEmpty()) {
// Make a list of worlds
StringBuilder worlds = new StringBuilder();
// Filter out ones that player already has
worldNames.forEach(w -> {
worlds.append(w);
worlds.append(", ");
});
if (worlds.length() > 2) {
worlds.setLength(worlds.length() - 2);
}
user.sendMessage("commands.island.create.pick-world", "[worlds]", worlds.toString());
return false;
} else {
world = getPlugin().getIslandWorldManager().getIslandWorld();
}
}
if (getIslands().hasIsland(world, user.getUniqueId())) {
user.sendMessage("general.errors.already-have-island");
return false;
}
if (getIslands().inTeam(world, user.getUniqueId())) {
user.sendMessage("general.errors.already-have-island");
return false;
}
user.sendMessage("commands.island.create.creating-island");

View File

@ -7,6 +7,7 @@ import java.util.List;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.ChatColor;
import org.bukkit.World;
import us.tastybento.bskyblock.Constants;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
@ -39,7 +40,24 @@ public class IslandGoCommand extends CompositeCommand {
*/
@Override
public boolean execute(User user, List<String> args) {
if (!getIslands().hasIsland(user.getWorld(), user.getUniqueId())) {
World world = user.getWorld();
if (!args.isEmpty() && !NumberUtils.isDigits(args.get(0))) {
// World?
if (getPlugin().getIslandWorldManager().isOverWorld(args.get(0))) {
world = getPlugin().getIslandWorldManager().getWorld(args.get(0));
} else {
// Make a list of worlds
StringBuilder worlds = new StringBuilder();
getPlugin().getIslandWorldManager().getOverWorldNames().forEach(w -> {
worlds.append(w);
worlds.append(", ");
});
worlds.setLength(worlds.length() - 2);
user.sendMessage("commands.island.create.pick-world", "[worlds]", worlds.toString());
return false;
}
}
if (!getIslands().hasIsland(world, user.getUniqueId())) {
user.sendMessage(ChatColor.RED + "general.errors.no-island");
return false;
}
@ -47,11 +65,11 @@ public class IslandGoCommand extends CompositeCommand {
int homeValue = Integer.valueOf(args.get(0));
int maxHomes = Util.getPermValue(user.getPlayer(), Constants.PERMPREFIX + "island.maxhomes", getSettings().getMaxHomes());
if (homeValue > 1 && homeValue <= maxHomes) {
getIslands().homeTeleport(user.getWorld(), user.getPlayer(), homeValue);
getIslands().homeTeleport(world, user.getPlayer(), homeValue);
return true;
}
}
getIslands().homeTeleport(user.getWorld(), user.getPlayer());
getIslands().homeTeleport(world, user.getPlayer());
return true;
}

View File

@ -3,6 +3,7 @@ package us.tastybento.bskyblock.island.builders;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.TreeType;
@ -45,12 +46,10 @@ public class IslandBuilder {
private List<ItemStack> chestItems;
private UUID playerUUID;
private String playerName;
private BSkyBlock plugin;
//TODO support companions?
public IslandBuilder(BSkyBlock plugin, Island island) {
this.plugin = plugin;
this.island = island;
world = island.getWorld();
}
@ -60,21 +59,6 @@ public class IslandBuilder {
*/
public IslandBuilder setType(IslandType type) {
this.type = type;
switch(type) {
case END:
world = plugin.getIslandWorldManager().getEndWorld();
break;
case ISLAND:
world = plugin.getIslandWorldManager().getIslandWorld();
break;
case NETHER:
world = plugin.getIslandWorldManager().getNetherWorld();
break;
default:
world = island.getWorld();
break;
}
return this;
}
@ -98,14 +82,23 @@ public class IslandBuilder {
public void build() {
// Switch on island type
if (type == IslandType.ISLAND) {
world = island.getWorld();
if (Constants.GAMETYPE == GameType.ACIDISLAND) {
generateAcidIslandBlocks();
} else {
generateIslandBlocks();
}
} else if (type == IslandType.NETHER){
} else if (type == IslandType.NETHER) {
world = Bukkit.getWorld(island.getWorld().getName() + "_nether");
if (world == null) {
return;
}
generateNetherBlocks();
} else if (type == IslandType.END){
} else if (type == IslandType.END) {
world = Bukkit.getWorld(island.getWorld().getName() + "_the_end");
if (world == null) {
return;
}
generateEndBlocks();
}
// Do other stuff

View File

@ -17,7 +17,7 @@ import us.tastybento.bskyblock.api.flags.Flag;
import us.tastybento.bskyblock.api.flags.Flag.Type;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
/**
@ -194,7 +194,7 @@ public abstract class AbstractFlagListener implements Listener {
* Get the island world manager
* @return Island World Manager
*/
protected IslandWorld getIslandWorldManager() {
protected IslandWorldManager getIslandWorldManager() {
return plugin.getIslandWorldManager();
}
}

View File

@ -19,7 +19,6 @@ import org.bukkit.entity.Slime;
import org.bukkit.entity.Snowman;
import org.bukkit.entity.Squid;
import org.bukkit.entity.Villager;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;

View File

@ -140,11 +140,11 @@ public class AddonsManager {
// Add it to the list of addons
addons.add(addon);
// Run the onLoad() method
addon.onLoad();
// Inform the console
plugin.log("Loading BSkyBlock addon " + addon.getDescription().getName() + "...");
// Run the onLoad() method
addon.onLoad();
}
} catch (Exception e) {

View File

@ -1,17 +1,22 @@
package us.tastybento.bskyblock.generators;
package us.tastybento.bskyblock.managers;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.generators.ChunkGeneratorWorld;
public class IslandWorld {
public class IslandWorldManager {
private static final String MULTIVERSE_SET_GENERATOR = "mv modify set generator ";
private static final String MULTIVERSE_IMPORT = "mv import ";
@ -23,14 +28,14 @@ public class IslandWorld {
private World islandWorld;
private World netherWorld;
private World endWorld;
private Set<World> worlds;
private Map<World, String> worlds;
/**
* Generates the Skyblock worlds.
*/
public IslandWorld(BSkyBlock plugin) {
public IslandWorldManager(BSkyBlock plugin) {
this.plugin = plugin;
worlds = new HashSet<>();
worlds = new HashMap<>();
if (plugin.getSettings().isUseOwnGenerator()) {
// Do nothing
return;
@ -41,6 +46,7 @@ public class IslandWorld {
// Create the world if it does not exist
islandWorld = WorldCreator.name(plugin.getSettings().getWorldName()).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld(plugin))
.createWorld();
addWorld("bsb", islandWorld);
// Make the nether if it does not exist
if (plugin.getSettings().isNetherGenerate()) {
if (plugin.getServer().getWorld(plugin.getSettings().getWorldName() + NETHER) == null) {
@ -52,6 +58,7 @@ public class IslandWorld {
netherWorld = WorldCreator.name(plugin.getSettings().getWorldName() + NETHER).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(plugin))
.environment(World.Environment.NETHER).createWorld();
}
addWorld("bsb_nether", netherWorld);
}
// Make the end if it does not exist
if (plugin.getSettings().isEndGenerate()) {
@ -64,42 +71,21 @@ public class IslandWorld {
endWorld = WorldCreator.name(plugin.getSettings().getWorldName() + THE_END).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(plugin))
.environment(World.Environment.THE_END).createWorld();
}
addWorld("bsb_end", endWorld);
}
fixMultiverse(plugin);
}
private void fixMultiverse(BSkyBlock plugin) {
// Multiverse configuration
private void multiverseReg(World world) {
if (Bukkit.getServer().getPluginManager().isPluginEnabled("Multiverse-Core")) {
plugin.log("Trying to register generator with Multiverse ");
try {
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
MULTIVERSE_IMPORT + plugin.getSettings().getWorldName() + " normal -g " + plugin.getName()));
Bukkit.getScheduler().runTask(plugin, () -> {
if (!Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
MULTIVERSE_SET_GENERATOR + plugin.getName() + " " + plugin.getSettings().getWorldName())) {
plugin.logError("Multiverse is out of date! - Upgrade to latest version!");
}
});
if (netherWorld != null && plugin.getSettings().isNetherGenerate() && plugin.getSettings().isNetherIslands()) {
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
MULTIVERSE_IMPORT + plugin.getSettings().getWorldName() + "_nether nether -g " + plugin.getName()));
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
MULTIVERSE_SET_GENERATOR + plugin.getName() + " " + plugin.getSettings().getWorldName() + NETHER));
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
MULTIVERSE_IMPORT + world.getName() + " normal -g " + plugin.getName()));
Bukkit.getScheduler().runTask(plugin, () -> {
if (!Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
MULTIVERSE_SET_GENERATOR + plugin.getName() + " " + world.getName())) {
plugin.logError("Multiverse is out of date! - Upgrade to latest version!");
}
if (endWorld != null && plugin.getSettings().isEndGenerate() && plugin.getSettings().isEndIslands()) {
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
MULTIVERSE_IMPORT + plugin.getSettings().getWorldName() + "_the_end end -g " + plugin.getName()));
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
MULTIVERSE_SET_GENERATOR + plugin.getName() + " " + plugin.getSettings().getWorldName() + THE_END));
}
} catch (Exception e) {
plugin.logError("Not successfull! Disabling " + plugin.getName() + "!");
Bukkit.getServer().getPluginManager().disablePlugin(plugin);
}
});
}
}
/**
@ -138,12 +124,62 @@ public class IslandWorld {
* @return true if in a world or false if not
*/
public boolean inWorld(Location loc) {
return loc.getWorld() !=null && (loc.getWorld().equals(islandWorld) || loc.getWorld().equals(netherWorld) || loc.getWorld().equals(endWorld));
return worlds.containsKey(loc.getWorld());
}
public void addWorld(World world) {
worlds.add(world);
/**
* @return Set of over worlds
*/
public Set<World> getOverWorlds() {
return worlds.keySet().stream().filter(w -> w.getEnvironment().equals(Environment.NORMAL)).collect(Collectors.toSet());
}
/**
* Get friendly names of all the over worlds
* @return Set of world names
*/
public Set<String> getOverWorldNames() {
return worlds.entrySet().stream().filter(e -> e.getKey().getEnvironment().equals(Environment.NORMAL)).map(w -> w.getValue()).collect(Collectors.toSet());
}
/**
* Get a set of world names that user does not already have an island in
* @param user - user
* @return set of world names, or empty set
*/
public Set<String> getFreeOverWorldNames(User user) {
return worlds.entrySet().stream().filter(e -> e.getKey().getEnvironment().equals(Environment.NORMAL))
.filter(w -> !plugin.getIslands().hasIsland(w.getKey(), user))
.map(w -> w.getValue()).collect(Collectors.toSet());
}
/**
* Check if a name is a known friendly world name, ignores case
* @param name - world name
* @return true if name is a known world name
*/
public boolean isOverWorld(String name) {
return worlds.entrySet().stream().filter(e -> e.getKey().getEnvironment().equals(Environment.NORMAL)).anyMatch(w -> w.getValue().equalsIgnoreCase(name));
}
/**
* Add world to the list of known worlds along with a friendly name that will be used in commands
* @param friendlyName - string
* @param world - world
*/
public void addWorld(String friendlyName, World world) {
plugin.log("Adding world " + friendlyName);
worlds.put(world, friendlyName);
multiverseReg(world);
}
/**
* Get the world based on friendly name.
* @param friendlyName - friendly name of world
* @return world, or null if it does not exist
*/
public World getWorld(String friendlyName) {
return worlds.entrySet().stream().filter(n -> n.getValue().equalsIgnoreCase(friendlyName)).map(e -> e.getKey()).findFirst().orElse(null);
}
}

View File

@ -55,7 +55,7 @@ public class NewIsland {
}
/**
* Build a new island for a player using a schematic
* Build a new island for a player
* @author tastybento
*
*/
@ -169,7 +169,7 @@ public class NewIsland {
private Location getNextIsland() {
Location last = plugin.getIslands().getLast(world);
if (last == null) {
last = new Location(plugin.getIslandWorldManager().getIslandWorld(), plugin.getSettings().getIslandXOffset() + plugin.getSettings().getIslandStartX(),
last = new Location(world, plugin.getSettings().getIslandXOffset() + plugin.getSettings().getIslandStartX(),
plugin.getSettings().getIslandHeight(), plugin.getSettings().getIslandZOffset() + plugin.getSettings().getIslandStartZ());
}
Location next = last.clone();

View File

@ -57,10 +57,10 @@ import us.tastybento.bskyblock.api.flags.Flag;
import us.tastybento.bskyblock.api.flags.FlagBuilder;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.listeners.flags.AbstractFlagListener;
import us.tastybento.bskyblock.lists.Flags;
import us.tastybento.bskyblock.managers.FlagsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.RanksManager;
import us.tastybento.bskyblock.util.Util;
@ -141,7 +141,7 @@ public class TestBSkyBlock {
block = Mockito.mock(Block.class);
// Worlds
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
Mockito.when(plugin.getIslandWorldManager()).thenReturn(iwm);
Mockito.when(iwm.getIslandWorld()).thenReturn(world);
Mockito.when(iwm.getNetherWorld()).thenReturn(world);

View File

@ -19,6 +19,7 @@ import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -37,8 +38,8 @@ import us.tastybento.bskyblock.api.events.island.IslandEvent;
import us.tastybento.bskyblock.api.events.island.IslandEvent.IslandEventBuilder;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.CommandsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.PlayersManager;
import us.tastybento.bskyblock.managers.island.NewIsland;
@ -56,6 +57,7 @@ public class IslandCommandTest {
public static void setUpBeforeClass() throws Exception {
Server server = mock(Server.class);
world = mock(World.class);
when(world.getName()).thenReturn("BSkyBlock_test_world");
when(server.getLogger()).thenReturn(Logger.getAnonymousLogger());
when(server.getWorld("world")).thenReturn(world);
when(server.getVersion()).thenReturn("BSB_Mocking");
@ -69,10 +71,14 @@ public class IslandCommandTest {
plugin = mock(BSkyBlock.class);
Whitebox.setInternalState(BSkyBlock.class, "instance", plugin);
}
@Before
public void setup() {
// Island World Manager
IslandWorld iwm = mock(IslandWorld.class);
World world = mock(World.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
when(iwm.getIslandWorld()).thenReturn(world);
when(iwm.getWorld(Mockito.anyString())).thenReturn(world);
when(plugin.getIslandWorldManager()).thenReturn(iwm);
}
@ -140,8 +146,9 @@ public class IslandCommandTest {
// User has an island - so go there!
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
assertTrue(ic.execute(user, new ArrayList<>()));
when(user.getWorld()).thenReturn(world);
//Island island = mock(Island.class);
Location location = mock(Location.class);
when(island.getCenter()).thenReturn(location);
// No island yet, one will be created

View File

@ -31,8 +31,8 @@ import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.commands.AdminCommand;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.CommandsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -93,7 +93,7 @@ public class AdminInfoCommandTest {
when(ac.getSubCommandAliases()).thenReturn(new HashMap<>());
// Island World Manager
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
World world = mock(World.class);
when(iwm.getIslandWorld()).thenReturn(world);
when(plugin.getIslandWorldManager()).thenReturn(iwm);

View File

@ -31,8 +31,8 @@ import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.commands.AdminCommand;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.CommandsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -94,7 +94,7 @@ public class AdminRegisterCommandTest {
when(ac.getSubCommandAliases()).thenReturn(new HashMap<>());
// Island World Manager
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
World world = mock(World.class);
when(iwm.getIslandWorld()).thenReturn(world);
when(plugin.getIslandWorldManager()).thenReturn(iwm);

View File

@ -30,8 +30,8 @@ import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.commands.AdminCommand;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.CommandsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -93,7 +93,7 @@ public class AdminUnregisterCommandTest {
when(ac.getSubCommandAliases()).thenReturn(new HashMap<>());
// Island World Manager
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
World world = mock(World.class);
when(iwm.getIslandWorld()).thenReturn(world);
when(plugin.getIslandWorldManager()).thenReturn(iwm);

View File

@ -29,8 +29,8 @@ import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.commands.AdminCommand;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.CommandsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -115,7 +115,7 @@ public class AdminTeamAddCommandTest {
when(plugin.getLocalesManager()).thenReturn(lm);
// Island World Manager
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
World world = mock(World.class);
when(iwm.getIslandWorld()).thenReturn(world);
when(plugin.getIslandWorldManager()).thenReturn(iwm);

View File

@ -30,8 +30,8 @@ import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.commands.AdminCommand;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.CommandsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -92,7 +92,7 @@ public class AdminTeamDisbandCommandTest {
when(ac.getSubCommandAliases()).thenReturn(new HashMap<>());
// Island World Manager
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
World world = mock(World.class);
when(iwm.getIslandWorld()).thenReturn(world);
when(plugin.getIslandWorldManager()).thenReturn(iwm);

View File

@ -32,8 +32,8 @@ import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.commands.AdminCommand;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.CommandsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -94,7 +94,7 @@ public class AdminTeamKickCommandTest {
when(ac.getSubCommandAliases()).thenReturn(new HashMap<>());
// Island World Manager
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
World world = mock(World.class);
when(iwm.getIslandWorld()).thenReturn(world);
when(plugin.getIslandWorldManager()).thenReturn(iwm);

View File

@ -30,8 +30,8 @@ import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.commands.AdminCommand;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.CommandsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -92,7 +92,7 @@ public class AdminTeamMakeLeaderCommandTest {
when(ac.getSubCommandAliases()).thenReturn(new HashMap<>());
// Island World Manager
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
World world = mock(World.class);
when(iwm.getIslandWorld()).thenReturn(world);
when(plugin.getIslandWorldManager()).thenReturn(iwm);

View File

@ -45,7 +45,7 @@ import org.powermock.reflect.Whitebox;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -67,7 +67,7 @@ public class NetherPortalsTest {
private PlayersManager pm;
private UUID notUUID;
private BukkitScheduler sch;
private IslandWorld iwm;
private IslandWorldManager iwm;
private World world;
private World nether;
private World end;
@ -82,7 +82,7 @@ public class NetherPortalsTest {
Whitebox.setInternalState(BSkyBlock.class, "instance", plugin);
// island world mgr
iwm = mock(IslandWorld.class);
iwm = mock(IslandWorldManager.class);
world = mock(World.class);
nether = mock(World.class);
end = mock(World.class);

View File

@ -33,7 +33,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
@ -95,7 +95,7 @@ public class ObsidianToLavaTest {
when(who.getLocation()).thenReturn(location);
// Worlds
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
when(plugin.getIslandWorldManager()).thenReturn(iwm);
when(iwm.getIslandWorld()).thenReturn(world);
when(iwm.getNetherWorld()).thenReturn(world);

View File

@ -44,9 +44,9 @@ import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.Notifier;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.lists.Flags;
import us.tastybento.bskyblock.managers.FlagsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
@ -60,7 +60,7 @@ public class FireListenerTest {
private static Zombie zombie;
private static Slime slime;
private static Cow cow;
private static IslandWorld iwm;
private static IslandWorldManager iwm;
@BeforeClass
public static void setUp() {
@ -98,7 +98,7 @@ public class FireListenerTest {
// Worlds
iwm = mock(IslandWorld.class);
iwm = mock(IslandWorldManager.class);
when(plugin.getIslandWorldManager()).thenReturn(iwm);
when(iwm.getIslandWorld()).thenReturn(world);
when(iwm.getNetherWorld()).thenReturn(world);

View File

@ -35,9 +35,9 @@ import org.powermock.reflect.Whitebox;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.lists.Flags;
import us.tastybento.bskyblock.managers.FlagsManager;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
@RunWith(PowerMockRunner.class)
@ -50,7 +50,7 @@ public class MobSpawnListenerTest {
private static Zombie zombie;
private static Slime slime;
private static Cow cow;
private static IslandWorld iwm;
private static IslandWorldManager iwm;
private static World world;
@BeforeClass
@ -103,7 +103,7 @@ public class MobSpawnListenerTest {
@Before
public void setUp() {
// Worlds
iwm = mock(IslandWorld.class);
iwm = mock(IslandWorldManager.class);
when(plugin.getIslandWorldManager()).thenReturn(iwm);
when(iwm.getIslandWorld()).thenReturn(world);
when(iwm.getNetherWorld()).thenReturn(world);

View File

@ -45,7 +45,7 @@ import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.LocalesManager;
import us.tastybento.bskyblock.managers.PlayersManager;
@ -67,7 +67,7 @@ public class FlyingMobEventsTest {
private PlayersManager pm;
private UUID notUUID;
private BukkitScheduler sch;
private IslandWorld iwm;
private IslandWorldManager iwm;
/**
* @throws java.lang.Exception
@ -120,7 +120,7 @@ public class FlyingMobEventsTest {
Util.setPlugin(plugin);
// Worlds
iwm = mock(IslandWorld.class);
iwm = mock(IslandWorldManager.class);
when(plugin.getIslandWorldManager()).thenReturn(iwm);
when(iwm.inWorld(any())).thenReturn(true);
}

View File

@ -45,7 +45,6 @@ import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.island.IslandCache;
import us.tastybento.bskyblock.util.Util;
@ -66,7 +65,7 @@ public class IslandsManagerTest {
private Block space2;
private Location location;
private BlockState blockState;
private IslandWorld iwm;
private IslandWorldManager iwm;
/**
* @throws java.lang.Exception
@ -151,7 +150,7 @@ public class IslandsManagerTest {
});
// Worlds
iwm = mock(IslandWorld.class);
iwm = mock(IslandWorldManager.class);
when(plugin.getIslandWorldManager()).thenReturn(iwm);
when(iwm.getIslandWorld()).thenReturn(world);
when(iwm.getNetherWorld()).thenReturn(world);
@ -378,7 +377,7 @@ public class IslandsManagerTest {
when(plugin.getSettings()).thenReturn(settings);
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
when(plugin.getIslandWorldManager()).thenReturn(iwm);
when(iwm.getIslandWorld()).thenReturn(world);

View File

@ -39,7 +39,6 @@ import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.BSBDatabase;
import us.tastybento.bskyblock.database.objects.Names;
import us.tastybento.bskyblock.database.objects.Players;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.util.Util;
/**
@ -57,7 +56,7 @@ public class PlayersManagerTest {
private IslandsManager im;
private UUID notUUID;
private BukkitScheduler sch;
private IslandWorld iwm;
private IslandWorldManager iwm;
private World world;
private World nether;
private World end;
@ -73,7 +72,7 @@ public class PlayersManagerTest {
Whitebox.setInternalState(BSkyBlock.class, "instance", plugin);
// island world mgr
iwm = mock(IslandWorld.class);
iwm = mock(IslandWorldManager.class);
world = mock(World.class);
when(world.getName()).thenReturn("world");
nether = mock(World.class);

View File

@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableSet.Builder;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.util.Util;
@ -47,7 +47,7 @@ public class IslandCacheTest {
world = mock(World.class);
// Worlds
IslandWorld iwm = mock(IslandWorld.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
when(plugin.getIslandWorldManager()).thenReturn(iwm);
when(iwm.getIslandWorld()).thenReturn(world);
when(iwm.getNetherWorld()).thenReturn(world);