diff --git a/.gitignore b/.gitignore
index fb448c0..172f9ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,10 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
-IslandCraft-NMS-v1_8_R1/bin/
+**/bin/
+**/build/
+**/.settings/
+/.checkstyle/
+/.gradle/
*.class
-*.yml
-/bin/
+*.classpath
+*.jar
+!/gradle/wrapper/gradle-wrapper.jar
+*.project
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/BiomeDistribution.java b/IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/BiomeDistribution.java
similarity index 100%
rename from IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/BiomeDistribution.java
rename to IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/BiomeDistribution.java
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICBiome.java b/IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICBiome.java
similarity index 100%
rename from IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICBiome.java
rename to IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICBiome.java
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICIsland.java b/IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICIsland.java
similarity index 100%
rename from IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICIsland.java
rename to IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICIsland.java
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICLocation.java b/IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICLocation.java
similarity index 100%
rename from IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICLocation.java
rename to IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICLocation.java
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICRegion.java b/IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICRegion.java
similarity index 100%
rename from IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICRegion.java
rename to IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICRegion.java
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICWorld.java b/IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICWorld.java
similarity index 100%
rename from IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICWorld.java
rename to IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/ICWorld.java
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandCraft.java b/IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandCraft.java
similarity index 100%
rename from IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandCraft.java
rename to IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandCraft.java
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandDistribution.java b/IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandDistribution.java
similarity index 100%
rename from IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandDistribution.java
rename to IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandDistribution.java
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandGenerator.java b/IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandGenerator.java
similarity index 100%
rename from IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandGenerator.java
rename to IslandCraft-API/src/main/java/com/github/hoqhuuep/islandcraft/api/IslandGenerator.java
diff --git a/IslandCraft-Api/.gitignore b/IslandCraft-Api/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-Api/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-Api/pom.xml b/IslandCraft-Api/pom.xml
deleted file mode 100644
index 1f363ef..0000000
--- a/IslandCraft-Api/pom.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-Api
-
\ No newline at end of file
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/BiomeGeneratorListener.java b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/BiomeGeneratorListener.java
similarity index 95%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/BiomeGeneratorListener.java
rename to IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/BiomeGeneratorListener.java
index ca7f06c..e57da73 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/BiomeGeneratorListener.java
+++ b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/BiomeGeneratorListener.java
@@ -12,10 +12,8 @@
import org.bukkit.event.world.WorldInitEvent;
import com.github.hoqhuuep.islandcraft.api.ICWorld;
-import com.github.hoqhuuep.islandcraft.api.IslandCraft;
import com.github.hoqhuuep.islandcraft.core.ICLogger;
import com.github.hoqhuuep.islandcraft.core.IslandCache;
-import com.github.hoqhuuep.islandcraft.core.DefaultIslandCraft;
import com.github.hoqhuuep.islandcraft.core.DefaultWorld;
import com.github.hoqhuuep.islandcraft.core.ICClassLoader;
import com.github.hoqhuuep.islandcraft.core.IslandDatabase;
@@ -60,7 +58,7 @@ public void onWorldInit(final WorldInitEvent event) {
return;
}
ICLogger.logger.info("Installing biome generator in WorldInitEvent for world with name: " + worldName);
- final ICWorld icWorld = new DefaultWorld(worldName, world.getSeed(), database, config, cache, classLoader);
+ final ICWorld icWorld = new DefaultWorld(worldName, world.getSeed(), database, new BukkitWorldConfig(worldName, config), cache, classLoader);
final BiomeGenerator biomeGenerator = new IslandCraftBiomeGenerator(icWorld);
nms.installBiomeGenerator(world, biomeGenerator);
worldsDone.add(worldName);
@@ -87,7 +85,7 @@ public void onChunkLoad(final ChunkLoadEvent event) {
return;
}
ICLogger.logger.info("Installing biome generator in ChunkLoadEvent for world with name: " + worldName);
- final ICWorld icWorld = new DefaultWorld(worldName, world.getSeed(), database, config, cache, classLoader);
+ final ICWorld icWorld = new DefaultWorld(worldName, world.getSeed(), database, new BukkitWorldConfig(worldName, config), cache, classLoader);
final BiomeGenerator biomeGenerator = new IslandCraftBiomeGenerator(icWorld);
if (nms.installBiomeGenerator(world, biomeGenerator)) {
// If this is the very first time, regenerate the chunk
diff --git a/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/BukkitWorldConfig.java b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/BukkitWorldConfig.java
new file mode 100644
index 0000000..02212fd
--- /dev/null
+++ b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/BukkitWorldConfig.java
@@ -0,0 +1,49 @@
+package com.github.hoqhuuep.islandcraft.bukkit;
+
+import java.util.List;
+
+import org.bukkit.configuration.ConfigurationSection;
+
+import com.github.hoqhuuep.islandcraft.core.ICWorldConfig;
+import com.github.hoqhuuep.islandcraft.core.ICLogger;
+
+public class BukkitWorldConfig implements ICWorldConfig {
+ private final String worldName;
+ private final ConfigurationSection config;
+
+ public BukkitWorldConfig(String worldName, ConfigurationSection config) {
+ this.worldName = worldName;
+ this.config = config;
+ }
+
+ @Override
+ public String getOcean() {
+ if (!config.contains("ocean") || !config.isString("ocean")) {
+ ICLogger.logger.warning("No string-value for 'worlds." + worldName + ".ocean' found in config.yml");
+ ICLogger.logger.warning("Default value 'com.github.hoqhuuep.islandcraft.core.ConstantBiomeDistribution DEEP_OCEAN' will be used");
+ }
+ return config.getString("ocean", "com.github.hoqhuuep.islandcraft.core.ConstantBiomeDistribution DEEP_OCEAN");
+ }
+
+ @Override
+ public String getIslandDistribution() {
+ if (!config.contains("island-distribution") || !config.isString("island-distribution")) {
+ ICLogger.logger.warning("No string-value for 'worlds." + worldName + ".island-distribution' found in config.yml");
+ ICLogger.logger.warning("Default value 'com.github.hoqhuuep.islandcraft.core.EmptyIslandDistribution' will be used");
+ }
+ return config.getString("island-distribution", "com.github.hoqhuuep.islandcraft.core.EmptyIslandDistribution");
+ }
+
+ @Override
+ public String[] getIslandGenerstors() {
+ if (!config.contains("island-generators") || !config.isList("island-generators")) {
+ ICLogger.logger.warning("No list-value for 'worlds." + worldName + ".island-generators' found in config.yml");
+ ICLogger.logger.warning("Default value '[com.github.hoqhuuep.islandcraft.core.EmptyIslandGenerator]' will be used");
+ }
+ List islandGenerators = config.getStringList("island-generators");
+ if (islandGenerators.isEmpty()) {
+ islandGenerators.add("com.github.hoqhuuep.islandcraft.core.EmptyIslandGenerator");
+ }
+ return islandGenerators.toArray(new String[islandGenerators.size()]);
+ }
+}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EbeanServerIslandDatabase.java b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/EbeanServerIslandDatabase.java
similarity index 97%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EbeanServerIslandDatabase.java
rename to IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/EbeanServerIslandDatabase.java
index 98df535..1ebbb7f 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EbeanServerIslandDatabase.java
+++ b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/EbeanServerIslandDatabase.java
@@ -1,4 +1,4 @@
-package com.github.hoqhuuep.islandcraft.core;
+package com.github.hoqhuuep.islandcraft.bukkit;
import java.io.Serializable;
@@ -9,6 +9,8 @@
import javax.persistence.Table;
import com.avaje.ebean.EbeanServer;
+import com.github.hoqhuuep.islandcraft.core.ICLogger;
+import com.github.hoqhuuep.islandcraft.core.IslandDatabase;
public class EbeanServerIslandDatabase implements IslandDatabase {
private final EbeanServer ebeanServer;
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EbeanServerUtil.java b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/EbeanServerUtil.java
similarity index 97%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EbeanServerUtil.java
rename to IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/EbeanServerUtil.java
index b1ce02e..670dc73 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EbeanServerUtil.java
+++ b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/EbeanServerUtil.java
@@ -1,4 +1,4 @@
-package com.github.hoqhuuep.islandcraft.core;
+package com.github.hoqhuuep.islandcraft.bukkit;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -17,6 +17,7 @@
import com.avaje.ebeaninternal.api.SpiEbeanServer;
import com.avaje.ebeaninternal.server.ddl.DdlGenerator;
import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation;
+import com.github.hoqhuuep.islandcraft.core.ICLogger;
public class EbeanServerUtil {
public static EbeanServer build(final JavaPlugin javaPlugin) {
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java
similarity index 98%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java
rename to IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java
index 4ed3d31..9d843df 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java
+++ b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java
@@ -42,6 +42,6 @@ public ICBiome[] generateChunkBiomes(final int x, final int z) {
@Override
public void cleanupCache() {
- // NOP
+ // Nothing to do
}
}
diff --git a/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftPlugin.java b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftPlugin.java
new file mode 100644
index 0000000..c4dab39
--- /dev/null
+++ b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftPlugin.java
@@ -0,0 +1,236 @@
+package com.github.hoqhuuep.islandcraft.bukkit;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+
+import org.bukkit.Bukkit;
+import org.bukkit.World;
+import org.bukkit.WorldCreator;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Listener;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.mcstats.Metrics;
+
+import com.avaje.ebean.EbeanServer;
+import com.github.hoqhuuep.islandcraft.api.ICLocation;
+import com.github.hoqhuuep.islandcraft.api.ICRegion;
+import com.github.hoqhuuep.islandcraft.api.IslandCraft;
+import com.github.hoqhuuep.islandcraft.core.DefaultIslandCraft;
+import com.github.hoqhuuep.islandcraft.core.ICLogger;
+import com.github.hoqhuuep.islandcraft.core.IslandDatabase;
+import com.github.hoqhuuep.islandcraft.nms.NmsWrapper;
+
+public class IslandCraftPlugin extends JavaPlugin {
+
+ private DefaultIslandCraft islandCraft = null;
+
+ @Override
+ public void onEnable() {
+ ICLogger.logger = new JavaUtilLogger(getLogger());
+
+ // https://github.com/Hidendra/Plugin-Metrics/wiki/Usage
+ try {
+ final Metrics metrics = new Metrics(this);
+ metrics.start();
+ } catch (final Exception e) {
+ ICLogger.logger.warning("Failed to start MCStats");
+ }
+
+ saveDefaultConfig();
+ FileConfiguration config = getConfig();
+ if (!config.contains("config-version") || !config.isString("config-version")) {
+ ICLogger.logger.error("No string-value for 'config-version' found in config.yml");
+ ICLogger.logger.error("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
+ setEnabled(false);
+ return;
+ }
+ final String configVersion = config.getString("config-version");
+ if (!configVersion.equals("1.0.0")) {
+ ICLogger.logger.error("Incompatible config-version found in config.yml");
+ ICLogger.logger.error("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
+ setEnabled(false);
+ return;
+ }
+
+ if (!config.contains("verbose-logging") || !config.isBoolean("verbose-logging")) {
+ ICLogger.logger.warning("No boolean-value for 'verbose-logging' found in config.yml");
+ ICLogger.logger.warning("Default value 'false' will be used");
+ }
+ final boolean verboseLogging = config.getBoolean("verbose-logging", false);
+ getLogger().setLevel(verboseLogging ? Level.ALL : Level.WARNING);
+
+ final NmsWrapper nms = NmsWrapper.getInstance(getServer());
+ if (nms == null) {
+ ICLogger.logger.error("IslandCraft does not currently support this CraftBukkit version");
+ ICLogger.logger.error("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
+ setEnabled(false);
+ return;
+ }
+
+ IslandDatabase database;
+ try {
+ final EbeanServer ebeanServer = EbeanServerUtil.build(this);
+ database = new EbeanServerIslandDatabase(ebeanServer);
+ } catch (final Exception e) {
+ ICLogger.logger.error("Error creating EbeanServer database");
+ ICLogger.logger.error("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
+ ICLogger.logger.error("Exception message: " + e.getMessage());
+ setEnabled(false);
+ return;
+ }
+
+ try {
+ islandCraft = new DefaultIslandCraft();
+ final Listener listener = new BiomeGeneratorListener(this, database, nms);
+ getServer().getPluginManager().registerEvents(listener, this);
+ } catch (final Exception e) {
+ ICLogger.logger.error("Error creating or registering BiomeGeneratorListener");
+ ICLogger.logger.error("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
+ ICLogger.logger.error("Exception message: " + e.getMessage());
+ setEnabled(false);
+ return;
+ }
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ if (sender instanceof Player) {
+ sender.sendMessage("This command can only be executed by console!");
+ return false;
+ }
+ if (args.length == 0) {
+ sender.sendMessage("/ic ");
+ return false;
+ }
+ if ("reload".equals(args[0])) {
+ sender.sendMessage("Reloaded IslandCraft configuration");
+ reloadConfig();
+ } else if ("create".equals(args[0])) {
+ // ic create 2 1 ConstantBiomeDistribution IslandGeneratorAlpha
+ if (args.length < 4) {
+ sender.sendMessage("/ic create ");
+ sender.sendMessage("OR");
+ sender.sendMessage("/ic create [distribution] [generator]");
+ sender.sendMessage("Note: An island size of 1 = 4 chunks");
+ return false;
+ }
+ String world = args[1];
+ int island;
+ int ocean;
+ try {
+ island = Integer.parseInt(args[2]) * 32;
+ ocean = Integer.parseInt(args[3]) * 32;
+ } catch (Exception e) {
+ sender.sendMessage("Invalid size for:");
+ sender.sendMessage("/ic create [distribution] [generator]");
+ return false;
+ }
+ String distribution = "SquareIslandDistribution";
+ String generator = "IslandGeneratorAlpha";
+ if (args.length > 4) {
+ distribution = args[4];
+ }
+ if (args.length > 5) {
+ distribution = args[5];
+ }
+ FileConfiguration config = getConfig();
+ String path = "worlds." + world;
+ config.set(path + "." + "ocean",
+ "com.github.hoqhuuep.islandcraft.core.ConstantBiomeDistribution DEEP_OCEAN");
+ config.set(path + "." + "island-distribution",
+ "com.github.hoqhuuep.islandcraft.core." + distribution + " " + island + " " + ocean);
+ String[] gen_types = {
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " BIRCH_FOREST BIRCH_FOREST_M BIRCH_FOREST_HILLS BIRCH_FOREST_HILLS_M ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " COLD_TAIGA COLD_TAIGA_M COLD_TAIGA_HILLS ~ ~ ~ OCEAN COLD_BEACH FROZEN_RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " DESERT DESERT_M DESERT_HILLS ~ ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " EXTREME_HILLS EXTREME_HILLS_M EXTREME_HILLS_PLUS EXTREME_HILLS_PLUS_M EXTREME_HILLS_EDGE ~ OCEAN STONE_BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " FOREST ~ FOREST_HILLS ~ FLOWER_FOREST ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " ICE_PLAINS ~ ICE_MOUNTAINS ~ ICE_PLAINS_SPIKES ~ OCEAN FROZEN_OCEAN FROZEN_RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " JUNGLE JUNGLE_M JUNGLE_HILLS ~ JUNGLE_EDGE JUNGLE_EDGE_M OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " MEGA_TAIGA MEGA_SPRUCE_TAIGA MEGA_TAIGA_HILLS MEGA_SPRUCE_TAIGA_HILLS ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " MESA MESA_BRYCE MESA_PLATEAU MESA_PLATEAU_M MESA_PLATEAU_F MESA_PLATEAU_F_M OCEAN MESA RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " MUSHROOM_ISLAND ~ ~ ~ ~ ~ OCEAN MUSHROOM_ISLAND_SHORE RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " PLAINS ~ SUNFLOWER_PLAINS ~ ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " ROOFED_FOREST ROOFED_FOREST_M ~ ~ ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " SAVANNA SAVANNA_M SAVANNA_PLATEAU SAVANNA_PLATEAU_M ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " SWAMPLAND SWAMPLAND_M ~ ~ ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core." + generator
+ + " TAIGA TAIGA_M TAIGA_HILLS ~ ~ ~ OCEAN BEACH RIVER" };
+
+ config.set(path + "." + "island-generators", gen_types);
+
+ sender.sendMessage("Saving configuration!");
+ saveConfig();
+ reloadConfig();
+ sender.sendMessage("Generating world; please wait...");
+ if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null)
+ && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
+ Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
+ "mv create " + world + " normal");
+ } else {
+ if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null)
+ && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
+ Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
+ } else {
+ Bukkit.createWorld(new WorldCreator(world).environment(World.Environment.NORMAL));
+ }
+ }
+ sender.sendMessage("Done!");
+ } else {
+ sender.sendMessage("/ic ");
+ }
+ return true;
+ }
+
+ @Override
+ public void onDisable() {
+ ICLogger.logger = null;
+ }
+
+ @Override
+ public List> getDatabaseClasses() {
+ final Class>[] classes = { EbeanServerIslandDatabase.IslandBean.class,
+ EbeanServerIslandDatabase.IslandPK.class };
+ return Arrays.asList(classes);
+ }
+
+ public IslandCraft getIslandCraft() {
+ return islandCraft;
+ }
+
+ private static final int BLOCKS_PER_CHUNK = 16;
+
+ public void regenerate(final World world, final ICRegion region) {
+ final ICLocation min = region.getMin();
+ final ICLocation max = region.getMax();
+ final int minX = min.getX() / BLOCKS_PER_CHUNK;
+ final int minZ = min.getZ() / BLOCKS_PER_CHUNK;
+ final int maxX = max.getX() / BLOCKS_PER_CHUNK;
+ final int maxZ = max.getZ() / BLOCKS_PER_CHUNK;
+ // Must loop from high to low for trees to generate correctly
+ for (int x = maxX - 1; x >= minX; --x) {
+ for (int z = maxZ - 1; z >= minZ; --z) {
+ // TODO queue these?
+ world.regenerateChunk(x, z);
+ }
+ }
+ }
+}
diff --git a/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/JavaUtilLogger.java b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/JavaUtilLogger.java
new file mode 100644
index 0000000..4c8f7d0
--- /dev/null
+++ b/IslandCraft-Bukkit/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/JavaUtilLogger.java
@@ -0,0 +1,28 @@
+package com.github.hoqhuuep.islandcraft.bukkit;
+
+import java.util.logging.Logger;
+
+import com.github.hoqhuuep.islandcraft.core.ICLogger;
+
+public class JavaUtilLogger extends ICLogger {
+ private final Logger logger;
+
+ public JavaUtilLogger(Logger logger) {
+ this.logger = logger;
+ }
+
+ @Override
+ public void info(String message) {
+ logger.info(message);
+ }
+
+ @Override
+ public void warning(String message) {
+ logger.warning(message);
+ }
+
+ @Override
+ public void error(String message) {
+ logger.severe(message);
+ }
+}
diff --git a/IslandCraft-Core/src/main/resources/config.yml b/IslandCraft-Bukkit/src/main/resources/config.yml
similarity index 100%
rename from IslandCraft-Core/src/main/resources/config.yml
rename to IslandCraft-Bukkit/src/main/resources/config.yml
diff --git a/IslandCraft-Core/src/main/resources/plugin.yml b/IslandCraft-Bukkit/src/main/resources/plugin.yml
similarity index 100%
rename from IslandCraft-Core/src/main/resources/plugin.yml
rename to IslandCraft-Bukkit/src/main/resources/plugin.yml
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantBiomeDistribution.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantBiomeDistribution.java
new file mode 100644
index 0000000..2f0dea3
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantBiomeDistribution.java
@@ -0,0 +1,23 @@
+package com.github.hoqhuuep.islandcraft.core;
+
+import com.github.hoqhuuep.islandcraft.api.BiomeDistribution;
+import com.github.hoqhuuep.islandcraft.api.ICBiome;
+import com.github.hoqhuuep.islandcraft.util.StringUtils;
+
+public class ConstantBiomeDistribution implements BiomeDistribution {
+ private final ICBiome biome;
+
+ public ConstantBiomeDistribution(final String[] args) {
+ ICLogger.logger.info("Creating ConstantBiomeDistribution with args: " + StringUtils.join(args, " "));
+ if (args.length != 1) {
+ ICLogger.logger.error("ConstantBiomeDistribution requrires 1 parameter, " + args.length + " given");
+ throw new IllegalArgumentException("ConstantBiomeDistribution requrires 1 parameter");
+ }
+ biome = ICBiome.valueOf(args[0]);
+ }
+
+ @Override
+ public ICBiome biomeAt(final int x, final int z, final long worldSeed) {
+ return biome;
+ }
+}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantIslandGenerator.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantIslandGenerator.java
similarity index 86%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantIslandGenerator.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantIslandGenerator.java
index 0d13c2d..76765ed 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantIslandGenerator.java
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantIslandGenerator.java
@@ -2,10 +2,9 @@
import java.util.Arrays;
-import org.apache.commons.lang.StringUtils;
-
import com.github.hoqhuuep.islandcraft.api.ICBiome;
import com.github.hoqhuuep.islandcraft.api.IslandGenerator;
+import com.github.hoqhuuep.islandcraft.util.StringUtils;
public class ConstantIslandGenerator implements IslandGenerator {
private final ICBiome biome;
@@ -13,7 +12,7 @@ public class ConstantIslandGenerator implements IslandGenerator {
public ConstantIslandGenerator(final String[] args) {
ICLogger.logger.info("Creating ConstantIslandGenerator with args: " + StringUtils.join(args, " "));
if (args.length != 1) {
- ICLogger.logger.severe("ConstantIslandGenerator requrires 1 parameter, " + args.length + " given");
+ ICLogger.logger.error("ConstantIslandGenerator requrires 1 parameter, " + args.length + " given");
throw new IllegalArgumentException("ConstantIslandGenerator requrires 1 parameter, " + args.length + " given");
}
biome = ICBiome.valueOf(args[0]);
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIsland.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIsland.java
similarity index 100%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIsland.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIsland.java
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIslandCraft.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIslandCraft.java
similarity index 100%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIslandCraft.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIslandCraft.java
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java
similarity index 73%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java
index e563e9e..1b66e4d 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java
@@ -1,13 +1,11 @@
package com.github.hoqhuuep.islandcraft.core;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.lang.StringUtils;
-import org.bukkit.configuration.ConfigurationSection;
import com.github.hoqhuuep.islandcraft.api.BiomeDistribution;
import com.github.hoqhuuep.islandcraft.api.ICBiome;
@@ -16,9 +14,10 @@
import com.github.hoqhuuep.islandcraft.api.ICRegion;
import com.github.hoqhuuep.islandcraft.api.ICWorld;
import com.github.hoqhuuep.islandcraft.api.IslandDistribution;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
+import com.github.hoqhuuep.islandcraft.util.Cache;
+import com.github.hoqhuuep.islandcraft.util.CacheLoader;
+import com.github.hoqhuuep.islandcraft.util.ExpiringLoadingCache;
+import com.github.hoqhuuep.islandcraft.util.StringUtils;
public class DefaultWorld implements ICWorld {
private final String worldName;
@@ -31,38 +30,22 @@ public class DefaultWorld implements ICWorld {
private final ICClassLoader classLoader;
private final Cache databaseCache;
- public DefaultWorld(final String name, final long seed, final IslandDatabase database, final ConfigurationSection config, final IslandCache cache, final ICClassLoader classLoader) {
+ public DefaultWorld(final String name, final long seed, final IslandDatabase database, final ICWorldConfig config, final IslandCache cache, final ICClassLoader classLoader) {
this.worldName = name;
this.worldSeed = seed;
this.database = database;
this.cache = cache;
this.classLoader = classLoader;
- if (!config.contains("ocean") || !config.isString("ocean")) {
- ICLogger.logger.warning("No string-value for 'worlds." + name + ".ocean' found in config.yml");
- ICLogger.logger.warning("Default value 'com.github.hoqhuuep.islandcraft.core.ConstantBiomeDistribution DEEP_OCEAN' will be used");
- }
- ocean = classLoader.getBiomeDistribution(config.getString("ocean", "com.github.hoqhuuep.islandcraft.core.ConstantBiomeDistribution DEEP_OCEAN"));
-
- if (!config.contains("island-distribution") || !config.isString("island-distribution")) {
- ICLogger.logger.warning("No string-value for 'worlds." + name + ".island-distribution' found in config.yml");
- ICLogger.logger.warning("Default value 'com.github.hoqhuuep.islandcraft.core.EmptyIslandDistribution' will be used");
- }
- islandDistribution = classLoader.getIslandDistribution(config.getString("island-distribution", "com.github.hoqhuuep.islandcraft.core.EmptyIslandDistribution"));
-
- if (!config.contains("island-generators") || !config.isList("island-generators")) {
- ICLogger.logger.warning("No list-value for 'worlds." + name + ".island-generators' found in config.yml");
- ICLogger.logger.warning("Default value '[com.github.hoqhuuep.islandcraft.core.EmptyIslandGenerator]' will be used");
- }
- islandGenerators = config.getStringList("island-generators");
- if (islandGenerators.isEmpty()) {
- islandGenerators.add("com.github.hoqhuuep.islandcraft.core.EmptyIslandGenerator");
- }
+ ocean = classLoader.getBiomeDistribution(config.getOcean());
+ islandDistribution = classLoader.getIslandDistribution(config.getIslandDistribution());
+ islandGenerators = new ArrayList(Arrays.asList(config.getIslandGenerstors()));
// Load islandGenerators just to make sure there are no errors
for (final String islandGenerator : islandGenerators) {
classLoader.getIslandGenerator(islandGenerator);
}
- databaseCache = CacheBuilder.newBuilder().expireAfterAccess(30, TimeUnit.SECONDS).build(new DatabaseCacheLoader());
+
+ databaseCache = new ExpiringLoadingCache(30, new DatabaseCacheLoader());
}
@Override
@@ -137,7 +120,7 @@ public ICIsland getIslandAt(final int x, final int z) {
if (center == null) {
return null;
}
- return databaseCache.getUnchecked(center);
+ return databaseCache.get(center);
}
@Override
@@ -150,12 +133,12 @@ public Set getIslandsAt(final int x, final int z) {
final Set centers = islandDistribution.getCentersAt(x, z, worldSeed);
final Set islands = new HashSet(centers.size());
for (final ICLocation center : centers) {
- islands.add(databaseCache.getUnchecked(center));
+ islands.add(databaseCache.get(center));
}
return islands;
}
- private class DatabaseCacheLoader extends CacheLoader {
+ private class DatabaseCacheLoader implements CacheLoader {
@Override
public ICIsland load(final ICLocation center) {
final ICRegion innerRegion = islandDistribution.getInnerRegion(center, worldSeed);
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandDistribution.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandDistribution.java
similarity index 87%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandDistribution.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandDistribution.java
index 38ef6e2..56737dd 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandDistribution.java
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandDistribution.java
@@ -3,17 +3,16 @@
import java.util.HashSet;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
-
import com.github.hoqhuuep.islandcraft.api.ICLocation;
import com.github.hoqhuuep.islandcraft.api.ICRegion;
import com.github.hoqhuuep.islandcraft.api.IslandDistribution;
+import com.github.hoqhuuep.islandcraft.util.StringUtils;
public class EmptyIslandDistribution implements IslandDistribution {
public EmptyIslandDistribution(final String[] args) {
ICLogger.logger.info("Creating EmptyIslandDistribution with args: " + StringUtils.join(args, " "));
if (args.length != 0) {
- ICLogger.logger.severe("EmptyIslandDistribution requrires 0 parameters, " + args.length + " given");
+ ICLogger.logger.error("EmptyIslandDistribution requrires 0 parameters, " + args.length + " given");
throw new IllegalArgumentException("EmptyIslandDistribution requrires 0 parameters, " + args.length + " given");
}
}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandGenerator.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandGenerator.java
similarity index 83%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandGenerator.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandGenerator.java
index 3520632..4b4f6b3 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandGenerator.java
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/EmptyIslandGenerator.java
@@ -1,15 +1,14 @@
package com.github.hoqhuuep.islandcraft.core;
-import org.apache.commons.lang.StringUtils;
-
import com.github.hoqhuuep.islandcraft.api.ICBiome;
import com.github.hoqhuuep.islandcraft.api.IslandGenerator;
+import com.github.hoqhuuep.islandcraft.util.StringUtils;
public class EmptyIslandGenerator implements IslandGenerator {
public EmptyIslandGenerator(final String[] args) {
ICLogger.logger.info("Creating EmptyIslandGenerator with args: " + StringUtils.join(args, " "));
if (args.length != 0) {
- ICLogger.logger.severe("EmptyIslandGenerator requrires 0 parameters, " + args.length + " given");
+ ICLogger.logger.error("EmptyIslandGenerator requrires 0 parameters, " + args.length + " given");
throw new IllegalArgumentException("EmptyIslandGenerator requrires 0 parameters, " + args.length + " given");
}
}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java
similarity index 95%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java
index 37b32f0..f3ae581 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java
@@ -3,11 +3,10 @@
import java.util.HashSet;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
-
import com.github.hoqhuuep.islandcraft.api.ICLocation;
import com.github.hoqhuuep.islandcraft.api.ICRegion;
import com.github.hoqhuuep.islandcraft.api.IslandDistribution;
+import com.github.hoqhuuep.islandcraft.util.StringUtils;
public class HexagonalIslandDistribution implements IslandDistribution {
private final int islandSize;
@@ -23,18 +22,18 @@ public class HexagonalIslandDistribution implements IslandDistribution {
public HexagonalIslandDistribution(final String[] args) {
ICLogger.logger.info("Creating HexagonalIslandDistribution with args: " + StringUtils.join(args, " "));
if (args.length != 2) {
- ICLogger.logger.severe("HexagonalIslandDistribution requrires 2 parameters, " + args.length + " given");
+ ICLogger.logger.error("HexagonalIslandDistribution requrires 2 parameters, " + args.length + " given");
throw new IllegalArgumentException("HexagonalIslandDistribution requrires 2 parameters");
}
islandSize = Integer.parseInt(args[0]);
oceanSize = Integer.parseInt(args[1]);
// Validate configuration values
if (islandSize <= 0 || islandSize % 32 != 0) {
- ICLogger.logger.severe("HexagonalIslandDistribution.island-size must be a positive multiple of 32");
+ ICLogger.logger.error("HexagonalIslandDistribution.island-size must be a positive multiple of 32");
throw new IllegalArgumentException("HexagonalIslandDistribution.island-size must be a positive multiple of 32");
}
if (oceanSize <= 0 || oceanSize % 32 != 0) {
- ICLogger.logger.severe("HexagonalIslandDistribution.ocean-size must be a positive multiple of 32");
+ ICLogger.logger.error("HexagonalIslandDistribution.ocean-size must be a positive multiple of 32");
throw new IllegalArgumentException("HexagonalIslandDistribution.ocean-size must be a positive multiple of 32");
}
islandSeparation = islandSize + oceanSize;
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ICClassLoader.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ICClassLoader.java
similarity index 75%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ICClassLoader.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ICClassLoader.java
index 9b2e548..c949aa5 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ICClassLoader.java
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ICClassLoader.java
@@ -6,9 +6,9 @@
import com.github.hoqhuuep.islandcraft.api.BiomeDistribution;
import com.github.hoqhuuep.islandcraft.api.IslandDistribution;
import com.github.hoqhuuep.islandcraft.api.IslandGenerator;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
+import com.github.hoqhuuep.islandcraft.util.Cache;
+import com.github.hoqhuuep.islandcraft.util.CacheLoader;
+import com.github.hoqhuuep.islandcraft.util.EternalLoadingCache;
public class ICClassLoader {
private final Cache islandDistributionCache;
@@ -16,14 +16,14 @@ public class ICClassLoader {
private final Cache biomeDistributionCache;
public ICClassLoader() {
- islandDistributionCache = CacheBuilder.newBuilder().build(new StringConstructorCacheLoader());
- islandGeneratorCache = CacheBuilder.newBuilder().build(new StringConstructorCacheLoader());
- biomeDistributionCache = CacheBuilder.newBuilder().build(new StringConstructorCacheLoader());
+ islandDistributionCache = new EternalLoadingCache(new StringConstructorCacheLoader());
+ islandGeneratorCache = new EternalLoadingCache(new StringConstructorCacheLoader());
+ biomeDistributionCache = new EternalLoadingCache(new StringConstructorCacheLoader());
}
public IslandDistribution getIslandDistribution(final String string) {
try {
- return islandDistributionCache.getUnchecked(string);
+ return islandDistributionCache.get(string);
} catch (final Exception e) {
ICLogger.logger.warning("Error creating IslandDistribution from string: " + string);
ICLogger.logger.warning("Using 'com.github.hoqhuuep.islandcraft.core.EmptyIslandDistribution' instead");
@@ -33,7 +33,7 @@ public IslandDistribution getIslandDistribution(final String string) {
public IslandGenerator getIslandGenerator(final String string) {
try {
- return islandGeneratorCache.getUnchecked(string);
+ return islandGeneratorCache.get(string);
} catch (final Exception e) {
ICLogger.logger.warning("Error creating IslandGenerator from string: " + string);
ICLogger.logger.warning("Using 'com.github.hoqhuuep.islandcraft.core.EmptyIslandGenerator' instead");
@@ -43,7 +43,7 @@ public IslandGenerator getIslandGenerator(final String string) {
public BiomeDistribution getBiomeDistribution(final String string) {
try {
- return biomeDistributionCache.getUnchecked(string);
+ return biomeDistributionCache.get(string);
} catch (final Exception e) {
ICLogger.logger.warning("Error creating BiomeDistribution from string: " + string);
ICLogger.logger.warning("Using 'com.github.hoqhuuep.islandcraft.core.ConstantBiomeDistribution DEEP_OCEAN' instead");
@@ -51,7 +51,7 @@ public BiomeDistribution getBiomeDistribution(final String string) {
}
}
- private static class StringConstructorCacheLoader extends CacheLoader {
+ private static class StringConstructorCacheLoader implements CacheLoader {
@Override
@SuppressWarnings("unchecked")
public T load(final String string) {
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ICLogger.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ICLogger.java
new file mode 100644
index 0000000..3e11f96
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ICLogger.java
@@ -0,0 +1,9 @@
+package com.github.hoqhuuep.islandcraft.core;
+
+public abstract class ICLogger {
+ public static ICLogger logger = null;
+
+ public abstract void info(String message);
+ public abstract void warning(String message);
+ public abstract void error(String message);
+}
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ICWorldConfig.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ICWorldConfig.java
new file mode 100644
index 0000000..8e21da3
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/ICWorldConfig.java
@@ -0,0 +1,9 @@
+package com.github.hoqhuuep.islandcraft.core;
+
+public interface ICWorldConfig {
+ String getOcean();
+
+ String getIslandDistribution();
+
+ String[] getIslandGenerstors();
+}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java
similarity index 72%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java
index e0d3243..ec9943c 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java
@@ -1,22 +1,20 @@
package com.github.hoqhuuep.islandcraft.core;
-import java.util.concurrent.TimeUnit;
-
import com.github.hoqhuuep.islandcraft.api.ICBiome;
import com.github.hoqhuuep.islandcraft.api.ICIsland;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
+import com.github.hoqhuuep.islandcraft.util.Cache;
+import com.github.hoqhuuep.islandcraft.util.CacheLoader;
+import com.github.hoqhuuep.islandcraft.util.ExpiringLoadingCache;
public class IslandCache {
private final Cache cache;
public IslandCache() {
- cache = CacheBuilder.newBuilder().expireAfterAccess(30, TimeUnit.SECONDS).build(new IslandCacheLoader());
+ cache = new ExpiringLoadingCache(30, new IslandCacheLoader());
}
public ICBiome biomeAt(final ICIsland island, final int relativeX, final int relativeZ) {
- final ICBiome[] biomes = cache.getUnchecked(island);
+ final ICBiome[] biomes = cache.get(island);
final int xSize = island.getInnerRegion().getMax().getZ() - island.getInnerRegion().getMin().getZ();
return biomes[relativeZ * xSize + relativeX];
}
@@ -26,7 +24,7 @@ public ICBiome biomeAt(final ICIsland island, final int relativeX, final int rel
public ICBiome[] biomeChunk(final ICIsland island, final int relativeX, final int relativeZ) {
final int xSize = island.getInnerRegion().getMax().getZ() - island.getInnerRegion().getMin().getZ();
final ICBiome[] result = new ICBiome[BLOCKS_PER_CHUNK * BLOCKS_PER_CHUNK];
- final ICBiome[] biomes = cache.getUnchecked(island);
+ final ICBiome[] biomes = cache.get(island);
for (int z = 0; z < BLOCKS_PER_CHUNK; ++z) {
System.arraycopy(biomes, xSize * (relativeZ + z) + relativeX, result, z * BLOCKS_PER_CHUNK, BLOCKS_PER_CHUNK);
}
@@ -34,14 +32,10 @@ public ICBiome[] biomeChunk(final ICIsland island, final int relativeX, final in
}
public ICBiome[] biomeAll(final ICIsland island) {
- return cache.getUnchecked(island).clone();
- }
-
- public void cleanUp() {
- cache.cleanUp();
+ return cache.get(island).clone();
}
- private static class IslandCacheLoader extends CacheLoader {
+ private static class IslandCacheLoader implements CacheLoader {
@Override
public ICBiome[] load(final ICIsland island) {
final int xSize = island.getInnerRegion().getMax().getX() - island.getInnerRegion().getMin().getX();
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandDatabase.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandDatabase.java
similarity index 100%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandDatabase.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandDatabase.java
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandGeneratorAlpha.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandGeneratorAlpha.java
new file mode 100644
index 0000000..868aa1a
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandGeneratorAlpha.java
@@ -0,0 +1,195 @@
+package com.github.hoqhuuep.islandcraft.core;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Random;
+
+import com.github.hoqhuuep.islandcraft.api.ICBiome;
+import com.github.hoqhuuep.islandcraft.api.IslandGenerator;
+import com.github.hoqhuuep.islandcraft.core.mosaic.Poisson;
+import com.github.hoqhuuep.islandcraft.core.mosaic.Site;
+import com.github.hoqhuuep.islandcraft.core.noise.Noise;
+import com.github.hoqhuuep.islandcraft.core.noise.OctaveNoise;
+import com.github.hoqhuuep.islandcraft.util.StringUtils;
+
+public class IslandGeneratorAlpha implements IslandGenerator {
+ private static final double MIN_DISTANCE = 8;
+ private static final double NOISE = 2.7;
+ private static final double CIRCLE = 2;
+ private static final double SQUARE = 0;
+ private static final double THRESHOLD = 2;
+ private final Color ocean;
+ private final Color normal;
+ private final Color mountains;
+ private final Color hills;
+ private final Color hillsMountains;
+ private final Color forest;
+ private final Color forestMountains;
+ private final Color outerCoast;
+ private final Color innerCoast;
+
+ // private final Color river; // unused for now
+
+ public IslandGeneratorAlpha(final String[] args) {
+ ICLogger.logger.info("Creating IslandGeneratorAlpha with args: " + StringUtils.join(args, " "));
+ if (args.length != 9) {
+ ICLogger.logger.error("IslandGeneratorAlpha requrires 9 parameters, " + args.length + " given");
+ throw new IllegalArgumentException("IslandGeneratorAlpha requrires 9 parameters");
+ }
+ ocean = new Color(ICBiome.values().length, true);
+ normal = biomeColor(args[0], ocean);
+ mountains = biomeColor(args[1], normal);
+ hills = biomeColor(args[2], normal);
+ hillsMountains = biomeColor(args[3], hills);
+ forest = biomeColor(args[4], normal);
+ forestMountains = biomeColor(args[5], forest);
+ outerCoast = biomeColor(args[6], normal);
+ innerCoast = biomeColor(args[7], normal);
+ // river = biomeColor(args[8], normal); // unused for now
+ }
+
+ @Override
+ public ICBiome[] generate(final int xSize, final int zSize, final long islandSeed) {
+ ICLogger.logger.info(String.format(
+ "Generating island from IslandGeneratorAlpha with xSize: %d, zSize: %d, islandSeed: %d, biome: %s",
+ xSize, zSize, islandSeed, ICBiome.values()[normal.getRGB()]));
+ final Poisson poisson = new Poisson(xSize, zSize, MIN_DISTANCE);
+ final List sites = poisson.generate(new Random(islandSeed));
+ final Noise shapeNoise = new OctaveNoise(islandSeed);
+ final Noise hillsNoise = new OctaveNoise(islandSeed + 1);
+ final Noise forestNoise = new OctaveNoise(islandSeed + 2);
+ final Noise mountainsNoise = new OctaveNoise(islandSeed + 3);
+ // Find borders
+ final Queue oceanSites = new LinkedList();
+ for (final Site site : sites) {
+ if (site.polygon == null) {
+ site.isOcean = true;
+ oceanSites.add(site);
+ }
+ }
+ final List suspectCoast = new ArrayList();
+ final List coast = new ArrayList();
+ // Find oceans and coasts
+ while (!oceanSites.isEmpty()) {
+ final Site site = oceanSites.remove();
+ for (final Site neighbor : site.neighbors) {
+ if (site.polygon == null) {
+ if (!neighbor.isOcean) {
+ neighbor.isOcean = true;
+ oceanSites.add(neighbor);
+ }
+ } else {
+ final double dx = (double) (neighbor.x - (xSize / 2)) / (double) (xSize / 2);
+ final double dz = (double) (neighbor.z - (zSize / 2)) / (double) (zSize / 2);
+ if (NOISE * noise(dx, dz, shapeNoise) + CIRCLE * circle(dx, dz)
+ + SQUARE * square(dx, dz) > THRESHOLD) {
+ if (!neighbor.isOcean) {
+ neighbor.isOcean = true;
+ oceanSites.add(neighbor);
+ }
+ } else {
+ neighbor.isInnerCoast = true;
+ suspectCoast.add(neighbor);
+ }
+ }
+ }
+ }
+ // Create coast
+ SITE: for (final Site site : suspectCoast) {
+ for (final Site neighbor : site.neighbors) {
+ if (!neighbor.isOcean && !neighbor.isInnerCoast) {
+ coast.add(site);
+ continue SITE;
+ }
+ }
+ site.isInnerCoast = false;
+ site.isOcean = true;
+ }
+ // Create shallow ocean
+ for (final Site site : coast) {
+ for (final Site neighbor : site.neighbors) {
+ if (neighbor.isOcean) {
+ neighbor.isOcean = false;
+ neighbor.isOuterCoast = true;
+ }
+ }
+ }
+ // Create blank image
+ final BufferedImage image = new BufferedImage(xSize, zSize, BufferedImage.TYPE_INT_ARGB);
+ final Graphics2D graphics = image.createGraphics();
+ graphics.setComposite(AlphaComposite.Src);
+ graphics.setBackground(ocean);
+ graphics.clearRect(0, 0, xSize, zSize);
+ // Render island
+ for (final Site site : sites) {
+ if (site.isOcean) {
+ continue;
+ } else if (site.isOuterCoast) {
+ graphics.setColor(outerCoast);
+ } else if (site.isInnerCoast) {
+ graphics.setColor(innerCoast);
+ } else if (noise(site, 0.375, 160.0, mountainsNoise)) {
+ if (noise(site, 0.375, 80.0, hillsNoise)) {
+ graphics.setColor(hillsMountains);
+ } else if (noise(site, 0.375, 160.0, forestNoise)) {
+ graphics.setColor(forestMountains);
+ } else {
+ graphics.setColor(mountains);
+ }
+ } else {
+ if (noise(site, 0.375, 80.0, hillsNoise)) {
+ graphics.setColor(hills);
+ } else if (noise(site, 0.375, 160.0, forestNoise)) {
+ graphics.setColor(forest);
+ } else {
+ graphics.setColor(normal);
+ }
+ }
+ graphics.fillPolygon(site.polygon);
+ graphics.drawPolygon(site.polygon);
+ }
+ // Save result
+ graphics.dispose();
+ final ICBiome[] result = new ICBiome[xSize * zSize];
+ final ICBiome[] values = ICBiome.values();
+ final int maxOrdinal = values.length;
+ for (int i = 0; i < result.length; ++i) {
+ final int x = i % xSize;
+ final int z = i / xSize;
+ final int ordinal = image.getRGB(x, z);
+ if (ordinal < maxOrdinal) {
+ result[i] = values[ordinal];
+ }
+ }
+ return result;
+ }
+
+ private static Color biomeColor(final String name, final Color backup) {
+ if (name.equals("~")) {
+ return backup;
+ }
+ return new Color(ICBiome.valueOf(name).ordinal(), true);
+ }
+
+ private static boolean noise(final Site site, final double threshold, final double period, final Noise noise) {
+ return noise.noise(site.x / period, site.z / period) < threshold;
+ }
+
+ private static double noise(final double dx, final double dz, final Noise noise) {
+ return noise.noise(dx, dz);
+ }
+
+ private static double circle(final double dx, final double dz) {
+ return (dx * dx + dz * dz) / 2;
+ }
+
+ private static double square(final double dx, final double dz) {
+ return Math.max(Math.abs(dx), Math.abs(dz));
+ }
+}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java
similarity index 94%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java
index a1e30ad..8d9f6bc 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java
@@ -3,11 +3,10 @@
import java.util.HashSet;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
-
import com.github.hoqhuuep.islandcraft.api.ICLocation;
import com.github.hoqhuuep.islandcraft.api.ICRegion;
import com.github.hoqhuuep.islandcraft.api.IslandDistribution;
+import com.github.hoqhuuep.islandcraft.util.StringUtils;
public class SquareIslandDistribution implements IslandDistribution {
private final int islandSize;
@@ -19,18 +18,18 @@ public class SquareIslandDistribution implements IslandDistribution {
public SquareIslandDistribution(final String[] args) {
ICLogger.logger.info("Creating SquareIslandDistribution with args: " + StringUtils.join(args, " "));
if (args.length != 2) {
- ICLogger.logger.severe("SquareIslandDistribution requrires 2 parameters, " + args.length + " given");
+ ICLogger.logger.error("SquareIslandDistribution requrires 2 parameters, " + args.length + " given");
throw new IllegalArgumentException("SquareIslandDistribution requrires 2 parameters");
}
islandSize = Integer.parseInt(args[0]);
oceanSize = Integer.parseInt(args[1]);
// Validate configuration values
if (islandSize <= 0 || islandSize % 32 != 0) {
- ICLogger.logger.severe("SquareIslandDistribution.island-size must be a positive multiple of 32");
+ ICLogger.logger.error("SquareIslandDistribution.island-size must be a positive multiple of 32");
throw new IllegalArgumentException("SquareIslandDistribution.island-size must be a positive multiple of 32");
}
if (oceanSize <= 0 || oceanSize % 32 != 0) {
- ICLogger.logger.severe("SquareIslandDistribution.ocean-size must be a positive multiple of 32");
+ ICLogger.logger.error("SquareIslandDistribution.ocean-size must be a positive multiple of 32");
throw new IllegalArgumentException("SquareIslandDistribution.ocean-size must be a positive multiple of 32");
}
islandSeparation = islandSize + oceanSize;
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/AngleComparator.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/AngleComparator.java
similarity index 100%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/AngleComparator.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/AngleComparator.java
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Grid.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Grid.java
similarity index 100%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Grid.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Grid.java
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Poisson.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Poisson.java
similarity index 100%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Poisson.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Poisson.java
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/RangeEntry.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/RangeEntry.java
similarity index 100%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/RangeEntry.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/RangeEntry.java
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/RangeList.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/RangeList.java
similarity index 100%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/RangeList.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/RangeList.java
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Site.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Site.java
similarity index 100%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Site.java
rename to IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/mosaic/Site.java
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/noise/Noise.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/noise/Noise.java
new file mode 100644
index 0000000..9f7bc2d
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/noise/Noise.java
@@ -0,0 +1,6 @@
+package com.github.hoqhuuep.islandcraft.core.noise;
+
+public interface Noise {
+ /** Returns noise value in range [0, 1] **/
+ double noise(double x, double z);
+}
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/noise/OctaveNoise.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/noise/OctaveNoise.java
new file mode 100644
index 0000000..f9d1167
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/noise/OctaveNoise.java
@@ -0,0 +1,21 @@
+package com.github.hoqhuuep.islandcraft.core.noise;
+
+import java.util.Random;
+
+public class OctaveNoise implements Noise {
+ private SimplexNoise octave1;
+ private SimplexNoise octave2;
+
+ public OctaveNoise(long seed) {
+ Random random = new Random(seed);
+ octave1 = new SimplexNoise(random);
+ octave2 = new SimplexNoise(random);
+ }
+
+ @Override
+ public double noise(double x, double y) {
+ double noise1 = octave1.noise(x, y, 0.0);
+ double noise2 = octave2.noise(x * 2.0, y * 2.0, 0.0) * 0.5;
+ return (noise1 + noise2) / 3.0 + 0.5;
+ }
+}
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/noise/SimplexNoise.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/noise/SimplexNoise.java
new file mode 100644
index 0000000..b9bb80e
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/core/noise/SimplexNoise.java
@@ -0,0 +1,500 @@
+package com.github.hoqhuuep.islandcraft.core.noise;
+
+import java.util.Random;
+
+/**
+ * Simplex noise in 2D, 3D and 4D
+ *
+ * This is a modified version of public domain code available from:
+ * http://webstaff.itn.liu.se/~stegu/simplexnoise/SimplexNoise.java
+ *
+ * It is based on the paper:
+ * http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
+ *
+ * A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java.
+ *
+ * Based on example code by Stefan Gustavson (stegu@itn.liu.se). Optimisations
+ * by Peter Eastman (peastman@drizzle.stanford.edu). Better rank ordering method
+ * by Stefan Gustavson in 2012. Modifications to mimic how Bukkit's noise
+ * generator handles seeding by Daniel Simmons in 2016.
+ *
+ * This could be speeded up even further, but it's useful as it is.
+ *
+ * Version 2016-02-20
+ *
+ * This code was placed in the public domain by its original author, Stefan
+ * Gustavson. You may use it as you see fit, but attribution is appreciated.
+ */
+public class SimplexNoise {
+ private static Grad grad3[] = {
+ new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0),
+ new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1),
+ new Grad(0, 1, 1), new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1),
+ };
+
+ private static Grad grad4[] = {
+ new Grad(0, 1, 1, 1), new Grad(0, 1, 1, -1), new Grad(0, 1, -1, 1), new Grad(0, 1, -1, -1),
+ new Grad(0, -1, 1, 1), new Grad(0, -1, 1, -1), new Grad(0, -1, -1, 1), new Grad(0, -1, -1, -1),
+ new Grad(1, 0, 1, 1), new Grad(1, 0, 1, -1), new Grad(1, 0, -1, 1), new Grad(1, 0, -1, -1),
+ new Grad(-1, 0, 1, 1), new Grad(-1, 0, 1, -1), new Grad(-1, 0, -1, 1), new Grad(-1, 0, -1, -1),
+ new Grad(1, 1, 0, 1), new Grad(1, 1, 0, -1), new Grad(1, -1, 0, 1), new Grad(1, -1, 0, -1),
+ new Grad(-1, 1, 0, 1), new Grad(-1, 1, 0, -1), new Grad(-1, -1, 0, 1), new Grad(-1, -1, 0, -1),
+ new Grad(1, 1, 1, 0), new Grad(1, 1, -1, 0), new Grad(1, -1, 1, 0), new Grad(1, -1, -1, 0),
+ new Grad(-1, 1, 1, 0), new Grad(-1, 1, -1, 0), new Grad(-1, -1, 1, 0), new Grad(-1, -1, -1, 0),
+ };
+
+ // To remove the need for index wrapping, double the permutation table length
+ private int perm[] = new int[512];
+ private int permMod12[] = new int[512];
+
+ // Skewing and unskewing factors for 2, 3, and 4 dimensions
+ private static final double F2 = 0.5 * (Math.sqrt(3.0) - 1.0);
+ private static final double G2 = (3.0 - Math.sqrt(3.0)) / 6.0;
+ private static final double F3 = 1.0 / 3.0;
+ private static final double G3 = 1.0 / 6.0;
+ private static final double F4 = (Math.sqrt(5.0) - 1.0) / 4.0;
+ private static final double G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
+
+ private double offsetX;
+ private double offsetY;
+ private double offsetZ;
+ private double offsetW;
+
+ public SimplexNoise(Random random) {
+ offsetX = random.nextDouble() * 256;
+ offsetY = random.nextDouble() * 256;
+ offsetZ = random.nextDouble() * 256;
+
+ for (int i = 0; i < 256; ++i) {
+ perm[i] = random.nextInt(256);
+ }
+
+ // Create a random permutation of "p"
+ for (int i = 0; i < 256; ++i) {
+ int pos = random.nextInt(256 - i) + i;
+ int temp = perm[i];
+ perm[i] = perm[pos];
+ perm[pos] = temp;
+ perm[i + 256] = perm[i];
+ }
+
+ for (int i = 0; i < 512; i++) {
+ permMod12[i] = (perm[i] % 12);
+ }
+ offsetW = random.nextDouble() * 256;
+ }
+
+ // This method is a *lot* faster than using (int) Math.floor(x)
+ private static int fastfloor(double x) {
+ int xi = (int) x;
+ return x < xi ? xi - 1 : xi;
+ }
+
+ private static double dot(Grad g, double x, double y) {
+ return g.x * x + g.y * y;
+ }
+
+ private static double dot(Grad g, double x, double y, double z) {
+ return g.x * x + g.y * y + g.z * z;
+ }
+
+ private static double dot(Grad g, double x, double y, double z, double w) {
+ return g.x * x + g.y * y + g.z * z + g.w * w;
+ }
+
+ // 2D simplex noise
+ public double noise(double x, double y) {
+ x += offsetX;
+ y += offsetY;
+
+ // Noise contributions from the three corners
+ double n0, n1, n2;
+
+ // Skew the input space to determine which simplex cell we're in
+ double s = (x + y) * F2; // Hairy factor for 2D
+ int i = fastfloor(x + s);
+ int j = fastfloor(y + s);
+ double t = (i + j) * G2;
+ double X0 = i - t; // Unskew the cell origin back to (x,y) space
+ double Y0 = j - t;
+ double x0 = x - X0; // The x,y distances from the cell origin
+ double y0 = y - Y0;
+
+ // For the 2D case, the simplex shape is an equilateral triangle.
+
+ // Determine which simplex we are in.
+ int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords
+ if (x0 > y0) {
+ i1 = 1;
+ j1 = 0;
+ } // lower triangle, XY order: (0,0)->(1,0)->(1,1)
+ else {
+ i1 = 0;
+ j1 = 1;
+ } // upper triangle, YX order: (0,0)->(0,1)->(1,1)
+
+ // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
+ // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
+ // c = (3-sqrt(3))/6
+
+ double x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords
+ double y1 = y0 - j1 + G2;
+ double x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords
+ double y2 = y0 - 1.0 + 2.0 * G2;
+
+ // Work out the hashed gradient indices of the three simplex corners
+ int ii = i & 255;
+ int jj = j & 255;
+ int gi0 = permMod12[ii + perm[jj]];
+ int gi1 = permMod12[ii + i1 + perm[jj + j1]];
+ int gi2 = permMod12[ii + 1 + perm[jj + 1]];
+
+ // Calculate the contribution from the three corners
+ double t0 = 0.5 - x0 * x0 - y0 * y0;
+ if (t0 < 0) {
+ n0 = 0.0;
+ } else {
+ t0 *= t0;
+ n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient
+ }
+
+ double t1 = 0.5 - x1 * x1 - y1 * y1;
+ if (t1 < 0) {
+ n1 = 0.0;
+ } else {
+ t1 *= t1;
+ n1 = t1 * t1 * dot(grad3[gi1], x1, y1);
+ }
+
+ double t2 = 0.5 - x2 * x2 - y2 * y2;
+ if (t2 < 0) {
+ n2 = 0.0;
+ } else {
+ t2 *= t2;
+ n2 = t2 * t2 * dot(grad3[gi2], x2, y2);
+ }
+
+ // Add contributions from each corner to get the final noise value.
+ // The result is scaled to return values in the interval [-1,1].
+ return 70.0 * (n0 + n1 + n2);
+ }
+
+ // 3D simplex noise
+ public double noise(double x, double y, double z) {
+ x += offsetX;
+ y += offsetY;
+ z += offsetZ;
+
+ double n0, n1, n2, n3; // Noise contributions from the four corners
+
+ // Skew the input space to determine which simplex cell we're in
+ double s = (x + y + z) * F3; // Very nice and simple skew factor for 3D
+ int i = fastfloor(x + s);
+ int j = fastfloor(y + s);
+ int k = fastfloor(z + s);
+ double t = (i + j + k) * G3;
+ double X0 = i - t; // Unskew the cell origin back to (x,y,z) space
+ double Y0 = j - t;
+ double Z0 = k - t;
+ double x0 = x - X0; // The x,y,z distances from the cell origin
+ double y0 = y - Y0;
+ double z0 = z - Z0;
+
+ // For the 3D case, the simplex shape is a slightly irregular tetrahedron.
+
+ // Determine which simplex we are in.
+ int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords
+ int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords
+ if (x0 >= y0) {
+ if (y0 >= z0) {
+ i1 = 1;
+ j1 = 0;
+ k1 = 0;
+ i2 = 1;
+ j2 = 1;
+ k2 = 0;
+ } // X Y Z order
+ else if (x0 >= z0) {
+ i1 = 1;
+ j1 = 0;
+ k1 = 0;
+ i2 = 1;
+ j2 = 0;
+ k2 = 1;
+ } // X Z Y order
+ else {
+ i1 = 0;
+ j1 = 0;
+ k1 = 1;
+ i2 = 1;
+ j2 = 0;
+ k2 = 1;
+ } // Z X Y order
+ } else { // x0 y0) {
+ rankx++;
+ } else {
+ ranky++;
+ }
+ if (x0 > z0) {
+ rankx++;
+ } else {
+ rankz++;
+ }
+ if (x0 > w0) {
+ rankx++;
+ } else {
+ rankw++;
+ }
+ if (y0 > z0) {
+ ranky++;
+ } else {
+ rankz++;
+ }
+ if (y0 > w0) {
+ ranky++;
+ } else {
+ rankw++;
+ }
+ if (z0 > w0) {
+ rankz++;
+ } else {
+ rankw++;
+ }
+
+ int i1, j1, k1, l1; // The integer offsets for the second simplex corner
+ int i2, j2, k2, l2; // The integer offsets for the third simplex corner
+ int i3, j3, k3, l3; // The integer offsets for the fourth simplex corner
+
+ // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order.
+ // Many values of c will never occur, since e.g. x>y>z>w makes x= 3 ? 1 : 0;
+ j1 = ranky >= 3 ? 1 : 0;
+ k1 = rankz >= 3 ? 1 : 0;
+ l1 = rankw >= 3 ? 1 : 0;
+
+ // Rank 2 denotes the second largest coordinate.
+ i2 = rankx >= 2 ? 1 : 0;
+ j2 = ranky >= 2 ? 1 : 0;
+ k2 = rankz >= 2 ? 1 : 0;
+ l2 = rankw >= 2 ? 1 : 0;
+
+ // Rank 1 denotes the second smallest coordinate.
+ i3 = rankx >= 1 ? 1 : 0;
+ j3 = ranky >= 1 ? 1 : 0;
+ k3 = rankz >= 1 ? 1 : 0;
+ l3 = rankw >= 1 ? 1 : 0;
+
+ // The fifth corner has all coordinate offsets = 1, so no need to compute that.
+ double x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
+ double y1 = y0 - j1 + G4;
+ double z1 = z0 - k1 + G4;
+ double w1 = w0 - l1 + G4;
+ double x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
+ double y2 = y0 - j2 + 2.0 * G4;
+ double z2 = z0 - k2 + 2.0 * G4;
+ double w2 = w0 - l2 + 2.0 * G4;
+ double x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
+ double y3 = y0 - j3 + 3.0 * G4;
+ double z3 = z0 - k3 + 3.0 * G4;
+ double w3 = w0 - l3 + 3.0 * G4;
+ double x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
+ double y4 = y0 - 1.0 + 4.0 * G4;
+ double z4 = z0 - 1.0 + 4.0 * G4;
+ double w4 = w0 - 1.0 + 4.0 * G4;
+
+ // Work out the hashed gradient indices of the five simplex corners
+ int ii = i & 255;
+ int jj = j & 255;
+ int kk = k & 255;
+ int ll = l & 255;
+ int gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32;
+ int gi1 = perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32;
+ int gi2 = perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32;
+ int gi3 = perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32;
+ int gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32;
+
+ // Calculate the contribution from the five corners
+ double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
+ if (t0 < 0) {
+ n0 = 0.0;
+ } else {
+ t0 *= t0;
+ n0 = t0 * t0 * dot(grad4[gi0], x0, y0, z0, w0);
+ }
+ double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
+ if (t1 < 0) {
+ n1 = 0.0;
+ } else {
+ t1 *= t1;
+ n1 = t1 * t1 * dot(grad4[gi1], x1, y1, z1, w1);
+ }
+ double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
+ if (t2 < 0) {
+ n2 = 0.0;
+ } else {
+ t2 *= t2;
+ n2 = t2 * t2 * dot(grad4[gi2], x2, y2, z2, w2);
+ }
+ double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
+ if (t3 < 0) {
+ n3 = 0.0;
+ } else {
+ t3 *= t3;
+ n3 = t3 * t3 * dot(grad4[gi3], x3, y3, z3, w3);
+ }
+ double t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
+ if (t4 < 0) {
+ n4 = 0.0;
+ } else {
+ t4 *= t4;
+ n4 = t4 * t4 * dot(grad4[gi4], x4, y4, z4, w4);
+ }
+
+ // Sum up and scale the result to cover the range [-1,1]
+ return 27.0 * (n0 + n1 + n2 + n3 + n4);
+ }
+
+ // Inner class to speed up gradient computations
+ // (array access is a lot slower than member access)
+ private static class Grad {
+ double x, y, z, w;
+
+ Grad(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ Grad(double x, double y, double z, double w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
+ }
+}
\ No newline at end of file
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/Cache.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/Cache.java
new file mode 100644
index 0000000..f0745c0
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/Cache.java
@@ -0,0 +1,5 @@
+package com.github.hoqhuuep.islandcraft.util;
+
+public interface Cache {
+ V get(K key);
+}
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/CacheLoader.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/CacheLoader.java
new file mode 100644
index 0000000..484dc02
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/CacheLoader.java
@@ -0,0 +1,5 @@
+package com.github.hoqhuuep.islandcraft.util;
+
+public interface CacheLoader {
+ V load(K key);
+}
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/EternalLoadingCache.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/EternalLoadingCache.java
new file mode 100644
index 0000000..dd00b1e
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/EternalLoadingCache.java
@@ -0,0 +1,28 @@
+package com.github.hoqhuuep.islandcraft.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class EternalLoadingCache implements Cache {
+ private final CacheLoader loader;
+ private final Map cache = new HashMap();
+
+ public EternalLoadingCache(CacheLoader loader) {
+ this.loader = loader;
+ }
+
+ @Override
+ public V get(K key) {
+ // Try to get value from cache
+ V value = cache.get(key);
+ if (value != null) {
+ return value;
+ }
+ // Otherwise generate new value using loader
+ value = loader.load(key);
+ if (value != null) {
+ cache.put(key, value);
+ }
+ return value;
+ }
+}
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/ExpiringLoadingCache.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/ExpiringLoadingCache.java
new file mode 100644
index 0000000..2a1c744
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/ExpiringLoadingCache.java
@@ -0,0 +1,77 @@
+package com.github.hoqhuuep.islandcraft.util;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class ExpiringLoadingCache implements Cache {
+ private final int millis;
+ private final CacheLoader loader;
+ private final Map> cache = new HashMap>();
+ private final Random random = new Random();
+
+ public ExpiringLoadingCache(int seconds, CacheLoader loader) {
+ this.millis = seconds * 1000;
+ this.loader = loader;
+ startTimer();
+ }
+
+ private void startTimer() {
+ Timer timer = new Timer();
+ timer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ removeExpired();
+ startTimer();
+ }
+ }, millis + random.nextInt(millis));
+ }
+
+ private void removeExpired() {
+ long nanos = System.nanoTime();
+ Iterator>> iterator = cache.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry> value = iterator.next();
+ if (value.getValue().expired(nanos)) {
+ iterator.remove();
+ }
+ }
+ }
+
+ @Override
+ public V get(K key) {
+ // Try to get value from cache
+ Expiring value = cache.get(key);
+ if (value == null) {
+ // Otherwise generate new value using loader
+ value = new Expiring(millis, loader.load(key));
+ cache.put(key, value);
+ }
+ return value.access();
+ }
+
+ private static class Expiring {
+ private long lifeNanos;
+ private long expiryNanos;
+ private final V value;
+
+ public Expiring(long millis, V value) {
+ this.lifeNanos = millis * 1000 * 1000;
+ this.expiryNanos = System.nanoTime() + lifeNanos;
+ this.value = value;
+ }
+
+ public V access() {
+ this.expiryNanos = System.nanoTime() + lifeNanos;
+ return this.value;
+ }
+
+ public boolean expired(long nanos) {
+ return nanos > expiryNanos;
+ }
+ }
+}
diff --git a/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/StringUtils.java b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/StringUtils.java
new file mode 100644
index 0000000..d44d25d
--- /dev/null
+++ b/IslandCraft-Common/src/main/java/com/github/hoqhuuep/islandcraft/util/StringUtils.java
@@ -0,0 +1,20 @@
+package com.github.hoqhuuep.islandcraft.util;
+
+public class StringUtils {
+ public static String join(String[] array, String sepeator) {
+ if (array.length == 0) {
+ return "";
+ }
+ StringBuilder result = new StringBuilder();
+ result.append(array[0]);
+ for (int i = 1; i < array.length; ++i) {
+ result.append(sepeator);
+ result.append(array[i]);
+ }
+ return result.toString();
+ }
+
+ public static boolean equals(String a, String b) {
+ return (a == null && b == null) || (a != null && a.equals(b));
+ }
+}
diff --git a/IslandCraft-Core/.gitignore b/IslandCraft-Core/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-Core/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-Core/dependency-reduced-pom.xml b/IslandCraft-Core/dependency-reduced-pom.xml
deleted file mode 100644
index 547fa17..0000000
--- a/IslandCraft-Core/dependency-reduced-pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-
- IslandCraft
- com.github.hoqhuuep
- 1.0.2
-
- 4.0.0
- IslandCraft-Core
-
-
-
- maven-shade-plugin
- 2.3
-
-
- package
-
- shade
-
-
-
-
-
-
- org.mcstats.*:*
- com.github.hoqhuuep:IslandCraft-Api
- com.github.hoqhuuep:IslandCraft-NMS*
- com.google*:*
-
-
-
-
- org.mcstats
- com.github.hoqhuuep.islandcraft.mcstats
-
-
- com.google
- com.github.hoqhuuep.islandcraft.google
-
-
-
-
-
- maven-jar-plugin
- 2.3.2
-
- IslandCraft-1.0.2
-
-
-
-
-
-
- commons-lang
- commons-lang
- 2.3
- provided
-
-
- org.bukkit
- bukkit
- 1.7.9-R0.2
- provided
-
-
-
-
diff --git a/IslandCraft-Core/logs/latest.log b/IslandCraft-Core/logs/latest.log
deleted file mode 100644
index e69de29..0000000
diff --git a/IslandCraft-Core/pom.xml b/IslandCraft-Core/pom.xml
deleted file mode 100644
index f046e6d..0000000
--- a/IslandCraft-Core/pom.xml
+++ /dev/null
@@ -1,145 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-Core
-
-
-
- com.google.guava
- guava
- 10.0.1
- compile
-
-
- com.github.hoqhuuep
- IslandCraft-Api
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_8_R3
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_8_R2
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_8_R1
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_7_R4
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_7_R3
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_7_R2
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_7_R1
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_6_R3
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_6_R2
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_6_R1
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_5_R3
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_5_R2
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_5_R1
- 1.0.2
-
-
- com.github.hoqhuuep
- IslandCraft-NMS-v1_4_R1
- 1.0.2
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 2.3
-
-
-
- org.mcstats.*:*
- com.github.hoqhuuep:IslandCraft-Api
- com.github.hoqhuuep:IslandCraft-NMS*
- com.google*:*
-
-
-
-
- org.mcstats
- com.github.hoqhuuep.islandcraft.mcstats
-
-
- com.google
- com.github.hoqhuuep.islandcraft.google
-
-
-
-
-
- package
-
- shade
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 2.3.2
-
- IslandCraft-1.0.2
-
-
-
-
-
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftPlugin.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftPlugin.java
deleted file mode 100644
index fe3a99f..0000000
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftPlugin.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package com.github.hoqhuuep.islandcraft.bukkit;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.logging.Level;
-
-import org.bukkit.Bukkit;
-import org.bukkit.World;
-import org.bukkit.WorldCreator;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Listener;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import com.avaje.ebean.EbeanServer;
-import com.github.hoqhuuep.islandcraft.api.ICLocation;
-import com.github.hoqhuuep.islandcraft.api.ICRegion;
-import com.github.hoqhuuep.islandcraft.api.IslandCraft;
-import com.github.hoqhuuep.islandcraft.core.DefaultIslandCraft;
-import com.github.hoqhuuep.islandcraft.core.EbeanServerIslandDatabase;
-import com.github.hoqhuuep.islandcraft.core.EbeanServerUtil;
-import com.github.hoqhuuep.islandcraft.core.ICLogger;
-import com.github.hoqhuuep.islandcraft.core.IslandDatabase;
-import com.github.hoqhuuep.islandcraft.nms.NmsWrapper;
-
-public class IslandCraftPlugin extends JavaPlugin {
-
- private DefaultIslandCraft islandCraft = null;
-
- @Override
- public void onEnable() {
- ICLogger.logger = getLogger();
-
- // https://github.com/Hidendra/Plugin-Metrics/wiki/Usage
- try {
- final Metrics metrics = new Metrics(this);
- metrics.start();
- } catch (final Exception e) {
- ICLogger.logger.warning("Failed to start MCStats");
- }
-
- saveDefaultConfig();
- FileConfiguration config = getConfig();
- if (!config.contains("config-version") || !config.isString("config-version")) {
- ICLogger.logger.severe("No string-value for 'config-version' found in config.yml");
- ICLogger.logger.severe("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
- setEnabled(false);
- return;
- }
- final String configVersion = config.getString("config-version");
- if (!configVersion.equals("1.0.0")) {
- ICLogger.logger.severe("Incompatible config-version found in config.yml");
- ICLogger.logger.severe("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
- setEnabled(false);
- return;
- }
-
- if (!config.contains("verbose-logging") || !config.isBoolean("verbose-logging")) {
- ICLogger.logger.warning("No boolean-value for 'verbose-logging' found in config.yml");
- ICLogger.logger.warning("Default value 'false' will be used");
- }
- final boolean verboseLogging = config.getBoolean("verbose-logging", false);
- ICLogger.logger.setLevel(verboseLogging ? Level.ALL : Level.WARNING);
-
- final NmsWrapper nms = NmsWrapper.getInstance(getServer());
- if (nms == null) {
- ICLogger.logger.severe("IslandCraft does not currently support this CraftBukkit version");
- ICLogger.logger.severe("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
- setEnabled(false);
- return;
- }
-
- IslandDatabase database;
- try {
- final EbeanServer ebeanServer = EbeanServerUtil.build(this);
- database = new EbeanServerIslandDatabase(ebeanServer);
- } catch (final Exception e) {
- ICLogger.logger.severe("Error creating EbeanServer database");
- ICLogger.logger.severe("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
- ICLogger.logger.severe("Exception message: " + e.getMessage());
- setEnabled(false);
- return;
- }
-
- try {
- islandCraft = new DefaultIslandCraft();
- final Listener listener = new BiomeGeneratorListener(this, database, nms);
- getServer().getPluginManager().registerEvents(listener, this);
- } catch (final Exception e) {
- ICLogger.logger.severe("Error creating or registering BiomeGeneratorListener");
- ICLogger.logger.severe("Check for updates at http://dev.bukkit.org/bukkit-plugins/islandcraft/");
- ICLogger.logger.severe("Exception message: " + e.getMessage());
- setEnabled(false);
- return;
- }
- }
-
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (sender instanceof Player) {
- sender.sendMessage("This command can only be executed by console!");
- return false;
- }
- if (args.length == 0) {
- sender.sendMessage("/ic ");
- return false;
- }
- if ("reload".equals(args[0])) {
- sender.sendMessage("Reloaded IslandCraft configuration");
- reloadConfig();
- } else if ("create".equals(args[0])) {
- // ic create 2 1 ConstantBiomeDistribution IslandGeneratorAlpha
- if (args.length < 4) {
- sender.sendMessage("/ic create ");
- sender.sendMessage("OR");
- sender.sendMessage("/ic create [distribution] [generator]");
- sender.sendMessage("Note: An island size of 1 = 4 chunks");
- return false;
- }
- String world = args[1];
- int island;
- int ocean;
- try {
- island = Integer.parseInt(args[2]) * 32;
- ocean = Integer.parseInt(args[3]) * 32;
- } catch (Exception e) {
- sender.sendMessage("Invalid size for:");
- sender.sendMessage("/ic create [distribution] [generator]");
- return false;
- }
- String distribution = "SquareIslandDistribution";
- String generator = "IslandGeneratorAlpha";
- if (args.length > 4) {
- distribution = args[4];
- }
- if (args.length > 5) {
- distribution = args[5];
- }
- FileConfiguration config = getConfig();
- String path = "worlds." + world;
- config.set(path + "." + "ocean", "com.github.hoqhuuep.islandcraft.core.ConstantBiomeDistribution DEEP_OCEAN");
- config.set(path + "." + "island-distribution", "com.github.hoqhuuep.islandcraft.core." + distribution + " " + island + " " + ocean);
- String[] gen_types = { "com.github.hoqhuuep.islandcraft.core." + generator + " BIRCH_FOREST BIRCH_FOREST_M BIRCH_FOREST_HILLS BIRCH_FOREST_HILLS_M ~ ~ OCEAN BEACH RIVER", "com.github.hoqhuuep.islandcraft.core." + generator + " COLD_TAIGA COLD_TAIGA_M COLD_TAIGA_HILLS ~ ~ ~ OCEAN COLD_BEACH FROZEN_RIVER",
- "com.github.hoqhuuep.islandcraft.core." + generator + " DESERT DESERT_M DESERT_HILLS ~ ~ ~ OCEAN BEACH RIVER", "com.github.hoqhuuep.islandcraft.core." + generator + " EXTREME_HILLS EXTREME_HILLS_M EXTREME_HILLS_PLUS EXTREME_HILLS_PLUS_M EXTREME_HILLS_EDGE ~ OCEAN STONE_BEACH RIVER",
- "com.github.hoqhuuep.islandcraft.core." + generator + " FOREST ~ FOREST_HILLS ~ FLOWER_FOREST ~ OCEAN BEACH RIVER", "com.github.hoqhuuep.islandcraft.core." + generator + " ICE_PLAINS ~ ICE_MOUNTAINS ~ ICE_PLAINS_SPIKES ~ OCEAN FROZEN_OCEAN FROZEN_RIVER",
- "com.github.hoqhuuep.islandcraft.core." + generator + " JUNGLE JUNGLE_M JUNGLE_HILLS ~ JUNGLE_EDGE JUNGLE_EDGE_M OCEAN BEACH RIVER", "com.github.hoqhuuep.islandcraft.core." + generator + " MEGA_TAIGA MEGA_SPRUCE_TAIGA MEGA_TAIGA_HILLS MEGA_SPRUCE_TAIGA_HILLS ~ ~ OCEAN BEACH RIVER",
- "com.github.hoqhuuep.islandcraft.core." + generator + " MESA MESA_BRYCE MESA_PLATEAU MESA_PLATEAU_M MESA_PLATEAU_F MESA_PLATEAU_F_M OCEAN MESA RIVER", "com.github.hoqhuuep.islandcraft.core." + generator + " MUSHROOM_ISLAND ~ ~ ~ ~ ~ OCEAN MUSHROOM_ISLAND_SHORE RIVER",
- "com.github.hoqhuuep.islandcraft.core." + generator + " PLAINS ~ SUNFLOWER_PLAINS ~ ~ ~ OCEAN BEACH RIVER", "com.github.hoqhuuep.islandcraft.core." + generator + " ROOFED_FOREST ROOFED_FOREST_M ~ ~ ~ ~ OCEAN BEACH RIVER",
- "com.github.hoqhuuep.islandcraft.core." + generator + " SAVANNA SAVANNA_M SAVANNA_PLATEAU SAVANNA_PLATEAU_M ~ ~ OCEAN BEACH RIVER", "com.github.hoqhuuep.islandcraft.core." + generator + " SWAMPLAND SWAMPLAND_M ~ ~ ~ ~ OCEAN BEACH RIVER",
- "com.github.hoqhuuep.islandcraft.core." + generator + " TAIGA TAIGA_M TAIGA_HILLS ~ ~ ~ OCEAN BEACH RIVER" };
-
- config.set(path + "." + "island-generators", gen_types);
-
- sender.sendMessage("Saving configuration!");
- saveConfig();
- reloadConfig();
- sender.sendMessage("Generating world; please wait...");
- if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
- } else {
- if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
- } else {
- Bukkit.createWorld(new WorldCreator(world).environment(World.Environment.NORMAL));
- }
- }
- sender.sendMessage("Done!");
- } else {
- sender.sendMessage("/ic ");
- }
- return true;
- }
-
- @Override
- public void onDisable() {
- ICLogger.logger = null;
- }
-
- @Override
- public List> getDatabaseClasses() {
- final Class>[] classes = { EbeanServerIslandDatabase.IslandBean.class, EbeanServerIslandDatabase.IslandPK.class };
- return Arrays.asList(classes);
- }
-
- public IslandCraft getIslandCraft() {
- return islandCraft;
- }
-
- private static final int BLOCKS_PER_CHUNK = 16;
-
- public void regenerate(final World world, final ICRegion region) {
- final ICLocation min = region.getMin();
- final ICLocation max = region.getMax();
- final int minX = min.getX() / BLOCKS_PER_CHUNK;
- final int minZ = min.getZ() / BLOCKS_PER_CHUNK;
- final int maxX = max.getX() / BLOCKS_PER_CHUNK;
- final int maxZ = max.getZ() / BLOCKS_PER_CHUNK;
- // Must loop from high to low for trees to generate correctly
- for (int x = maxX - 1; x >= minX; --x) {
- for (int z = maxZ - 1; z >= minZ; --z) {
- // TODO queue these?
- world.regenerateChunk(x, z);
- }
- }
- }
-}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantBiomeDistribution.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantBiomeDistribution.java
deleted file mode 100644
index 883bb4b..0000000
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ConstantBiomeDistribution.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.github.hoqhuuep.islandcraft.core;
-
-import org.apache.commons.lang.StringUtils;
-
-import com.github.hoqhuuep.islandcraft.api.BiomeDistribution;
-import com.github.hoqhuuep.islandcraft.api.ICBiome;
-
-public class ConstantBiomeDistribution implements BiomeDistribution {
- private final ICBiome biome;
-
- public ConstantBiomeDistribution(final String[] args) {
- ICLogger.logger.info("Creating ConstantBiomeDistribution with args: " + StringUtils.join(args, " "));
- if (args.length != 1) {
- ICLogger.logger.severe("ConstantBiomeDistribution requrires 1 parameter, " + args.length + " given");
- throw new IllegalArgumentException("ConstantBiomeDistribution requrires 1 parameter");
- }
- biome = ICBiome.valueOf(args[0]);
- }
-
- @Override
- public ICBiome biomeAt(final int x, final int z, final long worldSeed) {
- return biome;
- }
-}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ICLogger.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ICLogger.java
deleted file mode 100644
index 7174b46..0000000
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/ICLogger.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.github.hoqhuuep.islandcraft.core;
-
-import java.util.logging.Logger;
-
-public class ICLogger {
- public static Logger logger = null;
-}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandGeneratorAlpha.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandGeneratorAlpha.java
deleted file mode 100644
index 77ff29e..0000000
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandGeneratorAlpha.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package com.github.hoqhuuep.islandcraft.core;
-
-import java.awt.AlphaComposite;
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-import java.util.Random;
-
-import org.apache.commons.lang.StringUtils;
-import org.bukkit.util.noise.OctaveGenerator;
-import org.bukkit.util.noise.SimplexOctaveGenerator;
-
-import com.github.hoqhuuep.islandcraft.api.ICBiome;
-import com.github.hoqhuuep.islandcraft.api.IslandGenerator;
-import com.github.hoqhuuep.islandcraft.core.mosaic.Poisson;
-import com.github.hoqhuuep.islandcraft.core.mosaic.Site;
-
-public class IslandGeneratorAlpha implements IslandGenerator {
- private static final double MIN_DISTANCE = 8;
- private static final double NOISE = 2.7;
- private static final double CIRCLE = 2;
- private static final double SQUARE = 0;
- private static final double THRESHOLD = 2;
- private final Color ocean;
- private final Color normal;
- private final Color mountains;
- private final Color hills;
- private final Color hillsMountains;
- private final Color forest;
- private final Color forestMountains;
- private final Color outerCoast;
- private final Color innerCoast;
-
- // private final Color river; // unused for now
-
- public IslandGeneratorAlpha(final String[] args) {
- ICLogger.logger.info("Creating IslandGeneratorAlpha with args: " + StringUtils.join(args, " "));
- if (args.length != 9) {
- ICLogger.logger.severe("IslandGeneratorAlpha requrires 9 parameters, " + args.length + " given");
- throw new IllegalArgumentException("IslandGeneratorAlpha requrires 9 parameters");
- }
- ocean = new Color(ICBiome.values().length, true);
- normal = biomeColor(args[0], ocean);
- mountains = biomeColor(args[1], normal);
- hills = biomeColor(args[2], normal);
- hillsMountains = biomeColor(args[3], hills);
- forest = biomeColor(args[4], normal);
- forestMountains = biomeColor(args[5], forest);
- outerCoast = biomeColor(args[6], normal);
- innerCoast = biomeColor(args[7], normal);
- // river = biomeColor(args[8], normal); // unused for now
- }
-
- @Override
- public ICBiome[] generate(final int xSize, final int zSize, final long islandSeed) {
- ICLogger.logger.info(String.format("Generating island from IslandGeneratorAlpha with xSize: %d, zSize: %d, islandSeed: %d, biome: %s", xSize, zSize, islandSeed, ICBiome.values()[normal.getRGB()]));
- final Poisson poisson = new Poisson(xSize, zSize, MIN_DISTANCE);
- final List sites = poisson.generate(new Random(islandSeed));
- final SimplexOctaveGenerator shapeNoise = new SimplexOctaveGenerator(islandSeed, 2);
- final SimplexOctaveGenerator hillsNoise = new SimplexOctaveGenerator(islandSeed + 1, 2);
- final SimplexOctaveGenerator forestNoise = new SimplexOctaveGenerator(islandSeed + 2, 2);
- final SimplexOctaveGenerator mountainsNoise = new SimplexOctaveGenerator(islandSeed + 3, 2);
- // Find borders
- final Queue oceanSites = new LinkedList();
- for (final Site site : sites) {
- if (site.polygon == null) {
- site.isOcean = true;
- oceanSites.add(site);
- }
- }
- final List suspectCoast = new ArrayList();
- final List coast = new ArrayList();
- // Find oceans and coasts
- while (!oceanSites.isEmpty()) {
- final Site site = oceanSites.remove();
- for (final Site neighbor : site.neighbors) {
- if (site.polygon == null) {
- if (!neighbor.isOcean) {
- neighbor.isOcean = true;
- oceanSites.add(neighbor);
- }
- } else {
- final double dx = (double) (neighbor.x - (xSize / 2)) / (double) (xSize / 2);
- final double dz = (double) (neighbor.z - (zSize / 2)) / (double) (zSize / 2);
- if (NOISE * noise(dx, dz, shapeNoise) + CIRCLE * circle(dx, dz) + SQUARE * square(dx, dz) > THRESHOLD) {
- if (!neighbor.isOcean) {
- neighbor.isOcean = true;
- oceanSites.add(neighbor);
- }
- } else {
- neighbor.isInnerCoast = true;
- suspectCoast.add(neighbor);
- }
- }
- }
- }
- // Create coast
- SITE: for (final Site site : suspectCoast) {
- for (final Site neighbor : site.neighbors) {
- if (!neighbor.isOcean && !neighbor.isInnerCoast) {
- coast.add(site);
- continue SITE;
- }
- }
- site.isInnerCoast = false;
- site.isOcean = true;
- }
- // Create shallow ocean
- for (final Site site : coast) {
- for (final Site neighbor : site.neighbors) {
- if (neighbor.isOcean) {
- neighbor.isOcean = false;
- neighbor.isOuterCoast = true;
- }
- }
- }
- // Create blank image
- final BufferedImage image = new BufferedImage(xSize, zSize, BufferedImage.TYPE_INT_ARGB);
- final Graphics2D graphics = image.createGraphics();
- graphics.setComposite(AlphaComposite.Src);
- graphics.setBackground(ocean);
- graphics.clearRect(0, 0, xSize, zSize);
- // Render island
- for (final Site site : sites) {
- if (site.isOcean) {
- continue;
- } else if (site.isOuterCoast) {
- graphics.setColor(outerCoast);
- } else if (site.isInnerCoast) {
- graphics.setColor(innerCoast);
- } else if (noise(site, 0.375, 160.0, mountainsNoise)) {
- if (noise(site, 0.375, 80.0, hillsNoise)) {
- graphics.setColor(hillsMountains);
- } else if (noise(site, 0.375, 160.0, forestNoise)) {
- graphics.setColor(forestMountains);
- } else {
- graphics.setColor(mountains);
- }
- } else {
- if (noise(site, 0.375, 80.0, hillsNoise)) {
- graphics.setColor(hills);
- } else if (noise(site, 0.375, 160.0, forestNoise)) {
- graphics.setColor(forest);
- } else {
- graphics.setColor(normal);
- }
- }
- graphics.fillPolygon(site.polygon);
- graphics.drawPolygon(site.polygon);
- }
- // Save result
- graphics.dispose();
- final ICBiome[] result = new ICBiome[xSize * zSize];
- final ICBiome[] values = ICBiome.values();
- final int maxOrdinal = values.length;
- for (int i = 0; i < result.length; ++i) {
- final int x = i % xSize;
- final int z = i / xSize;
- final int ordinal = image.getRGB(x, z);
- if (ordinal < maxOrdinal) {
- result[i] = values[ordinal];
- }
- }
- return result;
- }
-
- private static Color biomeColor(final String name, final Color backup) {
- if (name.equals("~")) {
- return backup;
- }
- return new Color(ICBiome.valueOf(name).ordinal(), true);
- }
-
- private static boolean noise(final Site site, final double threshold, final double period, final OctaveGenerator octaveGenerator) {
- return octaveGenerator.noise(site.x / period, site.z / period, 2.0, 0.5, true) / 2.0 + 0.5 < threshold;
- }
-
- private static double noise(final double dx, final double dz, final OctaveGenerator octaveGenerator) {
- return octaveGenerator.noise(dx, dz, 2.0, 0.5, true) / 2.0 + 0.5;
- }
-
- private static double circle(final double dx, final double dz) {
- return (dx * dx + dz * dz) / 2;
- }
-
- private static double square(final double dx, final double dz) {
- return Math.max(Math.abs(dx), Math.abs(dz));
- }
-}
diff --git a/IslandCraft-NMS-v1_4_R1/.gitignore b/IslandCraft-NMS-v1_4_R1/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_4_R1/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_4_R1/pom.xml b/IslandCraft-NMS-v1_4_R1/pom.xml
deleted file mode 100644
index 0bfd8ff..0000000
--- a/IslandCraft-NMS-v1_4_R1/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_4_R1
-
-
-
- org.bukkit
- craftbukkit
- 1.4.7-R1.1-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_5_R1/.gitignore b/IslandCraft-NMS-v1_5_R1/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_5_R1/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_5_R1/pom.xml b/IslandCraft-NMS-v1_5_R1/pom.xml
deleted file mode 100644
index 789e35d..0000000
--- a/IslandCraft-NMS-v1_5_R1/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_5_R1
-
-
-
- org.bukkit
- craftbukkit
- 1.5-R0.1-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_5_R2/.gitignore b/IslandCraft-NMS-v1_5_R2/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_5_R2/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_5_R2/pom.xml b/IslandCraft-NMS-v1_5_R2/pom.xml
deleted file mode 100644
index 0520e70..0000000
--- a/IslandCraft-NMS-v1_5_R2/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_5_R2
-
-
-
- org.bukkit
- craftbukkit
- 1.5.1-R0.3-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_5_R3/.gitignore b/IslandCraft-NMS-v1_5_R3/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_5_R3/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_5_R3/pom.xml b/IslandCraft-NMS-v1_5_R3/pom.xml
deleted file mode 100644
index f97f0c1..0000000
--- a/IslandCraft-NMS-v1_5_R3/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_5_R3
-
-
-
- org.bukkit
- craftbukkit
- 1.5.2-R1.1-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_6_R1/.gitignore b/IslandCraft-NMS-v1_6_R1/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_6_R1/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_6_R1/pom.xml b/IslandCraft-NMS-v1_6_R1/pom.xml
deleted file mode 100644
index dccb5b5..0000000
--- a/IslandCraft-NMS-v1_6_R1/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_6_R1
-
-
-
- org.bukkit
- craftbukkit
- 1.6.1-R0.1-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_6_R2/.gitignore b/IslandCraft-NMS-v1_6_R2/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_6_R2/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_6_R2/pom.xml b/IslandCraft-NMS-v1_6_R2/pom.xml
deleted file mode 100644
index a3a239d..0000000
--- a/IslandCraft-NMS-v1_6_R2/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_6_R2
-
-
-
- org.bukkit
- craftbukkit
- 1.6.2-R1.1-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_6_R3/.gitignore b/IslandCraft-NMS-v1_6_R3/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_6_R3/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_6_R3/pom.xml b/IslandCraft-NMS-v1_6_R3/pom.xml
deleted file mode 100644
index 9994644..0000000
--- a/IslandCraft-NMS-v1_6_R3/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_6_R3
-
-
-
- org.bukkit
- craftbukkit
- 1.6.4-R2.1-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_7_R1/.gitignore b/IslandCraft-NMS-v1_7_R1/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_7_R1/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_7_R1/pom.xml b/IslandCraft-NMS-v1_7_R1/pom.xml
deleted file mode 100644
index 304cb87..0000000
--- a/IslandCraft-NMS-v1_7_R1/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_7_R1
-
-
-
- org.bukkit
- craftbukkit
- 1.7.2-R0.4-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_7_R2/.gitignore b/IslandCraft-NMS-v1_7_R2/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_7_R2/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_7_R2/pom.xml b/IslandCraft-NMS-v1_7_R2/pom.xml
deleted file mode 100644
index 018dc66..0000000
--- a/IslandCraft-NMS-v1_7_R2/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_7_R2
-
-
-
- org.bukkit
- craftbukkit
- 1.7.5-R0.1-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_7_R3/.gitignore b/IslandCraft-NMS-v1_7_R3/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_7_R3/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_7_R3/pom.xml b/IslandCraft-NMS-v1_7_R3/pom.xml
deleted file mode 100644
index 267201b..0000000
--- a/IslandCraft-NMS-v1_7_R3/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_7_R3
-
-
-
- org.bukkit
- craftbukkit
- 1.7.9-R0.3-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_7_R4/.gitignore b/IslandCraft-NMS-v1_7_R4/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_7_R4/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_7_R4/pom.xml b/IslandCraft-NMS-v1_7_R4/pom.xml
deleted file mode 100644
index 895f898..0000000
--- a/IslandCraft-NMS-v1_7_R4/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_7_R4
-
-
-
- org.bukkit
- craftbukkit
- 1.7.10-R0.1-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_8_R1/.gitignore b/IslandCraft-NMS-v1_8_R1/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_8_R1/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_8_R1/bin/.classpath.old b/IslandCraft-NMS-v1_8_R1/bin/.classpath.old
deleted file mode 100644
index 7092a1c..0000000
--- a/IslandCraft-NMS-v1_8_R1/bin/.classpath.old
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/IslandCraft-NMS-v1_8_R1/bin/.gitignore b/IslandCraft-NMS-v1_8_R1/bin/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_8_R1/bin/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_8_R1/bin/pom.xml b/IslandCraft-NMS-v1_8_R1/bin/pom.xml
deleted file mode 100644
index 0773f0c..0000000
--- a/IslandCraft-NMS-v1_8_R1/bin/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_8_R1
-
-
-
- org.bukkit
- craftbukkit
- 1.7.8-R1-SNAPSHOT
- provided
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/CustomWorldChunkManager.class b/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/CustomWorldChunkManager.class
deleted file mode 100644
index e2e6ae4..0000000
Binary files a/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/CustomWorldChunkManager.class and /dev/null differ
diff --git a/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/NmsHandler.class b/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/NmsHandler.class
deleted file mode 100644
index f01e8d2..0000000
Binary files a/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/NmsHandler.class and /dev/null differ
diff --git a/IslandCraft-NMS-v1_8_R1/pom.xml b/IslandCraft-NMS-v1_8_R1/pom.xml
deleted file mode 100644
index 85d9199..0000000
--- a/IslandCraft-NMS-v1_8_R1/pom.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_8_R1
-
-
-
- org.bukkit
- craftbukkit
- 1.8-R1-SNAPSHOT
- system
- C:\Users\Daniel\Dropbox\Projects\IslandCraft\Spigot\craftbukkit-1.8.jar
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_8_R2/.gitignore b/IslandCraft-NMS-v1_8_R2/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_8_R2/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_8_R2/pom.xml b/IslandCraft-NMS-v1_8_R2/pom.xml
deleted file mode 100644
index 29c706a..0000000
--- a/IslandCraft-NMS-v1_8_R2/pom.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_8_R2
-
-
-
- org.bukkit
- craftbukkit
- 1.8.3-R0.1-SNAPSHOT
- system
- C:\Users\Daniel\Dropbox\Projects\IslandCraft\Spigot-1.8.3\craftbukkit-1.8.3.jar
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/CustomWorldChunkManager.java
index 5ef6166..3d84966 100644
--- a/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/CustomWorldChunkManager.java
@@ -94,7 +94,7 @@ public CustomWorldChunkManager(final BiomeGenerator biomeGenerator) {
/** Returns a list of biome's which are valid for spawn */
@Override
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public List a() {
return super.a();
}
diff --git a/IslandCraft-NMS-v1_8_R3/.gitignore b/IslandCraft-NMS-v1_8_R3/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS-v1_8_R3/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS-v1_8_R3/pom.xml b/IslandCraft-NMS-v1_8_R3/pom.xml
deleted file mode 100644
index 518d480..0000000
--- a/IslandCraft-NMS-v1_8_R3/pom.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS-v1_8_R3
-
-
-
- org.bukkit
- craftbukkit
- 1.8.7-R0.1-SNAPSHOT
- system
- C:\Users\Daniel\Dropbox\Projects\IslandCraft\Spigot-1.8.7\craftbukkit-1.8.7.jar
-
-
- com.github.hoqhuuep
- IslandCraft-NMS
- 1.0.2
-
-
-
diff --git a/IslandCraft-NMS-v1_8_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R3/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_8_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R3/CustomWorldChunkManager.java
index 863bd8e..cc7897b 100644
--- a/IslandCraft-NMS-v1_8_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R3/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_8_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R3/CustomWorldChunkManager.java
@@ -94,7 +94,7 @@ public CustomWorldChunkManager(final BiomeGenerator biomeGenerator) {
/** Returns a list of biome's which are valid for spawn */
@Override
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public List a() {
return super.a();
}
diff --git a/IslandCraft-NMS/.gitignore b/IslandCraft-NMS/.gitignore
deleted file mode 100644
index c449f83..0000000
--- a/IslandCraft-NMS/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/target
-/.settings
-/.checkstyle
-/.classpath
-/.project
diff --git a/IslandCraft-NMS/pom.xml b/IslandCraft-NMS/pom.xml
deleted file mode 100644
index c31bcdd..0000000
--- a/IslandCraft-NMS/pom.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
- 4.0.0
-
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
-
- IslandCraft-NMS
-
-
-
- com.github.hoqhuuep
- IslandCraft-Api
- 1.0.2
-
-
-
\ No newline at end of file
diff --git a/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/IslandCraftBiomeGenerator.java b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/IslandCraftBiomeGenerator.java
new file mode 100644
index 0000000..adf0141
--- /dev/null
+++ b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/IslandCraftBiomeGenerator.java
@@ -0,0 +1,117 @@
+package com.github.hoqhuuep.islandcraft;
+
+import java.util.EnumMap;
+import java.util.Map;
+
+import org.spongepowered.api.world.biome.BiomeType;
+import org.spongepowered.api.world.biome.BiomeTypes;
+import org.spongepowered.api.world.extent.MutableBiomeArea;
+import org.spongepowered.api.world.gen.BiomeGenerator;
+
+import com.flowpowered.math.vector.Vector2i;
+import com.github.hoqhuuep.islandcraft.api.ICBiome;
+import com.github.hoqhuuep.islandcraft.api.ICWorld;
+import com.github.hoqhuuep.islandcraft.core.DefaultWorld;
+import com.github.hoqhuuep.islandcraft.core.ICClassLoader;
+import com.github.hoqhuuep.islandcraft.core.IslandCache;
+import com.github.hoqhuuep.islandcraft.core.IslandDatabase;
+
+import ninja.leaping.configurate.commented.CommentedConfigurationNode;
+
+public class IslandCraftBiomeGenerator implements BiomeGenerator {
+ private final ICWorld icWorld;
+
+ public IslandCraftBiomeGenerator(String worldName, long worldSeed, CommentedConfigurationNode config, IslandDatabase database) {
+ icWorld = new DefaultWorld(worldName, worldSeed, database, new SpongeWorldConfig(config), new IslandCache(), new ICClassLoader());
+ }
+
+ @Override
+ public void generateBiomes(MutableBiomeArea buffer) {
+ Vector2i min = buffer.getBiomeMin();
+ Vector2i max = buffer.getBiomeMax();
+ int xMin = min.getX();
+ int xMax = max.getX();
+ int zMin = min.getY();
+ int zMax = max.getY();
+ for (int z = zMin; z <= zMax; ++z) {
+ for (int x = xMin; x <= xMax; ++x) {
+ ICBiome icBiome = icWorld.getBiomeAt(x, z);
+ buffer.setBiome(x, z, convertBiome(icBiome));
+ }
+ }
+ }
+
+ private BiomeType convertBiome(ICBiome icBiome) {
+ BiomeType spongeBiome = spongeBiomeFromICBiome.get(icBiome);
+ if (spongeBiome == null) {
+ return BiomeTypes.DEEP_OCEAN;
+ }
+ return spongeBiome;
+ }
+
+ private final Map spongeBiomeFromICBiome = new EnumMap(ICBiome.class);
+
+ {
+ spongeBiomeFromICBiome.put(ICBiome.BEACH, BiomeTypes.BEACH);
+ spongeBiomeFromICBiome.put(ICBiome.BIRCH_FOREST, BiomeTypes.BIRCH_FOREST);
+ spongeBiomeFromICBiome.put(ICBiome.BIRCH_FOREST_HILLS, BiomeTypes.BIRCH_FOREST_HILLS);
+ spongeBiomeFromICBiome.put(ICBiome.BIRCH_FOREST_HILLS_M, BiomeTypes.BIRCH_FOREST_HILLS_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.BIRCH_FOREST_M, BiomeTypes.BIRCH_FOREST_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.COLD_BEACH, BiomeTypes.COLD_BEACH);
+ spongeBiomeFromICBiome.put(ICBiome.COLD_TAIGA, BiomeTypes.COLD_TAIGA);
+ spongeBiomeFromICBiome.put(ICBiome.COLD_TAIGA_HILLS, BiomeTypes.COLD_TAIGA_HILLS);
+ spongeBiomeFromICBiome.put(ICBiome.COLD_TAIGA_M, BiomeTypes.COLD_TAIGA_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.DEEP_OCEAN, BiomeTypes.DEEP_OCEAN);
+ spongeBiomeFromICBiome.put(ICBiome.DESERT, BiomeTypes.DESERT);
+ spongeBiomeFromICBiome.put(ICBiome.DESERT_HILLS, BiomeTypes.DESERT_HILLS);
+ spongeBiomeFromICBiome.put(ICBiome.DESERT_M, BiomeTypes.DESERT_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.END, BiomeTypes.SKY);
+ spongeBiomeFromICBiome.put(ICBiome.EXTREME_HILLS, BiomeTypes.EXTREME_HILLS);
+ spongeBiomeFromICBiome.put(ICBiome.EXTREME_HILLS_EDGE, BiomeTypes.EXTREME_HILLS_EDGE);
+ spongeBiomeFromICBiome.put(ICBiome.EXTREME_HILLS_M, BiomeTypes.EXTREME_HILLS_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.EXTREME_HILLS_PLUS, BiomeTypes.EXTREME_HILLS_PLUS);
+ spongeBiomeFromICBiome.put(ICBiome.EXTREME_HILLS_PLUS_M, BiomeTypes.EXTREME_HILLS_PLUS_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.FLOWER_FOREST, BiomeTypes.FLOWER_FOREST);
+ spongeBiomeFromICBiome.put(ICBiome.FOREST, BiomeTypes.FOREST);
+ spongeBiomeFromICBiome.put(ICBiome.FOREST_HILLS, BiomeTypes.FOREST_HILLS);
+ spongeBiomeFromICBiome.put(ICBiome.FROZEN_OCEAN, BiomeTypes.FROZEN_OCEAN);
+ spongeBiomeFromICBiome.put(ICBiome.FROZEN_RIVER, BiomeTypes.FROZEN_RIVER);
+ spongeBiomeFromICBiome.put(ICBiome.ICE_MOUNTAINS, BiomeTypes.ICE_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.ICE_PLAINS, BiomeTypes.ICE_PLAINS);
+ spongeBiomeFromICBiome.put(ICBiome.ICE_PLAINS_SPIKES, BiomeTypes.ICE_PLAINS_SPIKES);
+ spongeBiomeFromICBiome.put(ICBiome.JUNGLE, BiomeTypes.JUNGLE);
+ spongeBiomeFromICBiome.put(ICBiome.JUNGLE_EDGE, BiomeTypes.JUNGLE_EDGE);
+ spongeBiomeFromICBiome.put(ICBiome.JUNGLE_HILLS, BiomeTypes.JUNGLE_HILLS);
+ spongeBiomeFromICBiome.put(ICBiome.JUNGLE_M, BiomeTypes.JUNGLE_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.JUNGLE_EDGE_M, BiomeTypes.JUNGLE_EDGE_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.MEGA_SPRUCE_TAIGA, BiomeTypes.MEGA_SPRUCE_TAIGA);
+ spongeBiomeFromICBiome.put(ICBiome.MEGA_SPRUCE_TAIGA_HILLS, BiomeTypes.MEGA_SPRUCE_TAIGA_HILLS);
+ spongeBiomeFromICBiome.put(ICBiome.MEGA_TAIGA, BiomeTypes.MEGA_TAIGA);
+ spongeBiomeFromICBiome.put(ICBiome.MEGA_TAIGA_HILLS, BiomeTypes.MEGA_TAIGA_HILLS);
+ spongeBiomeFromICBiome.put(ICBiome.MESA, BiomeTypes.MESA);
+ spongeBiomeFromICBiome.put(ICBiome.MESA_BRYCE, BiomeTypes.MESA_BRYCE);
+ spongeBiomeFromICBiome.put(ICBiome.MESA_PLATEAU, BiomeTypes.MESA_PLATEAU);
+ spongeBiomeFromICBiome.put(ICBiome.MESA_PLATEAU_F, BiomeTypes.MESA_PLATEAU_FOREST);
+ spongeBiomeFromICBiome.put(ICBiome.MESA_PLATEAU_F_M, BiomeTypes.MESA_PLATEAU_FOREST_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.MESA_PLATEAU_M, BiomeTypes.MESA_PLATEAU_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.MUSHROOM_ISLAND, BiomeTypes.MUSHROOM_ISLAND);
+ spongeBiomeFromICBiome.put(ICBiome.MUSHROOM_ISLAND_SHORE, BiomeTypes.MUSHROOM_ISLAND_SHORE);
+ spongeBiomeFromICBiome.put(ICBiome.NETHER, BiomeTypes.HELL);
+ spongeBiomeFromICBiome.put(ICBiome.OCEAN, BiomeTypes.OCEAN);
+ spongeBiomeFromICBiome.put(ICBiome.PLAINS, BiomeTypes.PLAINS);
+ spongeBiomeFromICBiome.put(ICBiome.RIVER, BiomeTypes.RIVER);
+ spongeBiomeFromICBiome.put(ICBiome.ROOFED_FOREST, BiomeTypes.ROOFED_FOREST);
+ spongeBiomeFromICBiome.put(ICBiome.ROOFED_FOREST_M, BiomeTypes.ROOFED_FOREST_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.SAVANNA, BiomeTypes.SAVANNA);
+ spongeBiomeFromICBiome.put(ICBiome.SAVANNA_M, BiomeTypes.SAVANNA_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.SAVANNA_PLATEAU, BiomeTypes.SAVANNA_PLATEAU);
+ spongeBiomeFromICBiome.put(ICBiome.SAVANNA_PLATEAU_M, BiomeTypes.SAVANNA_PLATEAU_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.STONE_BEACH, BiomeTypes.STONE_BEACH);
+ spongeBiomeFromICBiome.put(ICBiome.SUNFLOWER_PLAINS, BiomeTypes.SUNFLOWER_PLAINS);
+ spongeBiomeFromICBiome.put(ICBiome.SWAMPLAND, BiomeTypes.SWAMPLAND);
+ spongeBiomeFromICBiome.put(ICBiome.SWAMPLAND_M, BiomeTypes.SWAMPLAND_MOUNTAINS);
+ spongeBiomeFromICBiome.put(ICBiome.TAIGA, BiomeTypes.TAIGA);
+ spongeBiomeFromICBiome.put(ICBiome.TAIGA_HILLS, BiomeTypes.TAIGA_HILLS);
+ spongeBiomeFromICBiome.put(ICBiome.TAIGA_M, BiomeTypes.TAIGA_MOUNTAINS);
+ }
+}
diff --git a/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/IslandCraftGeneratorModifier.java b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/IslandCraftGeneratorModifier.java
new file mode 100644
index 0000000..3ac9daf
--- /dev/null
+++ b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/IslandCraftGeneratorModifier.java
@@ -0,0 +1,38 @@
+package com.github.hoqhuuep.islandcraft;
+
+import org.spongepowered.api.data.DataContainer;
+import org.spongepowered.api.world.WorldCreationSettings;
+import org.spongepowered.api.world.gen.BiomeGenerator;
+import org.spongepowered.api.world.gen.WorldGenerator;
+import org.spongepowered.api.world.gen.WorldGeneratorModifier;
+
+import com.github.hoqhuuep.islandcraft.core.IslandDatabase;
+
+import ninja.leaping.configurate.commented.CommentedConfigurationNode;
+
+public class IslandCraftGeneratorModifier implements WorldGeneratorModifier {
+ private final CommentedConfigurationNode config;
+ private final IslandDatabase database;
+
+ public IslandCraftGeneratorModifier(CommentedConfigurationNode config, IslandDatabase database) {
+ this.config = config;
+ this.database = database;
+ }
+
+ @Override
+ public String getId() {
+ return "islandcraft:biomes";
+ }
+
+ @Override
+ public String getName() {
+ return "IslandCraft Biomes";
+ }
+
+ @Override
+ public void modifyWorldGenerator(WorldCreationSettings world, DataContainer settings, WorldGenerator worldGenerator) {
+ String worldName = world.getWorldName();
+ BiomeGenerator islandCraftBiomeGenerator = new IslandCraftBiomeGenerator(worldName, world.getSeed(), config.getNode(worldName), database);
+ worldGenerator.setBiomeGenerator(islandCraftBiomeGenerator);
+ }
+}
diff --git a/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/IslandCraftPlugin.java b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/IslandCraftPlugin.java
new file mode 100644
index 0000000..f979ae6
--- /dev/null
+++ b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/IslandCraftPlugin.java
@@ -0,0 +1,71 @@
+package com.github.hoqhuuep.islandcraft;
+
+import java.io.IOException;
+import java.sql.SQLException;
+
+import org.slf4j.Logger;
+import org.spongepowered.api.Sponge;
+import org.spongepowered.api.config.DefaultConfig;
+import org.spongepowered.api.event.Listener;
+import org.spongepowered.api.event.game.state.GameInitializationEvent;
+import org.spongepowered.api.event.game.state.GameStoppedEvent;
+import org.spongepowered.api.plugin.Plugin;
+import org.spongepowered.api.service.sql.SqlService;
+import org.spongepowered.api.world.gen.WorldGeneratorModifier;
+
+import com.github.hoqhuuep.islandcraft.core.ICLogger;
+import com.github.hoqhuuep.islandcraft.core.IslandDatabase;
+import com.google.inject.Inject;
+
+import ninja.leaping.configurate.ConfigurationOptions;
+import ninja.leaping.configurate.commented.CommentedConfigurationNode;
+import ninja.leaping.configurate.loader.ConfigurationLoader;
+
+@Plugin(id = "islandcraft", name = "IslandCraft", version = "1.0.3-SNAPSHOT")
+public class IslandCraftPlugin {
+ @Inject
+ private Logger logger;
+
+ @Inject
+ @DefaultConfig(sharedRoot = false)
+ private ConfigurationLoader configLoader;
+
+ private CommentedConfigurationNode config;
+
+ @Listener
+ public void onGameInitialization(GameInitializationEvent event) throws IOException, SQLException {
+ // Logging
+ ICLogger.logger = new Slf4jLogger(logger);
+
+ // Metrics
+ // https://github.com/Hidendra/Plugin-Metrics/wiki/Usage
+ try {
+ Metrics metrics = new Metrics(Sponge.getGame(), Sponge.getPluginManager().fromInstance(this).get());
+ metrics.start();
+ } catch (final Exception e) {
+ ICLogger.logger.warning("Failed to start MCStats");
+ }
+
+ // Configuration
+ config = configLoader.load(ConfigurationOptions.defaults().setShouldCopyDefaults(true));
+ if (!"1.0.0".equals(config.getNode("config-version").setComment("Do not modify config-version").getString("1.0.0"))) {
+ logger.error("Invalid config-version found in './config/islandcraft/islandcraft.config'. Must be '1.0.0'.");
+ return;
+ }
+
+ // Database
+ SqlService sqlService = Sponge.getServiceManager().provide(SqlService.class).get();
+ IslandDatabase database = new JdbcIslandDatabase(sqlService, config.getNode("database"));
+
+ // Modify world generator
+ WorldGeneratorModifier islandCraftGeneratorModifier = new IslandCraftGeneratorModifier(config.getNode("worlds"), database);
+ Sponge.getRegistry().register(WorldGeneratorModifier.class, islandCraftGeneratorModifier);
+ }
+
+ @Listener
+ public void onGameStopped(GameStoppedEvent event) throws IOException {
+ if (config != null) {
+ configLoader.save(config);
+ }
+ }
+}
diff --git a/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/JdbcIslandDatabase.java b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/JdbcIslandDatabase.java
new file mode 100644
index 0000000..b174eb9
--- /dev/null
+++ b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/JdbcIslandDatabase.java
@@ -0,0 +1,113 @@
+package com.github.hoqhuuep.islandcraft;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.spongepowered.api.service.sql.SqlService;
+
+import com.github.hoqhuuep.islandcraft.core.IslandDatabase;
+
+import ninja.leaping.configurate.commented.CommentedConfigurationNode;
+
+public class JdbcIslandDatabase implements IslandDatabase {
+ private final DataSource dataSource;
+ private final String username;
+ private final String password;
+
+ public JdbcIslandDatabase(SqlService sqlService, CommentedConfigurationNode config) throws SQLException {
+ String url = config.getNode("url").getString("jdbc:h2:./islandcraft");
+ username = config.getNode("username").getString(null);
+ password = config.getNode("password").getString(null);
+ dataSource = sqlService.getDataSource(url);
+ createTablesIfTheyDoNotExist();
+ }
+
+ Connection getConnection() throws SQLException {
+ if (username != null && password != null) {
+ return dataSource.getConnection(username, password);
+ }
+ return dataSource.getConnection();
+ }
+
+ private void createTablesIfTheyDoNotExist() throws SQLException {
+ try (Connection connection = getConnection();
+ PreparedStatement statement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS islandcraft_core (world_name VARCHAR(255) NOT NULL, center_x INTEGER NOT NULL, center_z INTEGER NOT NULL, island_seed BIGINT, generator VARCHAR(65535))")) {
+ statement.executeUpdate();
+ }
+ }
+
+ @Override
+ public void save(String worldName, int centerX, int centerZ, long islandSeed, String generator) {
+ if (load(worldName, centerX, centerZ) != null) {
+ // Already exists => UPDATE
+ try (Connection connection = getConnection();
+ PreparedStatement statement = connection.prepareStatement("UPDATE islandcraft_core SET island_seed=?, generator=? WHERE world_name=? AND center_x=? AND center_z=?")) {
+ statement.setLong(1, islandSeed);
+ statement.setString(2, generator);
+ statement.setString(3, worldName);
+ statement.setInt(4, centerX);
+ statement.setInt(5, centerZ);
+ statement.executeUpdate();
+ } catch (SQLException e) {
+ // Nothing we can do about this...
+ e.printStackTrace();
+ }
+ } else {
+ // Does not already exist => INSERT
+ try (Connection connection = getConnection();
+ PreparedStatement statement = connection.prepareStatement("INSERT INTO islandcraft_core (world_name, center_x, center_z, island_seed, generator) VALUES (?, ?, ?, ?, ?)")) {
+ statement.setString(1, worldName);
+ statement.setInt(2, centerX);
+ statement.setInt(3, centerZ);
+ statement.setLong(4, islandSeed);
+ statement.setString(5, generator);
+ statement.executeUpdate();
+ } catch (SQLException e) {
+ // Nothing we can do about this...
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public Result load(String worldName, int centerX, int centerZ) {
+ try (Connection connection = getConnection();
+ PreparedStatement statement = connection.prepareStatement("SELECT island_seed, generator FROM islandcraft_core WHERE world_name=? AND center_x=? AND center_z=?")) {
+ statement.setString(1, worldName);
+ statement.setInt(2, centerX);
+ statement.setInt(3, centerZ);
+ try (ResultSet result = statement.executeQuery()) {
+ if (result.next()) {
+ long islandSeed = result.getLong(1);
+ String generator = result.getString(2);
+ return new Result(islandSeed, generator);
+ }
+ }
+ } catch (SQLException e) {
+ // Nothing we can do about this...
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isEmpty(String worldName) {
+ try (Connection connection = getConnection();
+ PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) FROM islandcraft_core WHERE world_name=?")) {
+ statement.setString(1, worldName);
+ try (ResultSet result = statement.executeQuery()) {
+ if (result.next()) {
+ return result.getInt(1) == 0;
+ }
+ }
+ } catch (SQLException e) {
+ // Nothing we can do about this...
+ e.printStackTrace();
+ }
+ return false;
+ }
+}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/Metrics.java b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/Metrics.java
similarity index 82%
rename from IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/Metrics.java
rename to IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/Metrics.java
index 3f4525a..c1db281 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/Metrics.java
+++ b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/Metrics.java
@@ -1,5 +1,3 @@
-package com.github.hoqhuuep.islandcraft.bukkit;
-
/*
* Copyright 2011-2013 Tyler Blair. All rights reserved.
*
@@ -27,15 +25,16 @@
* authors and contributors and should not be interpreted as representing official policies,
* either expressed or implied, of anybody else.
*/
-import org.bukkit.Bukkit;
-import org.bukkit.Server;
-import org.bukkit.configuration.InvalidConfigurationException;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.plugin.PluginDescriptionFile;
-import org.bukkit.scheduler.BukkitTask;
+package com.github.hoqhuuep.islandcraft;
+
+import ninja.leaping.configurate.commented.CommentedConfigurationNode;
+import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
+import ninja.leaping.configurate.loader.ConfigurationLoader;
+import org.spongepowered.api.Game;
+import org.spongepowered.api.plugin.PluginContainer;
+import org.spongepowered.api.scheduler.Task;
+import javax.inject.Inject;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -43,19 +42,17 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Method;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
-import java.util.logging.Level;
+import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPOutputStream;
public class Metrics {
@@ -80,10 +77,15 @@ public class Metrics {
*/
private static final int PING_INTERVAL = 15;
+ /**
+ * The game data is being sent for
+ */
+ private final Game game;
+
/**
* The plugin this metrics submits for
*/
- private final Plugin plugin;
+ private final PluginContainer plugin;
/**
* All of the custom graphs to submit to metrics
@@ -93,22 +95,27 @@ public class Metrics {
/**
* The plugin configuration file
*/
- private final YamlConfiguration configuration;
+ private CommentedConfigurationNode config;
/**
* The plugin configuration file
*/
- private final File configurationFile;
+ private File configurationFile;
+
+ /**
+ * The configuration loader
+ */
+ private ConfigurationLoader configurationLoader;
/**
* Unique server id
*/
- private final String guid;
+ private String guid;
/**
* Debug mode
*/
- private final boolean debug;
+ private boolean debug;
/**
* Lock for synchronization
@@ -118,33 +125,47 @@ public class Metrics {
/**
* The scheduled task
*/
- private volatile int task = -1;
+ private volatile Task task = null;
- public Metrics(final Plugin plugin) throws IOException {
+ @Inject
+ public Metrics(final Game game, final PluginContainer plugin) throws IOException {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
+ this.game = game;
this.plugin = plugin;
- // load the config
+ loadConfiguration();
+ }
+
+ /**
+ * Loads the configuration
+ */
+ private void loadConfiguration() {
configurationFile = getConfigFile();
- configuration = YamlConfiguration.loadConfiguration(configurationFile);
+ configurationLoader = HoconConfigurationLoader.builder().setFile(configurationFile).build();
- // add some defaults
- configuration.addDefault("opt-out", false);
- configuration.addDefault("guid", UUID.randomUUID().toString());
- configuration.addDefault("debug", false);
+ try {
+ if (!configurationFile.exists()) {
+ configurationFile.createNewFile();
+ config = configurationLoader.load();
- // Do we need to create the file?
- if (configuration.get("guid", null) == null) {
- configuration.options().header("http://mcstats.org").copyDefaults(true);
- configuration.save(configurationFile);
- }
+ config.setComment("This contains settings for MCStats: http://mcstats.org");
+ config.getNode("mcstats.guid").setValue(UUID.randomUUID().toString());
+ config.getNode("mcstats.opt-out").setValue(false);
+ config.getNode("mcstats.debug").setValue(false);
- // Load the guid then
- guid = configuration.getString("guid");
- debug = configuration.getBoolean("debug", false);
+ configurationLoader.save(config);
+ } else {
+ config = configurationLoader.load();
+ }
+
+ guid = config.getNode("mcstats.guid").getString();
+ debug = config.getNode("mcstats.debug").getBoolean();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
/**
@@ -197,13 +218,12 @@ public boolean start() {
}
// Is metrics already running?
- if (task != -1) {
+ if (task != null) {
return true;
}
// Begin hitting the server with glorious data
- task = plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
-
+ game.getScheduler().createTaskBuilder().async().interval(PING_INTERVAL, TimeUnit.MINUTES).execute(new Runnable() {
private boolean firstPost = true;
public void run() {
@@ -211,9 +231,9 @@ public void run() {
// This has to be synchronized or it can collide with the disable method.
synchronized (optOutLock) {
// Disable Task, if it is running and the server owner decided to opt-out
- if (isOptOut() && task != -1) {
- plugin.getServer().getScheduler().cancelTask(task);
- task = -1;
+ if (isOptOut() && task != null) {
+ task.cancel();
+ task = null;
// Tell all plotters to stop gathering information.
for (Graph graph : graphs) {
graph.onOptOut();
@@ -231,11 +251,11 @@ public void run() {
firstPost = false;
} catch (IOException e) {
if (debug) {
- Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
+ System.out.println("[Metrics] " + e.getMessage());
}
}
}
- }, 0l, PING_INTERVAL * 1200l);
+ }).submit(plugin);
return true;
}
@@ -248,21 +268,9 @@ public void run() {
*/
public boolean isOptOut() {
synchronized (optOutLock) {
- try {
- // Reload the metrics file
- configuration.load(getConfigFile());
- } catch (IOException ex) {
- if (debug) {
- Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
- }
- return true;
- } catch (InvalidConfigurationException ex) {
- if (debug) {
- Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
- }
- return true;
- }
- return configuration.getBoolean("opt-out", false);
+ loadConfiguration();
+
+ return config.getNode("mcstats.opt-out").getBoolean();
}
}
@@ -276,12 +284,12 @@ public void enable() throws IOException {
synchronized (optOutLock) {
// Check if the server owner has already set opt-out, if not, set it.
if (isOptOut()) {
- configuration.set("opt-out", false);
- configuration.save(configurationFile);
+ config.getNode("mcstats.opt-out").setValue(false);
+ configurationLoader.save(config);
}
// Enable Task, if it is not running
- if (task == -1) {
+ if (task == null) {
start();
}
}
@@ -297,14 +305,14 @@ public void disable() throws IOException {
synchronized (optOutLock) {
// Check if the server owner has already set opt-out, if not, set it.
if (!isOptOut()) {
- configuration.set("opt-out", true);
- configuration.save(configurationFile);
+ config.getNode("mcstats.opt-out").setValue(true);
+ configurationLoader.save(config);
}
// Disable Task, if it is running
- if (task != -1) {
- Bukkit.getScheduler().cancelTask(task);
- task = -1;
+ if (task != null) {
+ task.cancel();
+ task = null;
}
}
}
@@ -315,37 +323,10 @@ public void disable() throws IOException {
* @return the File object for the config file
*/
public File getConfigFile() {
- // I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
- // is to abuse the plugin object we already have
- // plugin.getDataFolder() => base/plugins/PluginA/
- // pluginsFolder => base/plugins/
- // The base is not necessarily relative to the startup directory.
- File pluginsFolder = plugin.getDataFolder().getParentFile();
-
- // return => base/plugins/PluginMetrics/config.yml
- return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
- }
-
- /**
- * Gets the online player (backwards compatibility)
- *
- * @return online player amount
- */
- private int getOnlinePlayers() {
- try {
- Method onlinePlayerMethod = Server.class.getMethod("getOnlinePlayers");
- if(onlinePlayerMethod.getReturnType().equals(Collection.class)) {
- return ((Collection>)onlinePlayerMethod.invoke(Bukkit.getServer())).size();
- } else {
- return ((Player[])onlinePlayerMethod.invoke(Bukkit.getServer())).length;
- }
- } catch (Exception ex) {
- if (debug) {
- Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
- }
- }
-
- return 0;
+ // TODO configDir
+ File configFolder = new File("config");
+
+ return new File(configFolder, "PluginMetrics.conf");
}
/**
@@ -353,12 +334,13 @@ private int getOnlinePlayers() {
*/
private void postPlugin(final boolean isPing) throws IOException {
// Server software specific section
- PluginDescriptionFile description = plugin.getDescription();
- String pluginName = description.getName();
- boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
- String pluginVersion = description.getVersion();
- String serverVersion = Bukkit.getVersion();
- int playersOnline = this.getOnlinePlayers();
+ String pluginName = plugin.getName();
+ boolean onlineMode = game.getServer().getOnlineMode(); // TRUE if online mode is enabled
+ String pluginVersion = plugin.getVersion();
+ // TODO no visible way to get MC version at the moment
+ // TODO added by game.getPlatform().getMinecraftVersion() -- impl in 2.1
+ String serverVersion = String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion());
+ int playersOnline = game.getServer().getOnlinePlayers().size();
// END server software specific section -- all code below does not use any code outside of this class / Java
@@ -555,7 +537,7 @@ private boolean isMineshafterPresent() {
* @param json
* @param key
* @param value
- * @throws UnsupportedEncodingException
+ * @throws java.io.UnsupportedEncodingException
*/
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
diff --git a/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/Slf4jLogger.java b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/Slf4jLogger.java
new file mode 100644
index 0000000..d477c1b
--- /dev/null
+++ b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/Slf4jLogger.java
@@ -0,0 +1,28 @@
+package com.github.hoqhuuep.islandcraft;
+
+import org.slf4j.Logger;
+
+import com.github.hoqhuuep.islandcraft.core.ICLogger;
+
+public class Slf4jLogger extends ICLogger {
+ private final Logger logger;
+
+ public Slf4jLogger(Logger logger) {
+ this.logger = logger;
+ }
+
+ @Override
+ public void info(String message) {
+ logger.info(message);
+ }
+
+ @Override
+ public void warning(String message) {
+ logger.warn(message);
+ }
+
+ @Override
+ public void error(String message) {
+ logger.error(message);
+ }
+}
diff --git a/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/SpongeWorldConfig.java b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/SpongeWorldConfig.java
new file mode 100644
index 0000000..ca1642f
--- /dev/null
+++ b/IslandCraft-Sponge/src/main/java/com/github/hoqhuuep/islandcraft/SpongeWorldConfig.java
@@ -0,0 +1,63 @@
+package com.github.hoqhuuep.islandcraft;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.github.hoqhuuep.islandcraft.core.ICWorldConfig;
+import com.google.common.reflect.TypeToken;
+
+import ninja.leaping.configurate.commented.CommentedConfigurationNode;
+import ninja.leaping.configurate.objectmapping.ObjectMappingException;
+
+public class SpongeWorldConfig implements ICWorldConfig {
+ private final CommentedConfigurationNode config;
+ private static final String DEFAULT_OCEAN = "com.github.hoqhuuep.islandcraft.core.ConstantBiomeDistribution DEEP_OCEAN";
+ private static final String DEFAULT_ISLAND_DISTRIBUTION = "com.github.hoqhuuep.islandcraft.core.HexagonalIslandDistribution 288 32";
+ private static final String[] DEFAULT_ISLAND_GENERATORS = new String[] {
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha BIRCH_FOREST BIRCH_FOREST_M BIRCH_FOREST_HILLS BIRCH_FOREST_HILLS_M ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha COLD_TAIGA COLD_TAIGA_M COLD_TAIGA_HILLS ~ ~ ~ OCEAN COLD_BEACH FROZEN_RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha DESERT DESERT_M DESERT_HILLS ~ ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha EXTREME_HILLS EXTREME_HILLS_M EXTREME_HILLS_PLUS EXTREME_HILLS_PLUS_M EXTREME_HILLS_EDGE ~ OCEAN STONE_BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha FOREST ~ FOREST_HILLS ~ FLOWER_FOREST ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha ICE_PLAINS ~ ICE_MOUNTAINS ~ ICE_PLAINS_SPIKES ~ OCEAN FROZEN_OCEAN FROZEN_RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha JUNGLE JUNGLE_M JUNGLE_HILLS ~ JUNGLE_EDGE JUNGLE_EDGE_M OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha MEGA_TAIGA MEGA_SPRUCE_TAIGA MEGA_TAIGA_HILLS MEGA_SPRUCE_TAIGA_HILLS ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha MESA MESA_BRYCE MESA_PLATEAU MESA_PLATEAU_M MESA_PLATEAU_F MESA_PLATEAU_F_M OCEAN MESA RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha MUSHROOM_ISLAND ~ ~ ~ ~ ~ OCEAN MUSHROOM_ISLAND_SHORE RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha PLAINS ~ SUNFLOWER_PLAINS ~ ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha ROOFED_FOREST ROOFED_FOREST_M ~ ~ ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha SAVANNA SAVANNA_M SAVANNA_PLATEAU SAVANNA_PLATEAU_M ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha SWAMPLAND SWAMPLAND_M ~ ~ ~ ~ OCEAN BEACH RIVER",
+ "com.github.hoqhuuep.islandcraft.core.IslandGeneratorAlpha TAIGA TAIGA_M TAIGA_HILLS ~ ~ ~ OCEAN BEACH RIVER"
+ };
+
+ public SpongeWorldConfig(CommentedConfigurationNode config) {
+ this.config = config;
+ }
+
+ @Override
+ public String getOcean() {
+ return config.getNode("ocean").getString(DEFAULT_OCEAN);
+ }
+
+ @Override
+ public String getIslandDistribution() {
+ return config.getNode("island-distribution").getString(DEFAULT_ISLAND_DISTRIBUTION);
+ }
+
+ @Override
+ public String[] getIslandGenerstors() {
+ try {
+ List defaultGenerators = Arrays.asList(DEFAULT_ISLAND_GENERATORS);
+ List list = config.getNode("island-generators").getList(TypeToken.of(String.class), defaultGenerators);
+ if (list.isEmpty()) {
+ config.getNode("island-generators").setValue(defaultGenerators);
+ return DEFAULT_ISLAND_GENERATORS;
+ }
+ return list.toArray(new String[list.size()]);
+ } catch (ObjectMappingException e) {
+ e.printStackTrace();
+ return DEFAULT_ISLAND_GENERATORS;
+ }
+ }
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..a352714
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Daniel Simmons
+Copyright (c) contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..b3139b8
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,285 @@
+// To build the Sponge plugin, run 'gradle sponge'
+// To build the Bukkit plugin with support for all versions of CraftBukkit since 1.4.7, run 'gradle bukkit'
+// To build the Bukkit plugin with support for only the latest version of CraftBukkit, run 'gradle bukkitLatest'
+
+plugins {
+ id 'com.github.johnrengelman.shadow' version '1.2.3'
+}
+
+group = 'com.github.hoqhuuep'
+version = '1.0.3-BETA'
+
+allprojects {
+ repositories {
+ jcenter()
+ maven {
+ name = 'sponge-repo'
+ url = 'http://repo.spongepowered.org/maven'
+ }
+ maven {
+ name = 'bukkit-repo'
+ url 'http://repo.bukkit.org/content/groups/public/'
+ }
+ maven {
+ name = 'spigot-repo'
+ url 'https://hub.spigotmc.org/nexus/content/groups/public/'
+ }
+ maven {
+ name = 'mcstats-repo'
+ url 'http://repo.mcstats.org/content/repositories/public'
+ }
+ mavenLocal()
+ }
+
+ apply plugin: 'eclipse'
+}
+
+subprojects {
+ apply plugin: 'java'
+ apply plugin: 'maven'
+
+ sourceCompatibility = '1.7'
+ targetCompatibility = '1.7'
+}
+
+project(':IslandCraft-API') {
+}
+
+project(':IslandCraft-Common') {
+ dependencies {
+ compile project(':IslandCraft-API')
+ }
+}
+
+project(':IslandCraft-Sponge') {
+ sourceCompatibility = '1.8'
+ targetCompatibility = '1.8'
+
+ dependencies {
+ compile project(':IslandCraft-Common')
+ compile group: 'org.spongepowered', name:'spongeapi', version: '3.0.0'
+ compile group: 'org.mcstats.sponge', name: 'metrics', version: 'R8-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-Bukkit') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile project(':IslandCraft-Common')
+ compile group: 'org.bukkit', name: 'bukkit', version: '1.7.9-R0.2'
+ compile group: 'org.mcstats.bukkit', name: 'metrics', version: 'R7'
+ }
+}
+
+project(':IslandCraft-NMS') {
+ dependencies {
+ compile project(':IslandCraft-API')
+ compile group: 'org.bukkit', name: 'bukkit', version: '1.7.9-R0.2'
+ }
+}
+
+project(':IslandCraft-NMS-v1_4_R1') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.4.7-R1.1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_5_R1') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.5-R0.1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_5_R2') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.5.1-R0.3-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_5_R3') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.5.2-R1.1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_6_R1') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.6.1-R0.1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_6_R2') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.6.2-R1.1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_6_R3') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.6.4-R2.1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_7_R1') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.7.2-R0.4-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_7_R2') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.7.5-R0.1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_7_R3') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.7.9-R0.3-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_7_R4') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.7.10-R0.1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_8_R1') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.8-R1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_8_R2') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.8.3-R0.1-SNAPSHOT'
+ }
+}
+
+project(':IslandCraft-NMS-v1_8_R3') {
+ dependencies {
+ compile project(':IslandCraft-NMS')
+ compile group: 'org.bukkit', name: 'craftbukkit', version: '1.8.8-R0.1-SNAPSHOT'
+ }
+}
+
+configurations {
+ spongePlugin
+ bukkitPlugin
+ bukkitLatest
+}
+
+dependencies {
+ spongePlugin (project(':IslandCraft-Sponge')) {
+ exclude group: 'org.spongepowered'
+ }
+}
+
+task sponge(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
+ description = 'Create the IslandCraft Sponge plugin JAR'
+ group = project.group
+ baseName = project.name
+ appendix = 'Sponge'
+ version = project.version
+ configurations = [ project.configurations.spongePlugin ]
+ from {
+ project.configurations.spongePlugin
+ }
+ relocate 'org.mcstats', 'com.github.hoqhuuep.islandcraft.mcstats'
+}
+
+dependencies {
+ bukkitPlugin(project(':IslandCraft-Bukkit')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_4_R1')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_5_R1')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_5_R2')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_5_R3')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_6_R1')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_6_R2')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_6_R3')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_7_R1')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_7_R2')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_7_R3')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_7_R4')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_8_R1')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_8_R2')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitPlugin(project(':IslandCraft-NMS-v1_8_R3')) {
+ exclude group: 'org.bukkit'
+ }
+}
+
+task bukkit(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
+ description = 'Create the IslandCraft Bukkit plugin JAR'
+ group = project.group
+ baseName = project.name
+ appendix = 'Bukkit'
+ version = project.version
+ configurations = [ project.configurations.bukkitPlugin ]
+ from {
+ project.configurations.bukkitPlugin
+ }
+ relocate 'org.mcstats', 'com.github.hoqhuuep.islandcraft.mcstats'
+}
+
+dependencies {
+ bukkitLatest (project(':IslandCraft-Bukkit')) {
+ exclude group: 'org.bukkit'
+ }
+ bukkitLatest(project(':IslandCraft-NMS-v1_8_R3')) {
+ exclude group: 'org.bukkit'
+ }
+}
+
+task bukkitLatest(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
+ description = 'Create the IslandCraft Bukkit plugin JAR'
+ group = project.group
+ baseName = project.name
+ appendix = 'BukkitLatest'
+ version = project.version
+ configurations = [ project.configurations.bukkitLatest ]
+ from {
+ project.configurations.bukkitLatest
+ }
+ relocate 'org.mcstats', 'com.github.hoqhuuep.islandcraft.mcstats'
+}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..5ccda13
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..5531a20
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Feb 10 20:39:05 AEDT 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..9d82f78
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..5f19212
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 5b8cfce..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-
- 4.0.0
- com.github.hoqhuuep
- IslandCraft
- 1.0.2
- pom
-
-
- IslandCraft
- 2013
- http://dev.bukkit.org/bukkit-plugins/islandcraft/
- Modifies the terrain generation of Minecraft to create an ocean with many islands.
-
-
-
- UTF-8
-
-
-
- IslandCraft-Core
- IslandCraft-NMS
- IslandCraft-NMS-v1_8_R3
- IslandCraft-NMS-v1_8_R2
- IslandCraft-NMS-v1_8_R1
- IslandCraft-NMS-v1_7_R4
- IslandCraft-NMS-v1_7_R3
- IslandCraft-NMS-v1_7_R2
- IslandCraft-NMS-v1_7_R1
- IslandCraft-NMS-v1_6_R3
- IslandCraft-NMS-v1_6_R2
- IslandCraft-NMS-v1_6_R1
- IslandCraft-NMS-v1_5_R3
- IslandCraft-NMS-v1_5_R2
- IslandCraft-NMS-v1_5_R1
- IslandCraft-NMS-v1_4_R1
- IslandCraft-Api
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
-
- 1.6
-
-
-
- org.apache.maven.plugins
- maven-eclipse-plugin
-
- true
- true
-
- 2.9
-
-
-
-
-
-
- bukkit-repo
- http://repo.bukkit.org/content/groups/public/
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/groups/public/
-
-
- Plugin Metrics
- http://repo.mcstats.org/content/repositories/public
-
-
-
-
-
-
- com.google.guava
- guava
- 10.0.1
- compile
-
-
-
- commons-lang
- commons-lang
- 2.3
- provided
-
-
- org.bukkit
- bukkit
- 1.7.9-R0.2
- provided
-
-
- org.mcstats.bukkit
- metrics
- R7
- compile
-
-
-
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..c487b3a
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,19 @@
+include 'IslandCraft-API'
+include 'IslandCraft-Common'
+include 'IslandCraft-Bukkit'
+include 'IslandCraft-Sponge'
+include 'IslandCraft-NMS'
+include 'IslandCraft-NMS-v1_4_R1'
+include 'IslandCraft-NMS-v1_5_R1'
+include 'IslandCraft-NMS-v1_5_R2'
+include 'IslandCraft-NMS-v1_5_R3'
+include 'IslandCraft-NMS-v1_6_R1'
+include 'IslandCraft-NMS-v1_6_R2'
+include 'IslandCraft-NMS-v1_6_R3'
+include 'IslandCraft-NMS-v1_7_R1'
+include 'IslandCraft-NMS-v1_7_R2'
+include 'IslandCraft-NMS-v1_7_R3'
+include 'IslandCraft-NMS-v1_7_R4'
+include 'IslandCraft-NMS-v1_8_R1'
+include 'IslandCraft-NMS-v1_8_R2'
+include 'IslandCraft-NMS-v1_8_R3'