mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-12 13:54:22 +01:00
Added option to not paste a schem when creating a new island
This commit is contained in:
parent
b48cc89f73
commit
2fa60d0e2d
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -31,6 +32,7 @@ public class NewIsland {
|
|||||||
private final Reason reason;
|
private final Reason reason;
|
||||||
private final World world;
|
private final World world;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final boolean noPaste;
|
||||||
|
|
||||||
private enum Result {
|
private enum Result {
|
||||||
ISLAND_FOUND,
|
ISLAND_FOUND,
|
||||||
@ -39,13 +41,14 @@ public class NewIsland {
|
|||||||
FREE
|
FREE
|
||||||
}
|
}
|
||||||
|
|
||||||
private NewIsland(Island oldIsland, User user, Reason reason, World world, String name) {
|
private NewIsland(Island oldIsland, User user, Reason reason, World world, String name, boolean noPaste) {
|
||||||
super();
|
super();
|
||||||
plugin = BentoBox.getInstance();
|
plugin = BentoBox.getInstance();
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.noPaste = noPaste;
|
||||||
newIsland(oldIsland);
|
newIsland(oldIsland);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +78,7 @@ public class NewIsland {
|
|||||||
private Reason reason2;
|
private Reason reason2;
|
||||||
private World world2;
|
private World world2;
|
||||||
private String name2 = "island";
|
private String name2 = "island";
|
||||||
|
private boolean noPaste2;
|
||||||
|
|
||||||
public Builder oldIsland(Island oldIsland) {
|
public Builder oldIsland(Island oldIsland) {
|
||||||
this.oldIsland2 = oldIsland;
|
this.oldIsland2 = oldIsland;
|
||||||
@ -98,6 +102,14 @@ public class NewIsland {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No schematics will be pasted
|
||||||
|
*/
|
||||||
|
public Builder noPaste() {
|
||||||
|
this.noPaste2 = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name - filename of schematic
|
* @param name - filename of schematic
|
||||||
*/
|
*/
|
||||||
@ -108,7 +120,7 @@ public class NewIsland {
|
|||||||
|
|
||||||
public Island build() throws IOException {
|
public Island build() throws IOException {
|
||||||
if (user2 != null) {
|
if (user2 != null) {
|
||||||
NewIsland newIsland = new NewIsland(oldIsland2, user2, reason2, world2, name2);
|
NewIsland newIsland = new NewIsland(oldIsland2, user2, reason2, world2, name2, noPaste2);
|
||||||
return newIsland.getIsland();
|
return newIsland.getIsland();
|
||||||
}
|
}
|
||||||
throw new IOException("Insufficient parameters. Must have a schematic and a player");
|
throw new IOException("Insufficient parameters. Must have a schematic and a player");
|
||||||
@ -150,8 +162,8 @@ public class NewIsland {
|
|||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create island
|
// Task to run after creating the island
|
||||||
plugin.getSchemsManager().paste(world, island, name, () -> {
|
Runnable task = () -> {
|
||||||
// Set initial spawn point if one exists
|
// Set initial spawn point if one exists
|
||||||
if (island.getSpawnPoint(Environment.NORMAL) != null) {
|
if (island.getSpawnPoint(Environment.NORMAL) != null) {
|
||||||
plugin.getPlayers().setHomeLocation(user, island.getSpawnPoint(Environment.NORMAL), 1);
|
plugin.getPlayers().setHomeLocation(user, island.getSpawnPoint(Environment.NORMAL), 1);
|
||||||
@ -191,7 +203,12 @@ public class NewIsland {
|
|||||||
.island(island)
|
.island(island)
|
||||||
.location(island.getCenter())
|
.location(island.getCenter())
|
||||||
.build();
|
.build();
|
||||||
});
|
};
|
||||||
|
if (noPaste) {
|
||||||
|
Bukkit.getScheduler().runTask(plugin, task);
|
||||||
|
} else {
|
||||||
|
// Create island
|
||||||
|
plugin.getSchemsManager().paste(world, island, name, task);
|
||||||
// Make nether island
|
// Make nether island
|
||||||
if (plugin.getIWM().isNetherGenerate(world) && plugin.getIWM().isNetherIslands(world) && plugin.getIWM().getNetherWorld(world) != null) {
|
if (plugin.getIWM().isNetherGenerate(world) && plugin.getIWM().isNetherIslands(world) && plugin.getIWM().getNetherWorld(world) != null) {
|
||||||
plugin.getSchemsManager().paste(plugin.getIWM().getNetherWorld(world), island, "nether-" + name);
|
plugin.getSchemsManager().paste(plugin.getIWM().getNetherWorld(world), island, "nether-" + name);
|
||||||
@ -201,7 +218,7 @@ public class NewIsland {
|
|||||||
if (plugin.getIWM().isEndGenerate(world) && plugin.getIWM().isEndIslands(world) && plugin.getIWM().getEndWorld(world) != null) {
|
if (plugin.getIWM().isEndGenerate(world) && plugin.getIWM().isEndIslands(world) && plugin.getIWM().getEndWorld(world) != null) {
|
||||||
plugin.getSchemsManager().paste(plugin.getIWM().getEndWorld(world), island, "end-" + name);
|
plugin.getSchemsManager().paste(plugin.getIWM().getEndWorld(world), island, "end-" + name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Set default settings
|
// Set default settings
|
||||||
island.setFlagsDefaults();
|
island.setFlagsDefaults();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user