-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
517 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ | |
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>skyblock</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/main/resources=UTF-8 | ||
encoding//src/test/java=UTF-8 | ||
encoding/<project>=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.gekkedev.skyblock</groupId> | ||
<artifactId>skyblock</artifactId> | ||
<version>1.0</version> | ||
|
||
<name>skyblock</name> | ||
<!-- FIXME change it to the project's website --> | ||
<url>http://www.example.com</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigot-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.13.2-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> | ||
<resources> | ||
<resource> | ||
<directory>${project.basedir}/src/main/resources</directory> | ||
<includes> | ||
<include>plugin.yml</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> | ||
<plugins> | ||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
</plugin> | ||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.7.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package com.gekkedev.skyblock; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.Location; | ||
import org.bukkit.Material; | ||
import org.bukkit.TreeType; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.block.Chest; | ||
import org.bukkit.configuration.ConfigurationSection; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public class Island { | ||
private Player owner; | ||
|
||
public Island(Player player) { | ||
this.owner = player; | ||
if (!Main.config.isConfigurationSection("IslandBases." + player.getName())) { | ||
Location newLoc = getNewLocation(); | ||
ConfigurationSection section = Main.config.createSection("IslandBases." + player.getName()); | ||
section.set("x", newLoc.getX()); | ||
section.set("y", newLoc.getY()); | ||
section.set("z", newLoc.getZ()); | ||
|
||
generateIsland(); | ||
} | ||
} | ||
|
||
private Location getNewLocation() { | ||
//generate a random spawn location | ||
int radius = 15; | ||
int maxRadius = radius * Main.config.getConfigurationSection("IslandBases").getKeys(false).size(); | ||
return new Location( | ||
Main.sbworld, | ||
Math.random() * maxRadius * 2 - maxRadius, | ||
20, //height | ||
Math.random() * maxRadius * 2 - maxRadius | ||
); | ||
} | ||
|
||
public void generateIsland() { //generate island at predefined spawn location | ||
Bukkit.getLogger().info("Spawning SkyBlock island for " + this.owner.getName()); | ||
this.owner.sendMessage(ChatColor.AQUA + "Please wait while your island is being generated..."); | ||
Bukkit.broadcastMessage(this.owner.getName() + " joined the SkyBlock community!"); | ||
Block spawner = getIslandBase().getBlock(); | ||
for (int x = spawner.getX(); x <= spawner.getX() + 7; x++) { | ||
for (int z = spawner.getZ(); z <= spawner.getZ() + 4; z++) { | ||
for (int y = spawner.getY(); y <= spawner.getY() + 15; y++) { | ||
int height = y - spawner.getY(); | ||
if (height >= 0 && height <= 1) { | ||
int dice = (int) Math.round(Math.random() * 5); | ||
switch (dice) { | ||
case 0: | ||
case 1: | ||
Main.sbworld.getBlockAt(x, y, z).setType(Material.DIRT); | ||
break; | ||
case 2: | ||
case 3: | ||
case 4: | ||
Main.sbworld.getBlockAt(x, y, z).setType(Material.STONE); | ||
break; | ||
case 5: | ||
Main.sbworld.getBlockAt(x, y, z).setType(Material.IRON_ORE); | ||
break; | ||
} | ||
} else if (height == 2) { | ||
Main.sbworld.getBlockAt(x, y, z).setType(Material.SAND); | ||
} else if (height == 3) { | ||
Main.sbworld.getBlockAt(x, y, z).setType(Material.GRASS_BLOCK); | ||
}/* else if (height >= 6 && height <= 11) { | ||
Main.sbworld.getBlockAt(6, y, 4).setType(Material.STRIPPED_OAK_WOOD); | ||
}*/ | ||
else Main.sbworld.getBlockAt(x, y, z).setType(Material.AIR); | ||
} | ||
} | ||
} | ||
|
||
Block chestBlock = getPlayerSpawn().getBlock().getRelative(4, 0, 2); | ||
chestBlock.setType(Material.CHEST); | ||
Chest chest = (Chest) chestBlock.getState(); | ||
ItemStack seeds = new ItemStack(Material.WHEAT_SEEDS); | ||
seeds.setAmount(3); | ||
chest.getBlockInventory().addItem( | ||
new ItemStack(Material.LAVA_BUCKET), | ||
new ItemStack(Material.ICE), | ||
new ItemStack(Material.SUGAR_CANE), | ||
seeds | ||
); | ||
|
||
if (!Main.sbworld.generateTree(getPlayerSpawn().add(3, 0, 0), TreeType.TREE)) | ||
this.owner.sendMessage(ChatColor.RED + "Error: Could not generate tree!"); | ||
|
||
//generate a piece of bedrock to mark the spawn location | ||
getPlayerSpawn().getBlock().getRelative(0, -1, 0).setType(Material.BEDROCK); | ||
} | ||
|
||
private Location getIslandBase() { | ||
return new Location( | ||
Main.sbworld, | ||
Main.config.getDouble("IslandBases." + this.owner.getName() + ".x"), | ||
Main.config.getDouble("IslandBases." + this.owner.getName() + ".y"), | ||
Main.config.getDouble("IslandBases." + this.owner.getName() + ".z") | ||
); | ||
} | ||
|
||
private Location getPlayerSpawn() { | ||
return getIslandBase().add(2, 4, 2); | ||
} | ||
|
||
public void tpThere() { | ||
this.owner.sendMessage("Teleporting you to your SkyBlock island..."); | ||
this.owner.getInventory().clear(); | ||
this.owner.teleport(getPlayerSpawn()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.gekkedev.skyblock; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.bukkit.World; | ||
import org.bukkit.World.Environment; | ||
import org.bukkit.WorldCreator; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import com.gekkedev.skyblock.commands.SBCommand; | ||
import com.gekkedev.skyblock.handlers.AutoSaver; | ||
import com.gekkedev.skyblock.handlers.ChatModifier; | ||
import com.gekkedev.skyblock.handlers.MotdModifier; | ||
|
||
/** | ||
* Skyblock plugin by gekkedev | ||
*/ | ||
public class Main extends JavaPlugin | ||
{ | ||
public static World sbworld; | ||
String WORLDNAME = "skyblock_world"; | ||
public static YamlConfiguration config; | ||
String configName = "config.yml"; | ||
public static File cfgFile; | ||
@Override | ||
public void onEnable() { | ||
getLogger().info("SkyBlock by gekkedev initialized!"); | ||
|
||
//generate or load world | ||
WorldCreator creator = new WorldCreator(WORLDNAME); | ||
creator.generator(new SkyblockChunkGenerator()); | ||
creator.environment(Environment.NORMAL); | ||
sbworld = creator.createWorld(); | ||
|
||
//register events | ||
getServer().getPluginManager().registerEvents(new MotdModifier(), this); | ||
getServer().getPluginManager().registerEvents(new ChatModifier(), this); | ||
getServer().getPluginManager().registerEvents(new AutoSaver(), this); | ||
|
||
//register commands | ||
this.getCommand("skyblock").setExecutor(new SBCommand()); | ||
|
||
//init config | ||
cfgFile = new File(getDataFolder() + File.separator + configName); | ||
try { | ||
config = YamlConfiguration.loadConfiguration(cfgFile); | ||
getLogger().info("Loaded config."); | ||
} catch (Exception e) { | ||
getLogger().info("Could not load config."); | ||
config = new YamlConfiguration(); | ||
} | ||
if (!config.contains("IslandBases")) { | ||
config.createSection("IslandBases"); | ||
saveData(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
getLogger().info("Saving skyblock data!"); | ||
saveData(); | ||
} | ||
|
||
public static void saveData() { | ||
try { | ||
Main.config.save(Main.cfgFile); | ||
} catch (IOException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/gekkedev/skyblock/SkyblockChunkGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.gekkedev.skyblock; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.World; | ||
import org.bukkit.generator.BlockPopulator; | ||
import org.bukkit.generator.ChunkGenerator; | ||
|
||
public class SkyblockChunkGenerator extends ChunkGenerator { | ||
public Location getFixedSpawnLocation(World world, Random random){ | ||
return new Location(world, 0, 70, 0); | ||
} | ||
|
||
public List<BlockPopulator> getDefaultPopulators(World world){ | ||
return new ArrayList<BlockPopulator>(); | ||
} | ||
|
||
public short[][] generateExtBlockSections(World world, Random random, int chunkX, int chunkY, BiomeGrid biomegrid){ | ||
return new short[world.getMaxHeight() / 16][]; | ||
} | ||
public ChunkData generateChunkData(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biome) { | ||
return createChunkData(world); | ||
} | ||
} |
Oops, something went wrong.