WIP - switching to using simple schems instead of hardcoded islands

This commit is contained in:
tastybento 2018-06-16 10:44:04 +09:00
parent 9202cacb12
commit ce65d34cb4
6 changed files with 697 additions and 444 deletions

View File

@ -133,8 +133,10 @@ commands:
could-not-save: "&Hmm, something went wrong saving that file: [message]"
set-pos1: "&aPosition 1 set at [vector]"
set-pos2: "&aPosition 2 set at [vector]"
set-different-pos: "&cSet a different location - this pos is already set!"
need-pos1-pos2: "&cSet pos1 and pos2 first!"
copied-blocks: "&bCopied [number] blocks to clipboard"
look-at-a-block: "&cLook at block within 20 blocks to set"
world:
description: "Manage world settings"
island:

View File

@ -5,6 +5,10 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.island.builders.Clipboard;
@ -25,6 +29,7 @@ public class AdminSchemCommand extends CompositeCommand {
clipboards = new HashMap<>();
}
@SuppressWarnings("deprecation")
public boolean execute(User user, List<String> args) {
if (args.isEmpty()) {
showHelp(this, user);
@ -39,7 +44,7 @@ public class AdminSchemCommand extends CompositeCommand {
return true;
} else {
user.sendMessage("commands.admin.schem.copy-first");
return true;
return false;
}
}
@ -56,8 +61,30 @@ public class AdminSchemCommand extends CompositeCommand {
return false;
}
if (args.get(0).equalsIgnoreCase("origin")) {
if (cb.getPos1() == null || cb.getPos2() == null) {
user.sendMessage("commands.admin.schem.need-pos1-pos2");
return false;
}
// Get the block player is looking at
Block b = user.getPlayer().getLineOfSight(null, 20).stream().filter(x -> !x.getType().equals(Material.AIR)).findFirst().orElse(null);
if (b != null) {
cb.setOrigin(b.getLocation());
user.getPlayer().sendBlockChange(b.getLocation(), Material.STAINED_GLASS,(byte)14);
Bukkit.getScheduler().runTaskLater(getPlugin(),
() -> user.getPlayer().sendBlockChange(b.getLocation(), b.getType(), b.getData()), 20L);
user.sendMessage("general.success");
return true;
} else {
user.sendMessage("commands.admin.schem.look-at-a-block");
return false;
}
}
if (args.get(0).equalsIgnoreCase("copy")) {
return cb.copy(user);
boolean copyAir = (args.size() == 2 && args.get(1).equalsIgnoreCase("air"));
return cb.copy(user, copyAir);
}
if (args.get(0).equalsIgnoreCase("save")) {
@ -75,6 +102,10 @@ public class AdminSchemCommand extends CompositeCommand {
}
if (args.get(0).equalsIgnoreCase("pos1")) {
if (user.getLocation().equals(cb.getPos2())) {
user.sendMessage("commands.admin.schem.set-different-pos");
return false;
}
cb.setPos1(user.getLocation());
user.sendMessage("commands.admin.schem.set-pos1", "[vector]", Util.xyz(user.getLocation().toVector()));
clipboards.put(user.getUniqueId(), cb);
@ -82,6 +113,10 @@ public class AdminSchemCommand extends CompositeCommand {
}
if (args.get(0).equalsIgnoreCase("pos2")) {
if (user.getLocation().equals(cb.getPos1())) {
user.sendMessage("commands.admin.schem.set-different-pos");
return false;
}
cb.setPos2(user.getLocation());
user.sendMessage("commands.admin.schem.set-pos2", "[vector]", Util.xyz(user.getLocation().toVector()));
clipboards.put(user.getUniqueId(), cb);

View File

@ -14,7 +14,6 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -26,6 +25,7 @@ import org.bukkit.block.Sign;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
@ -53,12 +53,15 @@ public class Clipboard {
NORTH,
UP
}
private static final String ATTACHED = "attached";
private static final String BLOCK = "blocks";
private YamlConfiguration blockConfig = new YamlConfiguration();
private Location pos1;
private Location pos2;
private Location origin;
private BSkyBlock plugin;
private boolean copied;
@ -82,6 +85,7 @@ public class Clipboard {
* @param pos1 the pos1 to set
*/
public void setPos1(Location pos1) {
origin = null;
this.pos1 = pos1;
}
/**
@ -94,15 +98,28 @@ public class Clipboard {
* @param pos2 the pos2 to set
*/
public void setPos2(Location pos2) {
origin = null;
this.pos2 = pos2;
}
/**
* @return the origin
*/
public Location getOrigin() {
return origin;
}
/**
* @param origin the origin to set
*/
public void setOrigin(Location origin) {
this.origin = origin;
}
/**
* Copy the blocks between pos1 and pos2 to the clipboard
* @param user - user
* @return true if successful, false if pos1 or pos2 are undefined
*/
public boolean copy(User user) {
public boolean copy(User user, boolean copyAir) {
if (pos1 == null || pos2 == null) {
user.sendMessage("commands.admin.schem.need-pos1-pos2");
return false;
@ -110,14 +127,31 @@ public class Clipboard {
// Clear the clipboard
blockConfig = new YamlConfiguration();
int count = 0;
int minX = Math.max(pos1.getBlockX(),pos2.getBlockX());
int maxX = Math.min(pos1.getBlockX(), pos2.getBlockX());
int minY = Math.max(pos1.getBlockY(),pos2.getBlockY());
int maxY = Math.min(pos1.getBlockY(), pos2.getBlockY());
int minZ = Math.max(pos1.getBlockZ(),pos2.getBlockZ());
int maxZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ());
for (int x = Math.min(pos1.getBlockX(), pos2.getBlockX()); x <= Math.max(pos1.getBlockX(),pos2.getBlockX()); x++) {
for (int y = Math.min(pos1.getBlockY(), pos2.getBlockY()); y <= Math.max(pos1.getBlockY(),pos2.getBlockY()); y++) {
for (int z = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); z <= Math.max(pos1.getBlockZ(),pos2.getBlockZ()); z++) {
copyBlock(pos1.getWorld().getBlockAt(x, y, z), user.getLocation());
count++;
Block block = pos1.getWorld().getBlockAt(x, y, z);
if (copyBlock(block, origin == null ? user.getLocation() : origin, copyAir)) {
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
minZ = Math.min(minZ, z);
maxZ = Math.max(maxZ, z);
count ++;
}
}
}
}
blockConfig.set("size.xsize", maxX - minX + 1);
blockConfig.set("size.ysize", maxY - minY + 1);
blockConfig.set("size.zsize", maxZ - minZ + 1);
user.sendMessage("commands.admin.schem.copied-blocks", TextVariables.NUMBER, String.valueOf(count));
copied = true;
return true;
@ -128,7 +162,7 @@ public class Clipboard {
* @param location - location to paste
*/
public void paste(Location location) {
blockConfig.getKeys(false).forEach(b -> pasteBlock(location, blockConfig.getConfigurationSection(b)));
blockConfig.getConfigurationSection(BLOCK).getKeys(false).forEach(b -> pasteBlock(location, blockConfig.getConfigurationSection(BLOCK + "." + b)));
}
private void pasteBlock(Location location, ConfigurationSection s) {
@ -182,30 +216,25 @@ public class Clipboard {
// Material Data
MaterialData md = bs.getData();
if (md instanceof Openable) {
Bukkit.getLogger().info("Openable");
Openable open = (Openable)md;
open.setOpen(s.getBoolean("open"));
}
if (md instanceof Directional) {
Bukkit.getLogger().info("Directional");
Directional facing = (Directional)md;
facing.setFacingDirection(BlockFace.valueOf(s.getString("facing")));
}
if (md instanceof Lever) {
Bukkit.getLogger().info("Lever");
Lever r = (Lever)md;
r.setPowered(s.getBoolean("powered"));
}
if (md instanceof Button) {
Bukkit.getLogger().info("Button");
Button r = (Button)md;
r.setPowered(s.getBoolean("powered"));
}
// Block data
if (bs instanceof Sign) {
Bukkit.getLogger().info("Sign");
Sign sign = (Sign)bs;
List<String> lines = s.getStringList("lines");
for (int i =0 ; i < lines.size(); i++) {
@ -214,7 +243,6 @@ public class Clipboard {
sign.update();
}
if (bs instanceof Banner) {
Bukkit.getLogger().info("Banner");
Banner banner = (Banner)bs;
DyeColor baseColor = DyeColor.valueOf(s.getString("baseColor"));
banner.setBaseColor(baseColor);
@ -232,7 +260,6 @@ public class Clipboard {
bs.update(true, false);
if (bs instanceof InventoryHolder) {
Bukkit.getLogger().info("Inventory holder " + s.getCurrentPath());
Inventory ih = ((InventoryHolder)bs).getInventory();
ConfigurationSection inv = s.getConfigurationSection("inventory");
inv.getKeys(false).forEach(i -> ih.setItem(Integer.valueOf(i), (ItemStack)inv.get(i)));
@ -241,18 +268,18 @@ public class Clipboard {
}
@SuppressWarnings("deprecation")
private void copyBlock(Block block, Location origin) {
if (block.getType().equals(Material.AIR)) {
return;
private boolean copyBlock(Block block, Location copyOrigin, boolean copyAir) {
if (!copyAir && block.getType().equals(Material.AIR)) {
return false;
}
// Create position
int x = block.getLocation().getBlockX() - origin.getBlockX();
int y = block.getLocation().getBlockY() - origin.getBlockY();
int z = block.getLocation().getBlockZ() - origin.getBlockZ();
int x = block.getLocation().getBlockX() - copyOrigin.getBlockX();
int y = block.getLocation().getBlockY() - copyOrigin.getBlockY();
int z = block.getLocation().getBlockZ() - copyOrigin.getBlockZ();
String pos = x + "," + y + "," + z;
// Position defines the section
ConfigurationSection s = blockConfig.createSection(pos);
ConfigurationSection s = blockConfig.createSection(BLOCK + "." + pos);
// Set the block type
s.set("type", block.getType().toString());
if (block.getData() != 0) {
@ -265,52 +292,43 @@ public class Clipboard {
// Material Data
MaterialData md = bs.getData();
if (md instanceof Openable) {
Bukkit.getLogger().info("Openable");
Openable open = (Openable)md;
s.set("open", open.isOpen());
}
if (md instanceof Directional) {
Bukkit.getLogger().info("Directional");
Directional facing = (Directional)md;
s.set("facing", facing.getFacing().name());
}
if (md instanceof Attachable) {
Bukkit.getLogger().info("Attachable");
Attachable facing = (Attachable)md;
s.set("facing", facing.getFacing().name());
s.set("attached-face", facing.getAttachedFace().name());
s.set(ATTACHED, true);
}
if (md instanceof Colorable) {
Bukkit.getLogger().info("Colorable");
Colorable c = (Colorable)md;
s.set("color", c.getColor().name());
}
if (block.getType().equals(Material.CARPET)) {
Bukkit.getLogger().info("Carpet");
DyeColor c = DyeColor.getByWoolData(block.getData());
s.set("color", c.name());
}
if (md instanceof Redstone) {
Bukkit.getLogger().info("Redstone");
Redstone r = (Redstone)md;
blockConfig.set("powered", r.isPowered());
}
// Block data
if (bs instanceof Sign) {
Bukkit.getLogger().info("Sign");
Sign sign = (Sign)bs;
s.set("lines", Arrays.asList(sign.getLines()));
}
if (bs instanceof Banner) {
Bukkit.getLogger().info("Banner");
Banner banner = (Banner)bs;
s.set("baseColor", banner.getBaseColor().toString());
banner.getPatterns().forEach(p -> s.set("pattern." + p.getPattern().toString(), p.getColor().toString()));
}
if (bs instanceof InventoryHolder) {
Bukkit.getLogger().info("Inventory holder");
InventoryHolder ih = (InventoryHolder)bs;
for (int index = 0; index < ih.getInventory().getSize(); index++) {
ItemStack i = ih.getInventory().getItem(index);
@ -319,7 +337,7 @@ public class Clipboard {
}
}
}
return true;
}
/**
@ -384,42 +402,52 @@ public class Clipboard {
return copied;
}
/**
* Load a file to clipboard
* @param filename - filename in schems folder
* @return
* @throws IOException
* @throws InvalidConfigurationException
*/
public void load(String fileName) throws IOException, InvalidConfigurationException {
File zipFile = new File(schemFolder, fileName + ".schem");
if (!zipFile.exists()) {
plugin.logError("Could not load schems file - does not exist : " + zipFile.getName());
throw new IOException("Could not load schems file - does not exist : " + zipFile.getName());
}
unzip(zipFile.getAbsolutePath());
File file = new File(schemFolder, fileName);
if (!file.exists()) {
plugin.logError("Could not load schems file - does not exist : " + file.getName());
throw new IOException("Could not load schems file - does not exist : " + file.getName());
}
blockConfig = new YamlConfiguration();
blockConfig.load(file);
copied = true;
Files.delete(file.toPath());
}
/**
* Load a file to clipboard
*/
public boolean load(User user, String string) {
File zipFile = new File(schemFolder, string + ".schem");
if (!zipFile.exists()) {
user.sendMessage("commands.admin.schem.no-such-file");
return false;
}
/**
* @param user - use trying to load
* @param fileName - filename
* @return
*/
public boolean load(User user, String fileName) {
try {
unzip(zipFile.getAbsolutePath());
} catch (IOException e) {
load(fileName);
} catch (IOException e1) {
user.sendMessage("commands.admin.schem.could-not-load");
plugin.logError("Could not load schems file - could not unzip : " + zipFile.getName());
plugin.logError("Could not load schems file: " + fileName + " " + e1.getMessage());
return false;
}
File file = new File(schemFolder, string);
if (!file.exists()) {
} catch (InvalidConfigurationException e1) {
user.sendMessage("commands.admin.schem.could-not-load");
plugin.logError("Could not load schems file - does not exist : " + file.getName());
plugin.logError("Could not load schems file - YAML error : " + fileName + " " + e1.getMessage());
return false;
}
blockConfig = new YamlConfiguration();
try {
blockConfig.load(file);
} catch (Exception e) {
user.sendMessage("commands.admin.schem.could-not-load");
plugin.logError("Could not load schems file - YAML error : " + file.getName());
return false;
}
copied = true;
try {
Files.delete(file.toPath());
} catch (IOException e) {
plugin.logError("Could not delete temporary schems file: " + file.getName());
}
user.sendMessage("general.success");
return true;
}

View File

@ -1,31 +1,33 @@
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.TreeType;
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.entity.EntityType;
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.Constants;
import us.tastybento.bskyblock.Constants.GameType;
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;
/**
* Fired when a team event happens.
* Generates islands
*
* @author tastybento
* @since 1.0
@ -44,12 +46,64 @@ public class IslandBuilder {
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 IslandBuilder(Island island) {
public IslandBuilder(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
*/
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);
}
/**
@ -78,377 +132,32 @@ public class IslandBuilder {
}
public void build() {
plugin.log("Pasting island to " + type);
Location loc = island.getCenter();
// Switch on island type
switch (type) {
case ISLAND:
world = island.getWorld();
if (Constants.GAMETYPE == GameType.ACIDISLAND) {
generateAcidIslandBlocks();
} else {
generateIslandBlocks();
}
break;
case NETHER:
world = Bukkit.getWorld(island.getWorld().getName() + "_nether");
if (world == null) {
return;
}
generateNetherBlocks();
break;
case END:
world = Bukkit.getWorld(island.getWorld().getName() + "_the_end");
if (world == null) {
return;
}
generateEndBlocks();
break;
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
}
/**
* Creates the AcidIsland default island block by block
*/
private void generateAcidIslandBlocks() {
// AcidIsland
// 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);

View File

@ -0,0 +1,487 @@
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;
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.entity.EntityType;
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.Constants.GameType;
import us.tastybento.bskyblock.api.localization.TextVariables;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
/**
* Fired when a team event happens.
*
* @author tastybento
* @since 1.0
*/
public class IslandBuilderOld {
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;
//TODO support companions?
public IslandBuilderOld(Island island) {
this.island = island;
world = island.getWorld();
}
/**
* @param type the type to set
*/
public IslandBuilderOld setType(IslandType type) {
this.type = type;
return this;
}
/**
* @param player - the player the player to set
*/
public IslandBuilderOld setPlayer(Player player) {
playerUUID = player.getUniqueId();
playerName = player.getName();
return this;
}
/**
* @param list the default chestItems to set
*/
public IslandBuilderOld setChestItems(List<ItemStack> list) {
chestItems = list;
return this;
}
public void build() {
// Switch on island type
switch (type) {
case ISLAND:
world = island.getWorld();
if (Constants.GAMETYPE == GameType.ACIDISLAND) {
generateAcidIslandBlocks();
} else {
generateIslandBlocks();
}
break;
case NETHER:
world = Bukkit.getWorld(island.getWorld().getName() + "_nether");
if (world == null) {
return;
}
generateNetherBlocks();
break;
case END:
world = Bukkit.getWorld(island.getWorld().getName() + "_the_end");
if (world == null) {
return;
}
generateEndBlocks();
break;
}
// Do other stuff
}
/**
* Creates the AcidIsland default island block by block
*/
private void generateAcidIslandBlocks() {
// AcidIsland
// 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

@ -120,24 +120,16 @@ public class NewIsland {
.build();
if (!event.isCancelled()) {
// Create island
new IslandBuilder(island)
.setPlayer(user.getPlayer())
.setChestItems(plugin.getSettings().getChestItems())
.setType(IslandType.ISLAND)
.build();
if (plugin.getSettings().isNetherGenerate() && plugin.getSettings().isNetherIslands() && plugin.getIWM().getNetherWorld() != null) {
new IslandBuilder(island)
IslandBuilder ib = new IslandBuilder(plugin, island)
.setPlayer(user.getPlayer())
.setChestItems(plugin.getSettings().getChestItems())
.setType(IslandType.NETHER)
.build();
.setType(IslandType.ISLAND);
ib.build();
if (plugin.getSettings().isNetherGenerate() && plugin.getSettings().isNetherIslands() && plugin.getIWM().getNetherWorld() != null) {
ib.setType(IslandType.NETHER).build();
}
if (plugin.getSettings().isEndGenerate() && plugin.getSettings().isEndIslands() && plugin.getIWM().getEndWorld() != null) {
new IslandBuilder(island)
.setPlayer(user.getPlayer())
.setChestItems(plugin.getSettings().getChestItems())
.setType(IslandType.END)
.build();
ib.setType(IslandType.END).build();
}
// Teleport player to their island
plugin.getIslands().homeTeleport(world, user.getPlayer());