diff --git a/pom.xml b/pom.xml
index 43cc7b1..44a4f14 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
ch.mixin
IslandGenerator
- 1.2.2
+ 1.2.3
jar
IslandGenerator
diff --git a/src/main/java/ch/mixin/islandgenerator/command/commandList/ConfigCommand.java b/src/main/java/ch/mixin/islandgenerator/command/commandList/ConfigCommand.java
index ab44630..ee5a444 100644
--- a/src/main/java/ch/mixin/islandgenerator/command/commandList/ConfigCommand.java
+++ b/src/main/java/ch/mixin/islandgenerator/command/commandList/ConfigCommand.java
@@ -13,6 +13,7 @@
public class ConfigCommand extends SubCommand {
private final HashMap subCommandMap;
private final HashMap numberMinList;
+ private final List integerList;
public ConfigCommand(IslandGeneratorPlugin plugin) {
super(plugin);
@@ -25,6 +26,10 @@ public ConfigCommand(IslandGeneratorPlugin plugin) {
numberMinList.put("spawnRadius", 1);
numberMinList.put("islandDistance", 1);
numberMinList.put("islandRadius", 1);
+
+ integerList = new ArrayList<>();
+ integerList.add("maximumHeight");
+ integerList.add("minimumHeight");
}
@Override
@@ -54,8 +59,15 @@ public void execute(CommandSender sender, List arguments) {
}
String key = arguments.get(0);
- if (numberMinList.containsKey(key)) {
- int min = numberMinList.get(key);
+ if (numberMinList.containsKey(key) || integerList.contains(key)) {
+ boolean checkMinimum = false;
+ int min = 0;
+
+ if (numberMinList.containsKey(key)) {
+ checkMinimum = true;
+ min = numberMinList.get(key);
+ }
+
int value;
try {
@@ -65,7 +77,7 @@ public void execute(CommandSender sender, List arguments) {
return;
}
- if (value < min) {
+ if (checkMinimum && value < min) {
sender.sendMessage(ChatColor.RED + "Value must be at least " + min + ".");
return;
}
@@ -86,6 +98,7 @@ public List getOptions(List arguments) {
if (arguments.size() == 1) {
options.addAll(subCommandMap.keySet());
options.addAll(numberMinList.keySet());
+ options.addAll(integerList);
} else if (arguments.size() == 2) {
options.add("");
}
diff --git a/src/main/java/ch/mixin/islandgenerator/islandGeneration/IslandManager.java b/src/main/java/ch/mixin/islandgenerator/islandGeneration/IslandManager.java
index dbfdbca..e0e0694 100644
--- a/src/main/java/ch/mixin/islandgenerator/islandGeneration/IslandManager.java
+++ b/src/main/java/ch/mixin/islandgenerator/islandGeneration/IslandManager.java
@@ -79,7 +79,14 @@ public void startIslandGeneration() {
HashMap worldDataMap = plugin.getMetaData().getWorldDataMap();
Random random = plugin.getRandom();
HashMap> islandDataMap = new HashMap<>();
- List worldNames = IslandGeneratorPlugin.PLUGIN.getConfig().getStringList("worlds");
+ List worldNames = plugin.getConfig().getStringList("worlds");
+
+ int maximumHeight = plugin.getConfig().getInt("maximumHeight");
+ int minimumHeight = plugin.getConfig().getInt("minimumHeight");
+ int centerHeight = (maximumHeight - minimumHeight) / 2;
+
+ int spawnRadius = plugin.getConfig().getInt("spawnRadius");
+ int islandDistance = plugin.getConfig().getInt("islandDistance");
for (String worldName : worldNames) {
World world = plugin.getServer().getWorld(worldName);
@@ -99,15 +106,14 @@ public void startIslandGeneration() {
islandDataMap.put(world, newIslandDataList);
int limit = worldData.getSpawnRadius();
- if (limit >= plugin.getConfig().getInt("spawnRadius"))
+ if (limit >= spawnRadius)
continue;
ArrayList islandDatas = worldData.getIslandDatas();
- int yCenter = world.getMaxHeight() / 2;
- int yMin = Math.max(0, yCenter - plugin.getConfig().getInt("spawnRadius"));
- int yMax = Math.min(world.getMaxHeight(), yCenter + plugin.getConfig().getInt("spawnRadius"));
+ int yMin = Math.max(minimumHeight, centerHeight - spawnRadius);
+ int yMax = Math.min(maximumHeight, centerHeight + spawnRadius);
- int iterations = (int) (Math.pow(2 * plugin.getConfig().getInt("spawnRadius") + 1, 2) * (yMax - yMin + 1) / Math.pow(plugin.getConfig().getInt("islandDistance"), 3));
+ int iterations = (int) (Math.pow(2 * spawnRadius + 1, 2) * (yMax - yMin + 1) / Math.pow(islandDistance, 3));
consolePrint("Island Pointing: " + worldName + " x" + iterations);
int percentile = 0;
@@ -118,9 +124,9 @@ public void startIslandGeneration() {
consolePrint("Island Pointing: " + worldName + " " + percentile + "%");
}
- int x = random.nextInt(plugin.getConfig().getInt("spawnRadius") + 1) * (random.nextBoolean() ? 1 : -1);
+ int x = random.nextInt(spawnRadius + 1) * (random.nextBoolean() ? 1 : -1);
int y = random.nextInt(yMax + 1 - yMin) + yMin;
- int z = random.nextInt(plugin.getConfig().getInt("spawnRadius") + 1) * (random.nextBoolean() ? 1 : -1);
+ int z = random.nextInt(spawnRadius + 1) * (random.nextBoolean() ? 1 : -1);
if (x < limit && x > -limit
&& y < limit && y > -limit
@@ -130,7 +136,7 @@ public void startIslandGeneration() {
Coordinate3D newIslandCenter = new Coordinate3D(x, y, z);
for (IslandData islandData : islandDatas) {
- if (newIslandCenter.distance(islandData.getIslandCenter()) < plugin.getConfig().getInt("islandDistance"))
+ if (newIslandCenter.distance(islandData.getIslandCenter()) < islandDistance)
continue islandLoop;
}
@@ -139,7 +145,7 @@ public void startIslandGeneration() {
newIslandDataList.add(newIslandData);
}
- worldData.setSpawnRadius(plugin.getConfig().getInt("spawnRadius"));
+ worldData.setSpawnRadius(spawnRadius);
consolePrint("Finish Island Pointing: " + worldName);
consolePrint("+" + newIslandDataList.size() + " new Islands");
}
diff --git a/src/main/java/ch/mixin/islandgenerator/islandGeneration/islandConstructor/IslandConstructor.java b/src/main/java/ch/mixin/islandgenerator/islandGeneration/islandConstructor/IslandConstructor.java
index 58d7e8c..ab3824f 100644
--- a/src/main/java/ch/mixin/islandgenerator/islandGeneration/islandConstructor/IslandConstructor.java
+++ b/src/main/java/ch/mixin/islandgenerator/islandGeneration/islandConstructor/IslandConstructor.java
@@ -17,25 +17,33 @@
import java.util.Random;
public class IslandConstructor {
+ private final IslandGeneratorPlugin plugin;
private final IslandShapeGenerator islandShapeGenerator;
private final NameGenerator nameGenerator = new NameGenerator(new Random());
private final TitleGenerator titleGenerator = new TitleGenerator(new Random());
public IslandConstructor(IslandGeneratorPlugin plugin) {
+ this.plugin = plugin;
islandShapeGenerator = new IslandShapeGenerator(plugin);
}
public IslandBlueprint constructIsland(World world, IslandData islandData) {
Coordinate3D center = islandData.getIslandCenter();
IslandConstructorPremise islandConstructorPremise = new IslandConstructorPremise();
- IslandShape islandShape = islandShapeGenerator.generateIslandShape(world.getMaxHeight());
+ IslandShape islandShape = islandShapeGenerator.generateIslandShape(
+ plugin.getConfig().getInt("maximumHeight")
+ - plugin.getConfig().getInt("minimumHeight")
+ );
+
+ int maximumHeight = plugin.getConfig().getInt("maximumHeight");
+ int minimumHeight = plugin.getConfig().getInt("minimumHeight");
ArrayList emptyRoofSpaces = new ArrayList<>(islandShape.getLayerTop());
Coordinate3D lootPosition = constructLootPosition(center, emptyRoofSpaces);
- HashMap blockMap = constructBlocks(islandConstructorPremise, center, islandShape);
+ HashMap blockMap = constructBlocks(islandConstructorPremise, center, maximumHeight, minimumHeight, islandShape);
HashMap treeMap = constructTrees(islandConstructorPremise, center, emptyRoofSpaces);
- ArrayList cactusList = constructCacti(islandConstructorPremise, center, emptyRoofSpaces, blockMap);
+ ArrayList cactusList = constructCacti(islandConstructorPremise, center, maximumHeight, minimumHeight, emptyRoofSpaces, blockMap);
ArrayList names = constructNames();
Coordinate3D nameLocation = lootPosition.sum(0, 3, 0);
@@ -51,22 +59,31 @@ private Coordinate3D constructLootPosition(Coordinate3D center, ArrayList constructBlocks(IslandConstructorPremise islandConstructorPremise, Coordinate3D center, IslandShape islandShape) {
+ private HashMap constructBlocks(IslandConstructorPremise islandConstructorPremise, Coordinate3D center, int maximumHeight, int minimumHeight, IslandShape islandShape) {
HashMap blockMap = new HashMap<>();
if (islandConstructorPremise.getBlockTypesBot().size() > 0) {
for (Coordinate3D c3d : islandShape.getLayerBot()) {
- blockMap.put(c3d.sum(center), Functions.getRandomWithWeights(islandConstructorPremise.getBlockTypesBot()));
+ Coordinate3D point = c3d.sum(center);
+
+ if (point.getY() >= minimumHeight && point.getY() <= maximumHeight)
+ blockMap.put(point, Functions.getRandomWithWeights(islandConstructorPremise.getBlockTypesBot()));
}
}
for (Coordinate3D c3d : islandShape.getLayerMid()) {
- blockMap.put(c3d.sum(center), Functions.getRandomWithWeights(islandConstructorPremise.getBlockTypesMid()));
+ Coordinate3D point = c3d.sum(center);
+
+ if (point.getY() >= minimumHeight && point.getY() <= maximumHeight)
+ blockMap.put(point, Functions.getRandomWithWeights(islandConstructorPremise.getBlockTypesMid()));
}
if (islandConstructorPremise.getBlockTypesTop().size() > 0) {
for (Coordinate3D c3d : islandShape.getLayerTop()) {
- blockMap.put(c3d.sum(center), Functions.getRandomWithWeights(islandConstructorPremise.getBlockTypesTop()));
+ Coordinate3D point = c3d.sum(center);
+
+ if (point.getY() >= minimumHeight && point.getY() <= maximumHeight)
+ blockMap.put(point, Functions.getRandomWithWeights(islandConstructorPremise.getBlockTypesTop()));
}
}
@@ -89,7 +106,7 @@ private HashMap constructTrees(IslandConstructorPremise
return treeMap;
}
- private ArrayList constructCacti(IslandConstructorPremise islandConstructorPremise, Coordinate3D center, ArrayList emptyRoofSpaces, HashMap blockMap) {
+ private ArrayList constructCacti(IslandConstructorPremise islandConstructorPremise, Coordinate3D center, int maximumHeight, int minimumHeight, ArrayList emptyRoofSpaces, HashMap blockMap) {
ArrayList cactusList = new ArrayList<>();
for (int i = 0; i < emptyRoofSpaces.size(); i++) {
@@ -104,7 +121,12 @@ private ArrayList constructCacti(IslandConstructorPremise islandCo
i--;
for (int height = 0; height < 3; height++) {
- cactusList.add(c3d.sum(center).sum(0, height + 1, 0));
+ Coordinate3D point = c3d.sum(center).sum(0, height + 1, 0);
+
+ if (point.getY() < minimumHeight || point.getY() > maximumHeight)
+ break;
+
+ cactusList.add(point);
height++;
}
}
diff --git a/src/main/java/ch/mixin/islandgenerator/islandGeneration/islandShape/IslandShapeGenerator.java b/src/main/java/ch/mixin/islandgenerator/islandGeneration/islandShape/IslandShapeGenerator.java
index 4841182..1cbc430 100644
--- a/src/main/java/ch/mixin/islandgenerator/islandGeneration/islandShape/IslandShapeGenerator.java
+++ b/src/main/java/ch/mixin/islandgenerator/islandGeneration/islandShape/IslandShapeGenerator.java
@@ -11,14 +11,14 @@
import java.util.stream.Collectors;
public class IslandShapeGenerator {
- private IslandGeneratorPlugin plugin;
+ private final IslandGeneratorPlugin plugin;
private IslandShapePremise islandShapePremise;
public IslandShapeGenerator(IslandGeneratorPlugin plugin) {
this.plugin = plugin;
}
- public IslandShape generateIslandShape(int worldMaxHeight) {
+ public IslandShape generateIslandShape(int spawnRegionHeight) {
islandShapePremise = new IslandShapePremise(plugin.getConfig().getInt("islandDistance"), plugin.getConfig().getInt("islandRadius"));
ArrayList basePlane = generateBasePlane();
@@ -28,7 +28,7 @@ public IslandShape generateIslandShape(int worldMaxHeight) {
subPlane = new ArrayList<>(basePlane);
- for (int i = 1; i <= worldMaxHeight && i <= plugin.getConfig().getInt("islandDistance") * 0.5; i++) {
+ for (int i = 1; i <= spawnRegionHeight && i <= plugin.getConfig().getInt("islandDistance") * 0.5; i++) {
subPlane = generateSubPlane(subPlane, islandShapePremise.getPlaneTopReducers(), islandShapePremise.getTopFlatness());
if (subPlane.size() == 0)
break;
@@ -37,7 +37,7 @@ public IslandShape generateIslandShape(int worldMaxHeight) {
subPlane = new ArrayList<>(basePlane);
- for (int i = 1; i <= worldMaxHeight && i <= plugin.getConfig().getInt("islandDistance") * 0.5; i++) {
+ for (int i = 1; i <= spawnRegionHeight && i <= plugin.getConfig().getInt("islandDistance") * 0.5; i++) {
subPlane = generateSubPlane(subPlane, islandShapePremise.getPlaneBotReducers(), islandShapePremise.getBotFlatness());
if (subPlane.size() == 0)
break;
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index d48df8c..dd524ad 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -4,4 +4,6 @@ islandRadius: 20
tickBuffer: 1
worlds:
- world
+maximumHeight: 255
+minimumHeight: 0
lootMultiplier: 20