Fixed settings. Implemented useowngenerator

This commit is contained in:
tastybento 2018-07-06 08:07:37 -07:00
parent a72a49975f
commit a60bcc8a22
4 changed files with 43 additions and 5 deletions

View File

@ -166,7 +166,9 @@ public class Settings implements DataObject, WorldSettings {
@ConfigEntry(path = "world.start-z", needsReset = true)
private int islandStartZ = 0;
@ConfigEntry(path = "world.offset-x")
private int islandXOffset;
@ConfigEntry(path = "world.offset-z")
private int islandZOffset;
@ConfigComment("Island height - Lowest is 5.")
@ -174,6 +176,11 @@ public class Settings implements DataObject, WorldSettings {
@ConfigEntry(path = "world.island-height")
private int islandHeight = 100;
@ConfigComment("Use your own world generator for this world. In this case, the plugin will not generate")
@ConfigComment("anything.")
@ConfigEntry(path = "world.use-own-generator")
private boolean useOwnGenerator;
@ConfigComment("Sea height (don't changes this mid-game unless you delete the world)")
@ConfigComment("Minimum is 0, which means you are playing Skyblock!")
@ConfigComment("If sea height is less than about 10, then players will drop right through it")
@ -422,8 +429,6 @@ public class Settings implements DataObject, WorldSettings {
private EntityType companionType = EntityType.COW;
private boolean useOwnGenerator;
private Map<String,Integer> limitedBlocks = new HashMap<>();
private boolean teamJoinDeathReset;
@ -943,6 +948,7 @@ public class Settings implements DataObject, WorldSettings {
/**
* @return the useOwnGenerator
*/
@Override
public boolean isUseOwnGenerator() {
return useOwnGenerator;
}

View File

@ -203,5 +203,10 @@ public interface WorldSettings {
Map<Flag, Integer> getDefaultIslandSettings();
/**
* @return true if the default world generator should not operate in this world
*/
boolean isUseOwnGenerator();
}

View File

@ -54,7 +54,25 @@ public class IslandWorldManager {
worlds = new HashMap<>();
worldSettings = new HashMap<>();
if (plugin.getSettings().isUseOwnGenerator()) {
// Do nothing
plugin.log("Default world generator disabled.");
islandWorld = Bukkit.getWorld(plugin.getSettings().getWorldName());
if (plugin.getSettings().isNetherGenerate()) {
netherWorld = plugin.getServer().getWorld(plugin.getSettings().getWorldName() + NETHER);
if (netherWorld == null) {
plugin.logError("Island nether world does not exist - you must create it manually");
}
}
if (plugin.getSettings().isEndGenerate()) {
endWorld = plugin.getServer().getWorld(plugin.getSettings().getWorldName() + THE_END);
if (endWorld == null) {
plugin.logError("Island end world does not exist - you must create it manually");
}
}
if (islandWorld != null) {
addWorld(islandWorld, plugin.getSettings());
} else {
plugin.logError("Island world does not exist - you must create it manually");
}
return;
}
if (plugin.getServer().getWorld(plugin.getSettings().getWorldName()) == null) {
@ -90,8 +108,12 @@ public class IslandWorldManager {
}
}
/**
* Registers a world with Multiverse if the plugin exists
* @param world - world
*/
private void multiverseReg(World world) {
if (Bukkit.getServer().getPluginManager().isPluginEnabled("Multiverse-Core")) {
if (!isUseOwnGenerator(world) && Bukkit.getServer().getPluginManager().isPluginEnabled("Multiverse-Core")) {
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
MULTIVERSE_IMPORT + world.getName() + " normal -g " + plugin.getName()));
Bukkit.getScheduler().runTask(plugin, () -> {
@ -583,4 +605,9 @@ public class IslandWorldManager {
public Map<Flag, Integer> getDefaultIslandSettings(World world) {
return worldSettings.get(Util.getWorld(world)).getDefaultIslandSettings();
}
public boolean isUseOwnGenerator(World world) {
return worldSettings.get(Util.getWorld(world)).isUseOwnGenerator();
}
}

View File

@ -221,7 +221,7 @@ public class NewIsland {
return Result.ISLAND_FOUND;
}
if (!plugin.getSettings().isUseOwnGenerator()) {
if (!plugin.getIWM().isUseOwnGenerator(location.getWorld())) {
// Block check
if (!location.getBlock().isEmpty() && !location.getBlock().isLiquid()) {
plugin.getIslands().createIsland(location);