Schems: sign placeholders for names and spawn location

This commit is contained in:
tastybento 2018-07-02 11:21:10 -07:00
parent afa21d25ed
commit d725a3e1d8
10 changed files with 340 additions and 721 deletions

View File

@ -14,4 +14,5 @@ public class TextVariables {
public static final String RANK = "[rank]"; public static final String RANK = "[rank]";
public static final String LABEL = "[label]"; public static final String LABEL = "[label]";
public static final String PERMISSION = "[permission]"; public static final String PERMISSION = "[permission]";
public static final String SPAWN_HERE = "[spawn_here]";
} }

View File

@ -11,6 +11,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -101,7 +102,7 @@ public class Island implements DataObject {
@Expose @Expose
private int levelHandicap; private int levelHandicap;
@Expose @Expose
private Location spawnPoint; private Map<Environment, Location> spawnPoint = new HashMap<>();
public Island() {} public Island() {}
public Island(Location location, UUID owner, int protectionRange) { public Island(Location location, UUID owner, int protectionRange) {
@ -288,10 +289,6 @@ public class Island implements DataObject {
return members.getOrDefault(user.getUniqueId(), RanksManager.VISITOR_RANK); return members.getOrDefault(user.getUniqueId(), RanksManager.VISITOR_RANK);
} }
public Location getSpawnPoint() {
return spawnPoint;
}
/** /**
* @param material - Material * @param material - Material
* @return count of how many tile entities of type mat are on the island at last count. Counts are done when a player places * @return count of how many tile entities of type mat are on the island at last count. Counts are done when a player places
@ -620,9 +617,21 @@ public class Island implements DataObject {
//TODO default flags //TODO default flags
} }
public void setSpawnPoint(Location location) { /**
spawnPoint = location; * Get the default spawn location for this island. Note that this may only be valid
* after the initial pasting because the player can change the island after that point
* @return the spawnPoint
*/
public Map<Environment, Location> getSpawnPoint() {
return spawnPoint;
}
/**
* Set when island is pasted
* @param spawnPoint the spawnPoint to set
*/
public void setSpawnPoint(Map<Environment, Location> spawnPoint) {
this.spawnPoint = spawnPoint;
} }
@Override @Override
@ -731,5 +740,23 @@ public class Island implements DataObject {
} }
} }
/**
* Set the spawn location for this island type
* @param islandType - island type
* @param l - location
*/
public void setSpawnPoint(Environment islandType, Location l) {
spawnPoint.put(islandType, l);
}
/**
* Get the spawn point for this island type
* @param islandType - island type
* @return - location or null if one does not exist
*/
public Location getSpawnPoint(Environment islandType) {
return spawnPoint.get(islandType);
}
} }

View File

@ -10,7 +10,9 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
@ -82,6 +84,9 @@ public class Clipboard {
private BSkyBlock plugin; private BSkyBlock plugin;
private boolean copied; private boolean copied;
// Pasted items
private Map<Location, List<String>> signs = new HashMap<>();
private File schemFolder; private File schemFolder;
public Clipboard(BSkyBlock plugin) { public Clipboard(BSkyBlock plugin) {
@ -186,61 +191,61 @@ public class Clipboard {
* @param location - location to paste * @param location - location to paste
*/ */
public void paste(Location location) { public void paste(Location location) {
signs.clear();
blockConfig.getConfigurationSection(BLOCK).getKeys(false).forEach(b -> pasteBlock(location, blockConfig.getConfigurationSection(BLOCK + "." + b))); blockConfig.getConfigurationSection(BLOCK).getKeys(false).forEach(b -> pasteBlock(location, blockConfig.getConfigurationSection(BLOCK + "." + b)));
} }
private void pasteBlock(Location location, ConfigurationSection s) { private void pasteBlock(Location location, ConfigurationSection config) {
String[] pos = s.getName().split(","); String[] pos = config.getName().split(",");
int x = location.getBlockX() + Integer.valueOf(pos[0]); int x = location.getBlockX() + Integer.valueOf(pos[0]);
int y = location.getBlockY() + Integer.valueOf(pos[1]); int y = location.getBlockY() + Integer.valueOf(pos[1]);
int z = location.getBlockZ() + Integer.valueOf(pos[2]); int z = location.getBlockZ() + Integer.valueOf(pos[2]);
Material m = Material.getMaterial(s.getString("type", "AIR")); // Default type is air
Material material = Material.getMaterial(config.getString("type", "AIR"));
Block block = location.getWorld().getBlockAt(x, y, z); Block block = location.getWorld().getBlockAt(x, y, z);
if (s.getBoolean(ATTACHED)) { if (config.getBoolean(ATTACHED)) {
plugin.getServer().getScheduler().runTask(plugin, () -> setBlock(block, s, m)); plugin.getServer().getScheduler().runTask(plugin, () -> setBlock(block, config, material));
} else { } else {
setBlock(block, s, m); setBlock(block, config, material);
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void setBlock(Block block, ConfigurationSection s, Material m) { private void setBlock(Block block, ConfigurationSection config, Material material) {
// Block state // Block state
if (s.getBoolean(ATTACHED) && m.toString().contains("TORCH")) { if (config.getBoolean(ATTACHED) && material.toString().contains("TORCH")) {
TorchDir d = TorchDir.valueOf(s.getString(FACING)); TorchDir d = TorchDir.valueOf(config.getString(FACING));
// The block below has to be set to something solid for this to work
Block rel = block.getRelative(BlockFace.DOWN); Block rel = block.getRelative(BlockFace.DOWN);
Material rm = rel.getType(); Material rm = rel.getType();
Byte data = rel.getData(); Byte data = rel.getData();
if (rel.isEmpty() || rel.isLiquid()) { if (rel.isEmpty() || rel.isLiquid()) {
rel.setType(Material.STONE); rel.setType(Material.STONE);
block.setType(m); block.setType(material);
block.setData((byte)d.ordinal()); block.setData((byte)d.ordinal());
// Set the block back to what it was // Set the block back to what it was
rel.setType(rm); rel.setType(rm);
rel.setData(data); rel.setData(data);
} else { } else {
block.setType(m); block.setType(material);
block.setData((byte)d.ordinal()); block.setData((byte)d.ordinal());
} }
return; return;
} }
// Set the block type
block.setType(material, false);
block.setType(m, false); // Set the block data
byte data = (byte)config.getInt("data");
BlockState bs = block.getState();
byte data = (byte)s.getInt("data");
block.setData(data); block.setData(data);
// Get the block state
BlockState bs = block.getState();
// Material Data // Material Data
MaterialData md = bs.getData(); MaterialData md = bs.getData();
if (md instanceof Openable) { if (md instanceof Openable) {
Openable open = (Openable)md; Openable open = (Openable)md;
open.setOpen(s.getBoolean("open")); open.setOpen(config.getBoolean("open"));
} }
if (md instanceof Directional) { if (md instanceof Directional) {
@ -248,37 +253,40 @@ public class Clipboard {
if (md instanceof Stairs) { if (md instanceof Stairs) {
//facing.setFacingDirection(BlockFace.valueOf(s.getString(FACING)).getOppositeFace()); //facing.setFacingDirection(BlockFace.valueOf(s.getString(FACING)).getOppositeFace());
Stairs stairs = (Stairs)md; Stairs stairs = (Stairs)md;
stairs.setInverted(s.getBoolean("inverted")); stairs.setInverted(config.getBoolean("inverted"));
stairs.setFacingDirection(BlockFace.valueOf(s.getString(FACING, "NORTH"))); stairs.setFacingDirection(BlockFace.valueOf(config.getString(FACING, "NORTH")));
} else { } else {
facing.setFacingDirection(BlockFace.valueOf(s.getString(FACING, "NORTH"))); facing.setFacingDirection(BlockFace.valueOf(config.getString(FACING, "NORTH")));
} }
} }
if (md instanceof Lever) { if (md instanceof Lever) {
Lever r = (Lever)md; Lever r = (Lever)md;
r.setPowered(s.getBoolean(POWERED)); r.setPowered(config.getBoolean(POWERED));
} }
if (md instanceof Button) { if (md instanceof Button) {
Button r = (Button)md; Button r = (Button)md;
r.setPowered(s.getBoolean(POWERED)); r.setPowered(config.getBoolean(POWERED));
} }
// Block data // Block data
if (bs instanceof Sign) { if (bs instanceof Sign) {
Sign sign = (Sign)bs; Sign sign = (Sign)bs;
List<String> lines = s.getStringList("lines"); List<String> lines = config.getStringList("lines");
for (int i =0 ; i < lines.size(); i++) { for (int i =0 ; i < lines.size(); i++) {
sign.setLine(i, lines.get(i)); sign.setLine(i, lines.get(i));
} }
sign.update(); sign.update();
// Log the sign
signs.put(block.getLocation(), lines);
} }
if (bs instanceof Banner) { if (bs instanceof Banner) {
Banner banner = (Banner)bs; Banner banner = (Banner)bs;
DyeColor baseColor = DyeColor.valueOf(s.getString("baseColor", "RED")); DyeColor baseColor = DyeColor.valueOf(config.getString("baseColor", "RED"));
banner.setBaseColor(baseColor); banner.setBaseColor(baseColor);
int i = 0; int i = 0;
ConfigurationSection pat = s.getConfigurationSection("pattern"); ConfigurationSection pat = config.getConfigurationSection("pattern");
if (pat != null) { if (pat != null) {
for (String pattern : pat.getKeys(false)) { for (String pattern : pat.getKeys(false)) {
banner.setPattern(i, new Pattern(DyeColor.valueOf(pat.getString(pattern, "GREEN")) banner.setPattern(i, new Pattern(DyeColor.valueOf(pat.getString(pattern, "GREEN"))
@ -290,30 +298,27 @@ public class Clipboard {
} }
if (bs instanceof CreatureSpawner) { if (bs instanceof CreatureSpawner) {
CreatureSpawner spawner = ((CreatureSpawner) bs); CreatureSpawner spawner = ((CreatureSpawner) bs);
spawner.setSpawnedType(EntityType.valueOf(s.getString("spawnedType", "PIG"))); spawner.setSpawnedType(EntityType.valueOf(config.getString("spawnedType", "PIG")));
spawner.setMaxNearbyEntities(s.getInt("maxNearbyEntities", 16)); spawner.setMaxNearbyEntities(config.getInt("maxNearbyEntities", 16));
spawner.setMaxSpawnDelay(s.getInt("maxSpawnDelay", 2*60*20)); spawner.setMaxSpawnDelay(config.getInt("maxSpawnDelay", 2*60*20));
spawner.setMinSpawnDelay(s.getInt("minSpawnDelay", 5*20)); spawner.setMinSpawnDelay(config.getInt("minSpawnDelay", 5*20));
spawner.setDelay(s.getInt("delay", -1)); spawner.setDelay(config.getInt("delay", -1));
spawner.setRequiredPlayerRange(s.getInt("requiredPlayerRange", 16)); spawner.setRequiredPlayerRange(config.getInt("requiredPlayerRange", 16));
spawner.setSpawnRange(s.getInt("spawnRange", 4)); spawner.setSpawnRange(config.getInt("spawnRange", 4));
bs.update(true, false); bs.update(true, false);
} }
if (bs instanceof InventoryHolder) { if (bs instanceof InventoryHolder) {
bs.update(true, false); bs.update(true, false);
Inventory ih = ((InventoryHolder)bs).getInventory(); Inventory ih = ((InventoryHolder)bs).getInventory();
ConfigurationSection inv = s.getConfigurationSection("inventory"); ConfigurationSection inv = config.getConfigurationSection("inventory");
inv.getKeys(false).forEach(i -> ih.setItem(Integer.valueOf(i), (ItemStack)inv.get(i))); inv.getKeys(false).forEach(i -> ih.setItem(Integer.valueOf(i), (ItemStack)inv.get(i)));
} }
// Entities // Entities
if (s.isConfigurationSection("entity")) { if (config.isConfigurationSection("entity")) {
ConfigurationSection e = s.getConfigurationSection("entity"); ConfigurationSection e = config.getConfigurationSection("entity");
e.getKeys(false).forEach(k -> { e.getKeys(false).forEach(k -> {
Location center = block.getLocation().add(new Vector(0.5, 0.0, 0.5)); Location center = block.getLocation().add(new Vector(0.5, 0.0, 0.5));
LivingEntity ent = (LivingEntity)block.getWorld().spawnEntity(center, EntityType.valueOf(e.getString(k + ".type", "PIG"))); LivingEntity ent = (LivingEntity)block.getWorld().spawnEntity(center, EntityType.valueOf(e.getString(k + ".type", "PIG")));
@ -433,6 +438,13 @@ public class Clipboard {
return blockConfig; return blockConfig;
} }
/**
* @return the signs
*/
public Map<Location, List<String>> getSigns() {
plugin.log("DEBUG: signs " + signs.size());
return signs;
}
private void unzip(final String zipFilePath) throws IOException { private void unzip(final String zipFilePath) throws IOException {
Path path = Paths.get(zipFilePath); Path path = Paths.get(zipFilePath);
if (!(path.toFile().exists())) { if (!(path.toFile().exists())) {

View File

@ -1,61 +1,106 @@
package us.tastybento.bskyblock.island.builders; package us.tastybento.bskyblock.island.builders;
import java.io.File;
import java.io.IOException;
import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.World.Environment;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.EntityType; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Chest;
import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.Constants.GameType;
import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.localization.TextVariables;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island; import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.util.Util;
/** /**
* Fired when a team event happens. * Generates islands
* *
* @author tastybento * @author tastybento
* @since 1.0 * @since 1.0
*/ */
public class IslandBuilder { public class IslandBuilder {
public enum IslandType {
ISLAND,
NETHER,
END
}
private Island island; private Island island;
private World world; private World world;
private IslandType type = IslandType.ISLAND; private Environment type = Environment.NORMAL;
private List<ItemStack> chestItems;
private UUID playerUUID; private UUID playerUUID;
private String playerName; private String playerName;
private BSkyBlock plugin;
private Map<Environment, Clipboard> islandSchems = new EnumMap<>(Environment.class);
private Location spawnPoint;
private Runnable task;
//TODO support companions? //TODO support companions?
public IslandBuilder(Island island) { public IslandBuilder(BSkyBlock plugin, Island island) {
this.plugin = plugin;
this.island = island; this.island = island;
world = island.getWorld(); world = island.getWorld();
loadIslands();
}
private void loadIslands() {
File schems = new File(plugin.getDataFolder(), "schems");
if (!schems.exists()) {
if (!schems.mkdirs()) {
plugin.logError("Could not make schems folder!");
} else {
copySchems(schems);
}
}
try {
Clipboard cb = new Clipboard(plugin);
cb.load("island");
islandSchems.put(Environment.NORMAL, cb);
} catch (IOException | InvalidConfigurationException e) {
plugin.logError("Could not load default island");
}
if (plugin.getSettings().isNetherGenerate() && plugin.getSettings().isNetherIslands()) {
try {
Clipboard cbn = new Clipboard(plugin);
cbn.load("nether-island");
islandSchems.put(Environment.NETHER, cbn);
} catch (IOException | InvalidConfigurationException e) {
plugin.logError("Could not load default nether island");
}
}
if (plugin.getSettings().isEndGenerate() && plugin.getSettings().isEndIslands()) {
try {
Clipboard cbe = new Clipboard(plugin);
cbe.load("end-island");
islandSchems.put(Environment.THE_END, cbe);
} catch (IOException | InvalidConfigurationException e) {
plugin.logError("Could not load default end island");
}
}
plugin.log("Loaded " + islandSchems.size() + " islands");
}
/**
* Copies schems from the jar file
* @param schems2 - file containing schem
*/
private void copySchems(File schems2) {
plugin.saveResource("schems/island.schem", false);
plugin.saveResource("schems/nether-island.schem", false);
plugin.saveResource("schems/end-island.schem", false);
} }
/** /**
* @param type the type to set * @param type the type to set
*/ */
public IslandBuilder setType(IslandType type) { public IslandBuilder setType(Environment type) {
this.type = type; this.type = type;
return this; return this;
} }
@ -70,417 +115,72 @@ public class IslandBuilder {
} }
/** /**
* @param list the default chestItems to set * The task to run when the island is built
* @param task
* @return IslandBuilder
*/ */
public IslandBuilder setChestItems(List<ItemStack> list) { public IslandBuilder run(Runnable task) {
chestItems = list; this.task = task;
return this; return this;
} }
public void build() { public void build() {
plugin.log("Pasting island to " + type);
Location loc = island.getCenter();
// Switch on island type // Switch on island type
switch (type) { switch (type) {
case ISLAND:
world = island.getWorld();
if (Constants.GAMETYPE == GameType.ACIDISLAND) {
generateAcidIslandBlocks();
} else {
generateIslandBlocks();
}
break;
case NETHER: case NETHER:
world = Bukkit.getWorld(island.getWorld().getName() + "_nether"); world = Bukkit.getWorld(island.getWorld().getName() + "_nether");
if (world == null) { if (world == null) {
return; return;
} }
generateNetherBlocks(); loc = island.getCenter().toVector().toLocation(world);
break; break;
case END: case THE_END:
world = Bukkit.getWorld(island.getWorld().getName() + "_the_end"); world = Bukkit.getWorld(island.getWorld().getName() + "_the_end");
if (world == null) { if (world == null) {
return; return;
} }
generateEndBlocks(); loc = island.getCenter().toVector().toLocation(world);
break;
default:
break; break;
} }
islandSchems.get(type).paste(loc);
// Do other stuff // Do other stuff
// Handle signs - signs are attachable, so they are not there until 1 tick after pasting
if (playerUUID != null) {
Bukkit.getScheduler().runTaskLater(plugin, () -> islandSchems.get(type).getSigns().forEach(this::writeSign), 2L);
}
if (task != null) {
Bukkit.getScheduler().runTaskLater(plugin, task, 3L);
}
}
private void writeSign(Location loc, List<String> lines) {
Sign sign = (Sign) loc.getBlock().getState();
org.bukkit.material.Sign s = (org.bukkit.material.Sign) sign.getData();
lines.forEach(plugin::log);
// Handle spawn sign
if (!lines.isEmpty() && lines.get(0).equalsIgnoreCase(TextVariables.SPAWN_HERE)) {
loc.getBlock().setType(Material.AIR);
// Orient to face same direction as sign
spawnPoint = new Location(loc.getWorld(), loc.getBlockX() + 0.5D, loc.getBlockY(),
loc.getBlockZ() + 0.5D, Util.blockFaceToFloat(s.getFacing().getOppositeFace()), 30F);
return;
}
// Sub in player's name
for (int i = 0 ; i < lines.size(); i++) {
sign.setLine(i, lines.get(i).replace(TextVariables.NAME, playerName));
}
sign.update();
} }
/** /**
* Creates the AcidIsland default island block by block * @return the spawnPoint
*/ */
private void generateAcidIslandBlocks() { public Optional<Location> getSpawnPoint() {
// AcidIsland return Optional.ofNullable(spawnPoint);
// Build island layer by layer
// Start from the base
// half sandstone; half sand
int x = island.getCenter().getBlockX();
int z = island.getCenter().getBlockZ();
int islandHeight = island.getCenter().getBlockY();
int y = 0;
for (int x_space = x - 4; x_space <= x + 4; x_space++) {
for (int z_space = z - 4; z_space <= z + 4; z_space++) {
Block b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.BEDROCK);
}
}
for (y = 1; y < islandHeight + 5; y++) {
for (int x_space = x - 4; x_space <= x + 4; x_space++) {
for (int z_space = z - 4; z_space <= z + 4; z_space++) {
Block b = world.getBlockAt(x_space, y, z_space);
if (y < (islandHeight / 2)) {
b.setType(Material.SANDSTONE);
} else {
b.setType(Material.SAND);
}
}
}
}
// Then cut off the corners to make it round-ish
for (y = 0; y < islandHeight + 5; y++) {
for (int x_space = x - 4; x_space <= x + 4; x_space += 8) {
for (int z_space = z - 4; z_space <= z + 4; z_space += 8) {
Block b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.STATIONARY_WATER);
}
}
}
// Add some grass
for (y = islandHeight + 4; y < islandHeight + 5; y++) {
for (int x_space = x - 2; x_space <= x + 2; x_space++) {
for (int z_space = z - 2; z_space <= z + 2; z_space++) {
Block blockToChange = world.getBlockAt(x_space, y, z_space);
blockToChange.setType(Material.GRASS);
}
}
}
// Place bedrock - MUST be there (ensures island are not
// overwritten
Block b = world.getBlockAt(x, islandHeight, z);
b.setType(Material.BEDROCK);
// Then add some more dirt in the classic shape
y = islandHeight + 3;
for (int x_space = x - 2; x_space <= x + 2; x_space++) {
for (int z_space = z - 2; z_space <= z + 2; z_space++) {
b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.DIRT);
}
}
b = world.getBlockAt(x - 3, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x + 3, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z - 3);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z + 3);
b.setType(Material.DIRT);
y = islandHeight + 2;
for (int x_space = x - 1; x_space <= x + 1; x_space++) {
for (int z_space = z - 1; z_space <= z + 1; z_space++) {
b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.DIRT);
}
}
b = world.getBlockAt(x - 2, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x + 2, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z - 2);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z + 2);
b.setType(Material.DIRT);
y = islandHeight + 1;
b = world.getBlockAt(x - 1, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x + 1, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z - 1);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z + 1);
b.setType(Material.DIRT);
// Add island items
y = islandHeight;
// Add tree (natural)
Location treeLoc = new Location(world, x, y + 5D, z);
world.generateTree(treeLoc, TreeType.ACACIA);
// Place a helpful sign in front of player
placeSign(x, islandHeight + 5, z + 3);
// Place the chest - no need to use the safe spawn function
// because we
// know what this island looks like
placeChest(x, islandHeight + 5, z + 1);
}
private void generateIslandBlocks() {
// Skyblock
// Build island layer by layer
// Start from the base
// half sandstone; half sand
int x = island.getCenter().getBlockX();
int z = island.getCenter().getBlockZ();
int islandHeight = island.getCenter().getBlockY();
World world = island.getCenter().getWorld();
int y;
// Add some grass
for (y = islandHeight + 4; y < islandHeight + 5; y++) {
for (int x_space = x - 3; x_space <= x + 3; x_space++) {
for (int z_space = z - 3; z_space <= z + 3; z_space++) {
world.getBlockAt(x_space, y, z_space).setType(Material.GRASS);
}
}
}
// Then cut off the corners to make it round-ish
for (int x_space = x - 3; x_space <= x + 3; x_space += 6) {
for (int z_space = z - 3; z_space <= z + 3; z_space += 6) {
world.getBlockAt(x_space, y-1, z_space).setType(Material.AIR);
}
}
// Place bedrock - MUST be there (ensures island are not
// overwritten
Block b = world.getBlockAt(x, islandHeight, z);
b.setType(Material.BEDROCK);
// Then add some more dirt in the classic shape
y = islandHeight + 3;
for (int x_space = x - 2; x_space <= x + 2; x_space++) {
for (int z_space = z - 2; z_space <= z + 2; z_space++) {
b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.DIRT);
}
}
b = world.getBlockAt(x - 3, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x + 3, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z - 3);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z + 3);
b.setType(Material.DIRT);
y = islandHeight + 2;
for (int x_space = x - 1; x_space <= x + 1; x_space++) {
for (int z_space = z - 1; z_space <= z + 1; z_space++) {
b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.DIRT);
}
}
b = world.getBlockAt(x - 2, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x + 2, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z - 2);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z + 2);
b.setType(Material.DIRT);
y = islandHeight + 1;
b = world.getBlockAt(x - 1, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x + 1, y, z);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z - 1);
b.setType(Material.DIRT);
b = world.getBlockAt(x, y, z + 1);
b.setType(Material.DIRT);
// Add island items
y = islandHeight;
// Add tree (natural)
Location treeLoc = new Location(world, x, y + 5D, z);
world.generateTree(treeLoc, TreeType.TREE);
// Place a helpful sign in front of player
placeSign(x, islandHeight + 5, z + 3);
// Place the chest - no need to use the safe spawn function
// because we
// know what this island looks like
placeChest(x, islandHeight + 5, z + 1);
}
private void generateNetherBlocks() {
// Nether block
int x = island.getCenter().getBlockX();
int z = island.getCenter().getBlockZ();
int islandHeight = island.getCenter().getBlockY();
int y;
for (y = islandHeight + 4; y < islandHeight + 5; y++) {
for (int x_space = x - 3; x_space <= x + 3; x_space++) {
for (int z_space = z - 3; z_space <= z + 3; z_space++) {
world.getBlockAt(x_space, y, z_space).setType(Material.NETHER_BRICK);
}
}
}
// Then cut off the corners to make it round-ish
for (int x_space = x - 3; x_space <= x + 3; x_space += 6) {
for (int z_space = z - 3; z_space <= z + 3; z_space += 6) {
world.getBlockAt(x_space, y-1, z_space).setType(Material.AIR);
}
}
// Place bedrock - MUST be there (ensures island are not
// overwritten
Block b = world.getBlockAt(x, islandHeight, z);
b.setType(Material.BEDROCK);
// Then add some more dirt in the classic shape
y = islandHeight + 3;
for (int x_space = x - 2; x_space <= x + 2; x_space++) {
for (int z_space = z - 2; z_space <= z + 2; z_space++) {
b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.NETHERRACK);
}
}
b = world.getBlockAt(x - 3, y, z);
b.setType(Material.SOUL_SAND);
b = world.getBlockAt(x + 3, y, z);
b.setType(Material.SOUL_SAND);
b = world.getBlockAt(x, y, z - 3);
b.setType(Material.SOUL_SAND);
b = world.getBlockAt(x, y, z + 3);
b.setType(Material.SOUL_SAND);
y = islandHeight + 2;
for (int x_space = x - 1; x_space <= x + 1; x_space++) {
for (int z_space = z - 1; z_space <= z + 1; z_space++) {
b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.GRAVEL);
}
}
b = world.getBlockAt(x - 2, y, z);
b.setType(Material.QUARTZ_ORE);
b = world.getBlockAt(x + 2, y, z);
b.setType(Material.QUARTZ_ORE);
b = world.getBlockAt(x, y, z - 2);
b.setType(Material.QUARTZ_ORE);
b = world.getBlockAt(x, y, z + 2);
b.setType(Material.QUARTZ_ORE);
y = islandHeight + 1;
b = world.getBlockAt(x - 1, y, z);
b.setType(Material.MAGMA);
b = world.getBlockAt(x + 1, y, z);
b.setType(Material.MAGMA);
b = world.getBlockAt(x, y, z - 1);
b.setType(Material.MAGMA);
b = world.getBlockAt(x, y, z + 1);
b.setType(Material.MAGMA);
// Place a helpful sign in front of player
placeSign(x, islandHeight + 5, z + 3);
// Place the chest - no need to use the safe spawn function
// because we know what this island looks like
placeChest(x, islandHeight + 5, z + 1);
}
private void generateEndBlocks() {
// Nether block
int x = island.getCenter().getBlockX();
int z = island.getCenter().getBlockZ();
int islandHeight = island.getCenter().getBlockY();
int y;
// Add some grass
for (y = islandHeight + 4; y < islandHeight + 5; y++) {
for (int x_space = x - 3; x_space <= x + 3; x_space++) {
for (int z_space = z - 3; z_space <= z + 3; z_space++) {
world.getBlockAt(x_space, y, z_space).setType(Material.END_BRICKS);
}
}
}
// Then cut off the corners to make it round-ish
for (int x_space = x - 3; x_space <= x + 3; x_space += 6) {
for (int z_space = z - 3; z_space <= z + 3; z_space += 6) {
world.getBlockAt(x_space, y-1, z_space).setType(Material.AIR);
}
}
// Place bedrock - MUST be there (ensures island are not
// overwritten
Block b = world.getBlockAt(x, islandHeight, z);
b.setType(Material.BEDROCK);
// Then add some more dirt in the classic shape
y = islandHeight + 3;
for (int x_space = x - 2; x_space <= x + 2; x_space++) {
for (int z_space = z - 2; z_space <= z + 2; z_space++) {
b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.ENDER_STONE);
}
}
b = world.getBlockAt(x - 3, y, z);
b.setType(Material.OBSIDIAN);
b = world.getBlockAt(x + 3, y, z);
b.setType(Material.OBSIDIAN);
b = world.getBlockAt(x, y, z - 3);
b.setType(Material.OBSIDIAN);
b = world.getBlockAt(x, y, z + 3);
b.setType(Material.OBSIDIAN);
y = islandHeight + 2;
for (int x_space = x - 1; x_space <= x + 1; x_space++) {
for (int z_space = z - 1; z_space <= z + 1; z_space++) {
b = world.getBlockAt(x_space, y, z_space);
b.setType(Material.ENDER_STONE);
}
}
b = world.getBlockAt(x - 2, y, z);
b.setType(Material.ENDER_STONE);
b = world.getBlockAt(x + 2, y, z);
b.setType(Material.ENDER_STONE);
b = world.getBlockAt(x, y, z - 2);
b.setType(Material.ENDER_STONE);
b = world.getBlockAt(x, y, z + 2);
b.setType(Material.ENDER_STONE);
y = islandHeight + 1;
b = world.getBlockAt(x - 1, y, z);
b.setType(Material.ENDER_STONE);
b = world.getBlockAt(x + 1, y, z);
b.setType(Material.ENDER_STONE);
b = world.getBlockAt(x, y, z - 1);
b.setType(Material.ENDER_STONE);
b = world.getBlockAt(x, y, z + 1);
b.setType(Material.ENDER_STONE);
// Add island items
y = islandHeight;
// Spawn an ender crystal
world.spawnEntity(new Location(world, x, y + 5D, z), EntityType.ENDER_CRYSTAL);
// Place a helpful sign in front of player
placeSign(x, islandHeight + 5, z + 3);
// Place the chest - no need to use the safe spawn function
// because we know what this island looks like
placeChest(x, islandHeight + 5, z + 1);
}
private void placeSign(int x, int y, int z) {
Block blockToChange = world.getBlockAt(x, y, z);
blockToChange.setType(Material.SIGN_POST);
if (playerUUID != null) {
Sign sign = (Sign) blockToChange.getState();
User user = User.getInstance(playerUUID);
// Sets the lines of the sign
sign.setLine(0, user.getTranslation("new-island.sign.line0", TextVariables.NAME, playerName));
sign.setLine(1, user.getTranslation("new-island.sign.line1", TextVariables.NAME, playerName));
sign.setLine(2, user.getTranslation("new-island.sign.line2", TextVariables.NAME, playerName));
sign.setLine(3, user.getTranslation("new-island.sign.line3", TextVariables.NAME, playerName));
((org.bukkit.material.Sign) sign.getData()).setFacingDirection(BlockFace.NORTH);
sign.update();
}
}
private void placeChest(int x, int y, int z) {
// Fill the chest and orient it correctly
Block blockToChange = world.getBlockAt(x, y, z);
blockToChange.setType(Material.CHEST);
BlockState state = blockToChange.getState();
Chest chest = new Chest(BlockFace.SOUTH);
state.setData(chest);
state.update();
if (!chestItems.isEmpty()) {
InventoryHolder chestBlock = (InventoryHolder) state;
for (ItemStack item: chestItems) {
chestBlock.getInventory().addItem(item);
}
}
} }
} }

View File

@ -1,196 +0,0 @@
package us.tastybento.bskyblock.island.builders;
import java.io.File;
import java.io.IOException;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Chest;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.localization.TextVariables;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
/**
* Generates islands
*
* @author tastybento
* @since 1.0
*/
public class IslandBuilderNew {
public enum IslandType {
ISLAND,
NETHER,
END
}
private Island island;
private World world;
private IslandType type = IslandType.ISLAND;
private List<ItemStack> chestItems;
private UUID playerUUID;
private String playerName;
private BSkyBlock plugin;
private Map<IslandType, Clipboard> islandSchems = new EnumMap<>(IslandType.class);
//TODO support companions?
public IslandBuilderNew(BSkyBlock plugin, Island island) {
this.plugin = plugin;
this.island = island;
world = island.getWorld();
loadIslands();
}
private void loadIslands() {
File schems = new File(plugin.getDataFolder(), "schems");
if (!schems.exists()) {
if (!schems.mkdirs()) {
plugin.logError("Could not make schems folder!");
} else {
copySchems(schems);
}
}
try {
Clipboard cb = new Clipboard(plugin);
cb.load("island");
islandSchems.put(IslandType.ISLAND, cb);
} catch (IOException | InvalidConfigurationException e) {
plugin.logError("Could not load default island");
}
if (plugin.getSettings().isNetherGenerate() && plugin.getSettings().isNetherIslands()) {
try {
Clipboard cbn = new Clipboard(plugin);
cbn.load("nether-island");
islandSchems.put(IslandType.NETHER, cbn);
} catch (IOException | InvalidConfigurationException e) {
plugin.logError("Could not load default nether island");
}
}
if (plugin.getSettings().isEndGenerate() && plugin.getSettings().isEndIslands()) {
try {
Clipboard cbe = new Clipboard(plugin);
cbe.load("end-island");
islandSchems.put(IslandType.END, cbe);
} catch (IOException | InvalidConfigurationException e) {
plugin.logError("Could not load default end island");
}
}
plugin.log("Loaded " + islandSchems.size() + " islands");
}
/**
* Copies schems from the jar file
* @param schems2 - file containing schem
*/
private void copySchems(File schems2) {
plugin.saveResource("schems/island.schem", false);
plugin.saveResource("schems/nether-island.schem", false);
plugin.saveResource("schems/end-island.schem", false);
}
/**
* @param type the type to set
*/
public IslandBuilderNew setType(IslandType type) {
this.type = type;
return this;
}
/**
* @param player - the player the player to set
*/
public IslandBuilderNew setPlayer(Player player) {
playerUUID = player.getUniqueId();
playerName = player.getName();
return this;
}
/**
* @param list the default chestItems to set
*/
public IslandBuilderNew setChestItems(List<ItemStack> list) {
chestItems = list;
return this;
}
public void build() {
plugin.log("Pasting island to " + type);
Location loc = island.getCenter();
// Switch on island type
switch (type) {
case NETHER:
world = Bukkit.getWorld(island.getWorld().getName() + "_nether");
if (world == null) {
return;
}
loc = island.getCenter().toVector().toLocation(world);
break;
case END:
world = Bukkit.getWorld(island.getWorld().getName() + "_the_end");
if (world == null) {
return;
}
loc = island.getCenter().toVector().toLocation(world);
break;
default:
break;
}
plugin.log("Pasting island to " + loc);
islandSchems.get(type).paste(loc);
// Do other stuff
}
private void placeSign(int x, int y, int z) {
Block blockToChange = world.getBlockAt(x, y, z);
blockToChange.setType(Material.SIGN_POST);
if (playerUUID != null) {
Sign sign = (Sign) blockToChange.getState();
User user = User.getInstance(playerUUID);
// Sets the lines of the sign
sign.setLine(0, user.getTranslation("new-island.sign.line0", TextVariables.NAME, playerName));
sign.setLine(1, user.getTranslation("new-island.sign.line1", TextVariables.NAME, playerName));
sign.setLine(2, user.getTranslation("new-island.sign.line2", TextVariables.NAME, playerName));
sign.setLine(3, user.getTranslation("new-island.sign.line3", TextVariables.NAME, playerName));
((org.bukkit.material.Sign) sign.getData()).setFacingDirection(BlockFace.NORTH);
sign.update();
}
}
private void placeChest(int x, int y, int z) {
// Fill the chest and orient it correctly
Block blockToChange = world.getBlockAt(x, y, z);
blockToChange.setType(Material.CHEST);
BlockState state = blockToChange.getState();
Chest chest = new Chest(BlockFace.SOUTH);
state.setData(chest);
state.update();
if (!chestItems.isEmpty()) {
InventoryHolder chestBlock = (InventoryHolder) state;
for (ItemStack item: chestItems) {
chestBlock.getInventory().addItem(item);
}
}
}
}

View File

@ -348,6 +348,7 @@ public class IslandsManager {
public Location getSafeHomeLocation(World world, User user, int number) { public Location getSafeHomeLocation(World world, User user, int number) {
// Try the numbered home location first // Try the numbered home location first
Location l = plugin.getPlayers().getHomeLocation(world, user, number); Location l = plugin.getPlayers().getHomeLocation(world, user, number);
if (l == null) { if (l == null) {
// Get the default home, which may be null too, but that's okay // Get the default home, which may be null too, but that's okay
number = 1; number = 1;
@ -433,7 +434,7 @@ public class IslandsManager {
* @return the spawnPoint or null if spawn does not exist * @return the spawnPoint or null if spawn does not exist
*/ */
public Location getSpawnPoint(World world) { public Location getSpawnPoint(World world) {
return spawn.containsKey(world) ? spawn.get(world).getSpawnPoint() : null; return spawn.containsKey(world) ? spawn.get(world).getSpawnPoint(world.getEnvironment()) : null;
} }
/** /**
@ -723,7 +724,7 @@ public class IslandsManager {
// Move player to spawn // Move player to spawn
if (spawn.containsKey(island.getWorld())) { if (spawn.containsKey(island.getWorld())) {
// go to island spawn // go to island spawn
player.teleport(spawn.get(island.getWorld()).getSpawnPoint()); player.teleport(spawn.get(island.getWorld()).getSpawnPoint(island.getWorld().getEnvironment()));
} else { } else {
if (!player.performCommand(Constants.SPAWNCOMMAND)) { if (!player.performCommand(Constants.SPAWNCOMMAND)) {
plugin.logWarning("During island deletion player " + player.getName() + " could not be sent to spawn so was dropped, sorry."); plugin.logWarning("During island deletion player " + player.getName() + " could not be sent to spawn so was dropped, sorry.");

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment;
import us.tastybento.bskyblock.BSkyBlock; import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.events.IslandBaseEvent; import us.tastybento.bskyblock.api.events.IslandBaseEvent;
@ -11,7 +12,7 @@ import us.tastybento.bskyblock.api.events.island.IslandEvent;
import us.tastybento.bskyblock.api.events.island.IslandEvent.Reason; import us.tastybento.bskyblock.api.events.island.IslandEvent.Reason;
import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island; import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.island.builders.IslandBuilderNew; import us.tastybento.bskyblock.island.builders.IslandBuilder;
/** /**
* Create and paste a new island * Create and paste a new island
@ -117,21 +118,48 @@ public class NewIsland {
.island(island) .island(island)
.location(island.getCenter()) .location(island.getCenter())
.build(); .build();
if (!event.isCancelled()) { if (event.isCancelled()) {
return;
}
// Create island // Create island
IslandBuilderNew ib = new IslandBuilderNew(plugin, island) IslandBuilder ib = new IslandBuilder(plugin, island)
.setPlayer(user.getPlayer()) .setPlayer(user.getPlayer())
.setChestItems(plugin.getSettings().getChestItems()) .setType(Environment.NORMAL);
.setType(IslandBuilderNew.IslandType.ISLAND); ib.run(() -> {
ib.build(); // Set initial spawn point if one exists
if (plugin.getSettings().isNetherGenerate() && plugin.getSettings().isNetherIslands() && plugin.getIWM().getNetherWorld() != null) { ib.getSpawnPoint().ifPresent(l -> {
ib.setType(IslandBuilderNew.IslandType.NETHER).build(); plugin.getPlayers().setHomeLocation(user, l, 1);
} island.setSpawnPoint(Environment.NORMAL, l);
if (plugin.getSettings().isEndGenerate() && plugin.getSettings().isEndIslands() && plugin.getIWM().getEndWorld() != null) { });
ib.setType(IslandBuilderNew.IslandType.END).build(); // Teleport player after this island is built
}
// Teleport player to their island
plugin.getIslands().homeTeleport(world, user.getPlayer(), true); plugin.getIslands().homeTeleport(world, user.getPlayer(), true);
});
// Build it
ib.build();
// Make nether island
if (plugin.getSettings().isNetherGenerate() && plugin.getSettings().isNetherIslands() && plugin.getIWM().getNetherWorld() != null) {
IslandBuilder ib_nether = new IslandBuilder(plugin, island)
.setPlayer(user.getPlayer())
.setType(Environment.NETHER);
ib_nether.run(() -> ib_nether.getSpawnPoint().ifPresent(l -> island.setSpawnPoint(Environment.NETHER, l)));
// Build it
ib_nether.build();
}
// Make end island
if (plugin.getSettings().isEndGenerate() && plugin.getSettings().isEndIslands() && plugin.getIWM().getEndWorld() != null) {
IslandBuilder ib_end = new IslandBuilder(plugin, island)
.setPlayer(user.getPlayer())
.setType(Environment.THE_END);
ib_end.run(() -> {
// Set initial spawn point if one exists
ib_end.getSpawnPoint().ifPresent(l -> island.setSpawnPoint(Environment.NETHER, l));
});
// Build it
ib_end.build();
}
// Fire exit event // Fire exit event
Reason reasonDone = Reason.CREATED; Reason reasonDone = Reason.CREATED;
switch (reason) { switch (reason) {
@ -150,7 +178,7 @@ public class NewIsland {
.island(island) .island(island)
.location(island.getCenter()) .location(island.getCenter())
.build(); .build();
}
} }
/** /**

View File

@ -13,6 +13,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -243,5 +244,49 @@ public class Util {
return world.getEnvironment().equals(Environment.NORMAL) ? world : Bukkit.getWorld(world.getName().replaceAll(NETHER, "").replaceAll(THE_END, "")); return world.getEnvironment().equals(Environment.NORMAL) ? world : Bukkit.getWorld(world.getName().replaceAll(NETHER, "").replaceAll(THE_END, ""));
} }
/**
* Converts block face direction to radial degrees. Returns 0 if block face
* is not radial.
*
* @param face
* @return degrees
*/
public static float blockFaceToFloat(BlockFace face) {
switch (face) {
case EAST:
return 90F;
case EAST_NORTH_EAST:
return 67.5F;
case EAST_SOUTH_EAST:
return 0F;
case NORTH:
return 0F;
case NORTH_EAST:
return 45F;
case NORTH_NORTH_EAST:
return 22.5F;
case NORTH_NORTH_WEST:
return 337.5F;
case NORTH_WEST:
return 315F;
case SOUTH:
return 180F;
case SOUTH_EAST:
return 135F;
case SOUTH_SOUTH_EAST:
return 157.5F;
case SOUTH_SOUTH_WEST:
return 202.5F;
case SOUTH_WEST:
return 225F;
case WEST:
return 270F;
case WEST_NORTH_WEST:
return 292.5F;
case WEST_SOUTH_WEST:
return 247.5F;
default:
return 0F;
}
}
} }

View File

@ -16,6 +16,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -149,7 +150,7 @@ public class MySQLDatabaseHandlerTest {
island.setPurgeProtected(true); island.setPurgeProtected(true);
island.setRange(100); island.setRange(100);
island.setSpawn(true); island.setSpawn(true);
island.setSpawnPoint(location); island.setSpawnPoint(Environment.NORMAL, location);
island.setWorld(world); island.setWorld(world);
MySQLDatabaseHandler<Island> ih = new MySQLDatabaseHandler<>(plugin, Island.class, dbConn); MySQLDatabaseHandler<Island> ih = new MySQLDatabaseHandler<>(plugin, Island.class, dbConn);

View File

@ -600,7 +600,7 @@ public class IslandsManagerTest {
Island island = mock(Island.class); Island island = mock(Island.class);
when(island.getWorld()).thenReturn(world); when(island.getWorld()).thenReturn(world);
// Make a spawn position on the island // Make a spawn position on the island
when(island.getSpawnPoint()).thenReturn(location); when(island.getSpawnPoint(Mockito.any())).thenReturn(location);
// Set the spawn island // Set the spawn island
im.setSpawn(island); im.setSpawn(island);
assertEquals(location,im.getSpawnPoint(world)); assertEquals(location,im.getSpawnPoint(world));