Merge pull request #704 from VolmitSoftware/1.18.1

1.18.1
This commit is contained in:
Dan 2022-01-12 08:40:23 -05:00 committed by GitHub
commit 6921ad49db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
467 changed files with 12587 additions and 10813 deletions

View File

@ -4,7 +4,39 @@ For 1.16 and below, see the 1.14-1.16 branch. The master branch is for the lates
# [Support](https://discord.gg/3xxPTpT) **|** [Documentation](https://docs.volmit.com/iris/) **|** [Git](https://github.com/IrisDimensions)
## Iris Toolbelt
# Building
Building Iris is fairly simple, though you will need to setup a few things if your system has never been used for java development.
Consider supporting our development by buying Iris on spigot! We work hard to make Iris the best it can be for everyone.
### Command Line Builds
1. Install [Java JDK 17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
2. Set the JDK installation path to `JAVA_HOME` as an environment variable.
* Windows
1. Start > Type `env` and press Enter
2. Advanced > Environment Variables
3. Under System Variables, click `New...`
4. Variable Name: `JAVA_HOME`
5. Variable Value: `C:\Program Files\Java\jdk-17.0.1` (verify this eixsts after installing java dont just copy the example text)
* MacOS
1. Run `/usr/libexec/java_home -V` and look for Java 17
2. Run `sudo nano ~/.zshenv`
3. Add `export JAVA_HOME=$(/usr/libexec/java_home)` as a new line
4. Use `CTRL + X`, then Press `Y`, Then `ENTER`
5. Quit & Reopen Terminal and verify with `echo $JAVA_HOME`. It should print a directory
3. If this is your first time building Iris for MC 1.18+ run `gradlew setup` inside the root Iris project folder. Otherwise skip this step. Grab a coffee, this may take up to 5 minutes depending on your cpu & internet connection.
4. Once the project is setup, run `gradlew iris`
5. The Iris jar will be placed in `Iris/build/Iris-XXX-XXX.jar` Enjoy! Consider supporting us by buying it on spigot!
### IDE Builds (for development)
* Run `gradlew setup` any time you get dependency issues with craftbukkit
* Configure ITJ Gradle to use JDK 17 (in settings, search for gradle)
* Add a build line in the build.gradle for your own build task to directly compile Iris into your plugins folder if you prefer.
* Resync the project & run your newly created task (under the development folder in gradle tasks!)
# Iris Toolbelt
Everyone needs a toolbelt.

View File

@ -18,64 +18,30 @@
plugins {
id 'java'
id 'io.freefair.lombok' version '5.2.1'
id "com.github.johnrengelman.shadow" version "7.0.0"
id "com.github.johnrengelman.shadow" version "7.1.2"
id "de.undercouch.download" version "4.1.2"
}
group 'com.volmit.iris'
version '1.9.6-1.17.X'
def apiVersion = '1.17'
version '1.9.6-1.18.X'
def nmsVersion = "1.18.1"
def apiVersion = '1.18'
def spigotJarVersion = '1.18.1-R0.1-SNAPSHOT'
def name = getRootProject().getName() // Defined in settings.gradle
def main = 'com.volmit.iris.Iris'
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
// ======================== WINDOWS =============================
registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins', name)
registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins', name)
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins', name)
registerCustomOutputTask('Coco', 'C://Users/sjoer/Desktop/MCSM/plugins', name)
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins', name)
registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins')
registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins')
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins')
registerCustomOutputTask('Coco', 'C://Users/sjoer/Desktop/MCSM/plugins')
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
// ========================== UNIX ==============================
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/Documents/development/server/plugins', name)
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins', name)
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/Documents/development/server/plugins')
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
// ==============================================================
def registerCustomOutputTask(name, path, plugin) {
if (!System.properties['os.name'].toLowerCase().contains('windows'))
{
return;
}
tasks.register('build' + name, Copy) {
group('development')
outputs.upToDateWhen { false }
dependsOn ':shadowJar'
from(file('build/libs/' + plugin + '-' + version + '-all.jar'))
into(file(path))
rename { String fileName ->
fileName.replace(plugin + '-' + version + '-all.jar', plugin + ".jar")
}
}
}
def registerCustomOutputTaskUnix(name, path, plugin) {
if(System.properties['os.name'].toLowerCase().contains('windows'))
{
return;
}
tasks.register('build' + name, Copy) {
group('development')
outputs.upToDateWhen { false }
dependsOn ':shadowJar'
from(file('build/libs/' + plugin + '-' + version + '-all.jar'))
into(file(path))
rename { String fileName ->
fileName.replace(plugin + '-' + version + '-all.jar', plugin + ".jar")
}
}
}
/**
* Gradle is weird sometimes, we need to delete the plugin yml from the build folder to actually filter properly.
*/
@ -99,8 +65,15 @@ processResources {
* Unified repo
*/
repositories {
mavenLocal{
content{
includeGroup("org.bukkit")
includeGroup("org.spigotmc")
}
}
maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" }
mavenCentral()
mavenLocal()
}
/**
@ -114,7 +87,7 @@ compileJava {
* Configure Iris for shading
*/
shadowJar {
minimize()
//minimize()
append("plugin.yml")
relocate 'com.dfsek.paralithic', 'com.volmit.iris.util.paralithic'
relocate 'io.papermc.lib', 'com.volmit.iris.util.paper'
@ -147,10 +120,10 @@ dependencies {
// Provided or Classpath
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
implementation 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
implementation 'org.bukkit.craftbukkit:1.17.1:1.17.1'
implementation 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
implementation 'me.clip:placeholderapi:2.10.10'
implementation 'io.th0rgal:oraxen:1.94.0'
implementation 'org.bukkit:craftbukkit:1.18.1-R0.1-SNAPSHOT:remapped-mojang'
// Shaded
implementation 'com.dfsek:Paralithic:0.4.0'
@ -172,3 +145,175 @@ dependencies {
implementation 'com.github.ben-manes.caffeine:caffeine:3.0.5'
implementation 'org.apache.commons:commons-lang3:3.12.0'
}
if(JavaVersion.current().toString() != "17")
{
System.err.println()
System.err.println("=========================================================================================================")
System.err.println("You must run gradle on Java 17. You are using " + JavaVersion.current())
System.err.println()
System.err.println("=== For IDEs ===")
System.err.println("1. Configure the project for Java 17")
System.err.println("2. Configure the bundled gradle to use Java 17 in settings")
System.err.println()
System.err.println("=== For Command Line (gradlew) ===")
System.err.println("1. Install JDK 17 from https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html")
System.err.println("2. Set JAVA_HOME environment variable to the new jdk installation folder such as C:\\Program Files\\Java\\jdk-17.0.1")
System.err.println("3. Open a new command prompt window to get the new environment variables if need be.")
System.err.println("=========================================================================================================")
System.err.println()
System.exit(69);
}
def buildToolsJar = new File(buildDir, "buildtools/BuildTools.jar");
def specialSourceJar = new File(buildDir, "specialsource/SpecialSource.jar");
def buildToolsFolder = new File(buildDir, "buildtools");
def specialSourceFolder = new File(buildDir, "specialsource");
def buildToolsHint = new File(buildDir, "buildtools/craftbukkit-" + nmsVersion + ".jar");
def outputShadeJar = new File(buildDir, "libs/Iris-" + version + "-all.jar");
def ssiJar = new File(buildDir, "specialsource/Iris-" + version + "-all.jar");
def ssobfJar = new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar");
def ssJar = new File(buildDir, "specialsource/Iris-" + version + "-rma.jar");
def homePath = System.properties['user.home']
def m2 = new File(homePath + "/.m2/repository")
def m2s = m2.getAbsolutePath();
// ======================== Building Mapped Jars =============================
task downloadBuildtools(type: Download) {
group "remapping"
src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar'
dest buildToolsJar
onlyIf{
!buildToolsJar.exists()
}
}
task downloadSpecialSource(type: Download){
group "remapping"
src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar'
dest specialSourceJar
onlyIf{
!specialSourceJar.exists()
}
}
task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec)
{
group "remapping"
classpath = files(buildToolsJar)
workingDir = buildToolsFolder
args = [
"--rev",
nmsVersion,
"--compile",
"craftbukkit",
"--remap"
]
onlyIf{
!buildToolsHint.exists()
}
}
task copyBuildToSpecialSource(type: Copy)
{
group "remapping"
from outputShadeJar
into specialSourceFolder
dependsOn(downloadSpecialSource, shadowJar)
}
task specialSourceRemapObfuscate(type: JavaExec)
{
group "remapping"
dependsOn(copyBuildToSpecialSource, downloadSpecialSource, shadowJar)
workingDir = specialSourceFolder
classpath = files(specialSourceJar,
new File(m2s + "/org/spigotmc/spigot/"+spigotJarVersion+"/spigot-" + spigotJarVersion + "-remapped-mojang.jar"))
mainClass = "net.md_5.specialsource.SpecialSource"
args = [
"--live",
"-i",
ssiJar.getName(),
"-o",
ssobfJar.getName(),
"-m",
m2s + "/org/spigotmc/minecraft-server/"+spigotJarVersion+"/minecraft-server-" + spigotJarVersion + "-maps-mojang.txt",
"--reverse",
]
}
task specialSourceRemap(type: JavaExec)
{
group "remapping"
dependsOn(specialSourceRemapObfuscate)
workingDir = specialSourceFolder
classpath = files(specialSourceJar,
new File(m2s + "/org/spigotmc/spigot/"+spigotJarVersion+"/spigot-" + spigotJarVersion + "-remapped-obf.jar"))
mainClass = "net.md_5.specialsource.SpecialSource"
args = [
"--live",
"-i",
ssobfJar.getName(),
"-o",
ssJar.getName(),
"-m",
m2s + "/org/spigotmc/minecraft-server/"+spigotJarVersion+"/minecraft-server-" + spigotJarVersion + "-maps-spigot.csrg"
]
}
tasks.compileJava.dependsOn(executeBuildTools)
task setup()
{
group("iris")
dependsOn(clean, executeBuildTools)
}
task iris(type: Copy)
{
group "iris"
from ssJar
into buildDir
rename { String fileName ->
fileName.replace('Iris-' + version + '-rma.jar', "Iris-" + version + ".jar")
}
dependsOn(specialSourceRemap)
}
def registerCustomOutputTask(name, path) {
if (!System.properties['os.name'].toLowerCase().contains('windows'))
{
return;
}
tasks.register('build' + name, Copy) {
group('development')
outputs.upToDateWhen { false }
dependsOn(iris)
from(new File(buildDir, "Iris-" + version + ".jar"))
into(file(path))
rename { String fileName ->
fileName.replace("Iris-" + version + ".jar", "Iris.jar")
}
}
}
def registerCustomOutputTaskUnix(name, path) {
if(System.properties['os.name'].toLowerCase().contains('windows'))
{
return;
}
tasks.register('build' + name, Copy) {
group('development')
outputs.upToDateWhen { false }
dependsOn(iris)
from(new File(buildDir, "Iris-" + version + ".jar"))
into(file(path))
rename { String fileName ->
fileName.replace("Iris-" + version + ".jar", "Iris.jar")
}
}
}

View File

@ -17,6 +17,6 @@
#
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -301,8 +301,7 @@ public class Iris extends VolmitPlugin implements Listener {
@SuppressWarnings("deprecation")
public static void later(NastyRunnable object) {
try
{
try {
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
{
try {
@ -312,10 +311,7 @@ public class Iris extends VolmitPlugin implements Listener {
Iris.reportError(e);
}
}, RNG.r.i(100, 1200));
}
catch(IllegalPluginAccessException ignored)
{
} catch(IllegalPluginAccessException ignored) {
}
}
@ -476,13 +472,11 @@ public class Iris extends VolmitPlugin implements Listener {
postShutdown.add(r);
}
public static void panic()
{
public static void panic() {
EnginePanic.panic();
}
public static void addPanic(String s, String v)
{
public static void addPanic(String s, String v) {
EnginePanic.add(s, v);
}
@ -613,8 +607,8 @@ public class Iris extends VolmitPlugin implements Listener {
.seed(1337)
.environment(dim.getEnvironment())
.worldFolder(new File(worldName))
.minHeight(0)
.maxHeight(256)
.minHeight(dim.getMinHeight())
.maxHeight(dim.getMaxHeight())
.build();
Iris.debug("Generator Config: " + w.toString());

View File

@ -19,29 +19,21 @@
package com.volmit.iris.core.commands;
import com.volmit.iris.Iris;
import com.volmit.iris.core.edit.BlockSignal;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.util.data.B;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisCave;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisJigsawPiece;
import com.volmit.iris.engine.object.IrisJigsawPool;
import com.volmit.iris.engine.object.IrisJigsawStructure;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.matter.MatterMarker;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.Chunk;
import org.bukkit.FluidCollisionMode;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import java.awt.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.awt.Desktop;
@Decree(name = "edit", origin = DecreeOrigin.PLAYER, studio = true, description = "Edit something")
@ -64,10 +56,11 @@ public class CommandEdit implements DecreeExecutor {
}
@Decree(description = "Edit the biome you specified", aliases = {"b"}, origin = DecreeOrigin.PLAYER)
public void biome(@Param(contextual = false, description = "The biome to edit") IrisBiome biome) {
if (noStudio()) {return;}
if(noStudio()) {
return;
}
try {
if(biome == null || biome.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?");
@ -83,7 +76,9 @@ public class CommandEdit implements DecreeExecutor {
@Decree(description = "Edit the region you specified", aliases = {"r"}, origin = DecreeOrigin.PLAYER)
public void region(@Param(contextual = false, description = "The region to edit") IrisRegion region) {
if (noStudio()) {return;}
if(noStudio()) {
return;
}
try {
if(region == null || region.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?");
@ -99,7 +94,9 @@ public class CommandEdit implements DecreeExecutor {
@Decree(description = "Edit the dimension you specified", aliases = {"d"}, origin = DecreeOrigin.PLAYER)
public void dimension(@Param(contextual = false, description = "The dimension to edit") IrisDimension dimension) {
if (noStudio()) {return;}
if(noStudio()) {
return;
}
try {
if(dimension == null || dimension.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?");
@ -115,7 +112,9 @@ public class CommandEdit implements DecreeExecutor {
@Decree(description = "Edit the cave file you specified", aliases = {"c"}, origin = DecreeOrigin.PLAYER)
public void cave(@Param(contextual = false, description = "The cave to edit") IrisCave cave) {
if (noStudio()) {return;}
if(noStudio()) {
return;
}
try {
if(cave == null || cave.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?");
@ -131,7 +130,9 @@ public class CommandEdit implements DecreeExecutor {
@Decree(description = "Edit the structure file you specified", aliases = {"jigsawstructure", "structure"}, origin = DecreeOrigin.PLAYER)
public void jigsaw(@Param(contextual = false, description = "The jigsaw structure to edit") IrisJigsawStructure jigsaw) {
if (noStudio()) {return;}
if(noStudio()) {
return;
}
try {
if(jigsaw == null || jigsaw.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?");
@ -147,7 +148,9 @@ public class CommandEdit implements DecreeExecutor {
@Decree(description = "Edit the pool file you specified", aliases = {"jigsawpool", "pool"}, origin = DecreeOrigin.PLAYER)
public void jigsawPool(@Param(contextual = false, description = "The jigsaw pool to edit") IrisJigsawPool pool) {
if (noStudio()) {return;}
if(noStudio()) {
return;
}
try {
if(pool == null || pool.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?");
@ -163,7 +166,9 @@ public class CommandEdit implements DecreeExecutor {
@Decree(description = "Edit the jigsaw piece file you specified", aliases = {"jigsawpiece", "piece"}, origin = DecreeOrigin.PLAYER)
public void jigsawPiece(@Param(contextual = false, description = "The jigsaw piece to edit") IrisJigsawPiece piece) {
if (noStudio()) {return;}
if(noStudio()) {
return;
}
try {
if(piece == null || piece.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?");

View File

@ -101,6 +101,12 @@ public class CommandIris implements DecreeExecutor {
sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
}
@Decree(description = "Print version information", origin = DecreeOrigin.PLAYER)
public void height() {
sender().sendMessage(C.GREEN + "" + sender().player().getWorld().getMinHeight() + " to " + sender().player().getWorld().getMaxHeight());
sender().sendMessage(C.GREEN + "Total Height: " + (sender().player().getWorld().getMaxHeight() - sender().player().getWorld().getMinHeight()));
}
@Decree(description = "Set aura spins")
public void aura(
@Param(description = "The h color value", defaultValue = "-20")

View File

@ -23,7 +23,6 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.NoiseExplorerGUI;
import com.volmit.iris.core.gui.VisionGUI;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.service.ConversionSVC;
import com.volmit.iris.core.service.StudioSVC;
@ -82,7 +81,6 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import java.awt.Desktop;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -102,6 +100,7 @@ public class CommandStudio implements DecreeExecutor {
public static String hrf(Duration duration) {
return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase();
}
private CommandFind find;
private CommandEdit edit;
@ -301,7 +300,6 @@ public class CommandStudio implements DecreeExecutor {
}
@Decree(description = "Execute a script", aliases = "run", origin = DecreeOrigin.PLAYER)
public void execute(
@Param(description = "The script to run")

View File

@ -50,8 +50,10 @@ public class MythicMobsLink {
/**
* Spawn a mythic mob at this location
*
* @param mob The mob
* @param location The location
* @param mob
* The mob
* @param location
* The location
* @return The mob, or null if it can't be spawned
*/
public @Nullable

View File

@ -21,7 +21,6 @@ package com.volmit.iris.core.loader;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.object.IrisImage;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.data.KCache;

View File

@ -41,7 +41,6 @@ import java.io.File;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.nms;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.nms.v17_1.NMSBinding17_1;
import com.volmit.iris.core.nms.v18_1.NMSBinding18_1;
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import com.volmit.iris.util.collection.KMap;
import org.bukkit.Bukkit;
@ -28,7 +28,7 @@ import org.bukkit.Bukkit;
public class INMS {
//@builder
private static final KMap<String, Class<? extends INMSBinding>> bindings = new KMap<String, Class<? extends INMSBinding>>()
.qput("v1_17_R1", NMSBinding17_1.class);
.qput("v1_18_R1", NMSBinding18_1.class);
//@done
private static final INMSBinding binding = bind();

View File

@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.List;
public enum NMSVersion {
R1_18,
R1_17,
R1_16,
R1_15,
R1_14,
@ -88,6 +90,14 @@ public enum NMSVersion {
if(tryVersion("1_16_R1")) {
return R1_16;
}
if(tryVersion("1_17_R1")) {
return R1_17;
}
if(tryVersion("1_18_R1")) {
return R1_18;
}
return null;
}

View File

@ -1,486 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.nms.v17_1;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.mca.NBTWorld;
import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAChunkBiomeContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAGlobalPalette;
import com.volmit.iris.util.nbt.mca.palette.MCAIdMap;
import com.volmit.iris.util.nbt.mca.palette.MCAIdMapper;
import com.volmit.iris.util.nbt.mca.palette.MCAPalette;
import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess;
import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryWritable;
import net.minecraft.nbt.NBTCompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.chunk.BiomeStorage;
import net.minecraft.world.level.chunk.Chunk;
import net.minecraft.world.level.chunk.ChunkSection;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
import org.bukkit.entity.EntityType;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class NMSBinding17_1 implements INMSBinding {
private final BlockData AIR = Material.AIR.createBlockData();
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
private final AtomicCache<MCAIdMapper<IBlockData>> registryCache = new AtomicCache<>();
private final AtomicCache<MCAPalette<IBlockData>> globalCache = new AtomicCache<>();
private final AtomicCache<MCAIdMap<BiomeBase>> biomeMapCache = new AtomicCache<>();
private Field biomeStorageCache = null;
public boolean supportsDataPacks() {
return true;
}
@Override
public MCAPaletteAccess createPalette() {
MCAIdMapper<IBlockData> registry = registryCache.aquireNasty(() -> {
Field cf = net.minecraft.core.RegistryBlockID.class.getDeclaredField("c");
Field df = net.minecraft.core.RegistryBlockID.class.getDeclaredField("d");
Field bf = net.minecraft.core.RegistryBlockID.class.getDeclaredField("b");
cf.setAccessible(true);
df.setAccessible(true);
bf.setAccessible(true);
net.minecraft.core.RegistryBlockID<IBlockData> blockData = Block.p;
int b = bf.getInt(blockData);
IdentityHashMap<IBlockData, Integer> c = (IdentityHashMap<IBlockData, Integer>) cf.get(blockData);
List<IBlockData> d = (List<IBlockData>) df.get(blockData);
return new MCAIdMapper<>(c, d, b);
});
MCAPalette<IBlockData> global = globalCache.aquireNasty(() -> new MCAGlobalPalette<>(registry, ((CraftBlockData) AIR).getState()));
MCAPalettedContainer<IBlockData> container = new MCAPalettedContainer<>(global, registry,
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState(),
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
((CraftBlockData) AIR).getState());
return new MCAWrappedPalettedContainer<>(container,
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState());
}
private Object getBiomeStorage(ChunkGenerator.BiomeGrid g) {
try {
return getFieldForBiomeStorage(g).get(g);
} catch (IllegalAccessException e) {
Iris.reportError(e);
e.printStackTrace();
}
return null;
}
@Override
public boolean hasTile(Location l) {
return ((CraftWorld) l.getWorld()).getHandle().getTileEntity(new BlockPosition(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null;
}
@Override
public CompoundTag serializeTile(Location location) {
TileEntity e = ((CraftWorld) location.getWorld()).getHandle().getTileEntity(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true);
if (e == null) {
return null;
}
NBTTagCompound tag = new NBTTagCompound();
e.save(tag);
return convert(tag);
}
@Override
public void deserializeTile(CompoundTag s, Location newPosition) {
NBTTagCompound c = convert(s);
if (c != null) {
int x = newPosition.getBlockX();
int y = newPosition.getBlockY();
int z = newPosition.getBlockZ();
WorldServer w = ((CraftWorld) newPosition.getWorld()).getHandle();
Chunk ch = w.getChunkAt(x >> 4, z >> 4);
ChunkSection sect = ch.getSections()[y >> 4];
IBlockData block = sect.getBlocks().a(x & 15, y & 15, z & 15);
BlockPosition pos = new BlockPosition(x, y, z);
ch.b(TileEntity.create(pos, block, c));
}
}
private NBTTagCompound convert(CompoundTag tag) {
try {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
NBTUtil.write(tag, boas, false);
DataInputStream din = new DataInputStream(new ByteArrayInputStream(boas.toByteArray()));
NBTTagCompound c = NBTCompressedStreamTools.a((DataInput) din);
din.close();
return c;
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
private CompoundTag convert(NBTTagCompound tag) {
try {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(boas);
NBTCompressedStreamTools.a(tag, (DataOutput) dos);
dos.close();
return (CompoundTag) NBTUtil.read(new ByteArrayInputStream(boas.toByteArray()), false).getTag();
} catch (Throwable ex) {
ex.printStackTrace();
}
return null;
}
@Override
public CompoundTag serializeEntity(org.bukkit.entity.Entity be) {
Entity entity = ((CraftEntity) be).getHandle();
NBTTagCompound tag = new NBTTagCompound();
entity.save(tag);
CompoundTag t = convert(tag);
t.putInt("btype", be.getType().ordinal());
return t;
}
@Override
public org.bukkit.entity.Entity deserializeEntity(CompoundTag s, Location newPosition) {
EntityType type = EntityType.values()[s.getInt("btype")];
s.remove("btype");
NBTTagCompound tag = convert(s);
NBTTagList pos = tag.getList("Pos", 6);
pos.a(0, NBTTagDouble.a(newPosition.getX()));
pos.a(1, NBTTagDouble.a(newPosition.getY()));
pos.a(2, NBTTagDouble.a(newPosition.getZ()));
tag.set("Pos", pos);
org.bukkit.entity.Entity be = newPosition.getWorld().spawnEntity(newPosition, type);
((CraftEntity) be).getHandle().load(tag);
return be;
}
@Override
public boolean supportsCustomHeight() {
return false;
}
private Field getFieldForBiomeStorage(Object storage) {
Field f = biomeStorageCache;
if (f != null) {
return f;
}
try {
f = storage.getClass().getDeclaredField("biome");
f.setAccessible(true);
return f;
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
Iris.error(storage.getClass().getCanonicalName());
}
biomeStorageCache = f;
return null;
}
private IRegistryWritable<BiomeBase> getCustomBiomeRegistry() {
return ((CraftServer) Bukkit.getServer()).getHandle().getServer().getCustomRegistry().b(IRegistry.aO);
}
@Override
public Object getBiomeBaseFromId(int id) {
return getCustomBiomeRegistry().fromId(id);
}
@Override
public int getTrueBiomeBaseId(Object biomeBase) {
return getCustomBiomeRegistry().getId((BiomeBase) biomeBase);
}
@Override
public Object getTrueBiomeBase(Location location) {
return ((CraftWorld) location.getWorld()).getHandle().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
@Override
public String getTrueBiomeBaseKey(Location location) {
return getKeyForBiomeBase(getTrueBiomeBase(location));
}
@Override
public boolean supportsCustomBiomes() {
return true;
}
@Override
public int getMinHeight(World world) {
return world.getMinHeight();
}
@Override
public Object getCustomBiomeBaseFor(String mckey) {
try {
return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.aO, new MinecraftKey(mckey.toLowerCase())));
} catch (Throwable e) {
Iris.reportError(e);
}
return null;
}
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Override
public String getKeyForBiomeBase(Object biomeBase) {
return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString();
}
@Override
public Object getBiomeBase(World world, Biome biome) {
return getBiomeBase(((CraftWorld) world).getHandle().t().d(IRegistry.aO), biome);
}
private Class<?>[] classify(Object... par) {
Class<?>[] g = new Class<?>[par.length];
for (int i = 0; i < g.length; i++) {
g[i] = par[i].getClass();
}
return g;
}
private <T> T invoke(Object from, String name, Object... par) {
try {
Method f = from.getClass().getDeclaredMethod(name, classify(par));
f.setAccessible(true);
//noinspection unchecked
return (T) f.invoke(from, par);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
return null;
}
private <T> T invokeStatic(Class<?> from, String name, Object... par) {
try {
Method f = from.getDeclaredMethod(name, classify(par));
f.setAccessible(true);
//noinspection unchecked
return (T) f.invoke(null, par);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
return null;
}
private <T> T getField(Object from, String name) {
try {
Field f = from.getClass().getDeclaredField(name);
f.setAccessible(true);
//noinspection unchecked
return (T) f.get(from);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
return null;
}
private <T> T getStaticField(Class<?> t, String name) {
try {
Field f = t.getDeclaredField(name);
f.setAccessible(true);
//noinspection unchecked
return (T) f.get(null);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
return null;
}
@Override
public Object getBiomeBase(Object registry, Biome biome) {
Object v = baseBiomeCache.get(biome);
if (v != null) {
return v;
}
//noinspection unchecked
v = org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock.biomeToBiomeBase((IRegistry<BiomeBase>) registry, biome);
if (v == null) {
// Ok so there is this new biome name called "CUSTOM" in Paper's new releases.
// But, this does NOT exist within CraftBukkit which makes it return an error.
// So, we will just return the ID that the plains biome returns instead.
//noinspection unchecked
return org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock.biomeToBiomeBase((IRegistry<BiomeBase>) registry, Biome.PLAINS);
}
baseBiomeCache.put(biome, v);
return v;
}
@Override
public int getBiomeId(Biome biome) {
for (World i : Bukkit.getWorlds()) {
if (i.getEnvironment().equals(World.Environment.NORMAL)) {
IRegistry<BiomeBase> registry = ((CraftWorld) i).getHandle().t().d(IRegistry.aO);
return registry.getId((BiomeBase) getBiomeBase(registry, biome));
}
}
return biome.ordinal();
}
private MCAIdMap<BiomeBase> getBiomeMapping() {
return biomeMapCache.aquire(() -> new MCAIdMap<>() {
@NotNull
@Override
public Iterator<BiomeBase> iterator() {
return getCustomBiomeRegistry().iterator();
}
@Override
public int getId(BiomeBase paramT) {
return getCustomBiomeRegistry().getId(paramT);
}
@Override
public BiomeBase byId(int paramInt) {
return getCustomBiomeRegistry().fromId(paramInt);
}
});
}
@Override
public MCABiomeContainer newBiomeContainer(int min, int max) {
MCAChunkBiomeContainer<BiomeBase> base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max);
return getBiomeContainerInterface(getBiomeMapping(), base);
}
@Override
public MCABiomeContainer newBiomeContainer(int min, int max, int[] data) {
MCAChunkBiomeContainer<BiomeBase> base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max, data);
return getBiomeContainerInterface(getBiomeMapping(), base);
}
@NotNull
private MCABiomeContainer getBiomeContainerInterface(MCAIdMap<BiomeBase> biomeMapping, MCAChunkBiomeContainer<BiomeBase> base) {
return new MCABiomeContainer() {
@Override
public int[] getData() {
return base.writeBiomes();
}
@Override
public void setBiome(int x, int y, int z, int id) {
base.setBiome(x, y, z, biomeMapping.byId(id));
}
@Override
public int getBiome(int x, int y, int z) {
return biomeMapping.getId(base.getBiome(x, y, z));
}
};
}
@Override
public int countCustomBiomes() {
AtomicInteger a = new AtomicInteger(0);
getCustomBiomeRegistry().d().forEach((i) -> {
MinecraftKey k = i.getKey().a();
if (k.getNamespace().equals("minecraft")) {
return;
}
a.incrementAndGet();
Iris.debug("Custom Biome: " + k);
});
return a.get();
}
@Override
public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) {
try {
BiomeStorage s = (BiomeStorage) getFieldForBiomeStorage(chunk).get(chunk);
s.setBiome(x, y, z, (BiomeBase) somethingVeryDirty);
} catch (IllegalAccessException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
@Override
public boolean isBukkit() {
return false;
}
}

View File

@ -0,0 +1,431 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.nms.v18_1;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.mca.NBTWorld;
import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAChunkBiomeContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAGlobalPalette;
import com.volmit.iris.util.nbt.mca.palette.MCAIdMap;
import com.volmit.iris.util.nbt.mca.palette.MCAIdMapper;
import com.volmit.iris.util.nbt.mca.palette.MCAPalette;
import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess;
import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.IdMap;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_18_R1.CraftServer;
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData;
import org.bukkit.entity.Entity;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class NMSBinding18_1 implements INMSBinding {
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
private final BlockData AIR = Material.AIR.createBlockData();
private final AtomicCache<MCAIdMap<net.minecraft.world.level.biome.Biome>> biomeMapCache = new AtomicCache<>();
private final AtomicCache<MCAIdMapper<BlockState>> registryCache = new AtomicCache<>();
private final AtomicCache<MCAPalette<BlockState>> globalCache = new AtomicCache<>();
private final AtomicCache<RegistryAccess> registryAccess = new AtomicCache<>();
private final AtomicCache<Method> byIdRef = new AtomicCache<>();
private Field biomeStorageCache = null;
@Override
public boolean hasTile(Location l) {
return ((CraftWorld) l.getWorld()).getHandle().getBlockEntity(new BlockPos(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null;
}
@Override
public CompoundTag serializeTile(Location location) {
BlockEntity e = ((CraftWorld) location.getWorld()).getHandle().getBlockEntity(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true);
if(e == null) {
return null;
}
net.minecraft.nbt.CompoundTag tag = e.saveWithFullMetadata();
return convert(tag);
}
private CompoundTag convert(net.minecraft.nbt.CompoundTag tag) {
try {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(boas);
tag.write(dos);
dos.close();
return (CompoundTag) NBTUtil.read(new ByteArrayInputStream(boas.toByteArray()), false).getTag();
} catch(Throwable ex) {
ex.printStackTrace();
}
return null;
}
private net.minecraft.nbt.CompoundTag convert(CompoundTag tag) {
try {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
NBTUtil.write(tag, boas, false);
DataInputStream din = new DataInputStream(new ByteArrayInputStream(boas.toByteArray()));
net.minecraft.nbt.CompoundTag c = NbtIo.read(din);
din.close();
return c;
} catch(Throwable e) {
e.printStackTrace();
}
return null;
}
@Override
public void deserializeTile(CompoundTag c, Location newPosition) {
((CraftWorld) newPosition.getWorld()).getHandle().getChunkAt(new BlockPos(newPosition.getBlockX(), 0, newPosition.getBlockZ())).setBlockEntityNbt(convert(c));
}
@Override
public CompoundTag serializeEntity(Entity location) {
return null;// TODO:
}
@Override
public Entity deserializeEntity(CompoundTag s, Location newPosition) {
return null;// TODO:
}
@Override
public boolean supportsCustomHeight() {
return true;
}
private RegistryAccess registry() {
return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()));
}
private Registry<net.minecraft.world.level.biome.Biome> getCustomBiomeRegistry() {
return registry().registry(Registry.BIOME_REGISTRY).orElse(null);
}
private Registry<Block> getBlockRegistry() {
return registry().registry(Registry.BLOCK_REGISTRY).orElse(null);
}
@Override
public Object getBiomeBaseFromId(int id) {
try {
return byIdRef.aquire(() -> {
for(Method i : IdMap.class.getDeclaredMethods()) {
if(i.getParameterCount() == 1 && i.getParameterTypes()[0].equals(int.class)) {
Iris.info("[NMS] Found byId method in " + IdMap.class.getSimpleName() + "." + i.getName() + "(int) => " + Biome.class.getSimpleName());
return i;
}
}
Iris.error("Cannot find byId method!");
return null;
}).invoke(getCustomBiomeRegistry(), id);
} catch(IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
return null;
}
@Override
public int getMinHeight(World world) {
return world.getMinHeight();
}
@Override
public boolean supportsCustomBiomes() {
return true;
}
@Override
public int getTrueBiomeBaseId(Object biomeBase) {
return getCustomBiomeRegistry().getId((net.minecraft.world.level.biome.Biome) biomeBase);
}
@Override
public Object getTrueBiomeBase(Location location) {
return ((CraftWorld) location.getWorld()).getHandle().getBiome(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
}
@Override
public String getTrueBiomeBaseKey(Location location) {
return getKeyForBiomeBase(getTrueBiomeBase(location));
}
@Override
public Object getCustomBiomeBaseFor(String mckey) {
return getCustomBiomeRegistry().get(new ResourceLocation(mckey));
}
@Override
public String getKeyForBiomeBase(Object biomeBase) {
return getCustomBiomeRegistry().getKey((net.minecraft.world.level.biome.Biome) biomeBase).getPath(); // something, not something:something
}
@Override
public Object getBiomeBase(World world, Biome biome) {
return getBiomeBase(((CraftWorld) world).getHandle().registryAccess().registry(Registry.BIOME_REGISTRY).orElse(null), biome);
}
@Override
public Object getBiomeBase(Object registry, Biome biome) {
Object v = baseBiomeCache.get(biome);
if(v != null) {
return v;
}
//noinspection unchecked
v = org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
if(v == null) {
// Ok so there is this new biome name called "CUSTOM" in Paper's new releases.
// But, this does NOT exist within CraftBukkit which makes it return an error.
// So, we will just return the ID that the plains biome returns instead.
//noinspection unchecked
return org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
}
baseBiomeCache.put(biome, v);
return v;
}
@Override
public boolean isBukkit() {
return true;
}
@Override
public int getBiomeId(Biome biome) {
for(World i : Bukkit.getWorlds()) {
if(i.getEnvironment().equals(World.Environment.NORMAL)) {
Registry<net.minecraft.world.level.biome.Biome> registry = ((CraftWorld) i).getHandle().registryAccess().registry(Registry.BIOME_REGISTRY).orElse(null);
return registry.getId((net.minecraft.world.level.biome.Biome) getBiomeBase(registry, biome));
}
}
return biome.ordinal();
}
private MCAIdMap<net.minecraft.world.level.biome.Biome> getBiomeMapping() {
return biomeMapCache.aquire(() -> new MCAIdMap<>() {
@NotNull
@Override
public Iterator<net.minecraft.world.level.biome.Biome> iterator() {
return getCustomBiomeRegistry().iterator();
}
@Override
public int getId(net.minecraft.world.level.biome.Biome paramT) {
return getCustomBiomeRegistry().getId(paramT);
}
@Override
public net.minecraft.world.level.biome.Biome byId(int paramInt) {
return (net.minecraft.world.level.biome.Biome) getBiomeBaseFromId(paramInt);
}
});
}
@NotNull
private MCABiomeContainer getBiomeContainerInterface(MCAIdMap<net.minecraft.world.level.biome.Biome> biomeMapping, MCAChunkBiomeContainer<net.minecraft.world.level.biome.Biome> base) {
return new MCABiomeContainer() {
@Override
public int[] getData() {
return base.writeBiomes();
}
@Override
public void setBiome(int x, int y, int z, int id) {
base.setBiome(x, y, z, biomeMapping.byId(id));
}
@Override
public int getBiome(int x, int y, int z) {
return biomeMapping.getId(base.getBiome(x, y, z));
}
};
}
@Override
public MCABiomeContainer newBiomeContainer(int min, int max) {
MCAChunkBiomeContainer<net.minecraft.world.level.biome.Biome> base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max);
return getBiomeContainerInterface(getBiomeMapping(), base);
}
@Override
public MCABiomeContainer newBiomeContainer(int min, int max, int[] data) {
MCAChunkBiomeContainer<net.minecraft.world.level.biome.Biome> base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max, data);
return getBiomeContainerInterface(getBiomeMapping(), base);
}
@Override
public int countCustomBiomes() {
AtomicInteger a = new AtomicInteger(0);
getCustomBiomeRegistry().keySet().forEach((i) -> {
if(i.getNamespace().equals("minecraft")) {
return;
}
a.incrementAndGet();
Iris.debug("Custom Biome: " + i);
});
return a.get();
}
public boolean supportsDataPacks() {
return true;
}
@Override
public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) {
try {
ChunkAccess s = (ChunkAccess) getFieldForBiomeStorage(chunk).get(chunk);
s.setBiome(x, y, z, (net.minecraft.world.level.biome.Biome) somethingVeryDirty);
} catch(IllegalAccessException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
private Field getFieldForBiomeStorage(Object storage) {
Field f = biomeStorageCache;
if(f != null) {
return f;
}
try {
f = storage.getClass().getDeclaredField("biome");
f.setAccessible(true);
return f;
} catch(Throwable e) {
Iris.reportError(e);
e.printStackTrace();
Iris.error(storage.getClass().getCanonicalName());
}
biomeStorageCache = f;
return null;
}
@Override
public MCAPaletteAccess createPalette() {
MCAIdMapper<BlockState> registry = registryCache.aquireNasty(() -> {
Field cf = net.minecraft.core.IdMapper.class.getDeclaredField("tToId");
Field df = net.minecraft.core.IdMapper.class.getDeclaredField("idToT");
Field bf = net.minecraft.core.IdMapper.class.getDeclaredField("nextId");
cf.setAccessible(true);
df.setAccessible(true);
bf.setAccessible(true);
net.minecraft.core.IdMapper<BlockState> blockData = Block.BLOCK_STATE_REGISTRY;
int b = bf.getInt(blockData);
Object2IntMap<BlockState> c = (Object2IntMap<BlockState>) cf.get(blockData);
List<BlockState> d = (List<BlockState>) df.get(blockData);
return new MCAIdMapper<BlockState>(c, d, b);
});
MCAPalette<BlockState> global = globalCache.aquireNasty(() -> new MCAGlobalPalette<>(registry, ((CraftBlockData) AIR).getState()));
MCAPalettedContainer<BlockState> container = new MCAPalettedContainer<>(global, registry,
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState(),
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
((CraftBlockData) AIR).getState());
return new MCAWrappedPalettedContainer<>(container,
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState());
}
private static Object getFor(Class<?> type, Object source) {
Object o = fieldFor(type, source);
if(o != null) {
return o;
}
return invokeFor(type, source);
}
private static Object invokeFor(Class<?> returns, Object in) {
for(Method i : in.getClass().getMethods()) {
if(i.getReturnType().equals(returns)) {
i.setAccessible(true);
try {
Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()");
return i.invoke(in);
} catch(Throwable e) {
e.printStackTrace();
}
}
}
return null;
}
private static Object fieldFor(Class<?> returns, Object in) {
for(Field i : in.getClass().getFields()) {
if(i.getType().equals(returns)) {
i.setAccessible(true);
try {
Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName());
return i.get(in);
} catch(IllegalAccessException e) {
e.printStackTrace();
}
}
}
return null;
}
}

View File

@ -54,7 +54,8 @@ public class IrisPack {
* Create an iris pack backed by a data folder
* the data folder is assumed to be in the Iris/packs/NAME folder
*
* @param name the name
* @param name
* the name
*/
public IrisPack(String name) {
this(packsPack(name));
@ -63,7 +64,8 @@ public class IrisPack {
/**
* Create an iris pack backed by a data folder
*
* @param folder the folder of the pack. Must be a directory
* @param folder
* the folder of the pack. Must be a directory
*/
public IrisPack(File folder) {
this.folder = folder;
@ -82,10 +84,13 @@ public class IrisPack {
/**
* Create a new pack from the input url
*
* @param sender the sender
* @param url the url, or name, or really anything see IrisPackRepository.from(String)
* @param sender
* the sender
* @param url
* the url, or name, or really anything see IrisPackRepository.from(String)
* @return the iris pack
* @throws IrisException fails
* @throws IrisException
* fails
*/
public static Future<IrisPack> from(VolmitSender sender, String url) throws IrisException {
IrisPackRepository repo = IrisPackRepository.from(url);
@ -103,10 +108,13 @@ public class IrisPack {
/**
* Create a pack from a repo
*
* @param sender the sender
* @param repo the repo
* @param sender
* the sender
* @param repo
* the repo
* @return the pack
* @throws MalformedURLException shit happens
* @throws MalformedURLException
* shit happens
*/
public static Future<IrisPack> from(VolmitSender sender, IrisPackRepository repo) throws MalformedURLException {
CompletableFuture<IrisPack> pack = new CompletableFuture<>();
@ -119,9 +127,11 @@ public class IrisPack {
/**
* Create a blank pack with a given name
*
* @param name the name of the pack
* @param name
* the name of the pack
* @return the pack
* @throws IrisException if the pack already exists or another error
* @throws IrisException
* if the pack already exists or another error
*/
public static IrisPack blank(String name) throws IrisException {
File f = packsPack(name);
@ -149,7 +159,8 @@ public class IrisPack {
/**
* Get a packs pack folder for a name. Such that overworld would resolve as Iris/packs/overworld
*
* @param name the name
* @param name
* the name
* @return the file path
*/
public static File packsPack(String name) {
@ -232,7 +243,8 @@ public class IrisPack {
/**
* Install this pack into a world
*
* @param world the world to install into (world/iris/pack)
* @param world
* the world to install into (world/iris/pack)
* @return the installed pack
*/
public IrisPack install(World world) throws IrisException {
@ -242,7 +254,8 @@ public class IrisPack {
/**
* Install this pack into a world
*
* @param world the world to install into (world/iris/pack)
* @param world
* the world to install into (world/iris/pack)
* @return the installed pack
*/
public IrisPack install(IrisWorld world) throws IrisException {
@ -252,7 +265,8 @@ public class IrisPack {
/**
* Install this pack into a world
*
* @param folder the folder to install this pack into
* @param folder
* the folder to install this pack into
* @return the installed pack
*/
public IrisPack install(File folder) throws IrisException {
@ -275,7 +289,8 @@ public class IrisPack {
* Create a new pack using this pack as a template. The new pack will be renamed & have a renamed dimension
* to match it.
*
* @param newName the new pack name
* @param newName
* the new pack name
* @return the new IrisPack
*/
public IrisPack install(String newName) throws IrisException {
@ -330,7 +345,8 @@ public class IrisPack {
/**
* Find all files in this pack with the given extension
*
* @param fileExtension the extension
* @param fileExtension
* the extension
* @return the list of files
*/
public KList<File> collectFiles(String fileExtension) {

View File

@ -51,8 +51,7 @@ public class IrisPackRepository {
private String tag = "";
/**
* @param g
* @return
*
*/
public static IrisPackRepository from(String g) {
// https://github.com/IrisDimensions/overworld

View File

@ -43,8 +43,10 @@ public interface PregeneratorMethod {
/**
* Return true if regions can be generated
*
* @param x the x region
* @param z the z region
* @param x
* the x region
* @param z
* the z region
* @return true if they can be
*/
boolean supportsRegions(int x, int z, PregenListener listener);
@ -52,8 +54,10 @@ public interface PregeneratorMethod {
/**
* Return the name of the method being used
*
* @param x the x region
* @param z the z region
* @param x
* the x region
* @param z
* the z region
* @return the name
*/
String getMethod(int x, int z);
@ -62,18 +66,22 @@ public interface PregeneratorMethod {
* Called to generate a region. Execute sync, if multicore internally, wait
* for the task to complete
*
* @param x the x
* @param z the z
* @param listener signal chunks generating & generated. Parallel capable.
* @param x
* the x
* @param z
* the z
* @param listener
* signal chunks generating & generated. Parallel capable.
*/
void generateRegion(int x, int z, PregenListener listener);
/**
* Called to generate a chunk. You can go async so long as save will wait on the threads to finish
*
* @param x the x
* @param z the z
* @param listener
* @param x
* the x
* @param z
* the z
*/
void generateChunk(int x, int z, PregenListener listener);

View File

@ -19,9 +19,7 @@
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.board.BoardManager;
@ -87,8 +85,7 @@ public class BoardSVC implements IrisService, BoardProvider {
}
public void tick() {
if(!Iris.service(StudioSVC.class).isProjectOpen())
{
if(!Iris.service(StudioSVC.class).isProjectOpen()) {
return;
}
@ -134,7 +131,7 @@ public class BoardSVC implements IrisService, BoardProvider {
lines.add("&7&m ");
lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName());
lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z)));
lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z) + player.getWorld().getMinHeight()));
lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2));
lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond()));
lines.add("&7&m ");

View File

@ -65,7 +65,8 @@ public class ObjectSVC implements IrisService {
/**
* Reverts all the block changes provided, 200 blocks per tick
*
* @param blocks The blocks to remove
* @param blocks
* The blocks to remove
*/
private void revert(Map<Block, BlockData> blocks) {
int amount = 0;

View File

@ -79,7 +79,8 @@ public class TreeSVC implements IrisService {
* <br>4. Check biome, region and dimension for overrides for that sapling type -> Found -> use</br>
* <br>5. Exit if none are found, cancel event if one or more are.</br>
*
* @param event Checks the given event for sapling overrides
* @param event
* Checks the given event for sapling overrides
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void on(StructureGrowEvent event) {
@ -238,12 +239,17 @@ public class TreeSVC implements IrisService {
}
/**
* Finds a single object placement (which may contain more than one object) for the requirements species, location & size
* Finds a single object placement (which may contain more than one object) for the requirements species, location &
* size
*
* @param worldAccess The world to access (check for biome, region, dimension, etc)
* @param location The location of the growth event (For biome/region finding)
* @param type The bukkit TreeType to match
* @param size The size of the sapling area
* @param worldAccess
* The world to access (check for biome, region, dimension, etc)
* @param location
* The location of the growth event (For biome/region finding)
* @param type
* The bukkit TreeType to match
* @param size
* The size of the sapling area
* @return An object placement which contains the matched tree, or null if none were found / it's disabled.
*/
private IrisObjectPlacement getObjectPlacement(PlatformChunkGenerator worldAccess, Location location, TreeType type, IrisTreeSize size) {
@ -268,9 +274,12 @@ public class TreeSVC implements IrisService {
/**
* Filters out mismatches and returns matches
*
* @param objects The object placements to check
* @param size The size of the sapling area to filter with
* @param type The type of the tree to filter with
* @param objects
* The object placements to check
* @param size
* The size of the sapling area to filter with
* @param type
* The type of the tree to filter with
* @return A list of objectPlacements that matched. May be empty.
*/
private KList<IrisObjectPlacement> matchObjectPlacements(KList<IrisObjectPlacement> objects, IrisTreeSize size, TreeType type) {
@ -289,9 +298,12 @@ public class TreeSVC implements IrisService {
/**
* Get the Cuboid of sapling sizes at a location & blockData predicate
*
* @param at this location
* @param valid with this blockData predicate
* @param world the world to check in
* @param at
* this location
* @param valid
* with this blockData predicate
* @param world
* the world to check in
* @return A cuboid containing only saplings
*/
public Cuboid getSaplings(Location at, Predicate<BlockData> valid, World world) {
@ -343,10 +355,14 @@ public class TreeSVC implements IrisService {
/**
* Grows the blockPosition list by means of checking neighbours in
*
* @param world the world to check in
* @param center the location of this position
* @param valid validation on blockData to check block with
* @param l list of block positions to add new neighbors too
* @param world
* the world to check in
* @param center
* the location of this position
* @param valid
* validation on blockData to check block with
* @param l
* list of block positions to add new neighbors too
*/
private void grow(World world, BlockPosition center, Predicate<BlockData> valid, KList<BlockPosition> l) {
// Make sure size is less than 50, the block to check isn't already in, and make sure the blockData still matches

View File

@ -64,7 +64,8 @@ public class WandSVC implements IrisService {
/**
* Creates an Iris Object from the 2 coordinates selected with a wand
*
* @param wand The wand itemstack
* @param wand
* The wand itemstack
* @return The new object
*/
public static IrisObject createSchematic(ItemStack wand) {
@ -97,7 +98,8 @@ public class WandSVC implements IrisService {
/**
* Creates an Iris Object from the 2 coordinates selected with a wand
*
* @param wand The wand itemstack
* @param wand
* The wand itemstack
* @return The new object
*/
public static Matter createMatterSchem(Player p, ItemStack wand) {
@ -120,7 +122,8 @@ public class WandSVC implements IrisService {
/**
* Converts a user friendly location string to an actual Location
*
* @param s The string
* @param s
* The string
* @return The location
*/
public static Location stringToLocation(String s) {
@ -137,7 +140,8 @@ public class WandSVC implements IrisService {
/**
* Get a user friendly string of a location
*
* @param loc The location
* @param loc
* The location
* @return The string
*/
public static String locationToString(Location loc) {
@ -178,7 +182,8 @@ public class WandSVC implements IrisService {
/**
* Finds an existing wand in a users inventory
*
* @param inventory The inventory to search
* @param inventory
* The inventory to search
* @return The slot number the wand is in. Or -1 if none are found
*/
public static int findWand(Inventory inventory) {
@ -202,8 +207,10 @@ public class WandSVC implements IrisService {
/**
* Creates an Iris wand. The locations should be the currently selected locations, or null
*
* @param a Location A
* @param b Location B
* @param a
* Location A
* @param b
* Location B
* @return A new wand
*/
public static ItemStack createWand(Location a, Location b) {
@ -222,7 +229,8 @@ public class WandSVC implements IrisService {
/**
* Get a pair of locations that are selected in an Iris wand
*
* @param is The wand item
* @param is
* The wand item
* @return An array with the 2 locations
*/
public static Location[] getCuboid(ItemStack is) {
@ -233,7 +241,8 @@ public class WandSVC implements IrisService {
/**
* Is a player holding an Iris wand
*
* @param p The player
* @param p
* The player
* @return True if they are
*/
public static boolean isHoldingWand(Player p) {
@ -244,7 +253,8 @@ public class WandSVC implements IrisService {
/**
* Is the itemstack passed an Iris wand
*
* @param is The itemstack
* @param is
* The itemstack
* @return True if it is
*/
public static boolean isWand(ItemStack is) {
@ -291,8 +301,10 @@ public class WandSVC implements IrisService {
/**
* Draw the outline of a selected region
*
* @param d The cuboid
* @param p The player to show it to
* @param d
* The cuboid
* @param p
* The player to show it to
*/
public void draw(Cuboid d, Player p) {
draw(new Location[] {d.getLowerNE(), d.getUpperSW()}, p);
@ -301,8 +313,10 @@ public class WandSVC implements IrisService {
/**
* Draw the outline of a selected region
*
* @param d A pair of locations
* @param p The player to show them to
* @param d
* A pair of locations
* @param p
* The player to show them to
*/
public void draw(Location[] d, Player p) {
Vector gx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65);
@ -406,7 +420,8 @@ public class WandSVC implements IrisService {
/**
* Is the player holding Dust?
*
* @param p The player
* @param p
* The player
* @return True if they are
*/
public boolean isHoldingDust(Player p) {
@ -417,7 +432,8 @@ public class WandSVC implements IrisService {
/**
* Is the itemstack passed Iris dust?
*
* @param is The itemstack
* @param is
* The itemstack
* @return True if it is
*/
public boolean isDust(ItemStack is) {
@ -427,9 +443,12 @@ public class WandSVC implements IrisService {
/**
* Update the location on an Iris wand
*
* @param left True for first location, false for second
* @param a The location
* @param item The wand
* @param left
* True for first location, false for second
* @param a
* The location
* @param item
* The wand
* @return The updated wand
*/
public ItemStack update(boolean left, Location a, ItemStack item) {

View File

@ -88,7 +88,8 @@ public class IrisCreator {
* Create the IrisAccess (contains the world)
*
* @return the IrisAccess
* @throws IrisException shit happens
* @throws IrisException
* shit happens
*/
public World create() throws IrisException {
if(Bukkit.isPrimaryThread()) {

View File

@ -51,7 +51,8 @@ public class IrisToolbelt {
* - GithubUsername/repository
* - GithubUsername/repository/branch
*
* @param dimension the dimension id such as overworld or flat
* @param dimension
* the dimension id such as overworld or flat
* @return the IrisDimension or null
*/
public static IrisDimension getDimension(String dimension) {
@ -80,7 +81,8 @@ public class IrisToolbelt {
/**
* Checks if the given world is an Iris World (same as access(world) != null)
*
* @param world the world
* @param world
* the world
* @return true if it is an Iris Access world
*/
public static boolean isIrisWorld(World world) {
@ -103,7 +105,8 @@ public class IrisToolbelt {
/**
* Get the Iris generator for the given world
*
* @param world the given world
* @param world
* the given world
* @return the IrisAccess or null if it's not an Iris World
*/
public static PlatformChunkGenerator access(World world) {
@ -117,8 +120,10 @@ public class IrisToolbelt {
/**
* Start a pregenerator task
*
* @param task the scheduled task
* @param method the method to execute the task
* @param task
* the scheduled task
* @param method
* the method to execute the task
* @return the pregenerator job (already started)
*/
public static PregeneratorJob pregenerate(PregenTask task, PregeneratorMethod method, Engine engine) {
@ -129,8 +134,10 @@ public class IrisToolbelt {
* Start a pregenerator task. If the supplied generator is headless, headless mode is used,
* otherwise Hybrid mode is used.
*
* @param task the scheduled task
* @param gen the Iris Generator
* @param task
* the scheduled task
* @param gen
* the Iris Generator
* @return the pregenerator job (already started)
*/
public static PregeneratorJob pregenerate(PregenTask task, PlatformChunkGenerator gen) {
@ -146,8 +153,10 @@ public class IrisToolbelt {
* Start a pregenerator task. If the supplied generator is headless, headless mode is used,
* otherwise Hybrid mode is used.
*
* @param task the scheduled task
* @param world the World
* @param task
* the scheduled task
* @param world
* the World
* @return the pregenerator job (already started)
*/
public static PregeneratorJob pregenerate(PregenTask task, World world) {
@ -162,7 +171,8 @@ public class IrisToolbelt {
* Evacuate all players from the world into literally any other world.
* If there are no other worlds, kick them! Not the best but what's mine is mine sometimes...
*
* @param world the world to evac
* @param world
* the world to evac
*/
public static boolean evacuate(World world) {
for(World i : Bukkit.getWorlds()) {
@ -182,8 +192,10 @@ public class IrisToolbelt {
/**
* Evacuate all players from the world
*
* @param world the world to leave
* @param m the message
* @param world
* the world to leave
* @param m
* the message
* @return true if it was evacuated.
*/
public static boolean evacuate(World world, String m) {

View File

@ -33,8 +33,6 @@ public class IrisWorldCreator {
private boolean studio = false;
private String dimensionName = null;
private long seed = 1337;
private int maxHeight = 256;
private int minHeight = 0;
public IrisWorldCreator() {
@ -45,18 +43,6 @@ public class IrisWorldCreator {
return this;
}
public IrisWorldCreator height(int maxHeight) {
this.maxHeight = maxHeight;
this.minHeight = 0;
return this;
}
public IrisWorldCreator height(int minHeight, int maxHeight) {
this.maxHeight = maxHeight;
this.minHeight = minHeight;
return this;
}
public IrisWorldCreator name(String name) {
this.name = name;
return this;
@ -78,16 +64,18 @@ public class IrisWorldCreator {
}
public WorldCreator create() {
IrisDimension dim = IrisData.loadAnyDimension(dimensionName);
IrisWorld w = IrisWorld.builder()
.name(name)
.minHeight(minHeight)
.maxHeight(maxHeight)
.minHeight(dim.getMinHeight())
.maxHeight(dim.getMaxHeight())
.seed(seed)
.worldFolder(new File(name))
.environment(findEnvironment())
.build();
ChunkGenerator g = new BukkitChunkGenerator(w, studio, studio
? IrisData.loadAnyDimension(dimensionName).getLoader().getDataFolder() :
? dim.getLoader().getDataFolder() :
new File(w.worldFolder(), "iris/pack"), dimensionName);
return new WorldCreator(name)

View File

@ -25,29 +25,23 @@ public class EnginePanic {
private static final KMap<String, String> stuff = new KMap<>();
private static KMap<String, String> last = new KMap<>();
public static void add(String key, String value)
{
public static void add(String key, String value) {
stuff.put(key, value);
}
public static void saveLast()
{
public static void saveLast() {
last = stuff.copy();
}
public static void lastPanic()
{
for(String i : last.keySet())
{
public static void lastPanic() {
for(String i : last.keySet()) {
Iris.error("Last Panic " + i + ": " + stuff.get(i));
}
}
public static void panic()
{
public static void panic() {
lastPanic();
for(String i : stuff.keySet())
{
for(String i : stuff.keySet()) {
Iris.error("Engine Panic " + i + ": " + stuff.get(i));
}
}

View File

@ -35,7 +35,13 @@ import com.volmit.iris.engine.framework.EngineWorldManager;
import com.volmit.iris.engine.framework.SeedManager;
import com.volmit.iris.engine.framework.WrongEngineBroException;
import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
import com.volmit.iris.engine.object.IrisDecorator;
import com.volmit.iris.engine.object.IrisEngineData;
import com.volmit.iris.engine.object.IrisJigsawStructure;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
import com.volmit.iris.util.atomics.AtomicRollingSequence;
import com.volmit.iris.util.collection.KMap;
@ -488,6 +494,7 @@ public class IrisEngine implements Engine {
return getData().getRegionLoader().load(getDimension().getFocusRegion());
}
@Override
public void fail(String error, Throwable e) {
failing = true;

View File

@ -30,12 +30,14 @@ import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.view.BiomeGridHunkView;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator;
public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
private final RNG rng;
private final ChronoLatch cl = new ChronoLatch(5000);
public IrisBiomeActuator(Engine engine) {
super(engine, "Biome");
@ -78,6 +80,15 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
try {
IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z);
Object biomeBase = INMS.get().getCustomBiomeBaseFor(getDimension().getLoadKey() + ":" + custom.getId());
//
// int m = hits.size();
// String str = ib.getLoadKey() + ":custom:" + custom.getId();
// hits.add(str);
//
// if(m != hits.size())
// {
// Iris.info("Added " + str);
// }
if(biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) {
throw new RuntimeException("Cant inject biome!");
@ -95,9 +106,14 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
}
} else {
Biome v = ib.getSkyBiome(rng, x, 0, z);
if(v != null) {
for(int i = 0; i < maxHeight; i++) {
h.set(finalXf, i, zf, v);
}
} else if(cl.flip()) {
Iris.error("No biome provided for " + ib.getLoadKey());
}
}
}
});

View File

@ -21,7 +21,6 @@ package com.volmit.iris.engine.actuator;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedActuator;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.documentation.BlockCoordinates;
@ -71,10 +70,14 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
/**
* This is calling 1/16th of a chunk x/z slice. It is a plane from sky to bedrock 1 thick in the x direction.
*
* @param x the chunk x in blocks
* @param z the chunk z in blocks
* @param xf the current x slice
* @param h the blockdata
* @param x
* the chunk x in blocks
* @param z
* the chunk z in blocks
* @param xf
* the current x slice
* @param h
* the blockdata
*/
@BlockCoordinates
public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h) {

View File

@ -81,7 +81,7 @@ public class MCATerrainChunk implements TerrainChunk {
int xx = (x + ox) & 15;
int zz = (z + oz) & 15;
if (y > 255 || y < 0) {
if(y > getMaxHeight() || y < getMinHeight()) {
return;
}
@ -98,8 +98,8 @@ public class MCATerrainChunk implements TerrainChunk {
y = getMaxHeight();
}
if (y < 0) {
y = 0;
if(y < getMinHeight()) {
y = getMinHeight();
}
return NBTWorld.getBlockData(mcaChunk.getBlockStateAt((x + ox) & 15, y, (z + oz) & 15));

View File

@ -49,8 +49,10 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
/**
* Get biome at x, z within chunk being generated
*
* @param x - 0-15
* @param z - 0-15
* @param x
* - 0-15
* @param z
* - 0-15
* @return Biome value
* @deprecated biomes are now 3-dimensional
*/
@ -61,9 +63,12 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
/**
* Get biome at x, z within chunk being generated
*
* @param x - 0-15
* @param y - 0-255
* @param z - 0-15
* @param x
* - 0-15
* @param y
* - 0-255
* @param z
* - 0-15
* @return Biome value
*/
Biome getBiome(int x, int y, int z);
@ -71,9 +76,12 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
/**
* Set biome at x, z within chunk being generated
*
* @param x - 0-15
* @param z - 0-15
* @param bio - Biome value
* @param x
* - 0-15
* @param z
* - 0-15
* @param bio
* - Biome value
* @deprecated biomes are now 3-dimensional
*/
@Deprecated
@ -82,10 +90,14 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
/**
* Set biome at x, z within chunk being generated
*
* @param x - 0-15
* @param y - 0-255
* @param z - 0-15
* @param bio - Biome value
* @param x
* - 0-15
* @param y
* - 0-255
* @param z
* - 0-15
* @param bio
* - Biome value
*/
void setBiome(int x, int y, int z, Biome bio);
@ -103,11 +115,15 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* <p>
* Setting blocks outside the chunk's bounds does nothing.
*
* @param x the x location in the chunk from 0-15 inclusive
* @param y the y location in the chunk from 0 (inclusive) - maxHeight
* @param x
* the x location in the chunk from 0-15 inclusive
* @param y
* the y location in the chunk from 0 (inclusive) - maxHeight
* (exclusive)
* @param z the z location in the chunk from 0-15 inclusive
* @param blockData the type to set the block to
* @param z
* the z location in the chunk from 0-15 inclusive
* @param blockData
* the type to set the block to
*/
void setBlock(int x, int y, int z, BlockData blockData);
@ -116,10 +132,13 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* <p>
* Getting blocks outside the chunk's bounds returns air.
*
* @param x the x location in the chunk from 0-15 inclusive
* @param y the y location in the chunk from 0 (inclusive) - maxHeight
* @param x
* the x location in the chunk from 0-15 inclusive
* @param y
* the y location in the chunk from 0 (inclusive) - maxHeight
* (exclusive)
* @param z the z location in the chunk from 0-15 inclusive
* @param z
* the z location in the chunk from 0-15 inclusive
* @return the data of the block or the BlockData for air if x, y or z are
* outside the chunk's bounds
*/

View File

@ -78,7 +78,6 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
@ -145,7 +144,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
@BlockCoordinates
default void generate(int x, int z, TerrainChunk tc, boolean multicore) throws WrongEngineBroException {
generate(x, z, Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc), multicore);
generate(x, z, Hunk.view(tc), Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight()), multicore);
}
@BlockCoordinates

View File

@ -24,7 +24,6 @@ import com.volmit.iris.util.hunk.Hunk;
import lombok.Data;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator;
import java.util.concurrent.atomic.AtomicBoolean;
@ -56,7 +55,7 @@ public class PregeneratedData {
});
if(postMod.get()) {
return () -> Hunk.view((ChunkGenerator.ChunkData) tc).insertSoftly(0, 0, 0, post, (b) -> b == null || B.isAirOrFluid(b));
return () -> Hunk.view(tc).insertSoftly(0, 0, 0, post, (b) -> b == null || B.isAirOrFluid(b));
}
return () -> {

View File

@ -210,13 +210,20 @@ public class MantleWriter implements IObjectPlacer {
/**
* Set a sphere into the mantle
*
* @param cx the center x
* @param cy the center y
* @param cz the center z
* @param radius the radius of this sphere
* @param fill should it be filled? or just the outer shell?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param cx
* the center x
* @param cy
* the center y
* @param cz
* the center z
* @param radius
* the radius of this sphere
* @param fill
* should it be filled? or just the outer shell?
* @param data
* the data to set
* @param <T>
* the type of data to apply to the mantle
*/
public <T> void setSphere(int cx, int cy, int cz, double radius, boolean fill, T data) {
setElipsoid(cx, cy, cz, radius, radius, radius, fill, data);
@ -229,15 +236,24 @@ public class MantleWriter implements IObjectPlacer {
/**
* Set an elipsoid into the mantle
*
* @param cx the center x
* @param cy the center y
* @param cz the center z
* @param rx the x radius
* @param ry the y radius
* @param rz the z radius
* @param fill should it be filled or just the outer shell?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param cx
* the center x
* @param cy
* the center y
* @param cz
* the center z
* @param rx
* the x radius
* @param ry
* the y radius
* @param rz
* the z radius
* @param fill
* should it be filled or just the outer shell?
* @param data
* the data to set
* @param <T>
* the type of data to apply to the mantle
*/
public <T> void setElipsoidFunction(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, Function3<Integer, Integer, Integer, T> data) {
rx += 0.5;
@ -299,14 +315,22 @@ public class MantleWriter implements IObjectPlacer {
/**
* Set a cuboid of data in the mantle
*
* @param x1 the min x
* @param y1 the min y
* @param z1 the min z
* @param x2 the max x
* @param y2 the max y
* @param z2 the max z
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param x1
* the min x
* @param y1
* the min y
* @param z1
* the min z
* @param x2
* the max x
* @param y2
* the max y
* @param z2
* the max z
* @param data
* the data to set
* @param <T>
* the type of data to apply to the mantle
*/
public <T> void setCuboid(int x1, int y1, int z1, int x2, int y2, int z2, T data) {
int j, k;
@ -323,13 +347,20 @@ public class MantleWriter implements IObjectPlacer {
/**
* Set a pyramid of data in the mantle
*
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param size the size of the pyramid (width of base & height)
* @param filled should it be filled or hollow
* @param <T> the type of data to apply to the mantle
* @param cx
* the center x
* @param cy
* the base y
* @param cz
* the center z
* @param data
* the data to set
* @param size
* the size of the pyramid (width of base & height)
* @param filled
* should it be filled or hollow
* @param <T>
* the type of data to apply to the mantle
*/
@SuppressWarnings("ConstantConditions")
public <T> void setPyramid(int cx, int cy, int cz, T data, int size, boolean filled) {
@ -353,12 +384,18 @@ public class MantleWriter implements IObjectPlacer {
/**
* Set a 3d line
*
* @param a the first point
* @param b the second point
* @param radius the radius
* @param filled hollow or filled?
* @param data the data
* @param <T> the type of data to apply to the mantle
* @param a
* the first point
* @param b
* the second point
* @param radius
* the radius
* @param filled
* hollow or filled?
* @param data
* the data
* @param <T>
* the type of data to apply to the mantle
*/
public <T> void setLine(IrisPosition a, IrisPosition b, double radius, boolean filled, T data) {
setLine(ImmutableList.of(a, b), radius, filled, data);
@ -371,11 +408,16 @@ public class MantleWriter implements IObjectPlacer {
/**
* Set lines for points
*
* @param vectors the points
* @param radius the radius
* @param filled hollow or filled?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param vectors
* the points
* @param radius
* the radius
* @param filled
* hollow or filled?
* @param data
* the data to set
* @param <T>
* the type of data to apply to the mantle
*/
public <T> void setLineConsumer(List<IrisPosition> vectors, double radius, boolean filled, Function3<Integer, Integer, Integer, T> data) {
Set<IrisPosition> vset = new KSet<>();
@ -441,13 +483,20 @@ public class MantleWriter implements IObjectPlacer {
/**
* Set a cylinder in the mantle
*
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param radius the radius
* @param height the height of the cyl
* @param filled filled or not
* @param cx
* the center x
* @param cy
* the base y
* @param cz
* the center z
* @param data
* the data to set
* @param radius
* the radius
* @param height
* the height of the cyl
* @param filled
* filled or not
*/
public <T> void setCylinder(int cx, int cy, int cz, T data, double radius, int height, boolean filled) {
setCylinder(cx, cy, cz, data, radius, radius, height, filled);
@ -456,14 +505,22 @@ public class MantleWriter implements IObjectPlacer {
/**
* Set a cylinder in the mantle
*
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param radiusX the x radius
* @param radiusZ the z radius
* @param height the height of this cyl
* @param filled filled or hollow?
* @param cx
* the center x
* @param cy
* the base y
* @param cz
* the center z
* @param data
* the data to set
* @param radiusX
* the x radius
* @param radiusZ
* the z radius
* @param height
* the height of this cyl
* @param filled
* filled or hollow?
*/
public <T> void setCylinder(int cx, int cy, int cz, T data, double radiusX, double radiusZ, int height, boolean filled) {
int affected = 0;
@ -524,13 +581,9 @@ public class MantleWriter implements IObjectPlacer {
}
public <T> void set(IrisPosition pos, T data) {
try
{
try {
setData(pos.getX(), pos.getY(), pos.getZ(), data);
}
catch(Throwable e)
{
} catch(Throwable e) {
Iris.error("No set? " + data.toString() + " for " + pos.toString());
}
}

View File

@ -53,8 +53,8 @@ public class HeadlessWorld {
.environment(dimension.getEnvironment())
.worldFolder(new File(worldName))
.seed(seed)
.maxHeight(256)
.minHeight(0)
.maxHeight(dimension.getMaxHeight())
.minHeight(dimension.getMinHeight())
.name(worldName)
.build();
world.worldFolder().mkdirs();

View File

@ -18,19 +18,11 @@
package com.volmit.iris.engine.object;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.EnginePanic;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.reflect.V;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.arithmetic.FittedStream;
import com.volmit.iris.util.stream.interpolation.Interpolated;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.*;
import java.util.List;
public interface IRare {
static <T extends IRare> ProceduralStream<T> stream(ProceduralStream<Double> noise, List<T> possibilities) {

View File

@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.ArrayType;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
@ -158,6 +157,8 @@ public class IrisDimension extends IrisRegistrant {
@MaxNumber(255)
@Desc("The fluid height for this dimension")
private int fluidHeight = 63;
@Desc("Define the min and max Y bounds of this dimension. Please keep in mind that Iris internally generates from 0 to (max - min). \n\nFor example at -64 to 320, Iris is internally generating to 0 to 384, then on outputting chunks, it shifts it down by the min height (64 blocks). The default is -64 to 320. \n\nThe fluid height is placed at (fluid height + min height). So a fluid height of 63 would actually show up in the world at 1.")
private IrisRange dimensionHeight = new IrisRange(-64, 320);
@RegistryListResource(IrisBiome.class)
@Desc("Keep this either undefined or empty. Setting any biome name into this will force iris to only generate the specified biome. Great for testing.")
private String focus = "";
@ -229,6 +230,16 @@ public class IrisDimension extends IrisRegistrant {
@ArrayType(type = IrisOreGenerator.class, min = 1)
private KList<IrisOreGenerator> ores = new KList<>();
public int getMaxHeight() {
return 320;
// return (int) getDimensionHeight().getMax();
}
public int getMinHeight() {
return -64;
// return (int) getDimensionHeight().getMin();
}
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
if(ores.isEmpty()) {
return null;

View File

@ -174,7 +174,8 @@ public enum IrisDirection {
* Get the directional value from the given byte from common directional blocks
* (MUST BE BETWEEN 0 and 5 INCLUSIVE)
*
* @param b the byte
* @param b
* the byte
* @return the direction or null if the byte is outside of the inclusive range
* 0-5
*/

View File

@ -29,14 +29,11 @@ import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.util.noise.ExpressionNoise;
import com.volmit.iris.util.noise.ImageNoise;
import com.volmit.iris.util.stream.ProceduralStream;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.List;
@Snippet("style")
@Accessors(chain = true)
@NoArgsConstructor
@ -96,17 +93,13 @@ public class IrisGeneratorStyle {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
}
if(cellularFrequency > 0)
{
if(cellularFrequency > 0) {
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
}
return cng;
}
}
else if(getImageMap() != null)
{
} else if(getImageMap() != null) {
CNG cng = new CNG(rng, new ImageNoise(data, getImageMap()), 1D, 1).bake().scale(1D / zoom).pow(exponent).bake();
cng.setTrueFracturing(axialFracturing);
@ -114,8 +107,7 @@ public class IrisGeneratorStyle {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
}
if(cellularFrequency > 0)
{
if(cellularFrequency > 0) {
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
}
@ -129,8 +121,7 @@ public class IrisGeneratorStyle {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
}
if(cellularFrequency > 0)
{
if(cellularFrequency > 0) {
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
}

View File

@ -30,34 +30,28 @@ import java.io.File;
import java.io.IOException;
public class IrisImage extends IrisRegistrant {
private BufferedImage image;
private final BufferedImage image;
public int getWidth()
{
public int getWidth() {
return image.getWidth();
}
public int getHeight()
{
public int getHeight() {
return image.getHeight();
}
public int getRawValue(int x, int z)
{
if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0)
{
public int getRawValue(int x, int z) {
if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0) {
return 0;
}
return image.getRGB(x, z);
}
public double getValue(IrisImageChannel channel, int x, int z)
{
public double getValue(IrisImageChannel channel, int x, int z) {
int color = getRawValue(x, z);
switch(channel)
{
switch(channel) {
case RED -> {
return ((color >> 16) & 0xFF) / 255D;
}
@ -105,13 +99,11 @@ public class IrisImage extends IrisRegistrant {
return color;
}
public IrisImage()
{
public IrisImage() {
this(new BufferedImage(4, 4, BufferedImage.TYPE_INT_RGB));
}
public IrisImage(BufferedImage image)
{
public IrisImage(BufferedImage image) {
this.image = image;
}
@ -136,10 +128,8 @@ public class IrisImage extends IrisRegistrant {
try {
File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName());
BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
for(int i = 0; i < getWidth(); i++)
{
for(int j = 0; j < getHeight(); j++)
{
for(int i = 0; i < getWidth(); i++) {
for(int j = 0; j < getHeight(); j++) {
b.setRGB(i, j, Color.getHSBColor(0, 0, (float) getValue(channel, i, j)).getRGB());
}
}

View File

@ -20,21 +20,13 @@ package com.volmit.iris.engine.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.project.SchemaBuilder;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.engine.object.annotations.ArrayType;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Snippet;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.interpolation.InterpolationMethod;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -72,19 +64,16 @@ public class IrisImageMap {
private transient AtomicCache<IrisImage> imageCache = new AtomicCache<IrisImage>();
public double getNoise(IrisData data, int x, int z)
{
public double getNoise(IrisData data, int x, int z) {
IrisImage i = imageCache.aquire(() -> data.getImageLoader().load(image));
if(i == null)
{
if(i == null) {
Iris.error("NULL IMAGE FOR " + image);
}
return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx, zz) -> rawNoise(i, xx, zz));
}
private double rawNoise(IrisImage i, double x, double z)
{
private double rawNoise(IrisImage i, double x, double z) {
x /= coordinateScale;
z /= coordinateScale;
x = isCentered() ? x + ((i.getWidth() / 2D) * coordinateScale) : x;

View File

@ -685,7 +685,7 @@ public class IrisObject extends IrisRegistrant {
boolean a = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 1, 0))));
boolean fff = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 2, 0))));
if ((marker.isEmptyAbove() && a && fff) || !marker.isEmptyAbove()) {
if(!marker.isEmptyAbove() || (a && fff)) {
markers.put(i, j.getMarker());
max--;
}

View File

@ -243,8 +243,10 @@ public class IrisObjectPlacement {
/**
* Gets the loot table that should be used for the block
*
* @param data The block data of the block
* @param dataManager Iris Data Manager
* @param data
* The block data of the block
* @param dataManager
* Iris Data Manager
* @return The loot table it should use.
*/
public IrisLootTable getTable(BlockData data, IrisData dataManager) {

View File

@ -20,11 +20,9 @@ package com.volmit.iris.engine.object;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
import jdk.jfr.Description;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

View File

@ -44,7 +44,8 @@ public enum IrisSurface {
/**
* Check if this Iris surface matches the blockstate provided
*
* @param state The blockstate
* @param state
* The blockstate
* @return True if it matches
*/
public boolean matches(Block state) {

View File

@ -45,7 +45,8 @@ public class IrisTreeSize {
/**
* Does the size match
*
* @param size the size to check match
* @param size
* the size to check match
* @return true if it matches (fits within width and depth)
*/
public boolean doesMatch(IrisTreeSize size) {

View File

@ -138,8 +138,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
loadLock.acquire();
IrisBiomeStorage st = new IrisBiomeStorage();
TerrainChunk tc = TerrainChunk.createUnsafe(world, st);
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
Hunk<BlockData> blocks = Hunk.view(tc);
Hunk<Biome> biomes = Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight());
this.world.bind(world);
getEngine().generate(x << 4, z << 4, blocks, biomes, true);
Iris.debug("Regenerated " + x + " " + z);
@ -283,8 +283,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
if(studioGenerator != null) {
studioGenerator.generateChunk(getEngine(), tc, x, z);
} else {
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
Hunk<BlockData> blocks = Hunk.view(tc);
Hunk<Biome> biomes = Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight());
getEngine().generate(x << 4, z << 4, blocks, biomes, true);
}

View File

@ -44,7 +44,6 @@ import lombok.Data;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator;
import java.io.File;
import java.io.IOException;
@ -86,7 +85,7 @@ public class HeadlessGenerator implements PlatformChunkGenerator {
INMS.get().getTrueBiomeBaseId(biomeBase)))
.build();
getEngine().generate(x << 4, z << 4,
Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc),
Hunk.view(tc), Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight()),
false);
chunk.cleanupPalettesAndBlockStates();
} catch(Throwable e) {

View File

@ -40,7 +40,8 @@ public class AtomicAverage {
/**
* Create an average holder
*
* @param size the size of entries to keep
* @param size
* the size of entries to keep
*/
public AtomicAverage(int size) {
values = new AtomicDoubleArray(size);
@ -55,7 +56,8 @@ public class AtomicAverage {
/**
* Put a value into the average (rolls over if full)
*
* @param i the value
* @param i
* the value
*/
public void put(double i) {

View File

@ -24,8 +24,10 @@ import java.io.Serializable;
/**
* A Biset
*
* @param <A> the first object type
* @param <B> the second object type
* @param <A>
* the first object type
* @param <B>
* the second object type
* @author cyberpwn
*/
@SuppressWarnings("hiding")
@ -37,8 +39,10 @@ public class GBiset<A, B> implements Serializable {
/**
* Create a new Biset
*
* @param a the first object
* @param b the second object
* @param a
* the first object
* @param b
* the second object
*/
public GBiset(A a, B b) {
this.a = a;
@ -57,7 +61,8 @@ public class GBiset<A, B> implements Serializable {
/**
* Set the first object
*
* @param a the first object A
* @param a
* the first object A
*/
public void setA(A a) {
this.a = a;

View File

@ -24,15 +24,18 @@ import java.util.List;
/**
* Adapts a list of objects into a list of other objects
*
* @param <FROM> the from object in lists (the item INSIDE the list)
* @param <TO> the to object in lists (the item INSIDE the list)
* @param <FROM>
* the from object in lists (the item INSIDE the list)
* @param <TO>
* the to object in lists (the item INSIDE the list)
* @author cyberpwn
*/
public abstract class GListAdapter<FROM, TO> {
/**
* Adapts a list of FROM to a list of TO
*
* @param from the from list
* @param from
* the from list
* @return the to list
*/
public List<TO> adapt(List<FROM> from) {
@ -52,7 +55,8 @@ public abstract class GListAdapter<FROM, TO> {
/**
* Adapts a list object FROM to TO for use with the adapt method
*
* @param from the from object
* @param from
* the from object
* @return the to object
*/
public abstract TO onAdapt(FROM from);

View File

@ -119,8 +119,10 @@ public class KList<T> extends ArrayList<T> implements List<T> {
* returned map. You must specify each key for each value in this list. In the
* function, returning null will not add the keyval pair.
*
* @param <K> the inferred key type
* @param f the function
* @param <K>
* the inferred key type
* @param f
* the function
* @return the new map
*/
public <K> KMap<K, T> asValues(Function<T, K> f) {
@ -134,8 +136,10 @@ public class KList<T> extends ArrayList<T> implements List<T> {
* returned map. You must specify each value for each key in this list. In the
* function, returning null will not add the keyval pair.
*
* @param <V> the inferred value type
* @param f the function
* @param <V>
* the inferred value type
* @param f
* the function
* @return the new map
*/
public <V> KMap<T, V> asKeys(Function<T, V> f) {
@ -147,7 +151,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
/**
* Cut this list into targetCount sublists
*
* @param targetCount the target count of sublists
* @param targetCount
* the target count of sublists
* @return the list of sublists
*/
public KList<KList<T>> divide(int targetCount) {
@ -158,7 +163,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
* Split this list into a list of sublists with roughly targetSize elements of T
* per sublist
*
* @param targetSize the target size
* @param targetSize
* the target size
* @return the list of sublists
*/
public KList<KList<T>> split(int targetSize) {
@ -186,7 +192,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
* Rewrite this list by checking each value and changing the value (or not).
* Return null to remove the element in the function
*
* @param t the function
* @param t
* the function
* @return the same list (not a copy)
*/
public KList<T> rewrite(Function<T, T> t) {
@ -262,7 +269,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
/**
* Tostring with a seperator for each item in the list
*
* @param split the seperator
* @param split
* the seperator
* @return the string representing this object
*/
public String toString(String split) {
@ -295,9 +303,12 @@ public class KList<T> extends ArrayList<T> implements List<T> {
/**
* Add the contents of the given list (v) into this list using a converter
*
* @param <V> the type of the forign list
* @param v the forign (given) list
* @param converter the converter that converts the forign type into this list type
* @param <V>
* the type of the forign list
* @param v
* the forign (given) list
* @param converter
* the converter that converts the forign type into this list type
* @return this list (builder)
*/
public <V> KList<T> addFrom(List<V> v, Function<V, T> converter) {
@ -308,10 +319,6 @@ public class KList<T> extends ArrayList<T> implements List<T> {
/**
* Convert this list into another list type. Such as GList<Integer> to
* GList<String>. list.convert((i) -> "" + i);
*
* @param <V>
* @param converter
* @return
*/
public <V> KList<V> convert(Function<T, V> converter) {
KList<V> v = new KList<V>();
@ -332,7 +339,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
/**
* Adds T to the list, ignores if null
*
* @param t the value to add
* @param t
* the value to add
* @return the same list
*/
public KList<T> addNonNull(T t) {
@ -347,8 +355,10 @@ public class KList<T> extends ArrayList<T> implements List<T> {
* Swaps the values of index a and b. For example "hello", "world", "!" swap(1,
* 2) would change the list to "hello", "!", "world"
*
* @param a the first index
* @param b the second index
* @param a
* the first index
* @param b
* the second index
* @return the same list (builder), not a copy
*/
public KList<T> swapIndexes(int a, int b) {
@ -364,7 +374,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
/**
* Remove a number of elements from the list
*
* @param t the elements
* @param t
* the elements
* @return this list
*/
@SuppressWarnings("unchecked")
@ -379,7 +390,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
/**
* Add another glist's contents to this one (addall builder)
*
* @param t the list
* @param t
* the list
* @return the same list
*/
public KList<T> add(KList<T> t) {
@ -390,7 +402,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
/**
* Add a number of values to this list
*
* @param t the list
* @param t
* the list
* @return this list
*/
@SuppressWarnings("unchecked")
@ -405,7 +418,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
/**
* Check if this list has an index at the given index
*
* @param index the given index
* @param index
* the given index
* @return true if size > index
*/
public boolean hasIndex(int index) {

View File

@ -56,9 +56,12 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
* Puts a value into a map-value-list based on the key such that if GMap<K,
* GList<S>> where V is GList<S>
*
* @param <S> the list type in the value type
* @param k the key to look for
* @param vs the values to put into the list of the given key
* @param <S>
* the list type in the value type
* @param k
* the key to look for
* @param vs
* the values to put into the list of the given key
* @return the same list (builder)
*/
@SuppressWarnings("unchecked")
@ -143,7 +146,8 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
/**
* Put another map's values into this map
*
* @param m the map to insert
* @param m
* the map to insert
* @return this map (builder)
*/
public KMap<K, V> put(Map<K, V> m) {
@ -163,7 +167,8 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
/**
* Loop through each keyvalue set (copy of it) with the map parameter
*
* @param f the function
* @param f
* the function
* @return the same gmap
*/
public KMap<K, V> rewrite(Consumer3<K, V, KMap<K, V>> f) {
@ -179,7 +184,8 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
/**
* Loop through each keyvalue set (copy of it)
*
* @param f the function
* @param f
* the function
* @return the same gmap
*/
public KMap<K, V> each(Consumer2<K, V> f) {
@ -308,9 +314,10 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
/**
* Still works as it normally should except it returns itself (builder)
*
* @param key the key
* @param value the value (single only supported)
* @return
* @param key
* the key
* @param value
* the value (single only supported)
*/
public KMap<K, V> qput(K key, V value) {
super.put(key, value);
@ -321,8 +328,10 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
* Works just like put, except it wont put anything unless the key and value are
* nonnull
*
* @param key the nonnull key
* @param value the nonnull value
* @param key
* the nonnull key
* @param value
* the nonnull value
* @return the same map
*/
public KMap<K, V> putNonNull(K key, V value) {

View File

@ -21,8 +21,10 @@ package com.volmit.iris.util.collection;
/**
* Represents a keypair
*
* @param <K> the key type
* @param <V> the value type
* @param <K>
* the key type
* @param <V>
* the value type
* @author cyberpwn
*/
@SuppressWarnings("hiding")
@ -33,8 +35,10 @@ public class KeyPair<K, V> {
/**
* Create a keypair
*
* @param k the key
* @param v the value
* @param k
* the key
* @param v
* the value
*/
public KeyPair(K k, V v) {
this.k = k;

View File

@ -38,7 +38,6 @@ import org.bukkit.block.data.type.PointedDripstone;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier;
import java.util.stream.Collectors;

View File

@ -49,8 +49,10 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* Construct a Cuboid given two Location objects which represent any two corners
* of the Cuboid.
*
* @param l1 one of the corners
* @param l2 the other corner
* @param l1
* one of the corners
* @param l2
* the other corner
*/
public Cuboid(Location l1, Location l2) {
if(!l1.getWorld().equals(l2.getWorld())) {
@ -69,7 +71,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Construct a one-block Cuboid at the given Location of the Cuboid.
*
* @param l1 location of the Cuboid
* @param l1
* location of the Cuboid
*/
public Cuboid(Location l1) {
this(l1, l1);
@ -78,7 +81,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Copy constructor.
*
* @param other the Cuboid to copy
* @param other
* the Cuboid to copy
*/
public Cuboid(Cuboid other) {
this(other.getWorld().getName(), other.x1, other.y1, other.z1, other.x2, other.y2, other.z2);
@ -87,13 +91,20 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Construct a Cuboid in the given World and xyz co-ordinates
*
* @param world the Cuboid's world
* @param x1 X co-ordinate of corner 1
* @param y1 Y co-ordinate of corner 1
* @param z1 Z co-ordinate of corner 1
* @param x2 X co-ordinate of corner 2
* @param y2 Y co-ordinate of corner 2
* @param z2 Z co-ordinate of corner 2
* @param world
* the Cuboid's world
* @param x1
* X co-ordinate of corner 1
* @param y1
* Y co-ordinate of corner 1
* @param z1
* Z co-ordinate of corner 1
* @param x2
* X co-ordinate of corner 2
* @param y2
* Y co-ordinate of corner 2
* @param z2
* Z co-ordinate of corner 2
*/
public Cuboid(World world, int x1, int y1, int z1, int x2, int y2, int z2) {
this.worldName = world.getName();
@ -108,13 +119,20 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Construct a Cuboid in the given world name and xyz co-ordinates.
*
* @param worldName the Cuboid's world name
* @param x1 X co-ordinate of corner 1
* @param y1 Y co-ordinate of corner 1
* @param z1 Z co-ordinate of corner 1
* @param x2 X co-ordinate of corner 2
* @param y2 Y co-ordinate of corner 2
* @param z2 Z co-ordinate of corner 2
* @param worldName
* the Cuboid's world name
* @param x1
* X co-ordinate of corner 1
* @param y1
* Y co-ordinate of corner 1
* @param z1
* Z co-ordinate of corner 1
* @param x2
* X co-ordinate of corner 2
* @param y2
* Y co-ordinate of corner 2
* @param z2
* Z co-ordinate of corner 2
*/
private Cuboid(String worldName, int x1, int y1, int z1, int x2, int y2, int z2) {
this.worldName = worldName;
@ -153,8 +171,10 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Set the locations
*
* @param l1 a
* @param l2 b
* @param l1
* a
* @param l2
* b
*/
public void set(Location l1, Location l2) {
x1 = Math.min(l1.getBlockX(), l2.getBlockX());
@ -218,7 +238,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* Get the Cuboid's world.
*
* @return the World object representing this Cuboid's world
* @throws IllegalStateException if the world is not loaded
* @throws IllegalStateException
* if the world is not loaded
*/
public World getWorld() {
World world = Bukkit.getWorld(worldName);
@ -342,8 +363,10 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* amounts will shrink the Cuboid in the given direction. Shrinking a cuboid's
* face past the opposite face is not an error and will return a valid Cuboid.
*
* @param dir the direction in which to expand
* @param amount the number of blocks by which to expand
* @param dir
* the direction in which to expand
* @param amount
* the number of blocks by which to expand
* @return a new Cuboid expanded by the given direction and amount
*/
public Cuboid expand(CuboidDirection dir, int amount) {
@ -371,8 +394,10 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Shift the Cuboid in the given direction by the given amount.
*
* @param dir the direction in which to shift
* @param amount the number of blocks by which to shift
* @param dir
* the direction in which to shift
* @param amount
* the number of blocks by which to shift
* @return a new Cuboid shifted by the given direction and amount
*/
public Cuboid shift(CuboidDirection dir, int amount) {
@ -382,9 +407,11 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Outset (grow) the Cuboid in the given direction by the given amount.
*
* @param dir the direction in which to outset (must be Horizontal, Vertical, or
* @param dir
* the direction in which to outset (must be Horizontal, Vertical, or
* Both)
* @param amount the number of blocks by which to outset
* @param amount
* the number of blocks by which to outset
* @return a new Cuboid outset by the given direction and amount
*/
public Cuboid outset(CuboidDirection dir, int amount) {
@ -401,9 +428,11 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* Inset (shrink) the Cuboid in the given direction by the given amount.
* Equivalent to calling outset() with a negative amount.
*
* @param dir the direction in which to inset (must be Horizontal, Vertical, or
* @param dir
* the direction in which to inset (must be Horizontal, Vertical, or
* Both)
* @param amount the number of blocks by which to inset
* @param amount
* the number of blocks by which to inset
* @return a new Cuboid inset by the given direction and amount
*/
public Cuboid inset(CuboidDirection dir, int amount) {
@ -413,9 +442,12 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Return true if the point at (x,y,z) is contained within this Cuboid.
*
* @param x the X co-ordinate
* @param y the Y co-ordinate
* @param z the Z co-ordinate
* @param x
* the X co-ordinate
* @param y
* the Y co-ordinate
* @param z
* the Z co-ordinate
* @return true if the given point is within this Cuboid, false otherwise
*/
public boolean contains(int x, int y, int z) {
@ -425,7 +457,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Check if the given Block is contained within this Cuboid.
*
* @param b the Block to check for
* @param b
* the Block to check for
* @return true if the Block is within this Cuboid, false otherwise
*/
public boolean contains(Block b) {
@ -435,7 +468,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Check if the given Location is contained within this Cuboid.
*
* @param l the Location to check for
* @param l
* the Location to check for
* @return true if the Location is within this Cuboid, false otherwise
*/
public boolean contains(Location l) {
@ -484,7 +518,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* no exterior empty space. E.g. a direction of Down will push the top face
* downwards as much as possible.
*
* @param dir the direction in which to contract
* @param dir
* the direction in which to contract
* @return a new Cuboid contracted in the given direction
*/
public Cuboid contract(CuboidDirection dir) {
@ -534,7 +569,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* Get the Cuboid representing the face of this Cuboid. The resulting Cuboid
* will be one block thick in the axis perpendicular to the requested face.
*
* @param dir which face of the Cuboid to get
* @param dir
* which face of the Cuboid to get
* @return the Cuboid representing this Cuboid's requested face
*/
public Cuboid getFace(CuboidDirection dir) {
@ -552,7 +588,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Check if the Cuboid contains only blocks of the given type
*
* @param material the material to check for
* @param material
* the material to check for
* @return true if this Cuboid contains only blocks of the given type
*/
public boolean containsOnly(Material material) {
@ -567,7 +604,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Get the Cuboid big enough to hold both this Cuboid and the given one.
*
* @param other the other Cuboid to include
* @param other
* the other Cuboid to include
* @return a new Cuboid large enough to hold this Cuboid and the given Cuboid
*/
public Cuboid getBoundingCuboid(Cuboid other) {
@ -588,9 +626,12 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/**
* Get a block relative to the lower NE point of the Cuboid.
*
* @param x the X co-ordinate
* @param y the Y co-ordinate
* @param z the Z co-ordinate
* @param x
* the X co-ordinate
* @param y
* the Y co-ordinate
* @param z
* the Z co-ordinate
* @return the block at the given position
*/
public Block getRelativeBlock(int x, int y, int z) {
@ -602,10 +643,14 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* This version of getRelativeBlock() should be used if being called many times,
* to avoid excessive calls to getWorld().
*
* @param w the World
* @param x the X co-ordinate
* @param y the Y co-ordinate
* @param z the Z co-ordinate
* @param w
* the World
* @param x
* the X co-ordinate
* @param y
* the Y co-ordinate
* @param z
* the Z co-ordinate
* @return the block at the given position
*/
public Block getRelativeBlock(World w, int x, int y, int z) {

View File

@ -18,12 +18,9 @@
package com.volmit.iris.util.data;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
/**

View File

@ -31,9 +31,12 @@ public class Dimension {
/**
* Make a dimension
*
* @param width width of this (X)
* @param height the height (Y)
* @param depth the depth (Z)
* @param width
* width of this (X)
* @param height
* the height (Y)
* @param depth
* the depth (Z)
*/
public Dimension(int width, int height, int depth) {
this.width = width;
@ -44,8 +47,10 @@ public class Dimension {
/**
* Make a dimension
*
* @param width width of this (X)
* @param height the height (Y)
* @param width
* width of this (X)
* @param height
* the height (Y)
*/
public Dimension(int width, int height) {
this.width = width;

View File

@ -36,8 +36,10 @@ public class MaterialBlock {
/**
* Create a materialblock
*
* @param material the material
* @param data the data
* @param material
* the material
* @param data
* the data
*/
public MaterialBlock(Material material, Byte data) {
this.material = material;

View File

@ -33,96 +33,82 @@ public class VanillaBiomeMap {
private static final KMap<Biome, Short> BIOME_IDs = new KMap<>();
static {
add(Biome.OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.PLAINS, 0x8DB360, (short) 1, Color.GREEN, Luminosity.LIGHT, SaturationType.MEDIUM);
add(Biome.DESERT, 0xFA9418, (short) 2, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM);
add(Biome.MOUNTAINS, 0x606060, (short) 3, Color.MONOCHROME, Luminosity.BRIGHT, null);
add(Biome.FOREST, 0x056621, (short) 4, Color.GREEN, Luminosity.BRIGHT);
add(Biome.TAIGA, 0x0B6659, (short) 5, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.SWAMP, 0x07F9B2, (short) 6, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM);
add(Biome.RIVER, 0x0000FF, (short) 7, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.NETHER_WASTES, 0xBF3B3B, (short) 8, Color.RED, Luminosity.LIGHT, SaturationType.MEDIUM);
add(Biome.THE_END, 0x8080FF, (short) 9, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.FROZEN_OCEAN, 0x7070D6, (short) 10, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.FROZEN_RIVER, 0xA0A0FF, (short) 11, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.SNOWY_TUNDRA, 0xFFFFFF, (short) 12, Color.MONOCHROME, Luminosity.LIGHT);
add(Biome.SNOWY_MOUNTAINS, 0xA0A0A0, (short) 13, Color.MONOCHROME, Luminosity.LIGHT);
add(Biome.MUSHROOM_FIELDS, 0xFF00FF, (short) 14, Color.PURPLE, Luminosity.BRIGHT);
add(Biome.MUSHROOM_FIELD_SHORE, 0xA000FF, (short) 15, Color.PURPLE, Luminosity.BRIGHT);
add(Biome.BEACH, 0xFADE55, (short) 16, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.DESERT_HILLS, 0xD25F12, (short) 17, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM);
add(Biome.WOODED_HILLS, 0x22551C, (short) 18, Color.GREEN, Luminosity.LIGHT);
add(Biome.TAIGA_HILLS, 0x163933, (short) 19, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.MOUNTAIN_EDGE, 0x72789A, (short) 20, Color.MONOCHROME, Luminosity.BRIGHT);
add(Biome.JUNGLE, 0x537B09, (short) 21, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.JUNGLE_HILLS, 0x2C4205, (short) 22, Color.GREEN, Luminosity.DARK, SaturationType.HIGH);
add(Biome.JUNGLE_EDGE, 0x628B17, (short) 23, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.DEEP_OCEAN, 0x000030, (short) 24, Color.BLUE, Luminosity.DARK);
add(Biome.STONE_SHORE, 0xA2A284, (short) 25, Color.GREEN, Luminosity.DARK);
add(Biome.SNOWY_BEACH, 0xFAF0C0, (short) 26, Color.YELLOW, Luminosity.LIGHT);
add(Biome.BIRCH_FOREST, 0x307444, (short) 27, Color.GREEN, Luminosity.LIGHT);
add(Biome.BIRCH_FOREST_HILLS, 0x1F5F32, (short) 28, Color.GREEN, Luminosity.LIGHT);
add(Biome.DARK_FOREST, 0x40511A, (short) 29, Color.GREEN, Luminosity.DARK);
add(Biome.SNOWY_TAIGA, 0x31554A, (short) 30, Color.BLUE, Luminosity.LIGHT);
add(Biome.SNOWY_TAIGA_HILLS, 0x243F36, (short) 31, Color.BLUE, Luminosity.LIGHT);
add(Biome.GIANT_TREE_TAIGA, 0x596651, (short) 32, Color.ORANGE, Luminosity.LIGHT);
add(Biome.GIANT_TREE_TAIGA_HILLS, 0x454F3E, (short) 33, Color.ORANGE, Luminosity.LIGHT);
add(Biome.WOODED_MOUNTAINS, 0x507050, (short) 34, Color.MONOCHROME, Luminosity.BRIGHT);
add(Biome.SAVANNA, 0xBDB25F, (short) 35, Color.GREEN, Luminosity.LIGHT);
add(Biome.SAVANNA_PLATEAU, 0xA79D64, (short) 36, Color.GREEN, Luminosity.LIGHT);
add(Biome.BADLANDS, 0xD94515, (short) 37, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.WOODED_BADLANDS_PLATEAU, 0xB09765, (short) 38, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.BADLANDS_PLATEAU, 0xCA8C65, (short) 39, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.END_MIDLANDS, 0x8080FF, (short) 41, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.END_HIGHLANDS, 0x8080FF, (short) 42, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.END_BARRENS, 0x8080FF, (short) 43, Color.PURPLE, Luminosity.LIGHT, SaturationType.MEDIUM);
add(Biome.WARM_OCEAN, 0x0000AC, (short) 44, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW);
add(Biome.LUKEWARM_OCEAN, 0x000090, (short) 45, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.COLD_OCEAN, 0x202070, (short) 46, Color.BLUE, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.DEEP_WARM_OCEAN, 0x000050, (short) 47, Color.BLUE, Luminosity.DARK, SaturationType.LOW);
add(Biome.DEEP_LUKEWARM_OCEAN, 0x000040, (short) 48, Color.BLUE, Luminosity.DARK, SaturationType.MEDIUM);
add(Biome.DEEP_COLD_OCEAN, 0x202038, (short) 49, Color.BLUE, Luminosity.DARK, SaturationType.HIGH);
add(Biome.DEEP_FROZEN_OCEAN, 0x404090, (short) 50, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.THE_VOID, 0x000000, (short) 127, Color.MONOCHROME, Luminosity.DARK);
add(Biome.SUNFLOWER_PLAINS, 0xB5DB88, (short) 129, Color.GREEN, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.DESERT_LAKES, 0xFFBC40, (short) 130, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.GRAVELLY_MOUNTAINS, 0x888888, (short) 131, Color.MONOCHROME, Luminosity.LIGHT);
add(Biome.FLOWER_FOREST, 0x2D8E49, (short) 132, Color.RED, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.TAIGA_MOUNTAINS, 0x338E81, (short) 133, Color.GREEN, Luminosity.DARK, SaturationType.MEDIUM);
add(Biome.SWAMP_HILLS, 0x2FFFDA, (short) 134, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM);
add(Biome.ICE_SPIKES, 0xB4DCDC, (short) 140, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.MODIFIED_JUNGLE, 0x7BA331, (short) 149, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.MODIFIED_JUNGLE_EDGE, 0x8AB33F, (short) 151, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.TALL_BIRCH_FOREST, 0x589C6C, (short) 155, Color.GREEN, Luminosity.LIGHT);
add(Biome.TALL_BIRCH_HILLS, 0x47875A, (short) 156, Color.GREEN, Luminosity.LIGHT);
add(Biome.DARK_FOREST_HILLS, 0x687942, (short) 157, Color.GREEN, Luminosity.DARK);
add(Biome.SNOWY_TAIGA_MOUNTAINS, 0x597D72, (short) 158, Color.BLUE, Luminosity.LIGHT);
add(Biome.GIANT_SPRUCE_TAIGA, 0x818E79, (short) 160, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH);
add(Biome.GIANT_SPRUCE_TAIGA_HILLS, 0x6D7766, (short) 161, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH);
add(Biome.GRAVELLY_MOUNTAINS, 0x789878, (short) 162, Color.MONOCHROME, Luminosity.LIGHT);
add(Biome.SHATTERED_SAVANNA, 0xE5DA87, (short) 163, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH);
add(Biome.SHATTERED_SAVANNA_PLATEAU, 0xCFC58C, (short) 164, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH);
add(Biome.ERODED_BADLANDS, 0xFF6D3D, (short) 165, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH);
add(Biome.MODIFIED_WOODED_BADLANDS_PLATEAU, 0xD8BF8D, (short) 166, Color.ORANGE, Luminosity.BRIGHT);
add(Biome.MODIFIED_BADLANDS_PLATEAU, 0xF2B48D, (short) 167, Color.ORANGE, Luminosity.BRIGHT);
add(Biome.BAMBOO_JUNGLE, 0x768E14, (short) 168, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.BAMBOO_JUNGLE_HILLS, 0x3B470A, (short) 169, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.SOUL_SAND_VALLEY, 0x5E3830, (short) 170, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.CRIMSON_FOREST, 0xDD0808, (short) 171, Color.RED, Luminosity.DARK, SaturationType.HIGH);
add(Biome.WARPED_FOREST, 0x49907B, (short) 172, Color.BLUE, Luminosity.BRIGHT);
add(Biome.BASALT_DELTAS, 0x403636, (short) 173, Color.MONOCHROME, Luminosity.DARK);
add(Biome.OCEAN, 0x000070, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.PLAINS, 0x8DB360, Color.GREEN, Luminosity.LIGHT, SaturationType.MEDIUM);
add(Biome.DESERT, 0xFA9418, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM);
add(Biome.WINDSWEPT_HILLS, 0x606060, Color.MONOCHROME, Luminosity.BRIGHT, null);
add(Biome.FOREST, 0x056621, Color.GREEN, Luminosity.BRIGHT, null);
add(Biome.TAIGA, 0x0B6659, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.SWAMP, 0x07F9B2, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM);
add(Biome.RIVER, 0x0000FF, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.NETHER_WASTES, 0xBF3B3B, Color.RED, Luminosity.LIGHT, SaturationType.MEDIUM);
add(Biome.THE_END, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.FROZEN_OCEAN, 0x7070D6, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.FROZEN_RIVER, 0xA0A0FF, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.SNOWY_PLAINS, 0xFFFFFF, Color.MONOCHROME, Luminosity.LIGHT, null);
add(Biome.MUSHROOM_FIELDS, 0xFF00FF, Color.PURPLE, Luminosity.BRIGHT, null);
add(Biome.BEACH, 0xFADE55, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.JUNGLE, 0x537B09, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.SPARSE_JUNGLE, 0x628B17, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.DEEP_OCEAN, 0x000030, Color.BLUE, Luminosity.DARK, null);
add(Biome.STONY_SHORE, 0xA2A284, Color.GREEN, Luminosity.DARK, null);
add(Biome.SNOWY_BEACH, 0xFAF0C0, Color.YELLOW, Luminosity.LIGHT, null);
add(Biome.BIRCH_FOREST, 0x307444, Color.GREEN, Luminosity.LIGHT, null);
add(Biome.DARK_FOREST, 0x40511A, Color.GREEN, Luminosity.DARK, null);
add(Biome.SNOWY_TAIGA, 0x31554A, Color.BLUE, Luminosity.LIGHT, null);
add(Biome.OLD_GROWTH_PINE_TAIGA, 0x596651, Color.ORANGE, Luminosity.LIGHT, null);
add(Biome.WINDSWEPT_FOREST, 0x507050, Color.MONOCHROME, Luminosity.BRIGHT, null);
add(Biome.SAVANNA, 0xBDB25F, Color.GREEN, Luminosity.LIGHT, null);
add(Biome.SAVANNA_PLATEAU, 0xA79D64, Color.GREEN, Luminosity.LIGHT, null);
add(Biome.BADLANDS, 0xD94515, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.WOODED_BADLANDS, 0xB09765, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.SMALL_END_ISLANDS, 0xff1a8c, Color.PURPLE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.END_MIDLANDS, 0x8080FF, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.END_HIGHLANDS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.END_BARRENS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.MEDIUM);
add(Biome.WARM_OCEAN, 0x0000AC, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW);
add(Biome.LUKEWARM_OCEAN, 0x000090, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.COLD_OCEAN, 0x202070, Color.BLUE, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.DEEP_LUKEWARM_OCEAN, 0x000040, Color.BLUE, Luminosity.DARK, SaturationType.MEDIUM);
add(Biome.DEEP_COLD_OCEAN, 0x202038, Color.BLUE, Luminosity.DARK, SaturationType.HIGH);
add(Biome.DEEP_FROZEN_OCEAN, 0x404090, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.THE_VOID, 0x000000, Color.MONOCHROME, Luminosity.DARK, null);
add(Biome.SUNFLOWER_PLAINS, 0xB5DB88, Color.GREEN, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.WINDSWEPT_GRAVELLY_HILLS, 0x789878, Color.MONOCHROME, Luminosity.LIGHT, null);
add(Biome.FLOWER_FOREST, 0x2D8E49, Color.RED, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.ICE_SPIKES, 0xB4DCDC, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
add(Biome.OLD_GROWTH_BIRCH_FOREST, 0x589C6C, Color.GREEN, Luminosity.LIGHT, null);
add(Biome.OLD_GROWTH_SPRUCE_TAIGA, 0x818E79, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH);
add(Biome.WINDSWEPT_SAVANNA, 0xE5DA87, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH);
add(Biome.ERODED_BADLANDS, 0xFF6D3D, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH);
add(Biome.BAMBOO_JUNGLE, 0x768E14, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
add(Biome.SOUL_SAND_VALLEY, 0x5E3830, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.CRIMSON_FOREST, 0xDD0808, Color.RED, Luminosity.DARK, SaturationType.HIGH);
add(Biome.WARPED_FOREST, 0x49907B, Color.BLUE, Luminosity.BRIGHT, null);
add(Biome.BASALT_DELTAS, 0x403636, Color.MONOCHROME, Luminosity.DARK, null);
add(Biome.DRIPSTONE_CAVES, 0xcc6600, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.LUSH_CAVES, 0x003300, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.MEADOW, 0xff00ff, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW);
add(Biome.GROVE, 0x80ff80, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.SNOWY_SLOPES, 0x00ffff, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.FROZEN_PEAKS, 0xA0A0A0, Color.MONOCHROME, Luminosity.LIGHT, null);
add(Biome.JAGGED_PEAKS, 0x3d7bc2, Color.MONOCHROME, Luminosity.BRIGHT, SaturationType.MEDIUM);
add(Biome.STONY_PEAKS, 0x888888, Color.MONOCHROME, Luminosity.LIGHT, null);
add(Biome.CUSTOM, 0xffffff, Color.MONOCHROME, Luminosity.DARK, SaturationType.MONOCHROME);
}
private static void add(Biome biome, int color, short id, Color randomColor, Luminosity luminosity, SaturationType saturation) {
private static void add(Biome biome, int color, Color randomColor, Luminosity luminosity, SaturationType saturation) {
BIOME_HEX.put(biome, color);
BIOME_COLOR.put(biome, randomColor);
if(luminosity != null) BIOME_LUMINOSITY.put(biome, luminosity);
if(saturation != null) BIOME_SATURATION.put(biome, saturation);
BIOME_IDs.put(biome, id);
BIOME_IDs.put(biome, (short) biome.ordinal());
}
private static void add(Biome biome, int color, short id, Color randomColor, Luminosity luminosity) {
add(biome, color, id, randomColor, luminosity, null);
private static void add(Biome biome, int color, Color randomColor, Luminosity luminosity) {
add(biome, color, randomColor, luminosity, null);
}
public static int getColor(Biome biome) {

View File

@ -44,9 +44,12 @@ public final class Varint {
* encode signed values. If values are known to be nonnegative,
* {@link #writeUnsignedVarLong(long, DataOutput)} should be used.
*
* @param value value to encode
* @param out to writeNodeData bytes to
* @throws IOException if {@link DataOutput} throws {@link IOException}
* @param value
* value to encode
* @param out
* to writeNodeData bytes to
* @throws IOException
* if {@link DataOutput} throws {@link IOException}
*/
public static void writeSignedVarLong(long value, DataOutput out) throws IOException {
// Great trick from http://code.google.com/apis/protocolbuffers/docs/encoding.html#types
@ -60,9 +63,12 @@ public final class Varint {
* If values can be negative, use {@link #writeSignedVarLong(long, DataOutput)}
* instead. This method treats negative input as like a large unsigned value.
*
* @param value value to encode
* @param out to writeNodeData bytes to
* @throws IOException if {@link DataOutput} throws {@link IOException}
* @param value
* value to encode
* @param out
* to writeNodeData bytes to
* @throws IOException
* if {@link DataOutput} throws {@link IOException}
*/
public static void writeUnsignedVarLong(long value, DataOutput out) throws IOException {
while((value & 0xFFFFFFFFFFFFFF80L) != 0L) {
@ -118,10 +124,13 @@ public final class Varint {
}
/**
* @param in to read bytes from
* @param in
* to read bytes from
* @return decode value
* @throws IOException if {@link DataInput} throws {@link IOException}
* @throws IllegalArgumentException if variable-length value does not terminate
* @throws IOException
* if {@link DataInput} throws {@link IOException}
* @throws IllegalArgumentException
* if variable-length value does not terminate
* after 9 bytes have been read
* @see #writeSignedVarLong(long, DataOutput)
*/
@ -136,10 +145,13 @@ public final class Varint {
}
/**
* @param in to read bytes from
* @param in
* to read bytes from
* @return decode value
* @throws IOException if {@link DataInput} throws {@link IOException}
* @throws IllegalArgumentException if variable-length value does not terminate
* @throws IOException
* if {@link DataInput} throws {@link IOException}
* @throws IllegalArgumentException
* if variable-length value does not terminate
* after 9 bytes have been read
* @see #writeUnsignedVarLong(long, DataOutput)
*/
@ -158,9 +170,11 @@ public final class Varint {
}
/**
* @throws IllegalArgumentException if variable-length value does not terminate
* @throws IllegalArgumentException
* if variable-length value does not terminate
* after 5 bytes have been read
* @throws IOException if {@link DataInput} throws {@link IOException}
* @throws IOException
* if {@link DataInput} throws {@link IOException}
* @see #readSignedVarLong(DataInput)
*/
public static int readSignedVarInt(DataInput in) throws IOException {
@ -174,9 +188,11 @@ public final class Varint {
}
/**
* @throws IllegalArgumentException if variable-length value does not terminate
* @throws IllegalArgumentException
* if variable-length value does not terminate
* after 5 bytes have been read
* @throws IOException if {@link DataInput} throws {@link IOException}
* @throws IOException
* if {@link DataInput} throws {@link IOException}
* @see #readUnsignedVarLong(DataInput)
*/
public static int readUnsignedVarInt(DataInput in) throws IOException {

View File

@ -31,7 +31,8 @@ public enum DecreeOrigin {
/**
* Check if the origin is valid for a sender
*
* @param sender The sender to check
* @param sender
* The sender to check
* @return True if valid for origin
*/
public boolean validFor(VolmitSender sender) {

View File

@ -38,7 +38,8 @@ public interface DecreeParameterHandler<T> {
/**
* Converting the type back to a string (inverse of the {@link #parse(String) parse} method)
*
* @param t The input of the designated type to convert to a String
* @param t
* The input of the designated type to convert to a String
* @return The resulting string
*/
String toString(T t);
@ -46,7 +47,8 @@ public interface DecreeParameterHandler<T> {
/**
* Forces conversion to the designated type before converting to a string using {@link #toString(T t)}
*
* @param t The object to convert to string (that should be of this type)
* @param t
* The object to convert to string (that should be of this type)
* @return The resulting string.
*/
default String toStringForce(Object t) {
@ -56,9 +58,11 @@ public interface DecreeParameterHandler<T> {
/**
* Should parse a String into the designated type
*
* @param in The string to parse
* @param in
* The string to parse
* @return The value extracted from the string, of the designated type
* @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
* @throws DecreeParsingException
* Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
*/
default T parse(String in) throws DecreeParsingException {
return parse(in, false);
@ -67,17 +71,21 @@ public interface DecreeParameterHandler<T> {
/**
* Should parse a String into the designated type. You can force it to not throw a whichexception
*
* @param in The string to parse
* @param force force an option instead of throwing decreewhich
* @param in
* The string to parse
* @param force
* force an option instead of throwing decreewhich
* @return The value extracted from the string, of the designated type
* @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
* @throws DecreeParsingException
* Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
*/
T parse(String in, boolean force) throws DecreeParsingException;
/**
* Returns whether a certain type is supported by this handler<br>
*
* @param type The type to check
* @param type
* The type to check
* @return True if supported, false if not
*/
boolean supports(Class<?> type);
@ -85,7 +93,8 @@ public interface DecreeParameterHandler<T> {
/**
* The possible entries for the inputted string (support for autocomplete on partial entries)
*
* @param input The inputted string to check against
* @param input
* The inputted string to check against
* @return A {@link KList} of possibilities
*/
default KList<T> getPossibilities(String input) {

View File

@ -113,7 +113,8 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
/**
* Get the handler for the specified type
*
* @param type The type to handle
* @param type
* The type to handle
* @return The corresponding {@link DecreeParameterHandler}, or null
*/
static DecreeParameterHandler<?> getHandler(Class<?> type) {
@ -128,8 +129,6 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
/**
* The root class to start command searching from
*
* @return
*/
VirtualDecreeCommand getRoot();

View File

@ -63,7 +63,8 @@ public @interface Decree {
DecreeOrigin origin() default DecreeOrigin.BOTH;
/**
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))<br>
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of
* method))<br>
* Can be initialized as just a string (ex. "alias") or as an array (ex. {"alias1", "alias2"})<br>
* If someone uses /plugin foo and you specify alias="f" here, /plugin f will do the exact same.
*/

View File

@ -53,7 +53,8 @@ public @interface Param {
String defaultValue() default "";
/**
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))<br>
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of
* method))<br>
* Can be initialized as just a string (ex. "alias") or as an array (ex. {"alias1", "alias2"})<br>
* If someone uses /plugin foo bar=baz and you specify alias="b" here, /plugin foo b=baz will do the exact same.
*/

View File

@ -21,8 +21,6 @@ package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.object.IrisCave;
import com.volmit.iris.engine.object.IrisJigsawPiece;
import com.volmit.iris.engine.object.IrisJigsawPool;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.decree.DecreeParameterHandler;
@ -65,7 +63,8 @@ public class CaveHandler implements DecreeParameterHandler<IrisCave> {
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Cave \"" + in + "\"");
}try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Cave\"" + in + "\"");

View File

@ -60,7 +60,8 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\"");
} try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");

View File

@ -58,7 +58,8 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
/**
* Converting the type back to a string (inverse of the {@link #parse(String) parse} method)
*
* @param entity The input of the designated type to convert to a String
* @param entity
* The input of the designated type to convert to a String
* @return The resulting string
*/
@Override
@ -69,9 +70,11 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
/**
* Should parse a String into the designated type
*
* @param in The string to parse
* @param in
* The string to parse
* @return The value extracted from the string, of the designated type
* @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
* @throws DecreeParsingException
* Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
*/
@Override
public IrisEntity parse(String in, boolean force) throws DecreeParsingException {
@ -79,7 +82,8 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Entity \"" + in + "\"");
} try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
@ -89,7 +93,8 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
/**
* Returns whether a certain type is supported by this handler<br>
*
* @param type The type to check
* @param type
* The type to check
* @return True if supported, false if not
*/
@Override

View File

@ -60,7 +60,8 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Generator \"" + in + "\"");
} try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");

View File

@ -63,7 +63,8 @@ public class JigsawPieceHandler implements DecreeParameterHandler<IrisJigsawPiec
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Jigsaw Piece \"" + in + "\"");
}try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Jigsaw Piece \"" + in + "\"");

View File

@ -20,7 +20,6 @@ package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.object.IrisJigsawPiece;
import com.volmit.iris.engine.object.IrisJigsawPool;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
@ -64,7 +63,8 @@ public class JigsawPoolHandler implements DecreeParameterHandler<IrisJigsawPool>
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Jigsaw Pool \"" + in + "\"");
}try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Jigsaw Pool \"" + in + "\"");

View File

@ -63,7 +63,8 @@ public class JigsawStructureHandler implements DecreeParameterHandler<IrisJigsaw
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Jigsaw Structure \"" + in + "\"");
} try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Jigsaw Structure \"" + in + "\"");

View File

@ -44,7 +44,8 @@ public class PlayerHandler implements DecreeParameterHandler<Player> {
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Player \"" + in + "\"");
} try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");

View File

@ -63,7 +63,8 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Region \"" + in + "\"");
} try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");

View File

@ -60,7 +60,8 @@ public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Script \"" + in + "\"");
} try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");

View File

@ -49,7 +49,8 @@ public class WorldHandler implements DecreeParameterHandler<World> {
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find World \"" + in + "\"");
} try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");

View File

@ -54,7 +54,8 @@ public class ObjectHandler implements DecreeParameterHandler<String> {
if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Object \"" + in + "\"");
} try {
}
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");

View File

@ -20,7 +20,6 @@ package com.volmit.iris.util.decree.virtual;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.CommandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
@ -28,7 +27,6 @@ import com.volmit.iris.util.decree.DecreeContext;
import com.volmit.iris.util.decree.DecreeContextHandler;
import com.volmit.iris.util.decree.DecreeNode;
import com.volmit.iris.util.decree.DecreeParameter;
import com.volmit.iris.util.decree.DecreeParameterHandler;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.format.C;
@ -38,17 +36,11 @@ import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import lombok.Data;
import org.bukkit.Sound;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
@Data
@ -289,8 +281,11 @@ public class VirtualDecreeCommand {
/**
* Maps the input a player typed to the parameters of this command
* @param sender The sender
* @param in The input
*
* @param sender
* The sender
* @param in
* The input
* @return A map of all the parameter names and their values
*/
private KMap<String, Object> map(VolmitSender sender, KList<String> in) {

View File

@ -426,7 +426,8 @@ public enum C {
/**
* Gets the color represented by the specified color code
*
* @param code Code to check
* @param code
* Code to check
* @return Associative {@link org.bukkit.ChatColor} with the given code, or null
* if it doesn't exist
*/
@ -443,7 +444,8 @@ public enum C {
/**
* Gets the color represented by the specified color code
*
* @param code Code to check
* @param code
* Code to check
* @return Associative {@link org.bukkit.ChatColor} with the given code, or null
* if it doesn't exist
*/
@ -462,7 +464,8 @@ public enum C {
/**
* Strips the given message of all color codes
*
* @param input String to strip of color
* @param input
* String to strip of color
* @return A copy of the input string, without any coloring
*/
public static String stripColor(final String input) {
@ -476,7 +479,8 @@ public enum C {
/**
* DyeColor to ChatColor
*
* @param dclr the dye color
* @param dclr
* the dye color
* @return the color
*/
public static C dyeToChat(DyeColor dclr) {
@ -576,8 +580,10 @@ public enum C {
* alternate color code character will only be replaced if it is immediately
* followed by 0-9, A-F, a-f, K-O, k-o, R or r.
*
* @param altColorChar The alternate color code character to replace. Ex: {@literal &}
* @param textToTranslate Text containing the alternate color code character.
* @param altColorChar
* The alternate color code character to replace. Ex: {@literal &}
* @param textToTranslate
* Text containing the alternate color code character.
* @return Text containing the ChatColor.COLOR_CODE color code character.
*/
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) {
@ -612,7 +618,8 @@ public enum C {
/**
* Gets the ChatColors used at the end of the given input string.
*
* @param input Input string to retrieve the colors from.
* @param input
* Input string to retrieve the colors from.
* @return Any remaining ChatColors to pass onto the next line.
*/
public static String getLastColors(String input) {

View File

@ -73,9 +73,12 @@ public class Form {
/**
* Scroll text
*
* @param smx the text
* @param viewport the viewport length
* @param time the timeline value
* @param smx
* the text
* @param viewport
* the viewport length
* @param time
* the timeline value
*/
public static String scroll(String smx, int viewport, long time) {
String src = Form.repeat(" ", viewport) + smx + Form.repeat(" ", viewport);
@ -90,7 +93,8 @@ public class Form {
/**
* Capitalize the first letter
*
* @param s the string
* @param s
* the string
* @return the capitalized string
*/
public static String capitalize(String s) {
@ -112,7 +116,8 @@ public class Form {
/**
* Capitalize all words in the string
*
* @param s the string
* @param s
* the string
* @return the capitalized string
*/
public static String capitalizeWords(String s) {
@ -128,8 +133,10 @@ public class Form {
/**
* Hard word wrap
*
* @param s the words
* @param len the length per line
* @param s
* the words
* @param len
* the length per line
* @return the wrapped string
*/
public static String wrap(String s, int len) {
@ -139,8 +146,10 @@ public class Form {
/**
* Soft Word wrap
*
* @param s the string
* @param len the length to wrap
* @param s
* the string
* @param len
* the length to wrap
* @return the wrapped string
*/
public static String wrapWords(String s, int len) {
@ -150,10 +159,14 @@ public class Form {
/**
* Wrap words
*
* @param s the string
* @param len the wrap length
* @param newLineSep the new line seperator
* @param soft should it be soft wrapped or hard wrapped?
* @param s
* the string
* @param len
* the wrap length
* @param newLineSep
* the new line seperator
* @param soft
* should it be soft wrapped or hard wrapped?
* @return the wrapped words
*/
public static String wrap(String s, int len, String newLineSep, boolean soft) {
@ -163,10 +176,8 @@ public class Form {
public static String hardWrap(String s, int len) {
StringBuilder ss = new StringBuilder();
for(int i = 0; i < s.length(); i+= len)
{
if(i + len > s.length())
{
for(int i = 0; i < s.length(); i += len) {
if(i + len > s.length()) {
ss.append(s, i, s.length());
break;
}
@ -179,10 +190,8 @@ public class Form {
public static List<String> hardWrapList(String s, int len) {
List<String> l = new ArrayList<>();
for(int i = 0; i < s.length(); i+= len)
{
if(i + len > s.length())
{
for(int i = 0; i < s.length(); i += len) {
if(i + len > s.length()) {
l.add(s.substring(i));
break;
}
@ -197,11 +206,16 @@ public class Form {
/**
* Wrap words
*
* @param s the string
* @param len the length
* @param newLineSep the new line seperator
* @param soft soft or hard wrapping
* @param regex the regex
* @param s
* the string
* @param len
* the length
* @param newLineSep
* the new line seperator
* @param soft
* soft or hard wrapping
* @param regex
* the regex
* @return the wrapped string
*/
public static String wrap(String s, int len, String newLineSep, boolean soft, String regex) {
@ -278,7 +292,8 @@ public class Form {
/**
* Returns a fancy duration up to Years
*
* @param duration the duration in ms
* @param duration
* the duration in ms
* @return the fancy duration
*/
public static String duration(RollingSequence rollingSequence, long duration) {
@ -345,7 +360,8 @@ public class Form {
/**
* Fixes the minute issue with formatting
*
* @param c the calendar
* @param c
* the calendar
* @return the minute string
*/
public static String fmin(Calendar c) {
@ -360,7 +376,8 @@ public class Form {
/**
* Get a fancy time stamp
*
* @param time the stamp in time (ago)
* @param time
* the stamp in time (ago)
* @return the fancy stamp in time (ago)
*/
public static String ago(long time) {
@ -473,7 +490,8 @@ public class Form {
/**
* Get the suffix for a number i.e. 1st 2nd 3rd
*
* @param i the number
* @param i
* the number
* @return the suffix
*/
public static String numberSuffix(int i) {
@ -488,8 +506,10 @@ public class Form {
* Get a high accuracy but limited range duration (accurate up to a couple
* minutes)
*
* @param ms the milliseconds (double)
* @param prec the precision (decimal format)
* @param ms
* the milliseconds (double)
* @param prec
* the precision (decimal format)
* @return the formatted string
*/
public static String duration(double ms, int prec) {
@ -523,8 +543,10 @@ public class Form {
/**
* Get a duration from milliseconds up to days
*
* @param ms the ms
* @param prec the precision (decimal format)
* @param ms
* the ms
* @param prec
* the precision (decimal format)
* @return the formatted string
*/
public static String duration(long ms, int prec) {
@ -554,7 +576,8 @@ public class Form {
/**
* Format a big value
*
* @param i the number
* @param i
* the number
* @return the full value in string
*/
public static String b(int i) {
@ -564,7 +587,8 @@ public class Form {
/**
* Format a big value
*
* @param i the number
* @param i
* the number
* @return the full value in string
*/
public static String b(long i) {
@ -574,7 +598,8 @@ public class Form {
/**
* Format a big value
*
* @param i the number
* @param i
* the number
* @return the full value in string
*/
public static String b(double i) {
@ -584,7 +609,8 @@ public class Form {
/**
* Format a big number
*
* @param number the big number
* @param number
* the big number
* @return the value in string
*/
public static String b(BigInteger number) {
@ -610,7 +636,8 @@ public class Form {
* Calculate a fancy string representation of a file size. Adds a suffix of B,
* KB, MB, GB, or TB
*
* @param s the size (in bytes)
* @param s
* the size (in bytes)
* @return the string
*/
public static String fileSize(long s) {
@ -620,8 +647,10 @@ public class Form {
/**
* ":", "a", "b", "c" -> a:b:c
*
* @param splitter the splitter that goes in between
* @param strings the strings
* @param splitter
* the splitter that goes in between
* @param strings
* the strings
* @return the result
*/
public static String split(String splitter, String... strings) {
@ -639,7 +668,8 @@ public class Form {
* Calculate a fancy string representation of a file size. Adds a suffix of B,
* KB, MB, GB, or TB
*
* @param s the size (in bytes)
* @param s
* the size (in bytes)
* @return the string
*/
public static String memSize(long s) {
@ -653,7 +683,8 @@ public class Form {
/**
* Get the timestamp of the time t (ms since 1970)
*
* @param t the time
* @param t
* the time
* @return the stamp
*/
@SuppressWarnings("deprecation")
@ -688,8 +719,10 @@ public class Form {
* with a special divisor. The divisor decides how much goes up in the suffix
* chain.
*
* @param s the size (in bytes)
* @param div the divisor
* @param s
* the size (in bytes)
* @param div
* the divisor
* @return the string
*/
public static String ofSize(long s, int div) {
@ -728,9 +761,12 @@ public class Form {
* with a special divisor. The divisor decides how much goes up in the suffix
* chain.
*
* @param s the size (in bytes)
* @param div the divisor
* @param dec the decimal places
* @param s
* the size (in bytes)
* @param div
* the divisor
* @param dec
* the decimal places
* @return the string
*/
public static String ofSize(long s, int div, int dec) {
@ -765,9 +801,12 @@ public class Form {
* with a special divisor. The divisor decides how much goes up in the suffix
* chain.
*
* @param s the size (in bytes)
* @param div the divisor
* @param dec the decimal places
* @param s
* the size (in bytes)
* @param div
* the divisor
* @param dec
* the decimal places
* @return the string
*/
public static String ofSizeMetricWeight(long s, int div, int dec) {
@ -804,8 +843,10 @@ public class Form {
/**
* Trim a string to a length, then append ... at the end if it extends the limit
*
* @param s the string
* @param l the limit
* @param s
* the string
* @param l
* the limit
* @return the modified string
*/
public static String trim(String s, int l) {
@ -820,7 +861,8 @@ public class Form {
* Get a class name into a configuration/filename key For example,
* PhantomController.class is converted to phantom-controller
*
* @param clazz the class
* @param clazz
* the class
* @return the string representation
*/
public static String cname(String clazz) {
@ -844,7 +886,8 @@ public class Form {
/**
* Get a formatted representation of the memory given in megabytes
*
* @param mb the megabytes
* @param mb
* the megabytes
* @return the string representation with suffixes
*/
public static String mem(long mb) {
@ -879,7 +922,8 @@ public class Form {
/**
* Format a long. Changes -10334 into -10,334
*
* @param i the number
* @param i
* the number
* @return the string representation of the number
*/
public static String f(long i) {
@ -890,7 +934,8 @@ public class Form {
/**
* Format a number. Changes -10334 into -10,334
*
* @param i the number
* @param i
* the number
* @return the string representation of the number
*/
public static String f(int i) {
@ -901,8 +946,10 @@ public class Form {
/**
* Formats a double's decimals to a limit
*
* @param i the double
* @param p the number of decimal places to use
* @param i
* the double
* @param p
* the number of decimal places to use
* @return the formated string
*/
public static String f(double i, int p) {
@ -922,8 +969,10 @@ public class Form {
* decimal places that dont need to be placed down. 2.4343 formatted with 6
* decimals gets returned as 2.434300
*
* @param i the double
* @param p the number of decimal places to use
* @param i
* the double
* @param p
* the number of decimal places to use
* @return the formated string
*/
public static String fd(double i, int p) {
@ -941,8 +990,10 @@ public class Form {
/**
* Formats a float's decimals to a limit
*
* @param i the float
* @param p the number of decimal places to use
* @param i
* the float
* @param p
* the number of decimal places to use
* @return the formated string
*/
public static String f(float i, int p) {
@ -960,7 +1011,8 @@ public class Form {
/**
* Formats a double's decimals (one decimal point)
*
* @param i the double
* @param i
* the double
*/
public static String f(double i) {
return f(i, 1);
@ -969,7 +1021,8 @@ public class Form {
/**
* Formats a float's decimals (one decimal point)
*
* @param i the float
* @param i
* the float
*/
public static String f(float i) {
return f(i, 1);
@ -979,8 +1032,10 @@ public class Form {
* Get a percent representation of a double and decimal places (0.53) would
* return 53%
*
* @param i the double
* @param p the number of decimal points
* @param i
* the double
* @param p
* the number of decimal points
* @return a string
*/
public static String pc(double i, int p) {
@ -991,8 +1046,10 @@ public class Form {
* Get a percent representation of a float and decimal places (0.53) would
* return 53%
*
* @param i the float
* @param p the number of decimal points
* @param i
* the float
* @param p
* the number of decimal points
* @return a string
*/
public static String pc(float i, int p) {
@ -1003,7 +1060,8 @@ public class Form {
* Get a percent representation of a double and zero decimal places (0.53) would
* return 53%
*
* @param i the double
* @param i
* the double
* @return a string
*/
public static String pc(double i) {
@ -1014,7 +1072,8 @@ public class Form {
* Get a percent representation of a float and zero decimal places (0.53) would
* return 53%
*
* @param i the double
* @param i
* the double
* @return a string
*/
public static String pc(float i) {
@ -1024,9 +1083,12 @@ public class Form {
/**
* Get a percent as the percent of i out of "of" with custom decimal places
*
* @param i the percent out of
* @param of of of
* @param p the decimal places
* @param i
* the percent out of
* @param of
* of of
* @param p
* the decimal places
* @return the string
*/
public static String pc(int i, int of, int p) {
@ -1036,8 +1098,10 @@ public class Form {
/**
* Get a percent as the percent of i out of "of"
*
* @param i the percent out of
* @param of of of
* @param i
* the percent out of
* @param of
* of of
* @return the string
*/
public static String pc(int i, int of) {
@ -1047,9 +1111,12 @@ public class Form {
/**
* Get a percent as the percent of i out of "of" with custom decimal places
*
* @param i the percent out of
* @param of of of
* @param p the decimal places
* @param i
* the percent out of
* @param of
* of of
* @param p
* the decimal places
* @return the string
*/
public static String pc(long i, long of, int p) {
@ -1059,8 +1126,10 @@ public class Form {
/**
* Get a percent as the percent of i out of "of"
*
* @param i the percent out of
* @param of of of
* @param i
* the percent out of
* @param of
* of of
* @return the string
*/
public static String pc(long i, long of) {
@ -1070,7 +1139,8 @@ public class Form {
/**
* Milliseconds to seconds (double)
*
* @param ms the milliseconds
* @param ms
* the milliseconds
* @return a formatted string to milliseconds
*/
public static String msSeconds(long ms) {
@ -1080,8 +1150,10 @@ public class Form {
/**
* Milliseconds to seconds (double) custom decimals
*
* @param ms the milliseconds
* @param p number of decimal points
* @param ms
* the milliseconds
* @param p
* number of decimal points
* @return a formatted string to milliseconds
*/
public static String msSeconds(long ms, int p) {
@ -1100,7 +1172,8 @@ public class Form {
/**
* nanoseconds to seconds (double) custom decimals
*
* @param p number of decimal points
* @param p
* number of decimal points
* @return a formatted string to nanoseconds
*/
public static String nsMs(long ns, int p) {
@ -1110,7 +1183,8 @@ public class Form {
/**
* nanoseconds to seconds (double) custom decimals
*
* @param p number of decimal points
* @param p
* number of decimal points
* @return a formatted string to nanoseconds
*/
public static String nsMsd(long ns, int p) {
@ -1120,7 +1194,8 @@ public class Form {
/**
* Get roman numeral representation of the int
*
* @param num the int
* @param num
* the int
* @return the numerals
*/
public static String toRoman(int num) {
@ -1155,7 +1230,8 @@ public class Form {
/**
* Get the number representation from roman numerals.
*
* @param number the roman number
* @param number
* the roman number
* @return the int representation
*/
public static int fromRoman(String number) {
@ -1223,8 +1299,10 @@ public class Form {
/**
* Repeat a string
*
* @param s the string
* @param n the amount of times to repeat
* @param s
* the string
* @param n
* the amount of times to repeat
* @return the repeated string
*/
@SuppressWarnings("StringRepeatCanBeUsed")

View File

@ -78,8 +78,10 @@ public interface Hunk<T> {
* Create a hunk view from a source hunk. This view reads and writes through to
* the source hunk. Its is not a copy.
*
* @param <T> the type
* @param src the source hunk
* @param <T>
* the type
* @param src
* the source hunk
* @return the hunk view
*/
static <T> Hunk<T> view(Hunk<T> src) {
@ -98,8 +100,8 @@ public interface Hunk<T> {
return new FunctionalHunkView<A, B>(src, reader, writer);
}
static Hunk<Biome> view(BiomeGrid biome) {
return new BiomeGridHunkView(biome);
static Hunk<Biome> view(BiomeGrid biome, int minHeight, int maxHeight) {
return new BiomeGridHunkView(biome, minHeight, maxHeight);
}
static <T> Hunk<T> fringe(Hunk<T> i, Hunk<T> o) {
@ -197,9 +199,12 @@ public interface Hunk<T> {
/**
* Creates a new bounding hunk from the given hunks
*
* @param <T> the type
* @param factory the factory that creates a hunk
* @param hunks the hunks
* @param <T>
* the type
* @param factory
* the factory that creates a hunk
* @param hunks
* the hunks
* @return the new bounding hunk
*/
@SafeVarargs
@ -291,13 +296,20 @@ public interface Hunk<T> {
/**
* Create a hunk that is optimized for specific uses
*
* @param w width
* @param h height
* @param d depth
* @param type the class type
* @param packed if the hunk is generally more than 50% full (non-null nodes)
* @param concurrent if this hunk must be thread safe
* @param <T> the type
* @param w
* width
* @param h
* height
* @param d
* depth
* @param type
* the class type
* @param packed
* if the hunk is generally more than 50% full (non-null nodes)
* @param concurrent
* if this hunk must be thread safe
* @param <T>
* the type
* @return the hunk
*/
static <T> Hunk<T> newHunk(int w, int h, int d, Class<T> type, boolean packed, boolean concurrent) {
@ -556,8 +568,10 @@ public interface Hunk<T> {
* hunk.set(hunkX, ?, hunkZ, noise(actualBlockX, ?, actualBlockZ));<br>
* }<br>
*
* @param p the predicate
* @param c the consumer
* @param p
* the predicate
* @param c
* the consumer
* @return this
*/
default Hunk<T> iterateSurfaces2D(Predicate<T> p, Consumer8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Hunk<T>> c) {
@ -618,9 +632,12 @@ public interface Hunk<T> {
* hunk.set(hunkX, ?, hunkZ, noise(actualBlockX, ?, actualBlockZ));<br>
* }<br>
*
* @param parallelism the ideal threads to use on this
* @param p the predicate
* @param c the consumer
* @param parallelism
* the ideal threads to use on this
* @param p
* the predicate
* @param c
* the consumer
* @return this
*/
default Hunk<T> iterateSurfaces2D(int parallelism, Predicate<T> p, Consumer8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Hunk<T>> c) {
@ -657,7 +674,8 @@ public interface Hunk<T> {
* <p>
* hunk.set(ax, ?, az, NOISE.get(ax+hx, az+hz));
*
* @param c the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ.
* @param c
* the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ.
* @return this
*/
default Hunk<T> iterate2DTop(Consumer5<Integer, Integer, Integer, Integer, Hunk<T>> c) {
@ -675,8 +693,10 @@ public interface Hunk<T> {
* <p>
* hunk.set(ax, ?, az, NOISE.get(ax+hx, az+hz));
*
* @param parallelism the target parallelism value or 0 to disable
* @param c the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ.
* @param parallelism
* the target parallelism value or 0 to disable
* @param c
* the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ.
* @return this
*/
default Hunk<T> iterate2DTop(int parallelism, Consumer5<Integer, Integer, Integer, Integer, Hunk<T>> c) {
@ -1037,12 +1057,18 @@ public interface Hunk<T> {
/**
* Create a new hunk from a section of this hunk.
*
* @param x1 The min x (inclusive)
* @param y1 The min y (inclusive)
* @param z1 The min z (inclusive)
* @param x2 The max x (exclusive)
* @param y2 The max y (exclusive)
* @param z2 The max z (exclusive)
* @param x1
* The min x (inclusive)
* @param y1
* The min y (inclusive)
* @param z1
* The min z (inclusive)
* @param x2
* The max x (exclusive)
* @param y2
* The max y (exclusive)
* @param z2
* The max z (exclusive)
* @return the new hunk (x2-x1, y2-y1, z2-z1)
*/
default ArrayHunk<T> crop(int x1, int y1, int z1, int x2, int y2, int z2) {
@ -1063,12 +1089,18 @@ public interface Hunk<T> {
* Create a new view of this same hunk from a section of this hunk.
* Modifications are routed to this hunk!
*
* @param x1 The min x (inclusive)
* @param y1 The min y (inclusive)
* @param z1 The min z (inclusive)
* @param x2 The max x (exclusive)
* @param y2 The max y (exclusive)
* @param z2 The max z (exclusive)
* @param x1
* The min x (inclusive)
* @param y1
* The min y (inclusive)
* @param z1
* The min z (inclusive)
* @param x2
* The max x (exclusive)
* @param y2
* The max y (exclusive)
* @param z2
* The max z (exclusive)
* @return the cropped view of this hunk (x2-x1, y2-y1, z2-z1)
*/
default Hunk<T> croppedView(int x1, int y1, int z1, int x2, int y2, int z2) {
@ -1093,13 +1125,20 @@ public interface Hunk<T> {
/**
* Set a region
*
* @param x1 inclusive 1st x
* @param y1 inclusive 1st y
* @param z1 inclusive 1st z
* @param x2 inclusive 2nd x
* @param y2 inclusive 2nd y
* @param z2 inclusive 2nd z
* @param t the value to set
* @param x1
* inclusive 1st x
* @param y1
* inclusive 1st y
* @param z1
* inclusive 1st z
* @param x2
* inclusive 2nd x
* @param y2
* inclusive 2nd y
* @param z2
* inclusive 2nd z
* @param t
* the value to set
*/
default void set(int x1, int y1, int z1, int x2, int y2, int z2, T t) {
for(int i = x1; i <= x2; i++) {
@ -1114,9 +1153,12 @@ public interface Hunk<T> {
/**
* Get the value to the closest valid position
*
* @param x the x
* @param y the y
* @param z the z
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @return the value closest to the border of the hunk
*/
default T getClosest(int x, int y, int z) {
@ -1146,7 +1188,8 @@ public interface Hunk<T> {
/**
* Get a 1 node thick hunk representing the face of this hunk
*
* @param f the face
* @param f
* the face
* @return the hunk view of this hunk
*/
default Hunk<T> viewFace(HunkFace f) {
@ -1173,7 +1216,8 @@ public interface Hunk<T> {
/**
* Crop (copy) a 1 node thick hunk representing the face of this hunk
*
* @param f the face
* @param f
* the face
* @return the hunk copy (face) of this hunk
*/
default Hunk<T> cropFace(HunkFace f) {
@ -1200,10 +1244,14 @@ public interface Hunk<T> {
/**
* Set a value at the given position
*
* @param x the x
* @param y the y
* @param z the z
* @param t the value
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @param t
* the value
*/
default void set(int x, int y, int z, T t) {
setRaw(x, y, z, t);
@ -1232,19 +1280,26 @@ public interface Hunk<T> {
/**
* Set a value at the given position without checking coordinate bounds
*
* @param x the x
* @param y the y
* @param z the z
* @param t the value
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @param t
* the value
*/
void setRaw(int x, int y, int z, T t);
/**
* Get a value at the given position without checking coordinate bounds
*
* @param x the x
* @param y the y
* @param z the z
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @return the value or null
*/
T getRaw(int x, int y, int z);
@ -1252,9 +1307,12 @@ public interface Hunk<T> {
/**
* Get a value at the given position
*
* @param x the x
* @param y the y
* @param z the z
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @return the value or null
*/
default T get(int x, int y, int z) {
@ -1274,10 +1332,14 @@ public interface Hunk<T> {
/**
* Insert a hunk into this one with an offset the inserted hunk
*
* @param offX the offset from zero for x
* @param offY the offset from zero for y
* @param offZ the offset from zero for z
* @param hunk the hunk to insert
* @param offX
* the offset from zero for x
* @param offY
* the offset from zero for y
* @param offZ
* the offset from zero for z
* @param hunk
* the hunk to insert
*/
default void insert(int offX, int offY, int offZ, Hunk<T> hunk) {
insert(offX, offY, offZ, hunk, false);
@ -1290,7 +1352,8 @@ public interface Hunk<T> {
/**
* Insert a hunk into this one
*
* @param hunk the hunk to insert
* @param hunk
* the hunk to insert
*/
default void insert(Hunk<T> hunk) {
insert(0, 0, 0, hunk, false);
@ -1310,8 +1373,10 @@ public interface Hunk<T> {
/**
* Insert a hunk into this one
*
* @param hunk the hunk to insert
* @param inverted invert the inserted hunk or not
* @param hunk
* the hunk to insert
* @param inverted
* invert the inserted hunk or not
*/
default void insert(Hunk<T> hunk, boolean inverted) {
insert(0, 0, 0, hunk, inverted);
@ -1321,11 +1386,16 @@ public interface Hunk<T> {
* Insert a hunk into this one with an offset and possibly inverting the y of
* the inserted hunk
*
* @param offX the offset from zero for x
* @param offY the offset from zero for y
* @param offZ the offset from zero for z
* @param hunk the hunk to insert
* @param invertY should the inserted hunk be inverted
* @param offX
* the offset from zero for x
* @param offY
* the offset from zero for y
* @param offZ
* the offset from zero for z
* @param hunk
* the hunk to insert
* @param invertY
* should the inserted hunk be inverted
*/
default void insert(int offX, int offY, int offZ, Hunk<T> hunk, boolean invertY) {
for(int i = offX; i < offX + hunk.getWidth(); i++) {
@ -1338,14 +1408,20 @@ public interface Hunk<T> {
}
/**
* Insert a hunk into this one with an offset and possibly inverting the y of. Will never insert a node if its already used
* Insert a hunk into this one with an offset and possibly inverting the y of. Will never insert a node if its
* already used
* the inserted hunk
*
* @param offX the offset from zero for x
* @param offY the offset from zero for y
* @param offZ the offset from zero for z
* @param hunk the hunk to insert
* @param invertY should the inserted hunk be inverted
* @param offX
* the offset from zero for x
* @param offY
* the offset from zero for y
* @param offZ
* the offset from zero for z
* @param hunk
* the hunk to insert
* @param invertY
* should the inserted hunk be inverted
*/
default void insertSoftly(int offX, int offY, int offZ, Hunk<T> hunk, boolean invertY, Predicate<T> shouldOverwrite) {
for(int i = offX; i < offX + hunk.getWidth(); i++) {
@ -1362,7 +1438,8 @@ public interface Hunk<T> {
/**
* Acts like fill, however if used by a mapped hunk, will simply clear it
*
* @param b the data to use for fill
* @param b
* the data to use for fill
*/
default void empty(T b) {
fill(b);
@ -1371,9 +1448,12 @@ public interface Hunk<T> {
/**
* Take a hunk and scale it up using interpolation
*
* @param scale the scale
* @param d the interpolation method
* @param interpolated the interpolated value converter
* @param scale
* the scale
* @param d
* the interpolation method
* @param interpolated
* the interpolated value converter
* @return the new hunk
*/
default Hunk<T> interpolate3D(double scale, InterpolationMethod3D d, Interpolated<T> interpolated) {
@ -1398,9 +1478,12 @@ public interface Hunk<T> {
* Take a hunk and scale it up using interpolation
* 2D, (using only x and z) assumes the height is 1
*
* @param scale the scale
* @param d the interpolation method
* @param interpolated the interpolated value converter
* @param scale
* the scale
* @param d
* the interpolation method
* @param interpolated
* the interpolated value converter
* @return the new hunk
*/
default Hunk<T> interpolate2D(double scale, InterpolationMethod d, Interpolated<T> interpolated) {

View File

@ -18,7 +18,6 @@
package com.volmit.iris.util.hunk.bits;
import com.volmit.iris.Iris;
import com.volmit.iris.util.data.Varint;
import org.apache.commons.lang3.Validate;

View File

@ -18,7 +18,6 @@
package com.volmit.iris.util.hunk.bits;
import com.volmit.iris.Iris;
import com.volmit.iris.util.data.Varint;
import java.io.ByteArrayOutputStream;
@ -56,8 +55,7 @@ public class DataContainer<T> {
this.bits = new AtomicInteger(palette.get().bits());
}
public static String readBitString(DataInputStream din) throws IOException
{
public static String readBitString(DataInputStream din) throws IOException {
DataContainer<Character> c = new DataContainer<>(din, new Writable<Character>() {
@Override
public Character readNodeData(DataInputStream din) throws IOException {
@ -72,8 +70,7 @@ public class DataContainer<T> {
StringBuilder sb = new StringBuilder();
for(int i = c.size()-1; i >= 0; i--)
{
for(int i = c.size() - 1; i >= 0; i--) {
sb.setCharAt(i, c.get(i));
}
@ -93,21 +90,18 @@ public class DataContainer<T> {
}
}, s.length());
for(int i = 0; i < s.length(); i++)
{
for(int i = 0; i < s.length(); i++) {
c.set(i, s.charAt(i));
}
c.writeDos(dos);
}
public DataBits getData()
{
public DataBits getData() {
return data.get();
}
public Palette<T> getPalette()
{
public Palette<T> getPalette() {
return palette.get();
}
@ -156,8 +150,7 @@ public class DataContainer<T> {
}
public void set(int position, T t) {
synchronized (this)
{
synchronized(this) {
int id = palette.get().id(t);
if(id == -1) {
@ -176,8 +169,7 @@ public class DataContainer<T> {
}
public T get(int position) {
synchronized (this)
{
synchronized(this) {
int id = data.get().get(position) + 1;
if(id <= 0) {

View File

@ -59,8 +59,7 @@ public class HashPalette<T> implements Palette<T> {
@Override
public int id(T t) {
if(t == null)
{
if(t == null) {
return 0;
}
@ -76,8 +75,7 @@ public class HashPalette<T> implements Palette<T> {
@Override
public void iterate(Consumer2<T, Integer> c) {
for(T i : palette.keySet()) {
if(i == null)
{
if(i == null) {
continue;
}

View File

@ -18,9 +18,7 @@
package com.volmit.iris.util.hunk.bits;
import com.volmit.iris.Iris;
import com.volmit.iris.util.function.Consumer2;
import org.bukkit.block.data.BlockData;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@ -67,8 +65,7 @@ public class LinearPalette<T> implements Palette<T> {
@Override
public int id(T t) {
if(t == null)
{
if(t == null) {
return 0;
}

View File

@ -22,31 +22,23 @@ import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.slices.BlockMatter;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Set;
public class TecTest {
public static Set<BlockData> randomBlocks(int max)
{
public static Set<BlockData> randomBlocks(int max) {
KSet<BlockData> d = new KSet<>();
while(d.size() < max)
{
while(d.size() < max) {
Material m = Material.values()[RNG.r.i(Material.values().length - 1)];
if(m.isBlock())
{
if(m.isBlock()) {
d.add(m.createBlockData());
}
}
@ -54,23 +46,19 @@ public class TecTest {
return d;
}
public static void go()
{
public static void go() {
}
public static boolean test(int size, int pal)
{
try
{
public static boolean test(int size, int pal) {
try {
Iris.info("Test? " + size + " " + pal);
KList<BlockData> blocks = new KList<>(randomBlocks(pal));
Iris.info("Fill " + pal + " -> " + size + " Entries");
Writable<BlockData> writer = new BlockMatter();
DataContainer<BlockData> dc = new DataContainer<>(writer, size);
for(int i = 0; i < dc.size(); i++)
{
for(int i = 0; i < dc.size(); i++) {
dc.set(i, blocks.getRandom());
}
@ -84,13 +72,9 @@ public class TecTest {
if(Arrays.equals(dat, dat2)) {
Iris.info("MATCH");
return true;
}
else
{
for(int i = 0; i < dc.size(); i++)
{
if(!dx.get(i).equals(dc.get(i)))
{
} else {
for(int i = 0; i < dc.size(); i++) {
if(!dx.get(i).equals(dc.get(i))) {
Iris.info("FAIL Expected " + dc.get(i).getAsString(true) + " but got " + dx.get(i).getAsString(true));
return false;
}
@ -99,10 +83,7 @@ public class TecTest {
return true;
}
}
catch(Throwable e)
{
} catch(Throwable e) {
e.printStackTrace();
return false;
}

View File

@ -27,7 +27,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantLock;
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
@Data

View File

@ -29,9 +29,13 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid;
public class BiomeGridHunkView implements Hunk<Biome> {
@Getter
private final BiomeGrid chunk;
private final int minHeight;
private final int maxHeight;
public BiomeGridHunkView(BiomeGrid chunk) {
public BiomeGridHunkView(BiomeGrid chunk, int minHeight, int maxHeight) {
this.chunk = chunk;
this.minHeight = minHeight;
this.maxHeight = maxHeight;
}
@Override
@ -46,25 +50,24 @@ public class BiomeGridHunkView implements Hunk<Biome> {
@Override
public int getHeight() {
// TODO: WARNING HEIGHT
return 256;
return maxHeight - minHeight;
}
@Override
public void setRaw(int x, int y, int z, Biome t) {
chunk.setBiome(x, y, z, t);
chunk.setBiome(x, y + minHeight, z, t);
}
@Override
public Biome getRaw(int x, int y, int z) {
return chunk.getBiome(x, y, z);
return chunk.getBiome(x, y + minHeight, z);
}
public void forceBiomeBaseInto(int x, int y, int z, Object somethingVeryDirty) {
if(chunk instanceof LinkedTerrainChunk) {
INMS.get().forceBiomeInto(x, y, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome());
INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome());
return;
}
INMS.get().forceBiomeInto(x, y, z, somethingVeryDirty, chunk);
INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, chunk);
}
}

View File

@ -42,7 +42,7 @@ public class ChunkDataHunkView implements Hunk<BlockData> {
@Override
public int getHeight() {
return chunk.getMaxHeight();
return chunk.getMaxHeight() - chunk.getMinHeight();
}
@Override
@ -51,7 +51,7 @@ public class ChunkDataHunkView implements Hunk<BlockData> {
return;
}
chunk.setRegion(x1, y1, z1, x2, y2, z2, t);
chunk.setRegion(x1, y1 + chunk.getMinHeight(), z1, x2, y2 + chunk.getMinHeight(), z2, t);
}
@Override
@ -60,11 +60,11 @@ public class ChunkDataHunkView implements Hunk<BlockData> {
return;
}
chunk.setBlock(x, y, z, t);
chunk.setBlock(x, y + chunk.getMinHeight(), z, t);
}
@Override
public BlockData getRaw(int x, int y, int z) {
return chunk.getBlockData(x, y, z);
return chunk.getBlockData(x, y + chunk.getMinHeight(), z);
}
}

View File

@ -921,17 +921,28 @@ public class IrisInterpolation {
/**
* Get the interpolated 3D noise within a given cuboid size with offsets
*
* @param method the interpolation method to use
* @param xo the x offset for noise
* @param yo the y offset for noise
* @param zo the z offset for noise
* @param w the width of the result
* @param h the height of the result
* @param d the depth of the result
* @param radX the interpolation radius for the x axis
* @param radY the interpolation radius for the y axis
* @param radZ the interpolation radius for the z axis
* @param n the noise provider
* @param method
* the interpolation method to use
* @param xo
* the x offset for noise
* @param yo
* the y offset for noise
* @param zo
* the z offset for noise
* @param w
* the width of the result
* @param h
* the height of the result
* @param d
* the depth of the result
* @param radX
* the interpolation radius for the x axis
* @param radY
* the interpolation radius for the y axis
* @param radZ
* the interpolation radius for the z axis
* @param n
* the noise provider
* @return the resulting hunk of noise
*/
public static Hunk<Double> getNoise3D(InterpolationMethod3D method, int xo, int yo, int zo, int w, int h, int d, double radX, double radY, double radZ, NoiseProvider3 n) {

View File

@ -188,10 +188,13 @@ public class IO {
* Transfers the length of the buffer amount of data from the input stream to
* the output stream
*
* @param in the input
* @param out the output
* @param in
* the input
* @param out
* the output
* @return the actual transfered amount
* @throws IOException shit happens
* @throws IOException
* shit happens
*/
public static int transfer(InputStream in, OutputStream out, byte[] buffer) throws IOException {
int r = in.read(buffer);
@ -207,12 +210,17 @@ public class IO {
* Transfers the length of the buffer amount of data from the input stream to
* the output stream
*
* @param in the input
* @param out the output
* @param targetBuffer the buffer and size to use
* @param totalSize the total amount to transfer
* @param in
* the input
* @param out
* the output
* @param targetBuffer
* the buffer and size to use
* @param totalSize
* the total amount to transfer
* @return the actual transfered amount
* @throws IOException shit happens
* @throws IOException
* shit happens
*/
public static long transfer(InputStream in, OutputStream out, int targetBuffer, long totalSize) throws IOException {
long total = totalSize;
@ -237,10 +245,7 @@ public class IO {
* Fully move data from a finite inputstream to an output stream using a buffer
* size of 8192. This does NOT close streams.
*
* @param in
* @param out
* @return total size transfered
* @throws IOException
*/
public static long fillTransfer(InputStream in, OutputStream out) throws IOException {
return fullTransfer(in, out, 8192);
@ -260,11 +265,15 @@ public class IO {
* Fully move data from a finite inputstream to an output stream using a given
* buffer size. This does NOT close streams.
*
* @param in the input stream to read from
* @param out the output stream to writeNodeData to
* @param bufferSize the target buffer size
* @param in
* the input stream to read from
* @param out
* the output stream to writeNodeData to
* @param bufferSize
* the target buffer size
* @return total size transfered
* @throws IOException shit happens
* @throws IOException
* shit happens
*/
public static long fullTransfer(InputStream in, OutputStream out, int bufferSize) throws IOException {
long wrote = 0;
@ -282,7 +291,8 @@ public class IO {
/**
* Recursive delete (deleting folders)
*
* @param f the file to delete (and subfiles if folder)
* @param f
* the file to delete (and subfiles if folder)
*/
public static void delete(File f) {
if(f == null || !f.exists()) {
@ -433,8 +443,10 @@ public class IO {
* new file with size 0 or, if the file exists already, it is opened and closed
* without modifying it, but updating the file date and time.
*
* @param file the File to touch
* @throws IOException If an I/O problem occurs
* @param file
* the File to touch
* @throws IOException
* If an I/O problem occurs
*/
public static void touch(File file) throws IOException {
if(!file.exists()) {
@ -452,11 +464,16 @@ public class IO {
* does not exist. If the destination file exists, then this method will
* overwrite it.
*
* @param srcFile an existing file to copy, must not be null
* @param destFile the new file, must not be null
* @throws NullPointerException if source or destination is null
* @throws IOException if source or destination is invalid
* @throws IOException if an IO error occurs during copying
* @param srcFile
* an existing file to copy, must not be null
* @param destFile
* the new file, must not be null
* @throws NullPointerException
* if source or destination is null
* @throws IOException
* if source or destination is invalid
* @throws IOException
* if an IO error occurs during copying
*/
public static void copyFile(File srcFile, File destFile) throws IOException {
copyFile(srcFile, destFile, true);
@ -470,13 +487,19 @@ public class IO {
* does not exist. If the destination file exists, then this method will
* overwrite it.
*
* @param srcFile an existing file to copy, must not be null
* @param destFile the new file, must not be null
* @param preserveFileDate true if the file date of the copy should be the same as the
* @param srcFile
* an existing file to copy, must not be null
* @param destFile
* the new file, must not be null
* @param preserveFileDate
* true if the file date of the copy should be the same as the
* original
* @throws NullPointerException if source or destination is null
* @throws IOException if source or destination is invalid
* @throws IOException if an IO error occurs during copying
* @throws NullPointerException
* if source or destination is null
* @throws IOException
* if source or destination is invalid
* @throws IOException
* if an IO error occurs during copying
*/
public static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
if(srcFile == null) {
@ -510,10 +533,14 @@ public class IO {
/**
* Internal copy file method.
*
* @param srcFile the validated source file, not null
* @param destFile the validated destination file, not null
* @param preserveFileDate whether to preserve the file date
* @throws IOException if an error occurs
* @param srcFile
* the validated source file, not null
* @param destFile
* the validated destination file, not null
* @param preserveFileDate
* whether to preserve the file date
* @throws IOException
* if an error occurs
*/
private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
if(destFile.exists() && destFile.isDirectory()) {
@ -546,7 +573,8 @@ public class IO {
* Equivalent to {@link Reader#close()}, except any exceptions will be ignored.
* This is typically used in finally blocks.
*
* @param input the Reader to close, may be null or already closed
* @param input
* the Reader to close, may be null or already closed
*/
public static void closeQuietly(Reader input) {
try {
@ -565,7 +593,8 @@ public class IO {
* Equivalent to {@link Writer#close()}, except any exceptions will be ignored.
* This is typically used in finally blocks.
*
* @param output the Writer to close, may be null or already closed
* @param output
* the Writer to close, may be null or already closed
*/
public static void closeQuietly(Writer output) {
try {
@ -584,7 +613,8 @@ public class IO {
* Equivalent to {@link InputStream#close()}, except any exceptions will be
* ignored. This is typically used in finally blocks.
*
* @param input the InputStream to close, may be null or already closed
* @param input
* the InputStream to close, may be null or already closed
*/
public static void closeQuietly(InputStream input) {
try {
@ -606,7 +636,8 @@ public class IO {
* Equivalent to {@link OutputStream#close()}, except any exceptions will be
* ignored. This is typically used in finally blocks.
*
* @param output the OutputStream to close, may be null or already closed
* @param output
* the OutputStream to close, may be null or already closed
*/
public static void closeQuietly(OutputStream output) {
try {
@ -625,10 +656,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param input the <code>InputStream</code> to read from
* @param input
* the <code>InputStream</code> to read from
* @return the requested byte array
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
*/
public static byte[] toByteArray(InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
@ -643,10 +677,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>.
*
* @param input the <code>Reader</code> to read from
* @param input
* the <code>Reader</code> to read from
* @return the requested byte array
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
*/
public static byte[] toByteArray(Reader input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
@ -664,11 +701,15 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>.
*
* @param input the <code>Reader</code> to read from
* @param encoding the encoding to use, null means platform default
* @param input
* the <code>Reader</code> to read from
* @param encoding
* the encoding to use, null means platform default
* @return the requested byte array
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static byte[] toByteArray(Reader input, String encoding) throws IOException {
@ -686,7 +727,8 @@ public class IO {
* <p>
* This is the same as {@link String#getBytes()}.
*
* @param input the <code>String</code> to convert
* @param input
* the <code>String</code> to convert
* @return the requested byte array
* @deprecated Use {@link String#getBytes()}
*/
@ -702,10 +744,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param is the <code>InputStream</code> to read from
* @param is
* the <code>InputStream</code> to read from
* @return the requested character array
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static char[] toCharArray(InputStream is) throws IOException {
@ -724,11 +769,15 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param is the <code>InputStream</code> to read from
* @param encoding the encoding to use, null means platform default
* @param is
* the <code>InputStream</code> to read from
* @param encoding
* the encoding to use, null means platform default
* @return the requested character array
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static char[] toCharArray(InputStream is, String encoding) throws IOException {
@ -746,10 +795,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>.
*
* @param input the <code>Reader</code> to read from
* @param input
* the <code>Reader</code> to read from
* @return the requested character array
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static char[] toCharArray(Reader input) throws IOException {
@ -765,10 +817,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param input the <code>InputStream</code> to read from
* @param input
* the <code>InputStream</code> to read from
* @return the requested String
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
*/
public static String toString(InputStream input) throws IOException {
StringWriter sw = new StringWriter();
@ -786,11 +841,15 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param input the <code>InputStream</code> to read from
* @param encoding the encoding to use, null means platform default
* @param input
* the <code>InputStream</code> to read from
* @param encoding
* the encoding to use, null means platform default
* @return the requested String
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
*/
public static String toString(InputStream input, String encoding) throws IOException {
StringWriter sw = new StringWriter();
@ -804,10 +863,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>.
*
* @param input the <code>Reader</code> to read from
* @param input
* the <code>Reader</code> to read from
* @return the requested String
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
*/
public static String toString(Reader input) throws IOException {
StringWriter sw = new StringWriter();
@ -819,7 +881,8 @@ public class IO {
* Get the contents of a <code>byte[]</code> as a String using the default
* character encoding of the platform.
*
* @param input the byte array to read from
* @param input
* the byte array to read from
* @return the requested String
* @deprecated Use {@link String#String(byte[])}
*/
@ -838,11 +901,15 @@ public class IO {
* Character encoding names can be found at
* <a href="http://www.iana.org/assignments/character-sets">IANA</a>.
*
* @param input the byte array to read from
* @param encoding the encoding to use, null means platform default
* @param input
* the byte array to read from
* @param encoding
* the encoding to use, null means platform default
* @return the requested String
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs (never occurs)
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs (never occurs)
* @deprecated Use {@link String#String(byte[], String)}
*/
@Deprecated
@ -861,10 +928,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param input the <code>InputStream</code> to read from, not null
* @param input
* the <code>InputStream</code> to read from, not null
* @return the list of Strings, never null
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static List<String> readLines(InputStream input) throws IOException {
@ -882,11 +952,15 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param input the <code>InputStream</code> to read from, not null
* @param encoding the encoding to use, null means platform default
* @param input
* the <code>InputStream</code> to read from, not null
* @param encoding
* the encoding to use, null means platform default
* @return the list of Strings, never null
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static List<String> readLines(InputStream input, String encoding) throws IOException {
@ -907,10 +981,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>.
*
* @param input the <code>Reader</code> to read from, not null
* @param input
* the <code>Reader</code> to read from, not null
* @return the list of Strings, never null
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static List<String> readLines(Reader input) throws IOException {
@ -928,7 +1005,8 @@ public class IO {
* Convert the specified string to an input stream, encoded as bytes using the
* default character encoding of the platform.
*
* @param input the string to convert
* @param input
* the string to convert
* @return an input stream
* @since Commons IO 1.1
*/
@ -947,10 +1025,13 @@ public class IO {
* Character encoding names can be found at
* <a href="http://www.iana.org/assignments/character-sets">IANA</a>.
*
* @param input the string to convert
* @param encoding the encoding to use, null means platform default
* @param input
* the string to convert
* @param encoding
* the encoding to use, null means platform default
* @return an input stream
* @throws IOException if the encoding is invalid
* @throws IOException
* if the encoding is invalid
* @since Commons IO 1.1
*/
public static InputStream toInputStream(String input, String encoding) throws IOException {
@ -961,10 +1042,14 @@ public class IO {
/**
* Writes bytes from a <code>byte[]</code> to an <code>OutputStream</code>.
*
* @param data the byte array to writeNodeData, do not modify during output, null ignored
* @param output the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the byte array to writeNodeData, do not modify during output, null ignored
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(byte[] data, OutputStream output) throws IOException {
@ -979,10 +1064,14 @@ public class IO {
* <p>
* This method uses {@link String#String(byte[])}.
*
* @param data the byte array to writeNodeData, do not modify during output, null ignored
* @param output the <code>Writer</code> to writeNodeData to
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the byte array to writeNodeData, do not modify during output, null ignored
* @param output
* the <code>Writer</code> to writeNodeData to
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(byte[] data, Writer output) throws IOException {
@ -1003,11 +1092,16 @@ public class IO {
* <p>
* This method uses {@link String#String(byte[], String)}.
*
* @param data the byte array to writeNodeData, do not modify during output, null ignored
* @param output the <code>Writer</code> to writeNodeData to
* @param encoding the encoding to use, null means platform default
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the byte array to writeNodeData, do not modify during output, null ignored
* @param output
* the <code>Writer</code> to writeNodeData to
* @param encoding
* the encoding to use, null means platform default
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(byte[] data, Writer output, String encoding) throws IOException {
@ -1024,10 +1118,14 @@ public class IO {
* Writes chars from a <code>char[]</code> to a <code>Writer</code> using the
* default character encoding of the platform.
*
* @param data the char array to writeNodeData, do not modify during output, null ignored
* @param output the <code>Writer</code> to writeNodeData to
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the char array to writeNodeData, do not modify during output, null ignored
* @param output
* the <code>Writer</code> to writeNodeData to
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(char[] data, Writer output) throws IOException {
@ -1042,10 +1140,14 @@ public class IO {
* <p>
* This method uses {@link String#String(char[])} and {@link String#getBytes()}.
*
* @param data the char array to writeNodeData, do not modify during output, null ignored
* @param output the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the char array to writeNodeData, do not modify during output, null ignored
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(char[] data, OutputStream output) throws IOException {
@ -1067,11 +1169,16 @@ public class IO {
* This method uses {@link String#String(char[])} and
* {@link String#getBytes(String)}.
*
* @param data the char array to writeNodeData, do not modify during output, null ignored
* @param output the <code>OutputStream</code> to writeNodeData to
* @param encoding the encoding to use, null means platform default
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the char array to writeNodeData, do not modify during output, null ignored
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @param encoding
* the encoding to use, null means platform default
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(char[] data, OutputStream output, String encoding) throws IOException {
@ -1087,10 +1194,14 @@ public class IO {
/**
* Writes chars from a <code>String</code> to a <code>Writer</code>.
*
* @param data the <code>String</code> to writeNodeData, null ignored
* @param output the <code>Writer</code> to writeNodeData to
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the <code>String</code> to writeNodeData, null ignored
* @param output
* the <code>Writer</code> to writeNodeData to
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(String data, Writer output) throws IOException {
@ -1106,10 +1217,14 @@ public class IO {
* <p>
* This method uses {@link String#getBytes()}.
*
* @param data the <code>String</code> to writeNodeData, null ignored
* @param output the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the <code>String</code> to writeNodeData, null ignored
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(String data, OutputStream output) throws IOException {
@ -1130,11 +1245,16 @@ public class IO {
* <p>
* This method uses {@link String#getBytes(String)}.
*
* @param data the <code>String</code> to writeNodeData, null ignored
* @param output the <code>OutputStream</code> to writeNodeData to
* @param encoding the encoding to use, null means platform default
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the <code>String</code> to writeNodeData, null ignored
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @param encoding
* the encoding to use, null means platform default
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(String data, OutputStream output, String encoding) throws IOException {
@ -1150,10 +1270,14 @@ public class IO {
/**
* Writes chars from a <code>StringBuffer</code> to a <code>Writer</code>.
*
* @param data the <code>StringBuffer</code> to writeNodeData, null ignored
* @param output the <code>Writer</code> to writeNodeData to
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the <code>StringBuffer</code> to writeNodeData, null ignored
* @param output
* the <code>Writer</code> to writeNodeData to
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(StringBuffer data, Writer output) throws IOException {
@ -1169,10 +1293,14 @@ public class IO {
* <p>
* This method uses {@link String#getBytes()}.
*
* @param data the <code>StringBuffer</code> to writeNodeData, null ignored
* @param output the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the <code>StringBuffer</code> to writeNodeData, null ignored
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(StringBuffer data, OutputStream output) throws IOException {
@ -1193,11 +1321,16 @@ public class IO {
* <p>
* This method uses {@link String#getBytes(String)}.
*
* @param data the <code>StringBuffer</code> to writeNodeData, null ignored
* @param output the <code>OutputStream</code> to writeNodeData to
* @param encoding the encoding to use, null means platform default
* @throws NullPointerException if output is null
* @throws IOException if an I/O error occurs
* @param data
* the <code>StringBuffer</code> to writeNodeData, null ignored
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @param encoding
* the encoding to use, null means platform default
* @throws NullPointerException
* if output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void write(StringBuffer data, OutputStream output, String encoding) throws IOException {
@ -1215,11 +1348,16 @@ public class IO {
* <code>OutputStream</code> line by line, using the default character encoding
* of the platform and the specified line ending.
*
* @param lines the lines to writeNodeData, null entries produce blank lines
* @param lineEnding the line separator to use, null is system default
* @param output the <code>OutputStream</code> to writeNodeData to, not null, not closed
* @throws NullPointerException if the output is null
* @throws IOException if an I/O error occurs
* @param lines
* the lines to writeNodeData, null entries produce blank lines
* @param lineEnding
* the line separator to use, null is system default
* @param output
* the <code>OutputStream</code> to writeNodeData to, not null, not closed
* @throws NullPointerException
* if the output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void writeLines(Collection<String> lines, String lineEnding, OutputStream output) throws IOException {
@ -1246,12 +1384,18 @@ public class IO {
* Character encoding names can be found at
* <a href="http://www.iana.org/assignments/character-sets">IANA</a>.
*
* @param lines the lines to writeNodeData, null entries produce blank lines
* @param lineEnding the line separator to use, null is system default
* @param output the <code>OutputStream</code> to writeNodeData to, not null, not closed
* @param encoding the encoding to use, null means platform default
* @throws NullPointerException if the output is null
* @throws IOException if an I/O error occurs
* @param lines
* the lines to writeNodeData, null entries produce blank lines
* @param lineEnding
* the line separator to use, null is system default
* @param output
* the <code>OutputStream</code> to writeNodeData to, not null, not closed
* @param encoding
* the encoding to use, null means platform default
* @throws NullPointerException
* if the output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void writeLines(Collection<String> lines, String lineEnding, OutputStream output, String encoding) throws IOException {
@ -1281,11 +1425,16 @@ public class IO {
* Writes the <code>toString()</code> value of each item in a collection to a
* <code>Writer</code> line by line, using the specified line ending.
*
* @param lines the lines to writeNodeData, null entries produce blank lines
* @param lineEnding the line separator to use, null is system default
* @param writer the <code>Writer</code> to writeNodeData to, not null, not closed
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @param lines
* the lines to writeNodeData, null entries produce blank lines
* @param lineEnding
* the line separator to use, null is system default
* @param writer
* the <code>Writer</code> to writeNodeData to, not null, not closed
* @throws NullPointerException
* if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void writeLines(Collection<String> lines, String lineEnding, Writer writer) throws IOException {
@ -1315,12 +1464,17 @@ public class IO {
* returned as an int. For large streams use the
* <code>copyLarge(InputStream, OutputStream)</code> method.
*
* @param input the <code>InputStream</code> to read from
* @param output the <code>OutputStream</code> to writeNodeData to
* @param input
* the <code>InputStream</code> to read from
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @return the number of bytes copied
* @throws NullPointerException if the input or output is null
* @throws IOException if an I/O error occurs
* @throws ArithmeticException if the byte count is too large
* @throws NullPointerException
* if the input or output is null
* @throws IOException
* if an I/O error occurs
* @throws ArithmeticException
* if the byte count is too large
* @since Commons IO 1.1
*/
public static int copy(InputStream input, OutputStream output) throws IOException {
@ -1338,11 +1492,15 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param input the <code>InputStream</code> to read from
* @param output the <code>OutputStream</code> to writeNodeData to
* @param input
* the <code>InputStream</code> to read from
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @return the number of bytes copied
* @throws NullPointerException if the input or output is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input or output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.3
*/
public static long copyLarge(InputStream input, OutputStream output) throws IOException {
@ -1365,10 +1523,14 @@ public class IO {
* <p>
* This method uses {@link InputStreamReader}.
*
* @param input the <code>InputStream</code> to read from
* @param output the <code>Writer</code> to writeNodeData to
* @throws NullPointerException if the input or output is null
* @throws IOException if an I/O error occurs
* @param input
* the <code>InputStream</code> to read from
* @param output
* the <code>Writer</code> to writeNodeData to
* @throws NullPointerException
* if the input or output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void copy(InputStream input, Writer output) throws IOException {
@ -1391,11 +1553,16 @@ public class IO {
* <p>
* This method uses {@link InputStreamReader}.
*
* @param input the <code>InputStream</code> to read from
* @param output the <code>Writer</code> to writeNodeData to
* @param encoding the encoding to use, null means platform default
* @throws NullPointerException if the input or output is null
* @throws IOException if an I/O error occurs
* @param input
* the <code>InputStream</code> to read from
* @param output
* the <code>Writer</code> to writeNodeData to
* @param encoding
* the encoding to use, null means platform default
* @throws NullPointerException
* if the input or output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void copy(InputStream input, Writer output, String encoding) throws IOException {
@ -1418,12 +1585,17 @@ public class IO {
* returned as an int. For large streams use the
* <code>copyLarge(Reader, Writer)</code> method.
*
* @param input the <code>Reader</code> to read from
* @param output the <code>Writer</code> to writeNodeData to
* @param input
* the <code>Reader</code> to read from
* @param output
* the <code>Writer</code> to writeNodeData to
* @return the number of characters copied
* @throws NullPointerException if the input or output is null
* @throws IOException if an I/O error occurs
* @throws ArithmeticException if the character count is too large
* @throws NullPointerException
* if the input or output is null
* @throws IOException
* if an I/O error occurs
* @throws ArithmeticException
* if the character count is too large
* @since Commons IO 1.1
*/
public static int copy(Reader input, Writer output) throws IOException {
@ -1441,11 +1613,15 @@ public class IO {
* This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>.
*
* @param input the <code>Reader</code> to read from
* @param output the <code>Writer</code> to writeNodeData to
* @param input
* the <code>Reader</code> to read from
* @param output
* the <code>Writer</code> to writeNodeData to
* @return the number of characters copied
* @throws NullPointerException if the input or output is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if the input or output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.3
*/
public static long copyLarge(Reader input, Writer output) throws IOException {
@ -1472,10 +1648,14 @@ public class IO {
* <p>
* This method uses {@link OutputStreamWriter}.
*
* @param input the <code>Reader</code> to read from
* @param output the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException if the input or output is null
* @throws IOException if an I/O error occurs
* @param input
* the <code>Reader</code> to read from
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @throws NullPointerException
* if the input or output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void copy(Reader input, OutputStream output) throws IOException {
@ -1504,11 +1684,16 @@ public class IO {
* <p>
* This method uses {@link OutputStreamWriter}.
*
* @param input the <code>Reader</code> to read from
* @param output the <code>OutputStream</code> to writeNodeData to
* @param encoding the encoding to use, null means platform default
* @throws NullPointerException if the input or output is null
* @throws IOException if an I/O error occurs
* @param input
* the <code>Reader</code> to read from
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @param encoding
* the encoding to use, null means platform default
* @throws NullPointerException
* if the input or output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static void copy(Reader input, OutputStream output, String encoding) throws IOException {
@ -1528,12 +1713,16 @@ public class IO {
* This method buffers the input internally using
* <code>BufferedInputStream</code> if they are not already buffered.
*
* @param input1 the first stream
* @param input2 the second stream
* @param input1
* the first stream
* @param input2
* the second stream
* @return true if the content of the streams are equal or they both don't
* exist, false otherwise
* @throws NullPointerException if either input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if either input is null
* @throws IOException
* if an I/O error occurs
*/
public static boolean contentEquals(InputStream input1, InputStream input2) throws IOException {
if(!(input1 instanceof BufferedInputStream)) {
@ -1562,12 +1751,16 @@ public class IO {
* This method buffers the input internally using <code>BufferedReader</code> if
* they are not already buffered.
*
* @param input1 the first reader
* @param input2 the second reader
* @param input1
* the first reader
* @param input2
* the second reader
* @return true if the content of the readers are equal or they both don't
* exist, false otherwise
* @throws NullPointerException if either input is null
* @throws IOException if an I/O error occurs
* @throws NullPointerException
* if either input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1
*/
public static boolean contentEquals(Reader input1, Reader input2) throws IOException {

View File

@ -35,7 +35,8 @@ public class JarScanner {
/**
* Create a scanner
*
* @param jar the path to the jar
* @param jar
* the path to the jar
*/
public JarScanner(File jar, String superPackage) {
this.jar = jar;
@ -46,7 +47,8 @@ public class JarScanner {
/**
* Scan the jar
*
* @throws IOException bad things happen
* @throws IOException
* bad things happen
*/
public void scan() throws IOException {
classes.clear();

View File

@ -78,7 +78,8 @@ public class HTTP {
* It does no further checking or conversion. It does not parse dates. It
* does not do '%' transforms on URLs.
*
* @param string An HTTP header string.
* @param string
* An HTTP header string.
* @return A JSONObject containing the elements and attributes of the XML
* string.
*/
@ -141,9 +142,11 @@ public class HTTP {
* Any other members of the JSONObject will be output as HTTP fields. The
* result will end with two CRLF pairs.
*
* @param jo A JSONObject
* @param jo
* A JSONObject
* @return An HTTP header string.
* @throws JSONException if the object does not contain enough information.
* @throws JSONException
* if the object does not contain enough information.
*/
public static String toString(JSONObject jo) throws JSONException {
Iterator<String> keys = jo.keys();

View File

@ -31,7 +31,8 @@ public class HTTPTokener extends JSONTokener {
/**
* Construct an HTTPTokener from a string.
*
* @param string A source string.
* @param string
* A source string.
*/
public HTTPTokener(String string) {
super(string);

View File

@ -94,8 +94,10 @@ public class JSONArray implements Iterable<Object> {
/**
* Construct a JSONArray from a JSONTokener.
*
* @param x A JSONTokener
* @throws JSONException If there is a syntax error.
* @param x
* A JSONTokener
* @throws JSONException
* If there is a syntax error.
*/
public JSONArray(JSONTokener x) throws JSONException {
this();
@ -131,10 +133,12 @@ public class JSONArray implements Iterable<Object> {
/**
* Construct a JSONArray from a source JSON text.
*
* @param source A string that begins with <code>[</code>&nbsp;<small>(left
* @param source
* A string that begins with <code>[</code>&nbsp;<small>(left
* bracket)</small> and ends with <code>]</code> &nbsp;
* <small>(right bracket)</small>.
* @throws JSONException If there is a syntax error.
* @throws JSONException
* If there is a syntax error.
*/
public JSONArray(String source) throws JSONException {
this(new JSONTokener(source));
@ -143,7 +147,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Construct a JSONArray from a Collection.
*
* @param collection A Collection.
* @param collection
* A Collection.
*/
public JSONArray(Collection<Object> collection) {
this.myArrayList = new ArrayList<Object>();
@ -158,7 +163,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Construct a JSONArray from an array
*
* @throws JSONException If not an array.
* @throws JSONException
* If not an array.
*/
public JSONArray(Object array) throws JSONException {
this();
@ -180,9 +186,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the object value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return An object value.
* @throws JSONException If there is no value for the index.
* @throws JSONException
* If there is no value for the index.
*/
public Object get(int index) throws JSONException {
Object object = this.opt(index);
@ -196,9 +204,11 @@ public class JSONArray implements Iterable<Object> {
* Get the boolean value associated with an index. The string values "true"
* and "false" are converted to boolean.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The truth.
* @throws JSONException If there is no value for the index or if the value is not
* @throws JSONException
* If there is no value for the index or if the value is not
* convertible to boolean.
*/
public boolean getBoolean(int index) throws JSONException {
@ -214,9 +224,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the double value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot be converted
* @throws JSONException
* If the key is not found or if the value cannot be converted
* to a number.
*/
public double getDouble(int index) throws JSONException {
@ -232,10 +244,13 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the enum value associated with an index.
*
* @param clazz The type of enum to retrieve.
* @param index The index must be between 0 and length() - 1.
* @param clazz
* The type of enum to retrieve.
* @param index
* The index must be between 0 and length() - 1.
* @return The enum value at the index location
* @throws JSONException if the key is not found or if the value cannot be converted
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to an enum.
*/
public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONException {
@ -252,9 +267,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the BigDecimal value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot be converted
* @throws JSONException
* If the key is not found or if the value cannot be converted
* to a BigDecimal.
*/
public BigDecimal getBigDecimal(int index) throws JSONException {
@ -270,9 +287,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the BigInteger value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot be converted
* @throws JSONException
* If the key is not found or if the value cannot be converted
* to a BigInteger.
*/
public BigInteger getBigInteger(int index) throws JSONException {
@ -288,9 +307,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the int value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value is not a number.
* @throws JSONException
* If the key is not found or if the value is not a number.
*/
public int getInt(int index) throws JSONException {
Object object = this.get(index);
@ -305,9 +326,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the JSONArray associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return A JSONArray value.
* @throws JSONException If there is no value for the index. or if the value is not a
* @throws JSONException
* If there is no value for the index. or if the value is not a
* JSONArray
*/
public JSONArray getJSONArray(int index) throws JSONException {
@ -321,9 +344,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the JSONObject associated with an index.
*
* @param index subscript
* @param index
* subscript
* @return A JSONObject value.
* @throws JSONException If there is no value for the index or if the value is not a
* @throws JSONException
* If there is no value for the index or if the value is not a
* JSONObject
*/
public JSONObject getJSONObject(int index) throws JSONException {
@ -337,9 +362,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the long value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot be converted
* @throws JSONException
* If the key is not found or if the value cannot be converted
* to a number.
*/
public long getLong(int index) throws JSONException {
@ -355,9 +382,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the string associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return A string value.
* @throws JSONException If there is no string value for the index.
* @throws JSONException
* If there is no string value for the index.
*/
public String getString(int index) throws JSONException {
Object object = this.get(index);
@ -370,7 +399,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Determine if the value is null.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return true if the value at the index is null, or if there is no value.
*/
public boolean isNull(int index) {
@ -382,9 +412,11 @@ public class JSONArray implements Iterable<Object> {
* <code>separator</code> string is inserted between each element. Warning:
* This method assumes that the data structure is acyclical.
*
* @param separator A string that will be inserted between the elements.
* @param separator
* A string that will be inserted between the elements.
* @return a string.
* @throws JSONException If the array contains an invalid number.
* @throws JSONException
* If the array contains an invalid number.
*/
public String join(String separator) throws JSONException {
int len = this.length();
@ -411,7 +443,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the optional object value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return An object value, or null if there is no object at that index.
*/
public Object opt(int index) {
@ -423,7 +456,8 @@ public class JSONArray implements Iterable<Object> {
* if there is no value at that index, or if the value is not Boolean.TRUE
* or the String "true".
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The truth.
*/
public boolean optBoolean(int index) {
@ -435,8 +469,10 @@ public class JSONArray implements Iterable<Object> {
* defaultValue if there is no value at that index or if it is not a Boolean
* or the String "true" or "false" (case insensitive).
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue A boolean default.
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* A boolean default.
* @return The truth.
*/
public boolean optBoolean(int index, boolean defaultValue) {
@ -453,7 +489,8 @@ public class JSONArray implements Iterable<Object> {
* if there is no value for the index, or if the value is not a number and
* cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The value.
*/
public double optDouble(int index) {
@ -465,8 +502,10 @@ public class JSONArray implements Iterable<Object> {
* is returned if there is no value for the index, or if the value is not a
* number and cannot be converted to a number.
*
* @param index subscript
* @param defaultValue The default value.
* @param index
* subscript
* @param defaultValue
* The default value.
* @return The value.
*/
public double optDouble(int index, double defaultValue) {
@ -483,7 +522,8 @@ public class JSONArray implements Iterable<Object> {
* there is no value for the index, or if the value is not a number and
* cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The value.
*/
public int optInt(int index) {
@ -495,8 +535,10 @@ public class JSONArray implements Iterable<Object> {
* returned if there is no value for the index, or if the value is not a
* number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value.
*/
public int optInt(int index, int defaultValue) {
@ -511,8 +553,10 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the enum value associated with a key.
*
* @param clazz The type of enum to retrieve.
* @param index The index must be between 0 and length() - 1.
* @param clazz
* The type of enum to retrieve.
* @param index
* The index must be between 0 and length() - 1.
* @return The enum value at the index location or null if not found
*/
public <E extends Enum<E>> E optEnum(Class<E> clazz, int index) {
@ -522,9 +566,12 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the enum value associated with a key.
*
* @param clazz The type of enum to retrieve.
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default in case the value is not found
* @param clazz
* The type of enum to retrieve.
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default in case the value is not found
* @return The enum value at the index location or defaultValue if the value
* is not found or cannot be assigned to clazz
*/
@ -555,8 +602,10 @@ public class JSONArray implements Iterable<Object> {
* defaultValue is returned if there is no value for the index, or if the
* value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value.
*/
public BigInteger optBigInteger(int index, BigInteger defaultValue) {
@ -573,8 +622,10 @@ public class JSONArray implements Iterable<Object> {
* defaultValue is returned if there is no value for the index, or if the
* value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value.
*/
public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) {
@ -589,7 +640,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Get the optional JSONArray associated with an index.
*
* @param index subscript
* @param index
* subscript
* @return A JSONArray value, or null if the index has no value, or if the
* value is not a JSONArray.
*/
@ -603,7 +655,8 @@ public class JSONArray implements Iterable<Object> {
* the key is not found, or null if the index has no value, or if the value
* is not a JSONObject.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return A JSONObject value.
*/
public JSONObject optJSONObject(int index) {
@ -616,7 +669,8 @@ public class JSONArray implements Iterable<Object> {
* there is no value for the index, or if the value is not a number and
* cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return The value.
*/
public long optLong(int index) {
@ -628,8 +682,10 @@ public class JSONArray implements Iterable<Object> {
* returned if there is no value for the index, or if the value is not a
* number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value.
*/
public long optLong(int index, long defaultValue) {
@ -646,7 +702,8 @@ public class JSONArray implements Iterable<Object> {
* empty string if there is no value at that index. If the value is not a
* string and is not null, then it is coverted to a string.
*
* @param index The index must be between 0 and length() - 1.
* @param index
* The index must be between 0 and length() - 1.
* @return A String value.
*/
public String optString(int index) {
@ -657,8 +714,10 @@ public class JSONArray implements Iterable<Object> {
* Get the optional string associated with an index. The defaultValue is
* returned if the key is not found.
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return A String value.
*/
public String optString(int index, String defaultValue) {
@ -669,7 +728,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Append a boolean value. This increases the array's length by one.
*
* @param value A boolean value.
* @param value
* A boolean value.
* @return this.
*/
public JSONArray put(boolean value) {
@ -681,7 +741,8 @@ public class JSONArray implements Iterable<Object> {
* Put a value in the JSONArray, where the value will be a JSONArray which
* is produced from a Collection.
*
* @param value A Collection value.
* @param value
* A Collection value.
* @return this.
*/
public JSONArray put(Collection<Object> value) {
@ -692,9 +753,11 @@ public class JSONArray implements Iterable<Object> {
/**
* Append a double value. This increases the array's length by one.
*
* @param value A double value.
* @param value
* A double value.
* @return this.
* @throws JSONException if the value is not finite.
* @throws JSONException
* if the value is not finite.
*/
public JSONArray put(double value) throws JSONException {
Double d = Double.valueOf(value);
@ -706,7 +769,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Append an int value. This increases the array's length by one.
*
* @param value An int value.
* @param value
* An int value.
* @return this.
*/
public JSONArray put(int value) {
@ -717,7 +781,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Append an long value. This increases the array's length by one.
*
* @param value A long value.
* @param value
* A long value.
* @return this.
*/
public JSONArray put(long value) {
@ -729,7 +794,8 @@ public class JSONArray implements Iterable<Object> {
* Put a value in the JSONArray, where the value will be a JSONObject which
* is produced from a Map.
*
* @param value A Map value.
* @param value
* A Map value.
* @return this.
*/
public JSONArray put(Map<String, Object> value) {
@ -740,7 +806,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Append an object value. This increases the array's length by one.
*
* @param value An object value. The value should be a Boolean, Double,
* @param value
* An object value. The value should be a Boolean, Double,
* Integer, JSONArray, JSONObject, Long, or String, or the
* JSONObject.NULL object.
* @return this.
@ -755,10 +822,13 @@ public class JSONArray implements Iterable<Object> {
* than the length of the JSONArray, then null elements will be added as
* necessary to pad it out.
*
* @param index The subscript.
* @param value A boolean value.
* @param index
* The subscript.
* @param value
* A boolean value.
* @return this.
* @throws JSONException If the index is negative.
* @throws JSONException
* If the index is negative.
*/
public JSONArray put(int index, boolean value) throws JSONException {
this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
@ -769,10 +839,13 @@ public class JSONArray implements Iterable<Object> {
* Put a value in the JSONArray, where the value will be a JSONArray which
* is produced from a Collection.
*
* @param index The subscript.
* @param value A Collection value.
* @param index
* The subscript.
* @param value
* A Collection value.
* @return this.
* @throws JSONException If the index is negative or if the value is not finite.
* @throws JSONException
* If the index is negative or if the value is not finite.
*/
public JSONArray put(int index, Collection<Object> value) throws JSONException {
this.put(index, new JSONArray(value));
@ -784,10 +857,13 @@ public class JSONArray implements Iterable<Object> {
* the JSONArray, then null elements will be added as necessary to pad it
* out.
*
* @param index The subscript.
* @param value A double value.
* @param index
* The subscript.
* @param value
* A double value.
* @return this.
* @throws JSONException If the index is negative or if the value is not finite.
* @throws JSONException
* If the index is negative or if the value is not finite.
*/
public JSONArray put(int index, double value) throws JSONException {
this.put(index, Double.valueOf(value));
@ -799,10 +875,13 @@ public class JSONArray implements Iterable<Object> {
* the JSONArray, then null elements will be added as necessary to pad it
* out.
*
* @param index The subscript.
* @param value An int value.
* @param index
* The subscript.
* @param value
* An int value.
* @return this.
* @throws JSONException If the index is negative.
* @throws JSONException
* If the index is negative.
*/
public JSONArray put(int index, int value) throws JSONException {
this.put(index, Integer.valueOf(value));
@ -814,10 +893,13 @@ public class JSONArray implements Iterable<Object> {
* the JSONArray, then null elements will be added as necessary to pad it
* out.
*
* @param index The subscript.
* @param value A long value.
* @param index
* The subscript.
* @param value
* A long value.
* @return this.
* @throws JSONException If the index is negative.
* @throws JSONException
* If the index is negative.
*/
public JSONArray put(int index, long value) throws JSONException {
this.put(index, Long.valueOf(value));
@ -828,10 +910,13 @@ public class JSONArray implements Iterable<Object> {
* Put a value in the JSONArray, where the value will be a JSONObject that
* is produced from a Map.
*
* @param index The subscript.
* @param value The Map value.
* @param index
* The subscript.
* @param value
* The Map value.
* @return this.
* @throws JSONException If the index is negative or if the the value is an invalid
* @throws JSONException
* If the index is negative or if the the value is an invalid
* number.
*/
public JSONArray put(int index, Map<String, Object> value) throws JSONException {
@ -844,12 +929,15 @@ public class JSONArray implements Iterable<Object> {
* than the length of the JSONArray, then null elements will be added as
* necessary to pad it out.
*
* @param index The subscript.
* @param value The value to put into the array. The value should be a
* @param index
* The subscript.
* @param value
* The value to put into the array. The value should be a
* Boolean, Double, Integer, JSONArray, JSONObject, Long, or
* String, or the JSONObject.NULL object.
* @return this.
* @throws JSONException If the index is negative or if the the value is an invalid
* @throws JSONException
* If the index is negative or if the the value is an invalid
* number.
*/
public JSONArray put(int index, Object value) throws JSONException {
@ -871,7 +959,8 @@ public class JSONArray implements Iterable<Object> {
/**
* Remove an index and close the hole.
*
* @param index The index of the element to be removed.
* @param index
* The index of the element to be removed.
* @return The value that was associated with the index, or null if there
* was no value.
*/
@ -883,7 +972,8 @@ public class JSONArray implements Iterable<Object> {
* Determine if two JSONArrays are similar. They must contain similar
* sequences.
*
* @param other The other JSONArray
* @param other
* The other JSONArray
* @return true if they are equal
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
@ -917,11 +1007,13 @@ public class JSONArray implements Iterable<Object> {
* Produce a JSONObject by combining a JSONArray of names with the values of
* this JSONArray.
*
* @param names A JSONArray containing a list of key strings. These will be
* @param names
* A JSONArray containing a list of key strings. These will be
* paired with the values.
* @return A JSONObject, or null if there are no names or if this JSONArray
* has no values.
* @throws JSONException If any of the names are null.
* @throws JSONException
* If any of the names are null.
*/
public JSONObject toJSONObject(JSONArray names) throws JSONException {
if(names == null || names.length() == 0 || this.length() == 0) {
@ -959,12 +1051,12 @@ public class JSONArray implements Iterable<Object> {
* Make a prettyprinted JSON text of this JSONArray. Warning: This method
* assumes that the data structure is acyclical.
*
* @param indentFactor The number of spaces to add to each level of indentation.
* @param indentFactor
* The number of spaces to add to each level of indentation.
* @return a printable, displayable, transmittable representation of the
* object, beginning with <code>[</code>&nbsp;<small>(left
* bracket)</small> and ending with <code>]</code> &nbsp;
* <small>(right bracket)</small>.
* @throws JSONException
*/
public String toString(int indentFactor) throws JSONException {
StringWriter sw = new StringWriter();
@ -980,7 +1072,6 @@ public class JSONArray implements Iterable<Object> {
* Warning: This method assumes that the data structure is acyclical.
*
* @return The writer.
* @throws JSONException
*/
public Writer write(Writer writer) throws JSONException {
return this.write(writer, 0, 0);
@ -992,10 +1083,11 @@ public class JSONArray implements Iterable<Object> {
* <p>
* Warning: This method assumes that the data structure is acyclical.
*
* @param indentFactor The number of spaces to add to each level of indentation.
* @param indent The indention of the top level.
* @param indentFactor
* The number of spaces to add to each level of indentation.
* @param indent
* The indention of the top level.
* @return The writer.
* @throws JSONException
*/
Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
try {

View File

@ -32,7 +32,8 @@ public class JSONException extends RuntimeException {
/**
* Constructs a JSONException with an explanatory message.
*
* @param message Detail about the reason for the exception.
* @param message
* Detail about the reason for the exception.
*/
public JSONException(String message) {
super(message);
@ -41,7 +42,8 @@ public class JSONException extends RuntimeException {
/**
* Constructs a new JSONException with the specified cause.
*
* @param cause The cause.
* @param cause
* The cause.
*/
public JSONException(Throwable cause) {
super(cause.getMessage());

View File

@ -34,9 +34,12 @@ public class JSONML {
/**
* Parse XML values and store them in a JSONArray.
*
* @param x The XMLTokener containing the source string.
* @param arrayForm true if array form, false if object form.
* @param ja The JSONArray that is containing the current tag or null if we
* @param x
* The XMLTokener containing the source string.
* @param arrayForm
* true if array form, false if object form.
* @param ja
* The JSONArray that is containing the current tag or null if we
* are at the outermost level.
* @return A JSONArray if the value is the outermost tag, otherwise null.
*/
@ -228,7 +231,8 @@ public class JSONML {
* JSONArrays will represent the child tags. Comments, prologs, DTDs, and
* <code>&lt;[ [ ]]></code> are ignored.
*
* @param string The source string.
* @param string
* The source string.
* @return A JSONArray containing the structured data from the XML string.
*/
public static JSONArray toJSONArray(String string) throws JSONException {
@ -244,7 +248,8 @@ public class JSONML {
* JSONArrays will represent the child content and tags. Comments, prologs,
* DTDs, and <code>&lt;[ [ ]]></code> are ignored.
*
* @param x An XMLTokener.
* @param x
* An XMLTokener.
* @return A JSONArray containing the structured data from the XML string.
*/
public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
@ -261,7 +266,8 @@ public class JSONML {
* <p>
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
*
* @param x An XMLTokener of the XML source text.
* @param x
* An XMLTokener of the XML source text.
* @return A JSONObject containing the structured data from the XML string.
*/
public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
@ -278,7 +284,8 @@ public class JSONML {
* <p>
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
*
* @param string The XML source text.
* @param string
* The XML source text.
* @return A JSONObject containing the structured data from the XML string.
*/
public static JSONObject toJSONObject(String string) throws JSONException {
@ -288,7 +295,8 @@ public class JSONML {
/**
* Reverse the JSONML transformation, making an XML text from a JSONArray.
*
* @param ja A JSONArray.
* @param ja
* A JSONArray.
* @return An XML string.
*/
public static String toString(JSONArray ja) throws JSONException {
@ -371,7 +379,8 @@ public class JSONML {
* then it must have a "childNodes" property containing an array of objects.
* The other properties are attributes with string values.
*
* @param jo A JSONObject.
* @param jo
* A JSONObject.
* @return An XML string.
*/
public static String toString(JSONObject jo) throws JSONException {

View File

@ -114,10 +114,12 @@ public class JSONObject {
* strings is used to identify the keys that should be copied. Missing keys
* are ignored.
*
* @param jo A JSONObject.
* @param names An array of strings.
* @param jo
* A JSONObject.
* @param names
* An array of strings.
* @throws JSONException
* @throws JSONException If a value is a non-finite number or if a name is
* If a value is a non-finite number or if a name is
* duplicated.
*/
public JSONObject(JSONObject jo, String[] names) {
@ -134,8 +136,10 @@ public class JSONObject {
/**
* Construct a JSONObject from a JSONTokener.
*
* @param x A JSONTokener object containing the source string.
* @throws JSONException If there is a syntax error in the source string or a
* @param x
* A JSONTokener object containing the source string.
* @throws JSONException
* If there is a syntax error in the source string or a
* duplicated key.
*/
public JSONObject(JSONTokener x) throws JSONException {
@ -187,9 +191,9 @@ public class JSONObject {
/**
* Construct a JSONObject from a Map.
*
* @param map A map object that can be used to initialize the contents of
* @param map
* A map object that can be used to initialize the contents of
* the JSONObject.
* @throws JSONException
*/
public JSONObject(Map<String, Object> map) {
this.map = new LinkedHashMap<>();
@ -222,7 +226,8 @@ public class JSONObject {
* <code>"Larry Fine"</code>, then the JSONObject will contain
* <code>"name": "Larry Fine"</code>.
*
* @param bean An object that has getter methods that should be used to make
* @param bean
* An object that has getter methods that should be used to make
* a JSONObject.
*/
public JSONObject(Object bean) {
@ -237,9 +242,11 @@ public class JSONObject {
* those keys in the object. If a key is not found or not visible, then it
* will not be copied into the new JSONObject.
*
* @param object An object that has fields that should be used to make a
* @param object
* An object that has fields that should be used to make a
* JSONObject.
* @param names An array of strings, the names of the fields to be obtained
* @param names
* An array of strings, the names of the fields to be obtained
* from the object.
*/
public JSONObject(Object object, String[] names) {
@ -259,10 +266,12 @@ public class JSONObject {
* Construct a JSONObject from a source JSON text string. This is the most
* commonly used JSONObject constructor.
*
* @param source A string beginning with <code>{</code>&nbsp;<small>(left
* @param source
* A string beginning with <code>{</code>&nbsp;<small>(left
* brace)</small> and ending with <code>}</code> &nbsp;
* <small>(right brace)</small>.
* @throws JSONException If there is a syntax error in the source string or a
* @throws JSONException
* If there is a syntax error in the source string or a
* duplicated key.
*/
public JSONObject(String source) throws JSONException {
@ -272,9 +281,12 @@ public class JSONObject {
/**
* Construct a JSONObject from a ResourceBundle.
*
* @param baseName The ResourceBundle base name.
* @param locale The Locale to load the ResourceBundle for.
* @throws JSONException If any JSONExceptions are detected.
* @param baseName
* The ResourceBundle base name.
* @param locale
* The Locale to load the ResourceBundle for.
* @throws JSONException
* If any JSONExceptions are detected.
*/
public JSONObject(String baseName, Locale locale) throws JSONException {
this();
@ -314,7 +326,8 @@ public class JSONObject {
* Produce a string from a double. The string "null" will be returned if the
* number is not finite.
*
* @param d A double.
* @param d
* A double.
* @return A String.
*/
public static String doubleToString(double d) {
@ -381,9 +394,11 @@ public class JSONObject {
/**
* Produce a string from a Number.
*
* @param number A Number
* @param number
* A Number
* @return A String.
* @throws JSONException If n is a non-finite number.
* @throws JSONException
* If n is a non-finite number.
*/
public static String numberToString(Number number) throws JSONException {
if(number == null) {
@ -411,7 +426,8 @@ public class JSONObject {
* allowing JSON text to be delivered in HTML. In JSON text, a string cannot
* contain a control character or an unescaped quote or backslash.
*
* @param string A String
* @param string
* A String
* @return A String correctly formatted for insertion in a JSON text.
*/
public static String quote(String string) {
@ -489,7 +505,8 @@ public class JSONObject {
* Try to convert a string into a number, boolean, or null. If the string
* can't be converted, return the string.
*
* @param string A String.
* @param string
* A String.
* @return A simple JSON value.
*/
public static Object stringToValue(String string) {
@ -540,8 +557,10 @@ public class JSONObject {
/**
* Throw an exception if the object is a NaN or infinite number.
*
* @param o The object to test.
* @throws JSONException If o is a non-finite number.
* @param o
* The object to test.
* @throws JSONException
* If o is a non-finite number.
*/
public static void testValidity(Object o) throws JSONException {
if(o != null) {
@ -572,12 +591,14 @@ public class JSONObject {
* <p>
* Warning: This method assumes that the data structure is acyclical.
*
* @param value The value to be serialized.
* @param value
* The value to be serialized.
* @return a printable, displayable, transmittable representation of the
* object, beginning with <code>{</code>&nbsp;<small>(left
* brace)</small> and ending with <code>}</code>&nbsp;<small>(right
* brace)</small>.
* @throws JSONException If the value is or contains an invalid number.
* @throws JSONException
* If the value is or contains an invalid number.
*/
public static String valueToString(Object value) throws JSONException {
if(value == null || value.equals(null)) {
@ -626,7 +647,8 @@ public class JSONObject {
* one of the java packages, turn it into a string. And if it doesn't, try
* to wrap it in a JSONObject. If the wrapping fails, then null is returned.
*
* @param object The object to wrap
* @param object
* The object to wrap
* @return The wrapped value
*/
public static Object wrap(Object object) {
@ -716,10 +738,13 @@ public class JSONObject {
* will be the same as using put. But if multiple values are accumulated,
* then the result will be like append.
*
* @param key A key string.
* @param value An object to be accumulated under the key.
* @param key
* A key string.
* @param value
* An object to be accumulated under the key.
* @return this.
* @throws JSONException If the value is an invalid number or if the key is null.
* @throws JSONException
* If the value is an invalid number or if the key is null.
*/
public JSONObject accumulate(String key, Object value) throws JSONException {
testValidity(value);
@ -740,10 +765,13 @@ public class JSONObject {
* JSONArray containing the value parameter. If the key was already
* associated with a JSONArray, then the value parameter is appended to it.
*
* @param key A key string.
* @param value An object to be accumulated under the key.
* @param key
* A key string.
* @param value
* An object to be accumulated under the key.
* @return this.
* @throws JSONException If the key is null or if the current value associated with
* @throws JSONException
* If the key is null or if the current value associated with
* the key is not a JSONArray.
*/
public JSONObject append(String key, Object value) throws JSONException {
@ -762,9 +790,11 @@ public class JSONObject {
/**
* Get the value object associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return The object associated with the key.
* @throws JSONException if the key is not found.
* @throws JSONException
* if the key is not found.
*/
public Object get(String key) throws JSONException {
if(key == null) {
@ -780,10 +810,13 @@ public class JSONObject {
/**
* Get the enum value associated with a key.
*
* @param clazz The type of enum to retrieve.
* @param key A key string.
* @param clazz
* The type of enum to retrieve.
* @param key
* A key string.
* @return The enum value associated with the key
* @throws JSONException if the key is not found or if the value cannot be converted
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to an enum.
*/
public <E extends Enum<E>> E getEnum(Class<E> clazz, String key) throws JSONException {
@ -800,9 +833,11 @@ public class JSONObject {
/**
* Get the boolean value associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return The truth.
* @throws JSONException if the value is not a Boolean or the String "true" or
* @throws JSONException
* if the value is not a Boolean or the String "true" or
* "false".
*/
public boolean getBoolean(String key) throws JSONException {
@ -818,9 +853,11 @@ public class JSONObject {
/**
* Get the BigInteger value associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return The numeric value.
* @throws JSONException if the key is not found or if the value cannot be converted
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to BigInteger.
*/
public BigInteger getBigInteger(String key) throws JSONException {
@ -836,9 +873,11 @@ public class JSONObject {
/**
* Get the BigDecimal value associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return The numeric value.
* @throws JSONException if the key is not found or if the value cannot be converted
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to BigDecimal.
*/
public BigDecimal getBigDecimal(String key) throws JSONException {
@ -854,9 +893,11 @@ public class JSONObject {
/**
* Get the double value associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return The numeric value.
* @throws JSONException if the key is not found or if the value is not a Number
* @throws JSONException
* if the key is not found or if the value is not a Number
* object and cannot be converted to a number.
*/
public double getDouble(String key) throws JSONException {
@ -872,9 +913,11 @@ public class JSONObject {
/**
* Get the int value associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return The integer value.
* @throws JSONException if the key is not found or if the value cannot be converted
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to an integer.
*/
public int getInt(String key) throws JSONException {
@ -890,9 +933,11 @@ public class JSONObject {
/**
* Get the JSONArray value associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return A JSONArray which is the value.
* @throws JSONException if the key is not found or if the value is not a JSONArray.
* @throws JSONException
* if the key is not found or if the value is not a JSONArray.
*/
public JSONArray getJSONArray(String key) throws JSONException {
Object object = this.get(key);
@ -905,9 +950,11 @@ public class JSONObject {
/**
* Get the JSONObject value associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return A JSONObject which is the value.
* @throws JSONException if the key is not found or if the value is not a JSONObject.
* @throws JSONException
* if the key is not found or if the value is not a JSONObject.
*/
public JSONObject getJSONObject(String key) throws JSONException {
Object object = this.get(key);
@ -920,9 +967,11 @@ public class JSONObject {
/**
* Get the long value associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return The long value.
* @throws JSONException if the key is not found or if the value cannot be converted
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to a long.
*/
public long getLong(String key) throws JSONException {
@ -938,9 +987,11 @@ public class JSONObject {
/**
* Get the string associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return A string which is the value.
* @throws JSONException if there is no string value for the key.
* @throws JSONException
* if there is no string value for the key.
*/
public String getString(String key) throws JSONException {
Object object = this.get(key);
@ -953,7 +1004,8 @@ public class JSONObject {
/**
* Determine if the JSONObject contains a specific key.
*
* @param key A key string.
* @param key
* A key string.
* @return true if the key exists in the JSONObject.
*/
public boolean has(String key) {
@ -965,9 +1017,11 @@ public class JSONObject {
* create one with a value of 1. If there is such a property, and if it is
* an Integer, Long, Double, or Float, then add one to it.
*
* @param key A key string.
* @param key
* A key string.
* @return this.
* @throws JSONException If there is already a property with this name that is not an
* @throws JSONException
* If there is already a property with this name that is not an
* Integer, Long, Double, or Float.
*/
public JSONObject increment(String key) throws JSONException {
@ -996,7 +1050,8 @@ public class JSONObject {
* Determine if the value associated with the key is null or if there is no
* value.
*
* @param key A key string.
* @param key
* A key string.
* @return true if there is no value associated with the key or if the value
* is the JSONObject.NULL object.
*/
@ -1050,7 +1105,8 @@ public class JSONObject {
/**
* Get an optional value associated with a key.
*
* @param key A key string.
* @param key
* A key string.
* @return An object which is the value, or null if there is no value.
*/
public Object opt(String key) {
@ -1060,8 +1116,10 @@ public class JSONObject {
/**
* Get the enum value associated with a key.
*
* @param clazz The type of enum to retrieve.
* @param key A key string.
* @param clazz
* The type of enum to retrieve.
* @param key
* A key string.
* @return The enum value associated with the key or null if not found
*/
public <E extends Enum<E>> E optEnum(Class<E> clazz, String key) {
@ -1071,9 +1129,12 @@ public class JSONObject {
/**
* Get the enum value associated with a key.
*
* @param clazz The type of enum to retrieve.
* @param key A key string.
* @param defaultValue The default in case the value is not found
* @param clazz
* The type of enum to retrieve.
* @param key
* A key string.
* @param defaultValue
* The default in case the value is not found
* @return The enum value associated with the key or defaultValue if the
* value is not found or cannot be assigned to clazz
*/
@ -1103,7 +1164,8 @@ public class JSONObject {
* Get an optional boolean associated with a key. It returns false if there
* is no such key, or if the value is not Boolean.TRUE or the String "true".
*
* @param key A key string.
* @param key
* A key string.
* @return The truth.
*/
public boolean optBoolean(String key) {
@ -1115,8 +1177,10 @@ public class JSONObject {
* defaultValue if there is no such key, or if it is not a Boolean or the
* String "true" or "false" (case insensitive).
*
* @param key A key string.
* @param defaultValue The default.
* @param key
* A key string.
* @param defaultValue
* The default.
* @return The truth.
*/
public boolean optBoolean(String key, boolean defaultValue) {
@ -1133,7 +1197,8 @@ public class JSONObject {
* key or if its value is not a number. If the value is a string, an attempt
* will be made to evaluate it as a number.
*
* @param key A string which is the key.
* @param key
* A string which is the key.
* @return An object which is the value.
*/
public double optDouble(String key) {
@ -1145,8 +1210,10 @@ public class JSONObject {
* there is no such key or if its value is not a number. If the value is a
* string, an attempt will be made to evaluate it as a number.
*
* @param key A key string.
* @param defaultValue The default.
* @param key
* A key string.
* @param defaultValue
* The default.
* @return An object which is the value.
*/
public BigInteger optBigInteger(String key, BigInteger defaultValue) {
@ -1163,8 +1230,10 @@ public class JSONObject {
* there is no such key or if its value is not a number. If the value is a
* string, an attempt will be made to evaluate it as a number.
*
* @param key A key string.
* @param defaultValue The default.
* @param key
* A key string.
* @param defaultValue
* The default.
* @return An object which is the value.
*/
public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) {
@ -1181,8 +1250,10 @@ public class JSONObject {
* there is no such key or if its value is not a number. If the value is a
* string, an attempt will be made to evaluate it as a number.
*
* @param key A key string.
* @param defaultValue The default.
* @param key
* A key string.
* @param defaultValue
* The default.
* @return An object which is the value.
*/
public double optDouble(String key, double defaultValue) {
@ -1199,7 +1270,8 @@ public class JSONObject {
* such key or if the value is not a number. If the value is a string, an
* attempt will be made to evaluate it as a number.
*
* @param key A key string.
* @param key
* A key string.
* @return An object which is the value.
*/
public int optInt(String key) {
@ -1211,8 +1283,10 @@ public class JSONObject {
* is no such key or if the value is not a number. If the value is a string,
* an attempt will be made to evaluate it as a number.
*
* @param key A key string.
* @param defaultValue The default.
* @param key
* A key string.
* @param defaultValue
* The default.
* @return An object which is the value.
*/
public int optInt(String key, int defaultValue) {
@ -1228,7 +1302,8 @@ public class JSONObject {
* Get an optional JSONArray associated with a key. It returns null if there
* is no such key, or if its value is not a JSONArray.
*
* @param key A key string.
* @param key
* A key string.
* @return A JSONArray which is the value.
*/
public JSONArray optJSONArray(String key) {
@ -1240,7 +1315,8 @@ public class JSONObject {
* Get an optional JSONObject associated with a key. It returns null if
* there is no such key, or if its value is not a JSONObject.
*
* @param key A key string.
* @param key
* A key string.
* @return A JSONObject which is the value.
*/
public JSONObject optJSONObject(String key) {
@ -1253,7 +1329,8 @@ public class JSONObject {
* such key or if the value is not a number. If the value is a string, an
* attempt will be made to evaluate it as a number.
*
* @param key A key string.
* @param key
* A key string.
* @return An object which is the value.
*/
public long optLong(String key) {
@ -1265,8 +1342,10 @@ public class JSONObject {
* is no such key or if the value is not a number. If the value is a string,
* an attempt will be made to evaluate it as a number.
*
* @param key A key string.
* @param defaultValue The default.
* @param key
* A key string.
* @param defaultValue
* The default.
* @return An object which is the value.
*/
public long optLong(String key, long defaultValue) {
@ -1283,7 +1362,8 @@ public class JSONObject {
* if there is no such key. If the value is not a string and is not null,
* then it is converted to a string.
*
* @param key A key string.
* @param key
* A key string.
* @return A string which is the value.
*/
public String optString(String key) {
@ -1294,8 +1374,10 @@ public class JSONObject {
* Get an optional string associated with a key. It returns the defaultValue
* if there is no such key.
*
* @param key A key string.
* @param defaultValue The default.
* @param key
* A key string.
* @param defaultValue
* The default.
* @return A string which is the value.
*/
public String optString(String key, String defaultValue) {
@ -1348,10 +1430,13 @@ public class JSONObject {
/**
* Put a key/boolean pair in the JSONObject.
*
* @param key A key string.
* @param value A boolean which is the value.
* @param key
* A key string.
* @param value
* A boolean which is the value.
* @return this.
* @throws JSONException If the key is null.
* @throws JSONException
* If the key is null.
*/
public JSONObject put(String key, boolean value) throws JSONException {
this.put(key, value ? Boolean.TRUE : Boolean.FALSE);
@ -1362,10 +1447,11 @@ public class JSONObject {
* Put a key/value pair in the JSONObject, where the value will be a
* JSONArray which is produced from a Collection.
*
* @param key A key string.
* @param value A Collection value.
* @param key
* A key string.
* @param value
* A Collection value.
* @return this.
* @throws JSONException
*/
public JSONObject put(String key, Collection<Object> value) throws JSONException {
this.put(key, new JSONArray(value));
@ -1375,10 +1461,13 @@ public class JSONObject {
/**
* Put a key/double pair in the JSONObject.
*
* @param key A key string.
* @param value A double which is the value.
* @param key
* A key string.
* @param value
* A double which is the value.
* @return this.
* @throws JSONException If the key is null or if the number is invalid.
* @throws JSONException
* If the key is null or if the number is invalid.
*/
public JSONObject put(String key, double value) throws JSONException {
this.put(key, Double.valueOf(value));
@ -1388,10 +1477,13 @@ public class JSONObject {
/**
* Put a key/int pair in the JSONObject.
*
* @param key A key string.
* @param value An int which is the value.
* @param key
* A key string.
* @param value
* An int which is the value.
* @return this.
* @throws JSONException If the key is null.
* @throws JSONException
* If the key is null.
*/
public JSONObject put(String key, int value) throws JSONException {
this.put(key, Integer.valueOf(value));
@ -1401,10 +1493,13 @@ public class JSONObject {
/**
* Put a key/long pair in the JSONObject.
*
* @param key A key string.
* @param value A long which is the value.
* @param key
* A key string.
* @param value
* A long which is the value.
* @return this.
* @throws JSONException If the key is null.
* @throws JSONException
* If the key is null.
*/
public JSONObject put(String key, long value) throws JSONException {
this.put(key, Long.valueOf(value));
@ -1415,10 +1510,11 @@ public class JSONObject {
* Put a key/value pair in the JSONObject, where the value will be a
* JSONObject which is produced from a Map.
*
* @param key A key string.
* @param value A Map value.
* @param key
* A key string.
* @param value
* A Map value.
* @return this.
* @throws JSONException
*/
public JSONObject put(String key, Map<String, Object> value) throws JSONException {
this.put(key, new JSONObject(value));
@ -1429,12 +1525,15 @@ public class JSONObject {
* Put a key/value pair in the JSONObject. If the value is null, then the
* key will be removed from the JSONObject if it is present.
*
* @param key A key string.
* @param value An object which is the value. It should be of one of these
* @param key
* A key string.
* @param value
* An object which is the value. It should be of one of these
* types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
* String, or the JSONObject.NULL object.
* @return this.
* @throws JSONException If the value is non-finite number or if the key is null.
* @throws JSONException
* If the value is non-finite number or if the key is null.
*/
public JSONObject put(String key, Object value) throws JSONException {
if(key == null) {
@ -1454,10 +1553,13 @@ public class JSONObject {
* are both non-null, and only if there is not already a member with that
* name.
*
* @param key string
* @param value object
* @param key
* string
* @param value
* object
* @return this.
* @throws JSONException if the key is a duplicate
* @throws JSONException
* if the key is a duplicate
*/
public JSONObject putOnce(String key, Object value) throws JSONException {
if(key != null && value != null) {
@ -1473,12 +1575,15 @@ public class JSONObject {
* Put a key/value pair in the JSONObject, but only if the key and the value
* are both non-null.
*
* @param key A key string.
* @param value An object which is the value. It should be of one of these
* @param key
* A key string.
* @param value
* An object which is the value. It should be of one of these
* types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
* String, or the JSONObject.NULL object.
* @return this.
* @throws JSONException If the value is a non-finite number.
* @throws JSONException
* If the value is a non-finite number.
*/
public JSONObject putOpt(String key, Object value) throws JSONException {
if(key != null && value != null) {
@ -1490,7 +1595,8 @@ public class JSONObject {
/**
* Remove a name and its value, if present.
*
* @param key The name to be removed.
* @param key
* The name to be removed.
* @return The value that was associated with the name, or null if there was
* no value.
*/
@ -1502,7 +1608,8 @@ public class JSONObject {
* Determine if two JSONObjects are similar. They must contain the same set
* of names which must be associated with similar values.
*
* @param other The other JSONObject
* @param other
* The other JSONObject
* @return true if they are equal
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
@ -1543,10 +1650,12 @@ public class JSONObject {
* Produce a JSONArray containing the values of the members of this
* JSONObject.
*
* @param names A JSONArray containing a list of key strings. This determines
* @param names
* A JSONArray containing a list of key strings. This determines
* the sequence of the values in the result.
* @return A JSONArray of values.
* @throws JSONException If any of the values are non-finite numbers.
* @throws JSONException
* If any of the values are non-finite numbers.
*/
public JSONArray toJSONArray(JSONArray names) throws JSONException {
if(names == null || names.length() == 0) {
@ -1585,12 +1694,14 @@ public class JSONObject {
* <p>
* Warning: This method assumes that the data structure is acyclical.
*
* @param indentFactor The number of spaces to add to each level of indentation.
* @param indentFactor
* The number of spaces to add to each level of indentation.
* @return a printable, displayable, portable, transmittable representation
* of the object, beginning with <code>{</code>&nbsp;<small>(left
* brace)</small> and ending with <code>}</code>&nbsp;<small>(right
* brace)</small>.
* @throws JSONException If the object contains an invalid number.
* @throws JSONException
* If the object contains an invalid number.
*/
public String toString(int indentFactor) throws JSONException {
StringWriter w = new StringWriter();
@ -1606,7 +1717,6 @@ public class JSONObject {
* Warning: This method assumes that the data structure is acyclical.
*
* @return The writer.
* @throws JSONException
*/
public Writer write(Writer writer) throws JSONException {
return this.write(writer, 0, 0);
@ -1619,7 +1729,6 @@ public class JSONObject {
* Warning: This method assumes that the data structure is acyclical.
*
* @return The writer.
* @throws JSONException
*/
Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
try {
@ -1689,7 +1798,8 @@ public class JSONObject {
/**
* A Null object is equal to the null value and to itself.
*
* @param object An object to test for nullness.
* @param object
* An object to test for nullness.
* @return true if the object parameter is the JSONObject.NULL object or
* null.
*/

View File

@ -50,7 +50,8 @@ public class JSONTokener {
/**
* Construct a JSONTokener from a Reader.
*
* @param reader A reader.
* @param reader
* A reader.
*/
public JSONTokener(Reader reader) {
this.reader = reader.markSupported() ? reader : new BufferedReader(reader);
@ -65,7 +66,8 @@ public class JSONTokener {
/**
* Construct a JSONTokener from an InputStream.
*
* @param inputStream The source.
* @param inputStream
* The source.
*/
public JSONTokener(InputStream inputStream) throws JSONException {
this(new InputStreamReader(inputStream));
@ -74,7 +76,8 @@ public class JSONTokener {
/**
* Construct a JSONTokener from a string.
*
* @param s A source string.
* @param s
* A source string.
*/
public JSONTokener(String s) {
this(new StringReader(s));
@ -83,7 +86,8 @@ public class JSONTokener {
/**
* Get the hex value of a character (base16).
*
* @param c A character between '0' and '9' or between 'A' and 'F' or
* @param c
* A character between '0' and '9' or between 'A' and 'F' or
* between 'a' and 'f'.
* @return An int between 0 and 15, or -1 if c was not a hex digit.
*/
@ -175,9 +179,11 @@ public class JSONTokener {
* Consume the next character, and check that it matches a specified
* character.
*
* @param c The character to match.
* @param c
* The character to match.
* @return The character.
* @throws JSONException if the character does not match.
* @throws JSONException
* if the character does not match.
*/
public char next(char c) throws JSONException {
char n = this.next();
@ -190,9 +196,11 @@ public class JSONTokener {
/**
* Get the next n characters.
*
* @param n The number of characters to take.
* @param n
* The number of characters to take.
* @return A string of n characters.
* @throws JSONException Substring bounds error if there are not n characters
* @throws JSONException
* Substring bounds error if there are not n characters
* remaining in the source string.
*/
public String next(int n) throws JSONException {
@ -217,7 +225,6 @@ public class JSONTokener {
* Get the next char in the string, skipping whitespace.
*
* @return A character, or 0 if there are no more characters.
* @throws JSONException
*/
public char nextClean() throws JSONException {
for(; ; ) {
@ -233,11 +240,13 @@ public class JSONTokener {
* processing is done. The formal JSON format does not allow strings in
* single quotes, but an implementation is allowed to accept them.
*
* @param quote The quoting character, either <code>"</code>&nbsp;
* @param quote
* The quoting character, either <code>"</code>&nbsp;
* <small>(double quote)</small> or <code>'</code>&nbsp;
* <small>(single quote)</small>.
* @return A String.
* @throws JSONException Unterminated string.
* @throws JSONException
* Unterminated string.
*/
public String nextString(char quote) throws JSONException {
char c;
@ -293,7 +302,8 @@ public class JSONTokener {
* Get the text up but not including the specified character or the end of
* line, whichever comes first.
*
* @param delimiter A delimiter character.
* @param delimiter
* A delimiter character.
* @return A string.
*/
public String nextTo(char delimiter) throws JSONException {
@ -314,7 +324,8 @@ public class JSONTokener {
* Get the text up but not including one of the specified delimiter
* characters or the end of line, whichever comes first.
*
* @param delimiters A set of delimiter characters.
* @param delimiters
* A set of delimiter characters.
* @return A string, trimmed.
*/
public String nextTo(String delimiters) throws JSONException {
@ -337,7 +348,8 @@ public class JSONTokener {
* JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
*
* @return An object.
* @throws JSONException If syntax error.
* @throws JSONException
* If syntax error.
*/
public Object nextValue() throws JSONException {
char c = this.nextClean();
@ -382,7 +394,8 @@ public class JSONTokener {
* Skip characters until the next character is the requested character. If
* the requested character is not found, no characters are skipped.
*
* @param to A character to skip to.
* @param to
* A character to skip to.
* @return The requested character, or zero if the requested character is
* not found.
*/
@ -414,7 +427,8 @@ public class JSONTokener {
/**
* Make a JSONException to signal a syntax error.
*
* @param message The error message.
* @param message
* The error message.
* @return A JSONException object, suitable for throwing
*/
public JSONException syntaxError(String message) {

View File

@ -96,9 +96,11 @@ public class JSONWriter {
/**
* Append a value.
*
* @param string A string value.
* @param string
* A string value.
* @return this
* @throws JSONException If the value is out of sequence.
* @throws JSONException
* If the value is out of sequence.
*/
private JSONWriter append(String string) throws JSONException {
if(string == null) {
@ -129,7 +131,8 @@ public class JSONWriter {
* <code>endArray</code> method must be called to mark the array's end.
*
* @return this
* @throws JSONException If the nesting is too deep, or if the object is started in
* @throws JSONException
* If the nesting is too deep, or if the object is started in
* the wrong place (for example as a key or after the end of the
* outermost array or object).
*/
@ -146,10 +149,13 @@ public class JSONWriter {
/**
* End something.
*
* @param mode Mode
* @param c Closing character
* @param mode
* Mode
* @param c
* Closing character
* @return this
* @throws JSONException If unbalanced.
* @throws JSONException
* If unbalanced.
*/
private JSONWriter end(char mode, char c) throws JSONException {
if(this.mode != mode) {
@ -171,7 +177,8 @@ public class JSONWriter {
* <code>array</code>.
*
* @return this
* @throws JSONException If incorrectly nested.
* @throws JSONException
* If incorrectly nested.
*/
public JSONWriter endArray() throws JSONException {
return this.end('a', ']');
@ -182,7 +189,8 @@ public class JSONWriter {
* <code>object</code>.
*
* @return this
* @throws JSONException If incorrectly nested.
* @throws JSONException
* If incorrectly nested.
*/
public JSONWriter endObject() throws JSONException {
return this.end('k', '}');
@ -192,9 +200,11 @@ public class JSONWriter {
* Append a key. The key will be associated with the next value. In an
* object, every value must be preceded by a key.
*
* @param string A key string.
* @param string
* A key string.
* @return this
* @throws JSONException If the key is out of place. For example, keys do not belong
* @throws JSONException
* If the key is out of place. For example, keys do not belong
* in arrays or if the key is null.
*/
public JSONWriter key(String string) throws JSONException {
@ -226,7 +236,8 @@ public class JSONWriter {
* <code>endObject</code> method must be called to mark the object's end.
*
* @return this
* @throws JSONException If the nesting is too deep, or if the object is started in
* @throws JSONException
* If the nesting is too deep, or if the object is started in
* the wrong place (for example as a key or after the end of the
* outermost array or object).
*/
@ -247,8 +258,10 @@ public class JSONWriter {
/**
* Pop an array or object scope.
*
* @param c The scope to close.
* @throws JSONException If nesting is wrong.
* @param c
* The scope to close.
* @throws JSONException
* If nesting is wrong.
*/
private void pop(char c) throws JSONException {
if(this.top <= 0) {
@ -265,8 +278,10 @@ public class JSONWriter {
/**
* Push an array or object scope.
*
* @param jo The scope to open.
* @throws JSONException If nesting is too deep.
* @param jo
* The scope to open.
* @throws JSONException
* If nesting is too deep.
*/
private void push(JSONObject jo) throws JSONException {
if(this.top >= maxdepth) {
@ -281,7 +296,8 @@ public class JSONWriter {
* Append either the value <code>true</code> or the value <code>false</code>
* .
*
* @param b A boolean.
* @param b
* A boolean.
* @return this
*/
public JSONWriter value(boolean b) throws JSONException {
@ -291,9 +307,11 @@ public class JSONWriter {
/**
* Append a double value.
*
* @param d A double.
* @param d
* A double.
* @return this
* @throws JSONException If the number is not finite.
* @throws JSONException
* If the number is not finite.
*/
public JSONWriter value(double d) throws JSONException {
return this.value(Double.valueOf(d));
@ -302,7 +320,8 @@ public class JSONWriter {
/**
* Append a long value.
*
* @param l A long.
* @param l
* A long.
* @return this
*/
public JSONWriter value(long l) throws JSONException {
@ -312,11 +331,13 @@ public class JSONWriter {
/**
* Append an object value.
*
* @param object The object to append. It can be null, or a Boolean, Number,
* @param object
* The object to append. It can be null, or a Boolean, Number,
* String, JSONObject, or JSONArray, or an object that implements
* JSONString.
* @return this
* @throws JSONException If the value is out of sequence.
* @throws JSONException
* If the value is out of sequence.
*/
public JSONWriter value(Object object) throws JSONException {
return this.append(JSONObject.valueToString(object));

Some files were not shown because too many files have changed in this diff Show More