9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-22 08:39:14 +00:00
This commit is contained in:
cyberpwn
2022-01-12 01:47:38 -05:00
parent 8c00499e76
commit 2dde426df6
463 changed files with 11845 additions and 10159 deletions

View File

@@ -301,8 +301,7 @@ public class Iris extends VolmitPlugin implements Listener {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void later(NastyRunnable object) { public static void later(NastyRunnable object) {
try try {
{
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () -> Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
{ {
try { try {
@@ -312,10 +311,7 @@ public class Iris extends VolmitPlugin implements Listener {
Iris.reportError(e); Iris.reportError(e);
} }
}, RNG.r.i(100, 1200)); }, 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); postShutdown.add(r);
} }
public static void panic() public static void panic() {
{
EnginePanic.panic(); EnginePanic.panic();
} }
public static void addPanic(String s, String v) public static void addPanic(String s, String v) {
{
EnginePanic.add(s, v); EnginePanic.add(s, v);
} }

View File

@@ -19,29 +19,21 @@
package com.volmit.iris.core.commands; package com.volmit.iris.core.commands;
import com.volmit.iris.Iris; 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.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.*; import com.volmit.iris.engine.object.IrisCave;
import com.volmit.iris.util.data.B; 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.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C; 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") @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) @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) { public void biome(@Param(contextual = false, description = "The biome to edit") IrisBiome biome) {
if (noStudio()) {return;} if(noStudio()) {
return;
}
try { try {
if(biome == null || biome.getLoadFile() == null) { if(biome == null || biome.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); 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) @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) { public void region(@Param(contextual = false, description = "The region to edit") IrisRegion region) {
if (noStudio()) {return;} if(noStudio()) {
return;
}
try { try {
if(region == null || region.getLoadFile() == null) { if(region == null || region.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); 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) @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) { public void dimension(@Param(contextual = false, description = "The dimension to edit") IrisDimension dimension) {
if (noStudio()) {return;} if(noStudio()) {
return;
}
try { try {
if(dimension == null || dimension.getLoadFile() == null) { if(dimension == null || dimension.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); 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) @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) { public void cave(@Param(contextual = false, description = "The cave to edit") IrisCave cave) {
if (noStudio()) {return;} if(noStudio()) {
return;
}
try { try {
if(cave == null || cave.getLoadFile() == null) { if(cave == null || cave.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); 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) @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) { public void jigsaw(@Param(contextual = false, description = "The jigsaw structure to edit") IrisJigsawStructure jigsaw) {
if (noStudio()) {return;} if(noStudio()) {
return;
}
try { try {
if(jigsaw == null || jigsaw.getLoadFile() == null) { if(jigsaw == null || jigsaw.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); 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) @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) { public void jigsawPool(@Param(contextual = false, description = "The jigsaw pool to edit") IrisJigsawPool pool) {
if (noStudio()) {return;} if(noStudio()) {
return;
}
try { try {
if(pool == null || pool.getLoadFile() == null) { if(pool == null || pool.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); 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) @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) { public void jigsawPiece(@Param(contextual = false, description = "The jigsaw piece to edit") IrisJigsawPiece piece) {
if (noStudio()) {return;} if(noStudio()) {
return;
}
try { try {
if(piece == null || piece.getLoadFile() == null) { if(piece == null || piece.getLoadFile() == null) {
sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?");

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

View File

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

View File

@@ -21,7 +21,6 @@ package com.volmit.iris.core.loader;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.object.IrisImage; 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.KList;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.data.KCache; import com.volmit.iris.util.data.KCache;

View File

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

View File

@@ -35,16 +35,14 @@ 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.MCAPalettedContainer;
import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer; import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer;
import com.volmit.iris.util.nbt.tag.CompoundTag; import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.scheduling.Queue;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -53,11 +51,9 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_18_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_18_R1.CraftServer; import org.bukkit.craftbukkit.v1_18_R1.CraftServer;
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData; import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_18_R1.generator.CustomChunkGenerator;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -68,7 +64,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.IdentityHashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@@ -149,8 +144,7 @@ public class NMSBinding18_1 implements INMSBinding {
return true; return true;
} }
private RegistryAccess registry() private RegistryAccess registry() {
{
return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer())); return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()));
} }
@@ -377,20 +371,16 @@ public class NMSBinding18_1 implements INMSBinding {
private static Object getFor(Class<?> type, Object source) { private static Object getFor(Class<?> type, Object source) {
Object o = fieldFor(type, source); Object o = fieldFor(type, source);
if(o != null) if(o != null) {
{
return o; return o;
} }
return invokeFor(type, source); return invokeFor(type, source);
} }
private static Object invokeFor(Class<?> returns, Object in) private static Object invokeFor(Class<?> returns, Object in) {
{ for(Method i : in.getClass().getMethods()) {
for(Method i : in.getClass().getMethods()) if(i.getReturnType().equals(returns)) {
{
if(i.getReturnType().equals(returns))
{
i.setAccessible(true); i.setAccessible(true);
try { try {
Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()"); Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()");
@@ -404,12 +394,9 @@ public class NMSBinding18_1 implements INMSBinding {
return null; return null;
} }
private static Object fieldFor(Class<?> returns, Object in) private static Object fieldFor(Class<?> returns, Object in) {
{ for(Field i : in.getClass().getFields()) {
for(Field i : in.getClass().getFields()) if(i.getType().equals(returns)) {
{
if(i.getType().equals(returns))
{
i.setAccessible(true); i.setAccessible(true);
try { try {
Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName()); Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName());

View File

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

View File

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

View File

@@ -43,8 +43,10 @@ public interface PregeneratorMethod {
/** /**
* Return true if regions can be generated * Return true if regions can be generated
* *
* @param x the x region * @param x
* @param z the z region * the x region
* @param z
* the z region
* @return true if they can be * @return true if they can be
*/ */
boolean supportsRegions(int x, int z, PregenListener listener); boolean supportsRegions(int x, int z, PregenListener listener);
@@ -52,8 +54,10 @@ public interface PregeneratorMethod {
/** /**
* Return the name of the method being used * Return the name of the method being used
* *
* @param x the x region * @param x
* @param z the z region * the x region
* @param z
* the z region
* @return the name * @return the name
*/ */
String getMethod(int x, int z); String getMethod(int x, int z);
@@ -62,18 +66,22 @@ public interface PregeneratorMethod {
* Called to generate a region. Execute sync, if multicore internally, wait * Called to generate a region. Execute sync, if multicore internally, wait
* for the task to complete * for the task to complete
* *
* @param x the x * @param x
* @param z the z * the x
* @param listener signal chunks generating & generated. Parallel capable. * @param z
* the z
* @param listener
* signal chunks generating & generated. Parallel capable.
*/ */
void generateRegion(int x, int z, PregenListener listener); 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 * 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 x
* @param z the z * the x
* @param listener * @param z
* the z
*/ */
void generateChunk(int x, int z, PregenListener listener); void generateChunk(int x, int z, PregenListener listener);

View File

@@ -19,9 +19,7 @@
package com.volmit.iris.core.service; package com.volmit.iris.core.service;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.loader.IrisData; 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.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.board.BoardManager; import com.volmit.iris.util.board.BoardManager;
@@ -87,8 +85,7 @@ public class BoardSVC implements IrisService, BoardProvider {
} }
public void tick() { public void tick() {
if(!Iris.service(StudioSVC.class).isProjectOpen()) if(!Iris.service(StudioSVC.class).isProjectOpen()) {
{
return; return;
} }

View File

@@ -65,7 +65,8 @@ public class ObjectSVC implements IrisService {
/** /**
* Reverts all the block changes provided, 200 blocks per tick * 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) { private void revert(Map<Block, BlockData> blocks) {
int amount = 0; 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>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> * <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) @EventHandler(priority = EventPriority.HIGHEST)
public void on(StructureGrowEvent event) { 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 worldAccess
* @param location The location of the growth event (For biome/region finding) * The world to access (check for biome, region, dimension, etc)
* @param type The bukkit TreeType to match * @param location
* @param size The size of the sapling area * 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. * @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) { 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 * Filters out mismatches and returns matches
* *
* @param objects The object placements to check * @param objects
* @param size The size of the sapling area to filter with * The object placements to check
* @param type The type of the tree to filter with * @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. * @return A list of objectPlacements that matched. May be empty.
*/ */
private KList<IrisObjectPlacement> matchObjectPlacements(KList<IrisObjectPlacement> objects, IrisTreeSize size, TreeType type) { 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 * Get the Cuboid of sapling sizes at a location & blockData predicate
* *
* @param at this location * @param at
* @param valid with this blockData predicate * this location
* @param world the world to check in * @param valid
* with this blockData predicate
* @param world
* the world to check in
* @return A cuboid containing only saplings * @return A cuboid containing only saplings
*/ */
public Cuboid getSaplings(Location at, Predicate<BlockData> valid, World world) { 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 * Grows the blockPosition list by means of checking neighbours in
* *
* @param world the world to check in * @param world
* @param center the location of this position * the world to check in
* @param valid validation on blockData to check block with * @param center
* @param l list of block positions to add new neighbors too * 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) { 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 // 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 * 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 * @return The new object
*/ */
public static IrisObject createSchematic(ItemStack wand) { 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 * 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 * @return The new object
*/ */
public static Matter createMatterSchem(Player p, ItemStack wand) { 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 * Converts a user friendly location string to an actual Location
* *
* @param s The string * @param s
* The string
* @return The location * @return The location
*/ */
public static Location stringToLocation(String s) { public static Location stringToLocation(String s) {
@@ -137,7 +140,8 @@ public class WandSVC implements IrisService {
/** /**
* Get a user friendly string of a location * Get a user friendly string of a location
* *
* @param loc The location * @param loc
* The location
* @return The string * @return The string
*/ */
public static String locationToString(Location loc) { public static String locationToString(Location loc) {
@@ -178,7 +182,8 @@ public class WandSVC implements IrisService {
/** /**
* Finds an existing wand in a users inventory * 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 * @return The slot number the wand is in. Or -1 if none are found
*/ */
public static int findWand(Inventory inventory) { 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 * Creates an Iris wand. The locations should be the currently selected locations, or null
* *
* @param a Location A * @param a
* @param b Location B * Location A
* @param b
* Location B
* @return A new wand * @return A new wand
*/ */
public static ItemStack createWand(Location a, Location b) { 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 * 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 * @return An array with the 2 locations
*/ */
public static Location[] getCuboid(ItemStack is) { public static Location[] getCuboid(ItemStack is) {
@@ -233,7 +241,8 @@ public class WandSVC implements IrisService {
/** /**
* Is a player holding an Iris wand * Is a player holding an Iris wand
* *
* @param p The player * @param p
* The player
* @return True if they are * @return True if they are
*/ */
public static boolean isHoldingWand(Player p) { public static boolean isHoldingWand(Player p) {
@@ -244,7 +253,8 @@ public class WandSVC implements IrisService {
/** /**
* Is the itemstack passed an Iris wand * Is the itemstack passed an Iris wand
* *
* @param is The itemstack * @param is
* The itemstack
* @return True if it is * @return True if it is
*/ */
public static boolean isWand(ItemStack is) { public static boolean isWand(ItemStack is) {
@@ -291,8 +301,10 @@ public class WandSVC implements IrisService {
/** /**
* Draw the outline of a selected region * Draw the outline of a selected region
* *
* @param d The cuboid * @param d
* @param p The player to show it to * The cuboid
* @param p
* The player to show it to
*/ */
public void draw(Cuboid d, Player p) { public void draw(Cuboid d, Player p) {
draw(new Location[] {d.getLowerNE(), d.getUpperSW()}, 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 * Draw the outline of a selected region
* *
* @param d A pair of locations * @param d
* @param p The player to show them to * A pair of locations
* @param p
* The player to show them to
*/ */
public void draw(Location[] d, Player p) { public void draw(Location[] d, Player p) {
Vector gx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65); 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? * Is the player holding Dust?
* *
* @param p The player * @param p
* The player
* @return True if they are * @return True if they are
*/ */
public boolean isHoldingDust(Player p) { public boolean isHoldingDust(Player p) {
@@ -417,7 +432,8 @@ public class WandSVC implements IrisService {
/** /**
* Is the itemstack passed Iris dust? * Is the itemstack passed Iris dust?
* *
* @param is The itemstack * @param is
* The itemstack
* @return True if it is * @return True if it is
*/ */
public boolean isDust(ItemStack is) { public boolean isDust(ItemStack is) {
@@ -427,9 +443,12 @@ public class WandSVC implements IrisService {
/** /**
* Update the location on an Iris wand * Update the location on an Iris wand
* *
* @param left True for first location, false for second * @param left
* @param a The location * True for first location, false for second
* @param item The wand * @param a
* The location
* @param item
* The wand
* @return The updated wand * @return The updated wand
*/ */
public ItemStack update(boolean left, Location a, ItemStack item) { public ItemStack update(boolean left, Location a, ItemStack item) {

View File

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

View File

@@ -51,7 +51,8 @@ public class IrisToolbelt {
* - GithubUsername/repository * - GithubUsername/repository
* - GithubUsername/repository/branch * - 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 * @return the IrisDimension or null
*/ */
public static IrisDimension getDimension(String dimension) { 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) * 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 * @return true if it is an Iris Access world
*/ */
public static boolean isIrisWorld(World world) { public static boolean isIrisWorld(World world) {
@@ -103,7 +105,8 @@ public class IrisToolbelt {
/** /**
* Get the Iris generator for the given world * 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 * @return the IrisAccess or null if it's not an Iris World
*/ */
public static PlatformChunkGenerator access(World world) { public static PlatformChunkGenerator access(World world) {
@@ -117,8 +120,10 @@ public class IrisToolbelt {
/** /**
* Start a pregenerator task * Start a pregenerator task
* *
* @param task the scheduled task * @param task
* @param method the method to execute the task * the scheduled task
* @param method
* the method to execute the task
* @return the pregenerator job (already started) * @return the pregenerator job (already started)
*/ */
public static PregeneratorJob pregenerate(PregenTask task, PregeneratorMethod method, Engine engine) { 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, * Start a pregenerator task. If the supplied generator is headless, headless mode is used,
* otherwise Hybrid mode is used. * otherwise Hybrid mode is used.
* *
* @param task the scheduled task * @param task
* @param gen the Iris Generator * the scheduled task
* @param gen
* the Iris Generator
* @return the pregenerator job (already started) * @return the pregenerator job (already started)
*/ */
public static PregeneratorJob pregenerate(PregenTask task, PlatformChunkGenerator gen) { 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, * Start a pregenerator task. If the supplied generator is headless, headless mode is used,
* otherwise Hybrid mode is used. * otherwise Hybrid mode is used.
* *
* @param task the scheduled task * @param task
* @param world the World * the scheduled task
* @param world
* the World
* @return the pregenerator job (already started) * @return the pregenerator job (already started)
*/ */
public static PregeneratorJob pregenerate(PregenTask task, World world) { 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. * 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... * 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) { public static boolean evacuate(World world) {
for(World i : Bukkit.getWorlds()) { for(World i : Bukkit.getWorlds()) {
@@ -182,8 +192,10 @@ public class IrisToolbelt {
/** /**
* Evacuate all players from the world * Evacuate all players from the world
* *
* @param world the world to leave * @param world
* @param m the message * the world to leave
* @param m
* the message
* @return true if it was evacuated. * @return true if it was evacuated.
*/ */
public static boolean evacuate(World world, String m) { public static boolean evacuate(World world, String m) {

View File

@@ -25,29 +25,23 @@ public class EnginePanic {
private static final KMap<String, String> stuff = new KMap<>(); private static final KMap<String, String> stuff = new KMap<>();
private static KMap<String, String> last = 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); stuff.put(key, value);
} }
public static void saveLast() public static void saveLast() {
{
last = stuff.copy(); last = stuff.copy();
} }
public static void lastPanic() public static void lastPanic() {
{ for(String i : last.keySet()) {
for(String i : last.keySet())
{
Iris.error("Last Panic " + i + ": " + stuff.get(i)); Iris.error("Last Panic " + i + ": " + stuff.get(i));
} }
} }
public static void panic() public static void panic() {
{
lastPanic(); lastPanic();
for(String i : stuff.keySet()) for(String i : stuff.keySet()) {
{
Iris.error("Engine Panic " + i + ": " + stuff.get(i)); 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.SeedManager;
import com.volmit.iris.engine.framework.WrongEngineBroException; import com.volmit.iris.engine.framework.WrongEngineBroException;
import com.volmit.iris.engine.mantle.EngineMantle; 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.engine.scripting.EngineExecutionEnvironment;
import com.volmit.iris.util.atomics.AtomicRollingSequence; import com.volmit.iris.util.atomics.AtomicRollingSequence;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
@@ -488,6 +494,7 @@ public class IrisEngine implements Engine {
return getData().getRegionLoader().load(getDimension().getFocusRegion()); return getData().getRegionLoader().load(getDimension().getFocusRegion());
} }
@Override @Override
public void fail(String error, Throwable e) { public void fail(String error, Throwable e) {
failing = true; failing = true;

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.Engine;
import com.volmit.iris.engine.framework.EngineAssignedActuator; import com.volmit.iris.engine.framework.EngineAssignedActuator;
import com.volmit.iris.engine.object.IrisBiome; 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.engine.object.IrisRegion;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.documentation.BlockCoordinates; 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. * 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 x
* @param z the chunk z in blocks * the chunk x in blocks
* @param xf the current x slice * @param z
* @param h the blockdata * the chunk z in blocks
* @param xf
* the current x slice
* @param h
* the blockdata
*/ */
@BlockCoordinates @BlockCoordinates
public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h) { public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h) {

View File

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

View File

@@ -145,7 +145,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
@BlockCoordinates @BlockCoordinates
default void generate(int x, int z, TerrainChunk tc, boolean multicore) throws WrongEngineBroException { 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, tc.getMinHeight(), tc.getMaxHeight()), multicore); generate(x, z, Hunk.view(tc), Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight()), multicore);
} }
@BlockCoordinates @BlockCoordinates

View File

@@ -56,7 +56,7 @@ public class PregeneratedData {
}); });
if(postMod.get()) { 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 () -> { return () -> {

View File

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

View File

@@ -18,19 +18,11 @@
package com.volmit.iris.engine.object; 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.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.ProceduralStream;
import com.volmit.iris.util.stream.arithmetic.FittedStream;
import com.volmit.iris.util.stream.interpolation.Interpolated; import com.volmit.iris.util.stream.interpolation.Interpolated;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.*; import java.util.List;
public interface IRare { public interface IRare {
static <T extends IRare> ProceduralStream<T> stream(ProceduralStream<Double> noise, List<T> possibilities) { 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.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant; import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.data.cache.AtomicCache; 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.ArrayType;
import com.volmit.iris.engine.object.annotations.Desc; import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber; import com.volmit.iris.engine.object.annotations.MaxNumber;

View File

@@ -174,7 +174,8 @@ public enum IrisDirection {
* Get the directional value from the given byte from common directional blocks * Get the directional value from the given byte from common directional blocks
* (MUST BE BETWEEN 0 and 5 INCLUSIVE) * (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 * @return the direction or null if the byte is outside of the inclusive range
* 0-5 * 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.CNG;
import com.volmit.iris.util.noise.ExpressionNoise; import com.volmit.iris.util.noise.ExpressionNoise;
import com.volmit.iris.util.noise.ImageNoise; import com.volmit.iris.util.noise.ImageNoise;
import com.volmit.iris.util.stream.ProceduralStream;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.List;
@Snippet("style") @Snippet("style")
@Accessors(chain = true) @Accessors(chain = true)
@NoArgsConstructor @NoArgsConstructor
@@ -96,17 +93,13 @@ public class IrisGeneratorStyle {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier()); 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.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
} }
return cng; 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 cng = new CNG(rng, new ImageNoise(data, getImageMap()), 1D, 1).bake().scale(1D / zoom).pow(exponent).bake();
cng.setTrueFracturing(axialFracturing); cng.setTrueFracturing(axialFracturing);
@@ -114,8 +107,7 @@ public class IrisGeneratorStyle {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier()); 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.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()); 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.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
} }

View File

@@ -30,34 +30,28 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
public class IrisImage extends IrisRegistrant { public class IrisImage extends IrisRegistrant {
private BufferedImage image; private final BufferedImage image;
public int getWidth() public int getWidth() {
{
return image.getWidth(); return image.getWidth();
} }
public int getHeight() public int getHeight() {
{
return image.getHeight(); return image.getHeight();
} }
public int getRawValue(int x, int z) public int getRawValue(int x, int z) {
{ if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0) {
if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0)
{
return 0; return 0;
} }
return image.getRGB(x, z); 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); int color = getRawValue(x, z);
switch(channel) switch(channel) {
{
case RED -> { case RED -> {
return ((color >> 16) & 0xFF) / 255D; return ((color >> 16) & 0xFF) / 255D;
} }
@@ -105,13 +99,11 @@ public class IrisImage extends IrisRegistrant {
return color; return color;
} }
public IrisImage() public IrisImage() {
{
this(new BufferedImage(4, 4, BufferedImage.TYPE_INT_RGB)); this(new BufferedImage(4, 4, BufferedImage.TYPE_INT_RGB));
} }
public IrisImage(BufferedImage image) public IrisImage(BufferedImage image) {
{
this.image = image; this.image = image;
} }
@@ -136,10 +128,8 @@ public class IrisImage extends IrisRegistrant {
try { try {
File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName()); File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName());
BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
for(int i = 0; i < getWidth(); i++) for(int i = 0; i < getWidth(); i++) {
{ for(int j = 0; j < getHeight(); j++) {
for(int j = 0; j < getHeight(); j++)
{
b.setRGB(i, j, Color.getHSBColor(0, 0, (float) getValue(channel, i, j)).getRGB()); 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.Iris;
import com.volmit.iris.core.loader.IrisData; 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.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.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber; import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource; import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Snippet; 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.InterpolationMethod;
import com.volmit.iris.util.interpolation.IrisInterpolation; import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -72,19 +64,16 @@ public class IrisImageMap {
private transient AtomicCache<IrisImage> imageCache = new AtomicCache<IrisImage>(); 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)); IrisImage i = imageCache.aquire(() -> data.getImageLoader().load(image));
if(i == null) if(i == null) {
{
Iris.error("NULL IMAGE FOR " + image); Iris.error("NULL IMAGE FOR " + image);
} }
return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx, zz) -> rawNoise(i, xx, zz)); 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; x /= coordinateScale;
z /= coordinateScale; z /= coordinateScale;
x = isCentered() ? x + ((i.getWidth() / 2D) * coordinateScale) : x; 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 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)))); 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()); markers.put(i, j.getMarker());
max--; max--;
} }

View File

@@ -243,8 +243,10 @@ public class IrisObjectPlacement {
/** /**
* Gets the loot table that should be used for the block * Gets the loot table that should be used for the block
* *
* @param data The block data of the block * @param data
* @param dataManager Iris Data Manager * The block data of the block
* @param dataManager
* Iris Data Manager
* @return The loot table it should use. * @return The loot table it should use.
*/ */
public IrisLootTable getTable(BlockData data, IrisData dataManager) { 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.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache; 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.engine.object.annotations.Desc;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG; import com.volmit.iris.util.noise.CNG;
import jdk.jfr.Description;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;

View File

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

View File

@@ -45,7 +45,8 @@ public class IrisTreeSize {
/** /**
* Does the size match * 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) * @return true if it matches (fits within width and depth)
*/ */
public boolean doesMatch(IrisTreeSize size) { public boolean doesMatch(IrisTreeSize size) {

View File

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

View File

@@ -86,7 +86,7 @@ public class HeadlessGenerator implements PlatformChunkGenerator {
INMS.get().getTrueBiomeBaseId(biomeBase))) INMS.get().getTrueBiomeBaseId(biomeBase)))
.build(); .build();
getEngine().generate(x << 4, z << 4, getEngine().generate(x << 4, z << 4,
Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()), Hunk.view(tc), Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight()),
false); false);
chunk.cleanupPalettesAndBlockStates(); chunk.cleanupPalettesAndBlockStates();
} catch(Throwable e) { } catch(Throwable e) {

View File

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

View File

@@ -24,8 +24,10 @@ import java.io.Serializable;
/** /**
* A Biset * A Biset
* *
* @param <A> the first object type * @param <A>
* @param <B> the second object type * the first object type
* @param <B>
* the second object type
* @author cyberpwn * @author cyberpwn
*/ */
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
@@ -37,8 +39,10 @@ public class GBiset<A, B> implements Serializable {
/** /**
* Create a new Biset * Create a new Biset
* *
* @param a the first object * @param a
* @param b the second object * the first object
* @param b
* the second object
*/ */
public GBiset(A a, B b) { public GBiset(A a, B b) {
this.a = a; this.a = a;
@@ -57,7 +61,8 @@ public class GBiset<A, B> implements Serializable {
/** /**
* Set the first object * Set the first object
* *
* @param a the first object A * @param a
* the first object A
*/ */
public void setA(A a) { public void setA(A a) {
this.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 * Adapts a list of objects into a list of other objects
* *
* @param <FROM> the from object in lists (the item INSIDE the list) * @param <FROM>
* @param <TO> the to object in lists (the item INSIDE the list) * the from object in lists (the item INSIDE the list)
* @param <TO>
* the to object in lists (the item INSIDE the list)
* @author cyberpwn * @author cyberpwn
*/ */
public abstract class GListAdapter<FROM, TO> { public abstract class GListAdapter<FROM, TO> {
/** /**
* Adapts a list of FROM to a list of 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 * @return the to list
*/ */
public List<TO> adapt(List<FROM> from) { 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 * 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 * @return the to object
*/ */
public abstract TO onAdapt(FROM from); 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 * returned map. You must specify each key for each value in this list. In the
* function, returning null will not add the keyval pair. * function, returning null will not add the keyval pair.
* *
* @param <K> the inferred key type * @param <K>
* @param f the function * the inferred key type
* @param f
* the function
* @return the new map * @return the new map
*/ */
public <K> KMap<K, T> asValues(Function<T, K> f) { 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 * returned map. You must specify each value for each key in this list. In the
* function, returning null will not add the keyval pair. * function, returning null will not add the keyval pair.
* *
* @param <V> the inferred value type * @param <V>
* @param f the function * the inferred value type
* @param f
* the function
* @return the new map * @return the new map
*/ */
public <V> KMap<T, V> asKeys(Function<T, V> f) { 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 * 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 * @return the list of sublists
*/ */
public KList<KList<T>> divide(int targetCount) { 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 * Split this list into a list of sublists with roughly targetSize elements of T
* per sublist * per sublist
* *
* @param targetSize the target size * @param targetSize
* the target size
* @return the list of sublists * @return the list of sublists
*/ */
public KList<KList<T>> split(int targetSize) { 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). * Rewrite this list by checking each value and changing the value (or not).
* Return null to remove the element in the function * Return null to remove the element in the function
* *
* @param t the function * @param t
* the function
* @return the same list (not a copy) * @return the same list (not a copy)
*/ */
public KList<T> rewrite(Function<T, T> t) { 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 * Tostring with a seperator for each item in the list
* *
* @param split the seperator * @param split
* the seperator
* @return the string representing this object * @return the string representing this object
*/ */
public String toString(String split) { 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 * Add the contents of the given list (v) into this list using a converter
* *
* @param <V> the type of the forign list * @param <V>
* @param v the forign (given) list * the type of the forign list
* @param converter the converter that converts the forign type into this list type * @param v
* the forign (given) list
* @param converter
* the converter that converts the forign type into this list type
* @return this list (builder) * @return this list (builder)
*/ */
public <V> KList<T> addFrom(List<V> v, Function<V, T> converter) { 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 * Convert this list into another list type. Such as GList<Integer> to
* GList<String>. list.convert((i) -> "" + i); * GList<String>. list.convert((i) -> "" + i);
*
* @param <V>
* @param converter
* @return
*/ */
public <V> KList<V> convert(Function<T, V> converter) { public <V> KList<V> convert(Function<T, V> converter) {
KList<V> v = new KList<V>(); 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 * Adds T to the list, ignores if null
* *
* @param t the value to add * @param t
* the value to add
* @return the same list * @return the same list
*/ */
public KList<T> addNonNull(T t) { 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, * Swaps the values of index a and b. For example "hello", "world", "!" swap(1,
* 2) would change the list to "hello", "!", "world" * 2) would change the list to "hello", "!", "world"
* *
* @param a the first index * @param a
* @param b the second index * the first index
* @param b
* the second index
* @return the same list (builder), not a copy * @return the same list (builder), not a copy
*/ */
public KList<T> swapIndexes(int a, int b) { 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 * Remove a number of elements from the list
* *
* @param t the elements * @param t
* the elements
* @return this list * @return this list
*/ */
@SuppressWarnings("unchecked") @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) * Add another glist's contents to this one (addall builder)
* *
* @param t the list * @param t
* the list
* @return the same list * @return the same list
*/ */
public KList<T> add(KList<T> t) { 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 * Add a number of values to this list
* *
* @param t the list * @param t
* the list
* @return this list * @return this list
*/ */
@SuppressWarnings("unchecked") @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 * 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 * @return true if size > index
*/ */
public boolean hasIndex(int 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, * Puts a value into a map-value-list based on the key such that if GMap<K,
* GList<S>> where V is GList<S> * GList<S>> where V is GList<S>
* *
* @param <S> the list type in the value type * @param <S>
* @param k the key to look for * the list type in the value type
* @param vs the values to put into the list of the given key * @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) * @return the same list (builder)
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -143,7 +146,8 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
/** /**
* Put another map's values into this map * Put another map's values into this map
* *
* @param m the map to insert * @param m
* the map to insert
* @return this map (builder) * @return this map (builder)
*/ */
public KMap<K, V> put(Map<K, V> m) { 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 * Loop through each keyvalue set (copy of it) with the map parameter
* *
* @param f the function * @param f
* the function
* @return the same gmap * @return the same gmap
*/ */
public KMap<K, V> rewrite(Consumer3<K, V, KMap<K, V>> f) { 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) * Loop through each keyvalue set (copy of it)
* *
* @param f the function * @param f
* the function
* @return the same gmap * @return the same gmap
*/ */
public KMap<K, V> each(Consumer2<K, V> f) { 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) * Still works as it normally should except it returns itself (builder)
* *
* @param key the key * @param key
* @param value the value (single only supported) * the key
* @return * @param value
* the value (single only supported)
*/ */
public KMap<K, V> qput(K key, V value) { public KMap<K, V> qput(K key, V value) {
super.put(key, 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 * Works just like put, except it wont put anything unless the key and value are
* nonnull * nonnull
* *
* @param key the nonnull key * @param key
* @param value the nonnull value * the nonnull key
* @param value
* the nonnull value
* @return the same map * @return the same map
*/ */
public KMap<K, V> putNonNull(K key, V value) { public KMap<K, V> putNonNull(K key, V value) {

View File

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

View File

@@ -38,7 +38,6 @@ import org.bukkit.block.data.type.PointedDripstone;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; 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 * Construct a Cuboid given two Location objects which represent any two corners
* of the Cuboid. * of the Cuboid.
* *
* @param l1 one of the corners * @param l1
* @param l2 the other corner * one of the corners
* @param l2
* the other corner
*/ */
public Cuboid(Location l1, Location l2) { public Cuboid(Location l1, Location l2) {
if(!l1.getWorld().equals(l2.getWorld())) { 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. * 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) { public Cuboid(Location l1) {
this(l1, l1); this(l1, l1);
@@ -78,7 +81,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/** /**
* Copy constructor. * Copy constructor.
* *
* @param other the Cuboid to copy * @param other
* the Cuboid to copy
*/ */
public Cuboid(Cuboid other) { public Cuboid(Cuboid other) {
this(other.getWorld().getName(), other.x1, other.y1, other.z1, other.x2, other.y2, other.z2); 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 * Construct a Cuboid in the given World and xyz co-ordinates
* *
* @param world the Cuboid's world * @param world
* @param x1 X co-ordinate of corner 1 * the Cuboid's world
* @param y1 Y co-ordinate of corner 1 * @param x1
* @param z1 Z co-ordinate of corner 1 * X co-ordinate of corner 1
* @param x2 X co-ordinate of corner 2 * @param y1
* @param y2 Y co-ordinate of corner 2 * Y co-ordinate of corner 1
* @param z2 Z co-ordinate of corner 2 * @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) { public Cuboid(World world, int x1, int y1, int z1, int x2, int y2, int z2) {
this.worldName = world.getName(); 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. * Construct a Cuboid in the given world name and xyz co-ordinates.
* *
* @param worldName the Cuboid's world name * @param worldName
* @param x1 X co-ordinate of corner 1 * the Cuboid's world name
* @param y1 Y co-ordinate of corner 1 * @param x1
* @param z1 Z co-ordinate of corner 1 * X co-ordinate of corner 1
* @param x2 X co-ordinate of corner 2 * @param y1
* @param y2 Y co-ordinate of corner 2 * Y co-ordinate of corner 1
* @param z2 Z co-ordinate of corner 2 * @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) { private Cuboid(String worldName, int x1, int y1, int z1, int x2, int y2, int z2) {
this.worldName = worldName; this.worldName = worldName;
@@ -153,8 +171,10 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
/** /**
* Set the locations * Set the locations
* *
* @param l1 a * @param l1
* @param l2 b * a
* @param l2
* b
*/ */
public void set(Location l1, Location l2) { public void set(Location l1, Location l2) {
x1 = Math.min(l1.getBlockX(), l2.getBlockX()); x1 = Math.min(l1.getBlockX(), l2.getBlockX());
@@ -218,7 +238,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* Get the Cuboid's world. * Get the Cuboid's world.
* *
* @return the World object representing this 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() { public World getWorld() {
World world = Bukkit.getWorld(worldName); 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 * 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. * face past the opposite face is not an error and will return a valid Cuboid.
* *
* @param dir the direction in which to expand * @param dir
* @param amount the number of blocks by which to expand * 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 * @return a new Cuboid expanded by the given direction and amount
*/ */
public Cuboid expand(CuboidDirection dir, int 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. * Shift the Cuboid in the given direction by the given amount.
* *
* @param dir the direction in which to shift * @param dir
* @param amount the number of blocks by which to shift * 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 * @return a new Cuboid shifted by the given direction and amount
*/ */
public Cuboid shift(CuboidDirection dir, int 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. * 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) * 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 * @return a new Cuboid outset by the given direction and amount
*/ */
public Cuboid outset(CuboidDirection dir, int 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. * Inset (shrink) the Cuboid in the given direction by the given amount.
* Equivalent to calling outset() with a negative 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) * 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 * @return a new Cuboid inset by the given direction and amount
*/ */
public Cuboid inset(CuboidDirection dir, int 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. * Return true if the point at (x,y,z) is contained within this Cuboid.
* *
* @param x the X co-ordinate * @param x
* @param y the Y co-ordinate * the X co-ordinate
* @param z the Z 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 * @return true if the given point is within this Cuboid, false otherwise
*/ */
public boolean contains(int x, int y, int z) { 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. * 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 * @return true if the Block is within this Cuboid, false otherwise
*/ */
public boolean contains(Block b) { 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. * 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 * @return true if the Location is within this Cuboid, false otherwise
*/ */
public boolean contains(Location l) { 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 * no exterior empty space. E.g. a direction of Down will push the top face
* downwards as much as possible. * 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 * @return a new Cuboid contracted in the given direction
*/ */
public Cuboid contract(CuboidDirection dir) { 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 * 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. * 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 * @return the Cuboid representing this Cuboid's requested face
*/ */
public Cuboid getFace(CuboidDirection dir) { 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 * 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 * @return true if this Cuboid contains only blocks of the given type
*/ */
public boolean containsOnly(Material material) { 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. * 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 * @return a new Cuboid large enough to hold this Cuboid and the given Cuboid
*/ */
public Cuboid getBoundingCuboid(Cuboid other) { 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. * Get a block relative to the lower NE point of the Cuboid.
* *
* @param x the X co-ordinate * @param x
* @param y the Y co-ordinate * the X co-ordinate
* @param z the Z co-ordinate * @param y
* the Y co-ordinate
* @param z
* the Z co-ordinate
* @return the block at the given position * @return the block at the given position
*/ */
public Block getRelativeBlock(int x, int y, int z) { 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, * This version of getRelativeBlock() should be used if being called many times,
* to avoid excessive calls to getWorld(). * to avoid excessive calls to getWorld().
* *
* @param w the World * @param w
* @param x the X co-ordinate * the World
* @param y the Y co-ordinate * @param x
* @param z the Z co-ordinate * the X co-ordinate
* @param y
* the Y co-ordinate
* @param z
* the Z co-ordinate
* @return the block at the given position * @return the block at the given position
*/ */
public Block getRelativeBlock(World w, int x, int y, int z) { public Block getRelativeBlock(World w, int x, int y, int z) {

View File

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

View File

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

View File

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

View File

@@ -44,9 +44,12 @@ public final class Varint {
* encode signed values. If values are known to be nonnegative, * encode signed values. If values are known to be nonnegative,
* {@link #writeUnsignedVarLong(long, DataOutput)} should be used. * {@link #writeUnsignedVarLong(long, DataOutput)} should be used.
* *
* @param value value to encode * @param value
* @param out to writeNodeData bytes to * value to encode
* @throws IOException if {@link DataOutput} throws {@link IOException} * @param out
* to writeNodeData bytes to
* @throws IOException
* if {@link DataOutput} throws {@link IOException}
*/ */
public static void writeSignedVarLong(long value, DataOutput out) throws IOException { public static void writeSignedVarLong(long value, DataOutput out) throws IOException {
// Great trick from http://code.google.com/apis/protocolbuffers/docs/encoding.html#types // 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)} * If values can be negative, use {@link #writeSignedVarLong(long, DataOutput)}
* instead. This method treats negative input as like a large unsigned value. * instead. This method treats negative input as like a large unsigned value.
* *
* @param value value to encode * @param value
* @param out to writeNodeData bytes to * value to encode
* @throws IOException if {@link DataOutput} throws {@link IOException} * @param out
* to writeNodeData bytes to
* @throws IOException
* if {@link DataOutput} throws {@link IOException}
*/ */
public static void writeUnsignedVarLong(long value, DataOutput out) throws IOException { public static void writeUnsignedVarLong(long value, DataOutput out) throws IOException {
while((value & 0xFFFFFFFFFFFFFF80L) != 0L) { 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 * @return decode value
* @throws IOException if {@link DataInput} throws {@link IOException} * @throws IOException
* @throws IllegalArgumentException if variable-length value does not terminate * if {@link DataInput} throws {@link IOException}
* @throws IllegalArgumentException
* if variable-length value does not terminate
* after 9 bytes have been read * after 9 bytes have been read
* @see #writeSignedVarLong(long, DataOutput) * @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 * @return decode value
* @throws IOException if {@link DataInput} throws {@link IOException} * @throws IOException
* @throws IllegalArgumentException if variable-length value does not terminate * if {@link DataInput} throws {@link IOException}
* @throws IllegalArgumentException
* if variable-length value does not terminate
* after 9 bytes have been read * after 9 bytes have been read
* @see #writeUnsignedVarLong(long, DataOutput) * @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 * 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) * @see #readSignedVarLong(DataInput)
*/ */
public static int readSignedVarInt(DataInput in) throws IOException { 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 * 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) * @see #readUnsignedVarLong(DataInput)
*/ */
public static int readUnsignedVarInt(DataInput in) throws IOException { 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 * 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 * @return True if valid for origin
*/ */
public boolean validFor(VolmitSender sender) { 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) * 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 * @return The resulting string
*/ */
String toString(T t); 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)} * 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. * @return The resulting string.
*/ */
default String toStringForce(Object t) { default String toStringForce(Object t) {
@@ -56,9 +58,11 @@ public interface DecreeParameterHandler<T> {
/** /**
* Should parse a String into the designated type * 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 * @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 { default T parse(String in) throws DecreeParsingException {
return parse(in, false); 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 * Should parse a String into the designated type. You can force it to not throw a whichexception
* *
* @param in The string to parse * @param in
* @param force force an option instead of throwing decreewhich * The string to parse
* @param force
* force an option instead of throwing decreewhich
* @return The value extracted from the string, of the designated type * @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; T parse(String in, boolean force) throws DecreeParsingException;
/** /**
* Returns whether a certain type is supported by this handler<br> * 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 * @return True if supported, false if not
*/ */
boolean supports(Class<?> type); 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) * 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 * @return A {@link KList} of possibilities
*/ */
default KList<T> getPossibilities(String input) { 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 * 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 * @return The corresponding {@link DecreeParameterHandler}, or null
*/ */
static DecreeParameterHandler<?> getHandler(Class<?> type) { static DecreeParameterHandler<?> getHandler(Class<?> type) {
@@ -128,8 +129,6 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
/** /**
* The root class to start command searching from * The root class to start command searching from
*
* @return
*/ */
VirtualDecreeCommand getRoot(); VirtualDecreeCommand getRoot();

View File

@@ -63,7 +63,8 @@ public @interface Decree {
DecreeOrigin origin() default DecreeOrigin.BOTH; 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> * 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. * 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 ""; 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> * 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. * 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.Iris;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.object.IrisCave; 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.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.decree.DecreeParameterHandler; import com.volmit.iris.util.decree.DecreeParameterHandler;
@@ -65,7 +63,8 @@ public class CaveHandler implements DecreeParameterHandler<IrisCave> {
if(options.isEmpty()) { if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Cave \"" + in + "\""); throw new DecreeParsingException("Unable to find Cave \"" + in + "\"");
}try { }
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) { } catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Cave\"" + in + "\""); throw new DecreeParsingException("Unable to filter which Cave\"" + in + "\"");

View File

@@ -60,7 +60,8 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
if(options.isEmpty()) { if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\""); throw new DecreeParsingException("Unable to find Dimension \"" + in + "\"");
} try { }
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) { } catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); 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) * 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 * @return The resulting string
*/ */
@Override @Override
@@ -69,9 +70,11 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
/** /**
* Should parse a String into the designated type * 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 * @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 @Override
public IrisEntity parse(String in, boolean force) throws DecreeParsingException { public IrisEntity parse(String in, boolean force) throws DecreeParsingException {
@@ -79,7 +82,8 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
if(options.isEmpty()) { if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Entity \"" + in + "\""); throw new DecreeParsingException("Unable to find Entity \"" + in + "\"");
} try { }
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) { } catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); 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> * 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 * @return True if supported, false if not
*/ */
@Override @Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -54,7 +54,8 @@ public class ObjectHandler implements DecreeParameterHandler<String> {
if(options.isEmpty()) { if(options.isEmpty()) {
throw new DecreeParsingException("Unable to find Object \"" + in + "\""); throw new DecreeParsingException("Unable to find Object \"" + in + "\"");
} try { }
try {
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
} catch(Throwable e) { } catch(Throwable e) {
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); 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.Iris;
import com.volmit.iris.core.IrisSettings; 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.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet; 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.DecreeContextHandler;
import com.volmit.iris.util.decree.DecreeNode; import com.volmit.iris.util.decree.DecreeNode;
import com.volmit.iris.util.decree.DecreeParameter; 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.annotations.Decree;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException; import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.format.C; 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.ChronoLatch;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import lombok.Data; import lombok.Data;
import org.bukkit.Sound;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Objects; 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; import java.util.stream.Collectors;
@Data @Data
@@ -289,8 +281,11 @@ public class VirtualDecreeCommand {
/** /**
* Maps the input a player typed to the parameters of this command * 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 * @return A map of all the parameter names and their values
*/ */
private KMap<String, Object> map(VolmitSender sender, KList<String> in) { 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 * 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 * @return Associative {@link org.bukkit.ChatColor} with the given code, or null
* if it doesn't exist * if it doesn't exist
*/ */
@@ -443,7 +444,8 @@ public enum C {
/** /**
* Gets the color represented by the specified color code * 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 * @return Associative {@link org.bukkit.ChatColor} with the given code, or null
* if it doesn't exist * if it doesn't exist
*/ */
@@ -462,7 +464,8 @@ public enum C {
/** /**
* Strips the given message of all color codes * 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 * @return A copy of the input string, without any coloring
*/ */
public static String stripColor(final String input) { public static String stripColor(final String input) {
@@ -476,7 +479,8 @@ public enum C {
/** /**
* DyeColor to ChatColor * DyeColor to ChatColor
* *
* @param dclr the dye color * @param dclr
* the dye color
* @return the color * @return the color
*/ */
public static C dyeToChat(DyeColor dclr) { 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 * 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. * 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 altColorChar
* @param textToTranslate Text containing the alternate color code character. * 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. * @return Text containing the ChatColor.COLOR_CODE color code character.
*/ */
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) { 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. * 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. * @return Any remaining ChatColors to pass onto the next line.
*/ */
public static String getLastColors(String input) { public static String getLastColors(String input) {

View File

@@ -73,9 +73,12 @@ public class Form {
/** /**
* Scroll text * Scroll text
* *
* @param smx the text * @param smx
* @param viewport the viewport length * the text
* @param time the timeline value * @param viewport
* the viewport length
* @param time
* the timeline value
*/ */
public static String scroll(String smx, int viewport, long time) { public static String scroll(String smx, int viewport, long time) {
String src = Form.repeat(" ", viewport) + smx + Form.repeat(" ", viewport); String src = Form.repeat(" ", viewport) + smx + Form.repeat(" ", viewport);
@@ -90,7 +93,8 @@ public class Form {
/** /**
* Capitalize the first letter * Capitalize the first letter
* *
* @param s the string * @param s
* the string
* @return the capitalized string * @return the capitalized string
*/ */
public static String capitalize(String s) { public static String capitalize(String s) {
@@ -112,7 +116,8 @@ public class Form {
/** /**
* Capitalize all words in the string * Capitalize all words in the string
* *
* @param s the string * @param s
* the string
* @return the capitalized string * @return the capitalized string
*/ */
public static String capitalizeWords(String s) { public static String capitalizeWords(String s) {
@@ -128,8 +133,10 @@ public class Form {
/** /**
* Hard word wrap * Hard word wrap
* *
* @param s the words * @param s
* @param len the length per line * the words
* @param len
* the length per line
* @return the wrapped string * @return the wrapped string
*/ */
public static String wrap(String s, int len) { public static String wrap(String s, int len) {
@@ -139,8 +146,10 @@ public class Form {
/** /**
* Soft Word wrap * Soft Word wrap
* *
* @param s the string * @param s
* @param len the length to wrap * the string
* @param len
* the length to wrap
* @return the wrapped string * @return the wrapped string
*/ */
public static String wrapWords(String s, int len) { public static String wrapWords(String s, int len) {
@@ -150,10 +159,14 @@ public class Form {
/** /**
* Wrap words * Wrap words
* *
* @param s the string * @param s
* @param len the wrap length * the string
* @param newLineSep the new line seperator * @param len
* @param soft should it be soft wrapped or hard wrapped? * the wrap length
* @param newLineSep
* the new line seperator
* @param soft
* should it be soft wrapped or hard wrapped?
* @return the wrapped words * @return the wrapped words
*/ */
public static String wrap(String s, int len, String newLineSep, boolean soft) { 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) { public static String hardWrap(String s, int len) {
StringBuilder ss = new StringBuilder(); StringBuilder ss = new StringBuilder();
for(int i = 0; i < s.length(); i+= len) for(int i = 0; i < s.length(); i += len) {
{ if(i + len > s.length()) {
if(i + len > s.length())
{
ss.append(s, i, s.length()); ss.append(s, i, s.length());
break; break;
} }
@@ -179,10 +190,8 @@ public class Form {
public static List<String> hardWrapList(String s, int len) { public static List<String> hardWrapList(String s, int len) {
List<String> l = new ArrayList<>(); List<String> l = new ArrayList<>();
for(int i = 0; i < s.length(); i+= len) for(int i = 0; i < s.length(); i += len) {
{ if(i + len > s.length()) {
if(i + len > s.length())
{
l.add(s.substring(i)); l.add(s.substring(i));
break; break;
} }
@@ -197,11 +206,16 @@ public class Form {
/** /**
* Wrap words * Wrap words
* *
* @param s the string * @param s
* @param len the length * the string
* @param newLineSep the new line seperator * @param len
* @param soft soft or hard wrapping * the length
* @param regex the regex * @param newLineSep
* the new line seperator
* @param soft
* soft or hard wrapping
* @param regex
* the regex
* @return the wrapped string * @return the wrapped string
*/ */
public static String wrap(String s, int len, String newLineSep, boolean soft, String regex) { 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 * Returns a fancy duration up to Years
* *
* @param duration the duration in ms * @param duration
* the duration in ms
* @return the fancy duration * @return the fancy duration
*/ */
public static String duration(RollingSequence rollingSequence, long duration) { public static String duration(RollingSequence rollingSequence, long duration) {
@@ -345,7 +360,8 @@ public class Form {
/** /**
* Fixes the minute issue with formatting * Fixes the minute issue with formatting
* *
* @param c the calendar * @param c
* the calendar
* @return the minute string * @return the minute string
*/ */
public static String fmin(Calendar c) { public static String fmin(Calendar c) {
@@ -360,7 +376,8 @@ public class Form {
/** /**
* Get a fancy time stamp * 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) * @return the fancy stamp in time (ago)
*/ */
public static String ago(long time) { public static String ago(long time) {
@@ -473,7 +490,8 @@ public class Form {
/** /**
* Get the suffix for a number i.e. 1st 2nd 3rd * Get the suffix for a number i.e. 1st 2nd 3rd
* *
* @param i the number * @param i
* the number
* @return the suffix * @return the suffix
*/ */
public static String numberSuffix(int i) { 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 * Get a high accuracy but limited range duration (accurate up to a couple
* minutes) * minutes)
* *
* @param ms the milliseconds (double) * @param ms
* @param prec the precision (decimal format) * the milliseconds (double)
* @param prec
* the precision (decimal format)
* @return the formatted string * @return the formatted string
*/ */
public static String duration(double ms, int prec) { public static String duration(double ms, int prec) {
@@ -523,8 +543,10 @@ public class Form {
/** /**
* Get a duration from milliseconds up to days * Get a duration from milliseconds up to days
* *
* @param ms the ms * @param ms
* @param prec the precision (decimal format) * the ms
* @param prec
* the precision (decimal format)
* @return the formatted string * @return the formatted string
*/ */
public static String duration(long ms, int prec) { public static String duration(long ms, int prec) {
@@ -554,7 +576,8 @@ public class Form {
/** /**
* Format a big value * Format a big value
* *
* @param i the number * @param i
* the number
* @return the full value in string * @return the full value in string
*/ */
public static String b(int i) { public static String b(int i) {
@@ -564,7 +587,8 @@ public class Form {
/** /**
* Format a big value * Format a big value
* *
* @param i the number * @param i
* the number
* @return the full value in string * @return the full value in string
*/ */
public static String b(long i) { public static String b(long i) {
@@ -574,7 +598,8 @@ public class Form {
/** /**
* Format a big value * Format a big value
* *
* @param i the number * @param i
* the number
* @return the full value in string * @return the full value in string
*/ */
public static String b(double i) { public static String b(double i) {
@@ -584,7 +609,8 @@ public class Form {
/** /**
* Format a big number * Format a big number
* *
* @param number the big number * @param number
* the big number
* @return the value in string * @return the value in string
*/ */
public static String b(BigInteger number) { 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, * Calculate a fancy string representation of a file size. Adds a suffix of B,
* KB, MB, GB, or TB * KB, MB, GB, or TB
* *
* @param s the size (in bytes) * @param s
* the size (in bytes)
* @return the string * @return the string
*/ */
public static String fileSize(long s) { public static String fileSize(long s) {
@@ -620,8 +647,10 @@ public class Form {
/** /**
* ":", "a", "b", "c" -> a:b:c * ":", "a", "b", "c" -> a:b:c
* *
* @param splitter the splitter that goes in between * @param splitter
* @param strings the strings * the splitter that goes in between
* @param strings
* the strings
* @return the result * @return the result
*/ */
public static String split(String splitter, String... strings) { 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, * Calculate a fancy string representation of a file size. Adds a suffix of B,
* KB, MB, GB, or TB * KB, MB, GB, or TB
* *
* @param s the size (in bytes) * @param s
* the size (in bytes)
* @return the string * @return the string
*/ */
public static String memSize(long s) { public static String memSize(long s) {
@@ -653,7 +683,8 @@ public class Form {
/** /**
* Get the timestamp of the time t (ms since 1970) * Get the timestamp of the time t (ms since 1970)
* *
* @param t the time * @param t
* the time
* @return the stamp * @return the stamp
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@@ -688,8 +719,10 @@ public class Form {
* with a special divisor. The divisor decides how much goes up in the suffix * with a special divisor. The divisor decides how much goes up in the suffix
* chain. * chain.
* *
* @param s the size (in bytes) * @param s
* @param div the divisor * the size (in bytes)
* @param div
* the divisor
* @return the string * @return the string
*/ */
public static String ofSize(long s, int div) { 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 * with a special divisor. The divisor decides how much goes up in the suffix
* chain. * chain.
* *
* @param s the size (in bytes) * @param s
* @param div the divisor * the size (in bytes)
* @param dec the decimal places * @param div
* the divisor
* @param dec
* the decimal places
* @return the string * @return the string
*/ */
public static String ofSize(long s, int div, int dec) { 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 * with a special divisor. The divisor decides how much goes up in the suffix
* chain. * chain.
* *
* @param s the size (in bytes) * @param s
* @param div the divisor * the size (in bytes)
* @param dec the decimal places * @param div
* the divisor
* @param dec
* the decimal places
* @return the string * @return the string
*/ */
public static String ofSizeMetricWeight(long s, int div, int dec) { 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 * Trim a string to a length, then append ... at the end if it extends the limit
* *
* @param s the string * @param s
* @param l the limit * the string
* @param l
* the limit
* @return the modified string * @return the modified string
*/ */
public static String trim(String s, int l) { 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, * Get a class name into a configuration/filename key For example,
* PhantomController.class is converted to phantom-controller * PhantomController.class is converted to phantom-controller
* *
* @param clazz the class * @param clazz
* the class
* @return the string representation * @return the string representation
*/ */
public static String cname(String clazz) { public static String cname(String clazz) {
@@ -844,7 +886,8 @@ public class Form {
/** /**
* Get a formatted representation of the memory given in megabytes * Get a formatted representation of the memory given in megabytes
* *
* @param mb the megabytes * @param mb
* the megabytes
* @return the string representation with suffixes * @return the string representation with suffixes
*/ */
public static String mem(long mb) { public static String mem(long mb) {
@@ -879,7 +922,8 @@ public class Form {
/** /**
* Format a long. Changes -10334 into -10,334 * Format a long. Changes -10334 into -10,334
* *
* @param i the number * @param i
* the number
* @return the string representation of the number * @return the string representation of the number
*/ */
public static String f(long i) { public static String f(long i) {
@@ -890,7 +934,8 @@ public class Form {
/** /**
* Format a number. Changes -10334 into -10,334 * Format a number. Changes -10334 into -10,334
* *
* @param i the number * @param i
* the number
* @return the string representation of the number * @return the string representation of the number
*/ */
public static String f(int i) { public static String f(int i) {
@@ -901,8 +946,10 @@ public class Form {
/** /**
* Formats a double's decimals to a limit * Formats a double's decimals to a limit
* *
* @param i the double * @param i
* @param p the number of decimal places to use * the double
* @param p
* the number of decimal places to use
* @return the formated string * @return the formated string
*/ */
public static String f(double i, int p) { 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 * decimal places that dont need to be placed down. 2.4343 formatted with 6
* decimals gets returned as 2.434300 * decimals gets returned as 2.434300
* *
* @param i the double * @param i
* @param p the number of decimal places to use * the double
* @param p
* the number of decimal places to use
* @return the formated string * @return the formated string
*/ */
public static String fd(double i, int p) { public static String fd(double i, int p) {
@@ -941,8 +990,10 @@ public class Form {
/** /**
* Formats a float's decimals to a limit * Formats a float's decimals to a limit
* *
* @param i the float * @param i
* @param p the number of decimal places to use * the float
* @param p
* the number of decimal places to use
* @return the formated string * @return the formated string
*/ */
public static String f(float i, int p) { public static String f(float i, int p) {
@@ -960,7 +1011,8 @@ public class Form {
/** /**
* Formats a double's decimals (one decimal point) * Formats a double's decimals (one decimal point)
* *
* @param i the double * @param i
* the double
*/ */
public static String f(double i) { public static String f(double i) {
return f(i, 1); return f(i, 1);
@@ -969,7 +1021,8 @@ public class Form {
/** /**
* Formats a float's decimals (one decimal point) * Formats a float's decimals (one decimal point)
* *
* @param i the float * @param i
* the float
*/ */
public static String f(float i) { public static String f(float i) {
return f(i, 1); return f(i, 1);
@@ -979,8 +1032,10 @@ public class Form {
* Get a percent representation of a double and decimal places (0.53) would * Get a percent representation of a double and decimal places (0.53) would
* return 53% * return 53%
* *
* @param i the double * @param i
* @param p the number of decimal points * the double
* @param p
* the number of decimal points
* @return a string * @return a string
*/ */
public static String pc(double i, int p) { 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 * Get a percent representation of a float and decimal places (0.53) would
* return 53% * return 53%
* *
* @param i the float * @param i
* @param p the number of decimal points * the float
* @param p
* the number of decimal points
* @return a string * @return a string
*/ */
public static String pc(float i, int p) { 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 * Get a percent representation of a double and zero decimal places (0.53) would
* return 53% * return 53%
* *
* @param i the double * @param i
* the double
* @return a string * @return a string
*/ */
public static String pc(double i) { 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 * Get a percent representation of a float and zero decimal places (0.53) would
* return 53% * return 53%
* *
* @param i the double * @param i
* the double
* @return a string * @return a string
*/ */
public static String pc(float i) { 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 * Get a percent as the percent of i out of "of" with custom decimal places
* *
* @param i the percent out of * @param i
* @param of of of * the percent out of
* @param p the decimal places * @param of
* of of
* @param p
* the decimal places
* @return the string * @return the string
*/ */
public static String pc(int i, int of, int p) { 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" * Get a percent as the percent of i out of "of"
* *
* @param i the percent out of * @param i
* @param of of of * the percent out of
* @param of
* of of
* @return the string * @return the string
*/ */
public static String pc(int i, int of) { 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 * Get a percent as the percent of i out of "of" with custom decimal places
* *
* @param i the percent out of * @param i
* @param of of of * the percent out of
* @param p the decimal places * @param of
* of of
* @param p
* the decimal places
* @return the string * @return the string
*/ */
public static String pc(long i, long of, int p) { 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" * Get a percent as the percent of i out of "of"
* *
* @param i the percent out of * @param i
* @param of of of * the percent out of
* @param of
* of of
* @return the string * @return the string
*/ */
public static String pc(long i, long of) { public static String pc(long i, long of) {
@@ -1070,7 +1139,8 @@ public class Form {
/** /**
* Milliseconds to seconds (double) * Milliseconds to seconds (double)
* *
* @param ms the milliseconds * @param ms
* the milliseconds
* @return a formatted string to milliseconds * @return a formatted string to milliseconds
*/ */
public static String msSeconds(long ms) { public static String msSeconds(long ms) {
@@ -1080,8 +1150,10 @@ public class Form {
/** /**
* Milliseconds to seconds (double) custom decimals * Milliseconds to seconds (double) custom decimals
* *
* @param ms the milliseconds * @param ms
* @param p number of decimal points * the milliseconds
* @param p
* number of decimal points
* @return a formatted string to milliseconds * @return a formatted string to milliseconds
*/ */
public static String msSeconds(long ms, int p) { public static String msSeconds(long ms, int p) {
@@ -1100,7 +1172,8 @@ public class Form {
/** /**
* nanoseconds to seconds (double) custom decimals * nanoseconds to seconds (double) custom decimals
* *
* @param p number of decimal points * @param p
* number of decimal points
* @return a formatted string to nanoseconds * @return a formatted string to nanoseconds
*/ */
public static String nsMs(long ns, int p) { public static String nsMs(long ns, int p) {
@@ -1110,7 +1183,8 @@ public class Form {
/** /**
* nanoseconds to seconds (double) custom decimals * nanoseconds to seconds (double) custom decimals
* *
* @param p number of decimal points * @param p
* number of decimal points
* @return a formatted string to nanoseconds * @return a formatted string to nanoseconds
*/ */
public static String nsMsd(long ns, int p) { public static String nsMsd(long ns, int p) {
@@ -1120,7 +1194,8 @@ public class Form {
/** /**
* Get roman numeral representation of the int * Get roman numeral representation of the int
* *
* @param num the int * @param num
* the int
* @return the numerals * @return the numerals
*/ */
public static String toRoman(int num) { public static String toRoman(int num) {
@@ -1155,7 +1230,8 @@ public class Form {
/** /**
* Get the number representation from roman numerals. * Get the number representation from roman numerals.
* *
* @param number the roman number * @param number
* the roman number
* @return the int representation * @return the int representation
*/ */
public static int fromRoman(String number) { public static int fromRoman(String number) {
@@ -1223,8 +1299,10 @@ public class Form {
/** /**
* Repeat a string * Repeat a string
* *
* @param s the string * @param s
* @param n the amount of times to repeat * the string
* @param n
* the amount of times to repeat
* @return the repeated string * @return the repeated string
*/ */
@SuppressWarnings("StringRepeatCanBeUsed") @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 * Create a hunk view from a source hunk. This view reads and writes through to
* the source hunk. Its is not a copy. * the source hunk. Its is not a copy.
* *
* @param <T> the type * @param <T>
* @param src the source hunk * the type
* @param src
* the source hunk
* @return the hunk view * @return the hunk view
*/ */
static <T> Hunk<T> view(Hunk<T> src) { static <T> Hunk<T> view(Hunk<T> src) {
@@ -197,9 +199,12 @@ public interface Hunk<T> {
/** /**
* Creates a new bounding hunk from the given hunks * Creates a new bounding hunk from the given hunks
* *
* @param <T> the type * @param <T>
* @param factory the factory that creates a hunk * the type
* @param hunks the hunks * @param factory
* the factory that creates a hunk
* @param hunks
* the hunks
* @return the new bounding hunk * @return the new bounding hunk
*/ */
@SafeVarargs @SafeVarargs
@@ -291,13 +296,20 @@ public interface Hunk<T> {
/** /**
* Create a hunk that is optimized for specific uses * Create a hunk that is optimized for specific uses
* *
* @param w width * @param w
* @param h height * width
* @param d depth * @param h
* @param type the class type * height
* @param packed if the hunk is generally more than 50% full (non-null nodes) * @param d
* @param concurrent if this hunk must be thread safe * depth
* @param <T> the type * @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 * @return the hunk
*/ */
static <T> Hunk<T> newHunk(int w, int h, int d, Class<T> type, boolean packed, boolean concurrent) { 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> * hunk.set(hunkX, ?, hunkZ, noise(actualBlockX, ?, actualBlockZ));<br>
* }<br> * }<br>
* *
* @param p the predicate * @param p
* @param c the consumer * the predicate
* @param c
* the consumer
* @return this * @return this
*/ */
default Hunk<T> iterateSurfaces2D(Predicate<T> p, Consumer8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Hunk<T>> c) { 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> * hunk.set(hunkX, ?, hunkZ, noise(actualBlockX, ?, actualBlockZ));<br>
* }<br> * }<br>
* *
* @param parallelism the ideal threads to use on this * @param parallelism
* @param p the predicate * the ideal threads to use on this
* @param c the consumer * @param p
* the predicate
* @param c
* the consumer
* @return this * @return this
*/ */
default Hunk<T> iterateSurfaces2D(int parallelism, Predicate<T> p, Consumer8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Hunk<T>> c) { 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> * <p>
* hunk.set(ax, ?, az, NOISE.get(ax+hx, az+hz)); * 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 * @return this
*/ */
default Hunk<T> iterate2DTop(Consumer5<Integer, Integer, Integer, Integer, Hunk<T>> c) { default Hunk<T> iterate2DTop(Consumer5<Integer, Integer, Integer, Integer, Hunk<T>> c) {
@@ -675,8 +693,10 @@ public interface Hunk<T> {
* <p> * <p>
* hunk.set(ax, ?, az, NOISE.get(ax+hx, az+hz)); * hunk.set(ax, ?, az, NOISE.get(ax+hx, az+hz));
* *
* @param parallelism the target parallelism value or 0 to disable * @param parallelism
* @param c the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ. * the target parallelism value or 0 to disable
* @param c
* the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ.
* @return this * @return this
*/ */
default Hunk<T> iterate2DTop(int parallelism, Consumer5<Integer, Integer, Integer, Integer, Hunk<T>> c) { 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. * Create a new hunk from a section of this hunk.
* *
* @param x1 The min x (inclusive) * @param x1
* @param y1 The min y (inclusive) * The min x (inclusive)
* @param z1 The min z (inclusive) * @param y1
* @param x2 The max x (exclusive) * The min y (inclusive)
* @param y2 The max y (exclusive) * @param z1
* @param z2 The max z (exclusive) * 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) * @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) { 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. * Create a new view of this same hunk from a section of this hunk.
* Modifications are routed to this hunk! * Modifications are routed to this hunk!
* *
* @param x1 The min x (inclusive) * @param x1
* @param y1 The min y (inclusive) * The min x (inclusive)
* @param z1 The min z (inclusive) * @param y1
* @param x2 The max x (exclusive) * The min y (inclusive)
* @param y2 The max y (exclusive) * @param z1
* @param z2 The max z (exclusive) * 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) * @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) { 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 * Set a region
* *
* @param x1 inclusive 1st x * @param x1
* @param y1 inclusive 1st y * inclusive 1st x
* @param z1 inclusive 1st z * @param y1
* @param x2 inclusive 2nd x * inclusive 1st y
* @param y2 inclusive 2nd y * @param z1
* @param z2 inclusive 2nd z * inclusive 1st z
* @param t the value to set * @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) { default void set(int x1, int y1, int z1, int x2, int y2, int z2, T t) {
for(int i = x1; i <= x2; i++) { for(int i = x1; i <= x2; i++) {
@@ -1114,9 +1153,12 @@ public interface Hunk<T> {
/** /**
* Get the value to the closest valid position * Get the value to the closest valid position
* *
* @param x the x * @param x
* @param y the y * the x
* @param z the z * @param y
* the y
* @param z
* the z
* @return the value closest to the border of the hunk * @return the value closest to the border of the hunk
*/ */
default T getClosest(int x, int y, int z) { 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 * 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 * @return the hunk view of this hunk
*/ */
default Hunk<T> viewFace(HunkFace f) { 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 * 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 * @return the hunk copy (face) of this hunk
*/ */
default Hunk<T> cropFace(HunkFace f) { default Hunk<T> cropFace(HunkFace f) {
@@ -1200,10 +1244,14 @@ public interface Hunk<T> {
/** /**
* Set a value at the given position * Set a value at the given position
* *
* @param x the x * @param x
* @param y the y * the x
* @param z the z * @param y
* @param t the value * the y
* @param z
* the z
* @param t
* the value
*/ */
default void set(int x, int y, int z, T t) { default void set(int x, int y, int z, T t) {
setRaw(x, y, z, 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 * Set a value at the given position without checking coordinate bounds
* *
* @param x the x * @param x
* @param y the y * the x
* @param z the z * @param y
* @param t the value * the y
* @param z
* the z
* @param t
* the value
*/ */
void setRaw(int x, int y, int z, T t); void setRaw(int x, int y, int z, T t);
/** /**
* Get a value at the given position without checking coordinate bounds * Get a value at the given position without checking coordinate bounds
* *
* @param x the x * @param x
* @param y the y * the x
* @param z the z * @param y
* the y
* @param z
* the z
* @return the value or null * @return the value or null
*/ */
T getRaw(int x, int y, int z); T getRaw(int x, int y, int z);
@@ -1252,9 +1307,12 @@ public interface Hunk<T> {
/** /**
* Get a value at the given position * Get a value at the given position
* *
* @param x the x * @param x
* @param y the y * the x
* @param z the z * @param y
* the y
* @param z
* the z
* @return the value or null * @return the value or null
*/ */
default T get(int x, int y, int z) { 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 * Insert a hunk into this one with an offset the inserted hunk
* *
* @param offX the offset from zero for x * @param offX
* @param offY the offset from zero for y * the offset from zero for x
* @param offZ the offset from zero for z * @param offY
* @param hunk the hunk to insert * 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) { default void insert(int offX, int offY, int offZ, Hunk<T> hunk) {
insert(offX, offY, offZ, hunk, false); insert(offX, offY, offZ, hunk, false);
@@ -1290,7 +1352,8 @@ public interface Hunk<T> {
/** /**
* Insert a hunk into this one * Insert a hunk into this one
* *
* @param hunk the hunk to insert * @param hunk
* the hunk to insert
*/ */
default void insert(Hunk<T> hunk) { default void insert(Hunk<T> hunk) {
insert(0, 0, 0, hunk, false); insert(0, 0, 0, hunk, false);
@@ -1310,8 +1373,10 @@ public interface Hunk<T> {
/** /**
* Insert a hunk into this one * Insert a hunk into this one
* *
* @param hunk the hunk to insert * @param hunk
* @param inverted invert the inserted hunk or not * the hunk to insert
* @param inverted
* invert the inserted hunk or not
*/ */
default void insert(Hunk<T> hunk, boolean inverted) { default void insert(Hunk<T> hunk, boolean inverted) {
insert(0, 0, 0, hunk, 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 * Insert a hunk into this one with an offset and possibly inverting the y of
* the inserted hunk * the inserted hunk
* *
* @param offX the offset from zero for x * @param offX
* @param offY the offset from zero for y * the offset from zero for x
* @param offZ the offset from zero for z * @param offY
* @param hunk the hunk to insert * the offset from zero for y
* @param invertY should the inserted hunk be inverted * @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) { default void insert(int offX, int offY, int offZ, Hunk<T> hunk, boolean invertY) {
for(int i = offX; i < offX + hunk.getWidth(); i++) { 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 * the inserted hunk
* *
* @param offX the offset from zero for x * @param offX
* @param offY the offset from zero for y * the offset from zero for x
* @param offZ the offset from zero for z * @param offY
* @param hunk the hunk to insert * the offset from zero for y
* @param invertY should the inserted hunk be inverted * @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) { 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++) { 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 * 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) { default void empty(T b) {
fill(b); fill(b);
@@ -1371,9 +1448,12 @@ public interface Hunk<T> {
/** /**
* Take a hunk and scale it up using interpolation * Take a hunk and scale it up using interpolation
* *
* @param scale the scale * @param scale
* @param d the interpolation method * the scale
* @param interpolated the interpolated value converter * @param d
* the interpolation method
* @param interpolated
* the interpolated value converter
* @return the new hunk * @return the new hunk
*/ */
default Hunk<T> interpolate3D(double scale, InterpolationMethod3D d, Interpolated<T> interpolated) { 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 * Take a hunk and scale it up using interpolation
* 2D, (using only x and z) assumes the height is 1 * 2D, (using only x and z) assumes the height is 1
* *
* @param scale the scale * @param scale
* @param d the interpolation method * the scale
* @param interpolated the interpolated value converter * @param d
* the interpolation method
* @param interpolated
* the interpolated value converter
* @return the new hunk * @return the new hunk
*/ */
default Hunk<T> interpolate2D(double scale, InterpolationMethod d, Interpolated<T> interpolated) { default Hunk<T> interpolate2D(double scale, InterpolationMethod d, Interpolated<T> interpolated) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -921,17 +921,28 @@ public class IrisInterpolation {
/** /**
* Get the interpolated 3D noise within a given cuboid size with offsets * Get the interpolated 3D noise within a given cuboid size with offsets
* *
* @param method the interpolation method to use * @param method
* @param xo the x offset for noise * the interpolation method to use
* @param yo the y offset for noise * @param xo
* @param zo the z offset for noise * the x offset for noise
* @param w the width of the result * @param yo
* @param h the height of the result * the y offset for noise
* @param d the depth of the result * @param zo
* @param radX the interpolation radius for the x axis * the z offset for noise
* @param radY the interpolation radius for the y axis * @param w
* @param radZ the interpolation radius for the z axis * the width of the result
* @param n the noise provider * @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 * @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) { 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 * Transfers the length of the buffer amount of data from the input stream to
* the output stream * the output stream
* *
* @param in the input * @param in
* @param out the output * the input
* @param out
* the output
* @return the actual transfered amount * @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 { public static int transfer(InputStream in, OutputStream out, byte[] buffer) throws IOException {
int r = in.read(buffer); 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 * Transfers the length of the buffer amount of data from the input stream to
* the output stream * the output stream
* *
* @param in the input * @param in
* @param out the output * the input
* @param targetBuffer the buffer and size to use * @param out
* @param totalSize the total amount to transfer * the output
* @param targetBuffer
* the buffer and size to use
* @param totalSize
* the total amount to transfer
* @return the actual transfered amount * @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 { public static long transfer(InputStream in, OutputStream out, int targetBuffer, long totalSize) throws IOException {
long total = totalSize; long total = totalSize;
@@ -237,10 +245,7 @@ public class IO {
* Fully move data from a finite inputstream to an output stream using a buffer * Fully move data from a finite inputstream to an output stream using a buffer
* size of 8192. This does NOT close streams. * size of 8192. This does NOT close streams.
* *
* @param in
* @param out
* @return total size transfered * @return total size transfered
* @throws IOException
*/ */
public static long fillTransfer(InputStream in, OutputStream out) throws IOException { public static long fillTransfer(InputStream in, OutputStream out) throws IOException {
return fullTransfer(in, out, 8192); 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 * Fully move data from a finite inputstream to an output stream using a given
* buffer size. This does NOT close streams. * buffer size. This does NOT close streams.
* *
* @param in the input stream to read from * @param in
* @param out the output stream to writeNodeData to * the input stream to read from
* @param bufferSize the target buffer size * @param out
* the output stream to writeNodeData to
* @param bufferSize
* the target buffer size
* @return total size transfered * @return total size transfered
* @throws IOException shit happens * @throws IOException
* shit happens
*/ */
public static long fullTransfer(InputStream in, OutputStream out, int bufferSize) throws IOException { public static long fullTransfer(InputStream in, OutputStream out, int bufferSize) throws IOException {
long wrote = 0; long wrote = 0;
@@ -282,7 +291,8 @@ public class IO {
/** /**
* Recursive delete (deleting folders) * 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) { public static void delete(File f) {
if(f == null || !f.exists()) { 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 * 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. * without modifying it, but updating the file date and time.
* *
* @param file the File to touch * @param file
* @throws IOException If an I/O problem occurs * the File to touch
* @throws IOException
* If an I/O problem occurs
*/ */
public static void touch(File file) throws IOException { public static void touch(File file) throws IOException {
if(!file.exists()) { if(!file.exists()) {
@@ -452,11 +464,16 @@ public class IO {
* does not exist. If the destination file exists, then this method will * does not exist. If the destination file exists, then this method will
* overwrite it. * overwrite it.
* *
* @param srcFile an existing file to copy, must not be null * @param srcFile
* @param destFile the new file, must not be null * an existing file to copy, must not be null
* @throws NullPointerException if source or destination is null * @param destFile
* @throws IOException if source or destination is invalid * the new file, must not be null
* @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) throws IOException { public static void copyFile(File srcFile, File destFile) throws IOException {
copyFile(srcFile, destFile, true); copyFile(srcFile, destFile, true);
@@ -470,13 +487,19 @@ public class IO {
* does not exist. If the destination file exists, then this method will * does not exist. If the destination file exists, then this method will
* overwrite it. * overwrite it.
* *
* @param srcFile an existing file to copy, must not be null * @param srcFile
* @param destFile the new file, must not be null * an existing file to copy, must not be null
* @param preserveFileDate true if the file date of the copy should be the same as the * @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 * original
* @throws NullPointerException if source or destination is null * @throws NullPointerException
* @throws IOException if source or destination is invalid * if source or destination is null
* @throws IOException if an IO error occurs during copying * @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 { public static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
if(srcFile == null) { if(srcFile == null) {
@@ -510,10 +533,14 @@ public class IO {
/** /**
* Internal copy file method. * Internal copy file method.
* *
* @param srcFile the validated source file, not null * @param srcFile
* @param destFile the validated destination file, not null * the validated source file, not null
* @param preserveFileDate whether to preserve the file date * @param destFile
* @throws IOException if an error occurs * 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 { private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
if(destFile.exists() && destFile.isDirectory()) { if(destFile.exists() && destFile.isDirectory()) {
@@ -546,7 +573,8 @@ public class IO {
* Equivalent to {@link Reader#close()}, except any exceptions will be ignored. * Equivalent to {@link Reader#close()}, except any exceptions will be ignored.
* This is typically used in finally blocks. * 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) { public static void closeQuietly(Reader input) {
try { try {
@@ -565,7 +593,8 @@ public class IO {
* Equivalent to {@link Writer#close()}, except any exceptions will be ignored. * Equivalent to {@link Writer#close()}, except any exceptions will be ignored.
* This is typically used in finally blocks. * 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) { public static void closeQuietly(Writer output) {
try { try {
@@ -584,7 +613,8 @@ public class IO {
* Equivalent to {@link InputStream#close()}, except any exceptions will be * Equivalent to {@link InputStream#close()}, except any exceptions will be
* ignored. This is typically used in finally blocks. * 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) { public static void closeQuietly(InputStream input) {
try { try {
@@ -606,7 +636,8 @@ public class IO {
* Equivalent to {@link OutputStream#close()}, except any exceptions will be * Equivalent to {@link OutputStream#close()}, except any exceptions will be
* ignored. This is typically used in finally blocks. * 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) { public static void closeQuietly(OutputStream output) {
try { try {
@@ -625,10 +656,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a * This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>. * <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 * @return the requested byte array
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
*/ */
public static byte[] toByteArray(InputStream input) throws IOException { public static byte[] toByteArray(InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream(); 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>. * <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 * @return the requested byte array
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
*/ */
public static byte[] toByteArray(Reader input) throws IOException { public static byte[] toByteArray(Reader input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream(); 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>. * <code>BufferedReader</code>.
* *
* @param input the <code>Reader</code> to read from * @param input
* @param encoding the encoding to use, null means platform default * the <code>Reader</code> to read from
* @param encoding
* the encoding to use, null means platform default
* @return the requested byte array * @return the requested byte array
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static byte[] toByteArray(Reader input, String encoding) throws IOException { public static byte[] toByteArray(Reader input, String encoding) throws IOException {
@@ -686,7 +727,8 @@ public class IO {
* <p> * <p>
* This is the same as {@link String#getBytes()}. * 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 * @return the requested byte array
* @deprecated Use {@link String#getBytes()} * @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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>. * <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 * @return the requested character array
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static char[] toCharArray(InputStream is) throws IOException { 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>. * <code>BufferedInputStream</code>.
* *
* @param is the <code>InputStream</code> to read from * @param is
* @param encoding the encoding to use, null means platform default * the <code>InputStream</code> to read from
* @param encoding
* the encoding to use, null means platform default
* @return the requested character array * @return the requested character array
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static char[] toCharArray(InputStream is, String encoding) throws IOException { 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>. * <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 * @return the requested character array
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static char[] toCharArray(Reader input) throws IOException { 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>. * <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 * @return the requested String
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
*/ */
public static String toString(InputStream input) throws IOException { public static String toString(InputStream input) throws IOException {
StringWriter sw = new StringWriter(); 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>. * <code>BufferedInputStream</code>.
* *
* @param input the <code>InputStream</code> to read from * @param input
* @param encoding the encoding to use, null means platform default * the <code>InputStream</code> to read from
* @param encoding
* the encoding to use, null means platform default
* @return the requested String * @return the requested String
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
*/ */
public static String toString(InputStream input, String encoding) throws IOException { public static String toString(InputStream input, String encoding) throws IOException {
StringWriter sw = new StringWriter(); 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>. * <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 * @return the requested String
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
*/ */
public static String toString(Reader input) throws IOException { public static String toString(Reader input) throws IOException {
StringWriter sw = new StringWriter(); 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 * Get the contents of a <code>byte[]</code> as a String using the default
* character encoding of the platform. * 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 * @return the requested String
* @deprecated Use {@link String#String(byte[])} * @deprecated Use {@link String#String(byte[])}
*/ */
@@ -838,11 +901,15 @@ public class IO {
* Character encoding names can be found at * Character encoding names can be found at
* <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * <a href="http://www.iana.org/assignments/character-sets">IANA</a>.
* *
* @param input the byte array to read from * @param input
* @param encoding the encoding to use, null means platform default * the byte array to read from
* @param encoding
* the encoding to use, null means platform default
* @return the requested String * @return the requested String
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs (never occurs) * if the input is null
* @throws IOException
* if an I/O error occurs (never occurs)
* @deprecated Use {@link String#String(byte[], String)} * @deprecated Use {@link String#String(byte[], String)}
*/ */
@Deprecated @Deprecated
@@ -861,10 +928,13 @@ public class IO {
* This method buffers the input internally, so there is no need to use a * This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>. * <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 * @return the list of Strings, never null
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static List<String> readLines(InputStream input) throws IOException { 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>. * <code>BufferedInputStream</code>.
* *
* @param input the <code>InputStream</code> to read from, not null * @param input
* @param encoding the encoding to use, null means platform default * 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 * @return the list of Strings, never null
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static List<String> readLines(InputStream input, String encoding) throws IOException { 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>. * <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 * @return the list of Strings, never null
* @throws NullPointerException if the input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static List<String> readLines(Reader input) throws IOException { 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 * Convert the specified string to an input stream, encoded as bytes using the
* default character encoding of the platform. * default character encoding of the platform.
* *
* @param input the string to convert * @param input
* the string to convert
* @return an input stream * @return an input stream
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
@@ -947,10 +1025,13 @@ public class IO {
* Character encoding names can be found at * Character encoding names can be found at
* <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * <a href="http://www.iana.org/assignments/character-sets">IANA</a>.
* *
* @param input the string to convert * @param input
* @param encoding the encoding to use, null means platform default * the string to convert
* @param encoding
* the encoding to use, null means platform default
* @return an input stream * @return an input stream
* @throws IOException if the encoding is invalid * @throws IOException
* if the encoding is invalid
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static InputStream toInputStream(String input, String encoding) throws IOException { 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>. * 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 data
* @param output the <code>OutputStream</code> to writeNodeData to * the byte array to writeNodeData, do not modify during output, null ignored
* @throws NullPointerException if output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void write(byte[] data, OutputStream output) throws IOException { public static void write(byte[] data, OutputStream output) throws IOException {
@@ -979,10 +1064,14 @@ public class IO {
* <p> * <p>
* This method uses {@link String#String(byte[])}. * This method uses {@link String#String(byte[])}.
* *
* @param data the byte array to writeNodeData, do not modify during output, null ignored * @param data
* @param output the <code>Writer</code> to writeNodeData to * the byte array to writeNodeData, do not modify during output, null ignored
* @throws NullPointerException if output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void write(byte[] data, Writer output) throws IOException { public static void write(byte[] data, Writer output) throws IOException {
@@ -1003,11 +1092,16 @@ public class IO {
* <p> * <p>
* This method uses {@link String#String(byte[], String)}. * This method uses {@link String#String(byte[], String)}.
* *
* @param data the byte array to writeNodeData, do not modify during output, null ignored * @param data
* @param output the <code>Writer</code> to writeNodeData to * the byte array to writeNodeData, do not modify during output, null ignored
* @param encoding the encoding to use, null means platform default * @param output
* @throws NullPointerException if output is null * the <code>Writer</code> to writeNodeData to
* @throws IOException if an I/O error occurs * @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 * @since Commons IO 1.1
*/ */
public static void write(byte[] data, Writer output, String encoding) throws IOException { 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 * Writes chars from a <code>char[]</code> to a <code>Writer</code> using the
* default character encoding of the platform. * default character encoding of the platform.
* *
* @param data the char array to writeNodeData, do not modify during output, null ignored * @param data
* @param output the <code>Writer</code> to writeNodeData to * the char array to writeNodeData, do not modify during output, null ignored
* @throws NullPointerException if output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void write(char[] data, Writer output) throws IOException { public static void write(char[] data, Writer output) throws IOException {
@@ -1042,10 +1140,14 @@ public class IO {
* <p> * <p>
* This method uses {@link String#String(char[])} and {@link String#getBytes()}. * 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 data
* @param output the <code>OutputStream</code> to writeNodeData to * the char array to writeNodeData, do not modify during output, null ignored
* @throws NullPointerException if output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void write(char[] data, OutputStream output) throws IOException { 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 * This method uses {@link String#String(char[])} and
* {@link String#getBytes(String)}. * {@link String#getBytes(String)}.
* *
* @param data the char array to writeNodeData, do not modify during output, null ignored * @param data
* @param output the <code>OutputStream</code> to writeNodeData to * the char array to writeNodeData, do not modify during output, null ignored
* @param encoding the encoding to use, null means platform default * @param output
* @throws NullPointerException if output is null * the <code>OutputStream</code> to writeNodeData to
* @throws IOException if an I/O error occurs * @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 * @since Commons IO 1.1
*/ */
public static void write(char[] data, OutputStream output, String encoding) throws IOException { 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>. * Writes chars from a <code>String</code> to a <code>Writer</code>.
* *
* @param data the <code>String</code> to writeNodeData, null ignored * @param data
* @param output the <code>Writer</code> to writeNodeData to * the <code>String</code> to writeNodeData, null ignored
* @throws NullPointerException if output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void write(String data, Writer output) throws IOException { public static void write(String data, Writer output) throws IOException {
@@ -1106,10 +1217,14 @@ public class IO {
* <p> * <p>
* This method uses {@link String#getBytes()}. * This method uses {@link String#getBytes()}.
* *
* @param data the <code>String</code> to writeNodeData, null ignored * @param data
* @param output the <code>OutputStream</code> to writeNodeData to * the <code>String</code> to writeNodeData, null ignored
* @throws NullPointerException if output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void write(String data, OutputStream output) throws IOException { public static void write(String data, OutputStream output) throws IOException {
@@ -1130,11 +1245,16 @@ public class IO {
* <p> * <p>
* This method uses {@link String#getBytes(String)}. * This method uses {@link String#getBytes(String)}.
* *
* @param data the <code>String</code> to writeNodeData, null ignored * @param data
* @param output the <code>OutputStream</code> to writeNodeData to * the <code>String</code> to writeNodeData, null ignored
* @param encoding the encoding to use, null means platform default * @param output
* @throws NullPointerException if output is null * the <code>OutputStream</code> to writeNodeData to
* @throws IOException if an I/O error occurs * @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 * @since Commons IO 1.1
*/ */
public static void write(String data, OutputStream output, String encoding) throws IOException { 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>. * Writes chars from a <code>StringBuffer</code> to a <code>Writer</code>.
* *
* @param data the <code>StringBuffer</code> to writeNodeData, null ignored * @param data
* @param output the <code>Writer</code> to writeNodeData to * the <code>StringBuffer</code> to writeNodeData, null ignored
* @throws NullPointerException if output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void write(StringBuffer data, Writer output) throws IOException { public static void write(StringBuffer data, Writer output) throws IOException {
@@ -1169,10 +1293,14 @@ public class IO {
* <p> * <p>
* This method uses {@link String#getBytes()}. * This method uses {@link String#getBytes()}.
* *
* @param data the <code>StringBuffer</code> to writeNodeData, null ignored * @param data
* @param output the <code>OutputStream</code> to writeNodeData to * the <code>StringBuffer</code> to writeNodeData, null ignored
* @throws NullPointerException if output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void write(StringBuffer data, OutputStream output) throws IOException { public static void write(StringBuffer data, OutputStream output) throws IOException {
@@ -1193,11 +1321,16 @@ public class IO {
* <p> * <p>
* This method uses {@link String#getBytes(String)}. * This method uses {@link String#getBytes(String)}.
* *
* @param data the <code>StringBuffer</code> to writeNodeData, null ignored * @param data
* @param output the <code>OutputStream</code> to writeNodeData to * the <code>StringBuffer</code> to writeNodeData, null ignored
* @param encoding the encoding to use, null means platform default * @param output
* @throws NullPointerException if output is null * the <code>OutputStream</code> to writeNodeData to
* @throws IOException if an I/O error occurs * @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 * @since Commons IO 1.1
*/ */
public static void write(StringBuffer data, OutputStream output, String encoding) throws IOException { 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 * <code>OutputStream</code> line by line, using the default character encoding
* of the platform and the specified line ending. * of the platform and the specified line ending.
* *
* @param lines the lines to writeNodeData, null entries produce blank lines * @param lines
* @param lineEnding the line separator to use, null is system default * the lines to writeNodeData, null entries produce blank lines
* @param output the <code>OutputStream</code> to writeNodeData to, not null, not closed * @param lineEnding
* @throws NullPointerException if the output is null * the line separator to use, null is system default
* @throws IOException if an I/O error occurs * @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 * @since Commons IO 1.1
*/ */
public static void writeLines(Collection<String> lines, String lineEnding, OutputStream output) throws IOException { 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 * Character encoding names can be found at
* <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * <a href="http://www.iana.org/assignments/character-sets">IANA</a>.
* *
* @param lines the lines to writeNodeData, null entries produce blank lines * @param lines
* @param lineEnding the line separator to use, null is system default * the lines to writeNodeData, null entries produce blank lines
* @param output the <code>OutputStream</code> to writeNodeData to, not null, not closed * @param lineEnding
* @param encoding the encoding to use, null means platform default * the line separator to use, null is system default
* @throws NullPointerException if the output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void writeLines(Collection<String> lines, String lineEnding, OutputStream output, String encoding) throws IOException { 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 * 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. * <code>Writer</code> line by line, using the specified line ending.
* *
* @param lines the lines to writeNodeData, null entries produce blank lines * @param lines
* @param lineEnding the line separator to use, null is system default * the lines to writeNodeData, null entries produce blank lines
* @param writer the <code>Writer</code> to writeNodeData to, not null, not closed * @param lineEnding
* @throws NullPointerException if the input is null * the line separator to use, null is system default
* @throws IOException if an I/O error occurs * @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 * @since Commons IO 1.1
*/ */
public static void writeLines(Collection<String> lines, String lineEnding, Writer writer) throws IOException { 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 * returned as an int. For large streams use the
* <code>copyLarge(InputStream, OutputStream)</code> method. * <code>copyLarge(InputStream, OutputStream)</code> method.
* *
* @param input the <code>InputStream</code> to read from * @param input
* @param output the <code>OutputStream</code> to writeNodeData to * the <code>InputStream</code> to read from
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @return the number of bytes copied * @return the number of bytes copied
* @throws NullPointerException if the input or output is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input or output is null
* @throws ArithmeticException if the byte count is too large * @throws IOException
* if an I/O error occurs
* @throws ArithmeticException
* if the byte count is too large
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static int copy(InputStream input, OutputStream output) throws IOException { 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>. * <code>BufferedInputStream</code>.
* *
* @param input the <code>InputStream</code> to read from * @param input
* @param output the <code>OutputStream</code> to writeNodeData to * the <code>InputStream</code> to read from
* @param output
* the <code>OutputStream</code> to writeNodeData to
* @return the number of bytes copied * @return the number of bytes copied
* @throws NullPointerException if the input or output is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input or output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.3 * @since Commons IO 1.3
*/ */
public static long copyLarge(InputStream input, OutputStream output) throws IOException { public static long copyLarge(InputStream input, OutputStream output) throws IOException {
@@ -1365,10 +1523,14 @@ public class IO {
* <p> * <p>
* This method uses {@link InputStreamReader}. * This method uses {@link InputStreamReader}.
* *
* @param input the <code>InputStream</code> to read from * @param input
* @param output the <code>Writer</code> to writeNodeData to * the <code>InputStream</code> to read from
* @throws NullPointerException if the input or output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void copy(InputStream input, Writer output) throws IOException { public static void copy(InputStream input, Writer output) throws IOException {
@@ -1391,11 +1553,16 @@ public class IO {
* <p> * <p>
* This method uses {@link InputStreamReader}. * This method uses {@link InputStreamReader}.
* *
* @param input the <code>InputStream</code> to read from * @param input
* @param output the <code>Writer</code> to writeNodeData to * the <code>InputStream</code> to read from
* @param encoding the encoding to use, null means platform default * @param output
* @throws NullPointerException if the input or output is null * the <code>Writer</code> to writeNodeData to
* @throws IOException if an I/O error occurs * @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 * @since Commons IO 1.1
*/ */
public static void copy(InputStream input, Writer output, String encoding) throws IOException { 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 * returned as an int. For large streams use the
* <code>copyLarge(Reader, Writer)</code> method. * <code>copyLarge(Reader, Writer)</code> method.
* *
* @param input the <code>Reader</code> to read from * @param input
* @param output the <code>Writer</code> to writeNodeData to * the <code>Reader</code> to read from
* @param output
* the <code>Writer</code> to writeNodeData to
* @return the number of characters copied * @return the number of characters copied
* @throws NullPointerException if the input or output is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input or output is null
* @throws ArithmeticException if the character count is too large * @throws IOException
* if an I/O error occurs
* @throws ArithmeticException
* if the character count is too large
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static int copy(Reader input, Writer output) throws IOException { 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 * This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>. * <code>BufferedReader</code>.
* *
* @param input the <code>Reader</code> to read from * @param input
* @param output the <code>Writer</code> to writeNodeData to * the <code>Reader</code> to read from
* @param output
* the <code>Writer</code> to writeNodeData to
* @return the number of characters copied * @return the number of characters copied
* @throws NullPointerException if the input or output is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if the input or output is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.3 * @since Commons IO 1.3
*/ */
public static long copyLarge(Reader input, Writer output) throws IOException { public static long copyLarge(Reader input, Writer output) throws IOException {
@@ -1472,10 +1648,14 @@ public class IO {
* <p> * <p>
* This method uses {@link OutputStreamWriter}. * This method uses {@link OutputStreamWriter}.
* *
* @param input the <code>Reader</code> to read from * @param input
* @param output the <code>OutputStream</code> to writeNodeData to * the <code>Reader</code> to read from
* @throws NullPointerException if the input or output is null * @param output
* @throws IOException if an I/O error occurs * 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 * @since Commons IO 1.1
*/ */
public static void copy(Reader input, OutputStream output) throws IOException { public static void copy(Reader input, OutputStream output) throws IOException {
@@ -1504,11 +1684,16 @@ public class IO {
* <p> * <p>
* This method uses {@link OutputStreamWriter}. * This method uses {@link OutputStreamWriter}.
* *
* @param input the <code>Reader</code> to read from * @param input
* @param output the <code>OutputStream</code> to writeNodeData to * the <code>Reader</code> to read from
* @param encoding the encoding to use, null means platform default * @param output
* @throws NullPointerException if the input or output is null * the <code>OutputStream</code> to writeNodeData to
* @throws IOException if an I/O error occurs * @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 * @since Commons IO 1.1
*/ */
public static void copy(Reader input, OutputStream output, String encoding) throws IOException { 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 * This method buffers the input internally using
* <code>BufferedInputStream</code> if they are not already buffered. * <code>BufferedInputStream</code> if they are not already buffered.
* *
* @param input1 the first stream * @param input1
* @param input2 the second stream * the first stream
* @param input2
* the second stream
* @return true if the content of the streams are equal or they both don't * @return true if the content of the streams are equal or they both don't
* exist, false otherwise * exist, false otherwise
* @throws NullPointerException if either input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if either input is null
* @throws IOException
* if an I/O error occurs
*/ */
public static boolean contentEquals(InputStream input1, InputStream input2) throws IOException { public static boolean contentEquals(InputStream input1, InputStream input2) throws IOException {
if(!(input1 instanceof BufferedInputStream)) { if(!(input1 instanceof BufferedInputStream)) {
@@ -1562,12 +1751,16 @@ public class IO {
* This method buffers the input internally using <code>BufferedReader</code> if * This method buffers the input internally using <code>BufferedReader</code> if
* they are not already buffered. * they are not already buffered.
* *
* @param input1 the first reader * @param input1
* @param input2 the second reader * the first reader
* @param input2
* the second reader
* @return true if the content of the readers are equal or they both don't * @return true if the content of the readers are equal or they both don't
* exist, false otherwise * exist, false otherwise
* @throws NullPointerException if either input is null * @throws NullPointerException
* @throws IOException if an I/O error occurs * if either input is null
* @throws IOException
* if an I/O error occurs
* @since Commons IO 1.1 * @since Commons IO 1.1
*/ */
public static boolean contentEquals(Reader input1, Reader input2) throws IOException { public static boolean contentEquals(Reader input1, Reader input2) throws IOException {

View File

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

View File

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

View File

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

View File

@@ -94,8 +94,10 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Construct a JSONArray from a JSONTokener. * Construct a JSONArray from a JSONTokener.
* *
* @param x A JSONTokener * @param x
* @throws JSONException If there is a syntax error. * A JSONTokener
* @throws JSONException
* If there is a syntax error.
*/ */
public JSONArray(JSONTokener x) throws JSONException { public JSONArray(JSONTokener x) throws JSONException {
this(); this();
@@ -131,10 +133,12 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Construct a JSONArray from a source JSON text. * 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; * bracket)</small> and ends with <code>]</code> &nbsp;
* <small>(right bracket)</small>. * <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 { public JSONArray(String source) throws JSONException {
this(new JSONTokener(source)); this(new JSONTokener(source));
@@ -143,7 +147,8 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Construct a JSONArray from a Collection. * Construct a JSONArray from a Collection.
* *
* @param collection A Collection. * @param collection
* A Collection.
*/ */
public JSONArray(Collection<Object> collection) { public JSONArray(Collection<Object> collection) {
this.myArrayList = new ArrayList<Object>(); this.myArrayList = new ArrayList<Object>();
@@ -158,7 +163,8 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Construct a JSONArray from an array * Construct a JSONArray from an array
* *
* @throws JSONException If not an array. * @throws JSONException
* If not an array.
*/ */
public JSONArray(Object array) throws JSONException { public JSONArray(Object array) throws JSONException {
this(); this();
@@ -180,9 +186,11 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Get the object value associated with an index. * 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. * @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 { public Object get(int index) throws JSONException {
Object object = this.opt(index); 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" * Get the boolean value associated with an index. The string values "true"
* and "false" are converted to boolean. * 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. * @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. * convertible to boolean.
*/ */
public boolean getBoolean(int index) throws JSONException { 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. * 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. * @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. * to a number.
*/ */
public double getDouble(int index) throws JSONException { 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. * Get the enum value associated with an index.
* *
* @param clazz The type of enum to retrieve. * @param clazz
* @param index The index must be between 0 and length() - 1. * 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 * @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. * to an enum.
*/ */
public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONException { 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. * 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. * @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. * to a BigDecimal.
*/ */
public BigDecimal getBigDecimal(int index) throws JSONException { 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. * 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. * @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. * to a BigInteger.
*/ */
public BigInteger getBigInteger(int index) throws JSONException { 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. * 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. * @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 { public int getInt(int index) throws JSONException {
Object object = this.get(index); Object object = this.get(index);
@@ -305,9 +326,11 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Get the JSONArray associated with an index. * 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. * @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 * JSONArray
*/ */
public JSONArray getJSONArray(int index) throws JSONException { public JSONArray getJSONArray(int index) throws JSONException {
@@ -321,9 +344,11 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Get the JSONObject associated with an index. * Get the JSONObject associated with an index.
* *
* @param index subscript * @param index
* subscript
* @return A JSONObject value. * @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 * JSONObject
*/ */
public JSONObject getJSONObject(int index) throws JSONException { 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. * 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. * @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. * to a number.
*/ */
public long getLong(int index) throws JSONException { public long getLong(int index) throws JSONException {
@@ -355,9 +382,11 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Get the string associated with an index. * 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. * @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 { public String getString(int index) throws JSONException {
Object object = this.get(index); Object object = this.get(index);
@@ -370,7 +399,8 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Determine if the value is null. * 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. * @return true if the value at the index is null, or if there is no value.
*/ */
public boolean isNull(int index) { 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: * <code>separator</code> string is inserted between each element. Warning:
* This method assumes that the data structure is acyclical. * 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. * @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 { public String join(String separator) throws JSONException {
int len = this.length(); int len = this.length();
@@ -411,7 +443,8 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Get the optional object value associated with an index. * 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. * @return An object value, or null if there is no object at that index.
*/ */
public Object opt(int 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 * if there is no value at that index, or if the value is not Boolean.TRUE
* or the String "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. * @return The truth.
*/ */
public boolean optBoolean(int index) { 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 * defaultValue if there is no value at that index or if it is not a Boolean
* or the String "true" or "false" (case insensitive). * or the String "true" or "false" (case insensitive).
* *
* @param index The index must be between 0 and length() - 1. * @param index
* @param defaultValue A boolean default. * The index must be between 0 and length() - 1.
* @param defaultValue
* A boolean default.
* @return The truth. * @return The truth.
*/ */
public boolean optBoolean(int index, boolean defaultValue) { 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 * if there is no value for the index, or if the value is not a number and
* cannot be converted to a number. * 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. * @return The value.
*/ */
public double optDouble(int index) { 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 * 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. * number and cannot be converted to a number.
* *
* @param index subscript * @param index
* @param defaultValue The default value. * subscript
* @param defaultValue
* The default value.
* @return The value. * @return The value.
*/ */
public double optDouble(int index, double defaultValue) { 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 * there is no value for the index, or if the value is not a number and
* cannot be converted to a number. * 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. * @return The value.
*/ */
public int optInt(int index) { 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 * returned if there is no value for the index, or if the value is not a
* number and cannot be converted to a number. * number and cannot be converted to a number.
* *
* @param index The index must be between 0 and length() - 1. * @param index
* @param defaultValue The default value. * The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value. * @return The value.
*/ */
public int optInt(int index, int defaultValue) { 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. * Get the enum value associated with a key.
* *
* @param clazz The type of enum to retrieve. * @param clazz
* @param index The index must be between 0 and length() - 1. * 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 * @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) { 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. * Get the enum value associated with a key.
* *
* @param clazz The type of enum to retrieve. * @param clazz
* @param index The index must be between 0 and length() - 1. * The type of enum to retrieve.
* @param defaultValue The default in case the value is not found * @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 * @return The enum value at the index location or defaultValue if the value
* is not found or cannot be assigned to clazz * 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 * 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. * 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
* @param defaultValue The default value. * The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value. * @return The value.
*/ */
public BigInteger optBigInteger(int index, BigInteger defaultValue) { 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 * 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. * 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
* @param defaultValue The default value. * The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value. * @return The value.
*/ */
public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) { 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. * 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 * @return A JSONArray value, or null if the index has no value, or if the
* value is not a JSONArray. * 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 * the key is not found, or null if the index has no value, or if the value
* is not a JSONObject. * 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. * @return A JSONObject value.
*/ */
public JSONObject optJSONObject(int index) { 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 * there is no value for the index, or if the value is not a number and
* cannot be converted to a number. * 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. * @return The value.
*/ */
public long optLong(int index) { 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 * returned if there is no value for the index, or if the value is not a
* number and cannot be converted to a number. * number and cannot be converted to a number.
* *
* @param index The index must be between 0 and length() - 1. * @param index
* @param defaultValue The default value. * The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value. * @return The value.
*/ */
public long optLong(int index, long defaultValue) { 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 * 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. * 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. * @return A String value.
*/ */
public String optString(int index) { 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 * Get the optional string associated with an index. The defaultValue is
* returned if the key is not found. * returned if the key is not found.
* *
* @param index The index must be between 0 and length() - 1. * @param index
* @param defaultValue The default value. * The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return A String value. * @return A String value.
*/ */
public String optString(int index, String defaultValue) { 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. * Append a boolean value. This increases the array's length by one.
* *
* @param value A boolean value. * @param value
* A boolean value.
* @return this. * @return this.
*/ */
public JSONArray put(boolean value) { 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 * Put a value in the JSONArray, where the value will be a JSONArray which
* is produced from a Collection. * is produced from a Collection.
* *
* @param value A Collection value. * @param value
* A Collection value.
* @return this. * @return this.
*/ */
public JSONArray put(Collection<Object> value) { 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. * Append a double value. This increases the array's length by one.
* *
* @param value A double value. * @param value
* A double value.
* @return this. * @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 { public JSONArray put(double value) throws JSONException {
Double d = Double.valueOf(value); 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. * Append an int value. This increases the array's length by one.
* *
* @param value An int value. * @param value
* An int value.
* @return this. * @return this.
*/ */
public JSONArray put(int value) { 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. * Append an long value. This increases the array's length by one.
* *
* @param value A long value. * @param value
* A long value.
* @return this. * @return this.
*/ */
public JSONArray put(long value) { 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 * Put a value in the JSONArray, where the value will be a JSONObject which
* is produced from a Map. * is produced from a Map.
* *
* @param value A Map value. * @param value
* A Map value.
* @return this. * @return this.
*/ */
public JSONArray put(Map<String, Object> value) { 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. * 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 * Integer, JSONArray, JSONObject, Long, or String, or the
* JSONObject.NULL object. * JSONObject.NULL object.
* @return this. * @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 * than the length of the JSONArray, then null elements will be added as
* necessary to pad it out. * necessary to pad it out.
* *
* @param index The subscript. * @param index
* @param value A boolean value. * The subscript.
* @param value
* A boolean value.
* @return this. * @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 { public JSONArray put(int index, boolean value) throws JSONException {
this.put(index, value ? Boolean.TRUE : Boolean.FALSE); 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 * Put a value in the JSONArray, where the value will be a JSONArray which
* is produced from a Collection. * is produced from a Collection.
* *
* @param index The subscript. * @param index
* @param value A Collection value. * The subscript.
* @param value
* A Collection value.
* @return this. * @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 { public JSONArray put(int index, Collection<Object> value) throws JSONException {
this.put(index, new JSONArray(value)); 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 * the JSONArray, then null elements will be added as necessary to pad it
* out. * out.
* *
* @param index The subscript. * @param index
* @param value A double value. * The subscript.
* @param value
* A double value.
* @return this. * @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 { public JSONArray put(int index, double value) throws JSONException {
this.put(index, Double.valueOf(value)); 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 * the JSONArray, then null elements will be added as necessary to pad it
* out. * out.
* *
* @param index The subscript. * @param index
* @param value An int value. * The subscript.
* @param value
* An int value.
* @return this. * @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 { public JSONArray put(int index, int value) throws JSONException {
this.put(index, Integer.valueOf(value)); 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 * the JSONArray, then null elements will be added as necessary to pad it
* out. * out.
* *
* @param index The subscript. * @param index
* @param value A long value. * The subscript.
* @param value
* A long value.
* @return this. * @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 { public JSONArray put(int index, long value) throws JSONException {
this.put(index, Long.valueOf(value)); 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 * Put a value in the JSONArray, where the value will be a JSONObject that
* is produced from a Map. * is produced from a Map.
* *
* @param index The subscript. * @param index
* @param value The Map value. * The subscript.
* @param value
* The Map value.
* @return this. * @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. * number.
*/ */
public JSONArray put(int index, Map<String, Object> value) throws JSONException { 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 * than the length of the JSONArray, then null elements will be added as
* necessary to pad it out. * necessary to pad it out.
* *
* @param index The subscript. * @param index
* @param value The value to put into the array. The value should be a * The subscript.
* @param value
* The value to put into the array. The value should be a
* Boolean, Double, Integer, JSONArray, JSONObject, Long, or * Boolean, Double, Integer, JSONArray, JSONObject, Long, or
* String, or the JSONObject.NULL object. * String, or the JSONObject.NULL object.
* @return this. * @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. * number.
*/ */
public JSONArray put(int index, Object value) throws JSONException { 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. * 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 * @return The value that was associated with the index, or null if there
* was no value. * was no value.
*/ */
@@ -883,7 +972,8 @@ public class JSONArray implements Iterable<Object> {
* Determine if two JSONArrays are similar. They must contain similar * Determine if two JSONArrays are similar. They must contain similar
* sequences. * sequences.
* *
* @param other The other JSONArray * @param other
* The other JSONArray
* @return true if they are equal * @return true if they are equal
*/ */
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @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 * Produce a JSONObject by combining a JSONArray of names with the values of
* this JSONArray. * 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. * paired with the values.
* @return A JSONObject, or null if there are no names or if this JSONArray * @return A JSONObject, or null if there are no names or if this JSONArray
* has no values. * 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 { public JSONObject toJSONObject(JSONArray names) throws JSONException {
if(names == null || names.length() == 0 || this.length() == 0) { 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 * Make a prettyprinted JSON text of this JSONArray. Warning: This method
* assumes that the data structure is acyclical. * 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 * @return a printable, displayable, transmittable representation of the
* object, beginning with <code>[</code>&nbsp;<small>(left * object, beginning with <code>[</code>&nbsp;<small>(left
* bracket)</small> and ending with <code>]</code> &nbsp; * bracket)</small> and ending with <code>]</code> &nbsp;
* <small>(right bracket)</small>. * <small>(right bracket)</small>.
* @throws JSONException
*/ */
public String toString(int indentFactor) throws JSONException { public String toString(int indentFactor) throws JSONException {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
@@ -980,7 +1072,6 @@ public class JSONArray implements Iterable<Object> {
* Warning: This method assumes that the data structure is acyclical. * Warning: This method assumes that the data structure is acyclical.
* *
* @return The writer. * @return The writer.
* @throws JSONException
*/ */
public Writer write(Writer writer) throws JSONException { public Writer write(Writer writer) throws JSONException {
return this.write(writer, 0, 0); return this.write(writer, 0, 0);
@@ -992,10 +1083,11 @@ public class JSONArray implements Iterable<Object> {
* <p> * <p>
* Warning: This method assumes that the data structure is acyclical. * 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
* @param indent The indention of the top level. * The number of spaces to add to each level of indentation.
* @param indent
* The indention of the top level.
* @return The writer. * @return The writer.
* @throws JSONException
*/ */
Writer write(Writer writer, int indentFactor, int indent) throws JSONException { Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
try { try {

View File

@@ -32,7 +32,8 @@ public class JSONException extends RuntimeException {
/** /**
* Constructs a JSONException with an explanatory message. * 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) { public JSONException(String message) {
super(message); super(message);
@@ -41,7 +42,8 @@ public class JSONException extends RuntimeException {
/** /**
* Constructs a new JSONException with the specified cause. * Constructs a new JSONException with the specified cause.
* *
* @param cause The cause. * @param cause
* The cause.
*/ */
public JSONException(Throwable cause) { public JSONException(Throwable cause) {
super(cause.getMessage()); super(cause.getMessage());

View File

@@ -34,9 +34,12 @@ public class JSONML {
/** /**
* Parse XML values and store them in a JSONArray. * Parse XML values and store them in a JSONArray.
* *
* @param x The XMLTokener containing the source string. * @param x
* @param arrayForm true if array form, false if object form. * The XMLTokener containing the source string.
* @param ja The JSONArray that is containing the current tag or null if we * @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. * are at the outermost level.
* @return A JSONArray if the value is the outermost tag, otherwise null. * @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 * JSONArrays will represent the child tags. Comments, prologs, DTDs, and
* <code>&lt;[ [ ]]></code> are ignored. * <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. * @return A JSONArray containing the structured data from the XML string.
*/ */
public static JSONArray toJSONArray(String string) throws JSONException { 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, * JSONArrays will represent the child content and tags. Comments, prologs,
* DTDs, and <code>&lt;[ [ ]]></code> are ignored. * 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. * @return A JSONArray containing the structured data from the XML string.
*/ */
public static JSONArray toJSONArray(XMLTokener x) throws JSONException { public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
@@ -261,7 +266,8 @@ public class JSONML {
* <p> * <p>
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored. * 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. * @return A JSONObject containing the structured data from the XML string.
*/ */
public static JSONObject toJSONObject(XMLTokener x) throws JSONException { public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
@@ -278,7 +284,8 @@ public class JSONML {
* <p> * <p>
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored. * 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. * @return A JSONObject containing the structured data from the XML string.
*/ */
public static JSONObject toJSONObject(String string) throws JSONException { 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. * Reverse the JSONML transformation, making an XML text from a JSONArray.
* *
* @param ja A JSONArray. * @param ja
* A JSONArray.
* @return An XML string. * @return An XML string.
*/ */
public static String toString(JSONArray ja) throws JSONException { 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. * then it must have a "childNodes" property containing an array of objects.
* The other properties are attributes with string values. * The other properties are attributes with string values.
* *
* @param jo A JSONObject. * @param jo
* A JSONObject.
* @return An XML string. * @return An XML string.
*/ */
public static String toString(JSONObject jo) throws JSONException { 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 * strings is used to identify the keys that should be copied. Missing keys
* are ignored. * are ignored.
* *
* @param jo A JSONObject. * @param jo
* @param names An array of strings. * A JSONObject.
* @param names
* An array of strings.
* @throws JSONException * @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. * duplicated.
*/ */
public JSONObject(JSONObject jo, String[] names) { public JSONObject(JSONObject jo, String[] names) {
@@ -134,8 +136,10 @@ public class JSONObject {
/** /**
* Construct a JSONObject from a JSONTokener. * Construct a JSONObject from a JSONTokener.
* *
* @param x A JSONTokener object containing the source string. * @param x
* @throws JSONException If there is a syntax error in the source string or a * A JSONTokener object containing the source string.
* @throws JSONException
* If there is a syntax error in the source string or a
* duplicated key. * duplicated key.
*/ */
public JSONObject(JSONTokener x) throws JSONException { public JSONObject(JSONTokener x) throws JSONException {
@@ -187,9 +191,9 @@ public class JSONObject {
/** /**
* Construct a JSONObject from a Map. * 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. * the JSONObject.
* @throws JSONException
*/ */
public JSONObject(Map<String, Object> map) { public JSONObject(Map<String, Object> map) {
this.map = new LinkedHashMap<>(); this.map = new LinkedHashMap<>();
@@ -222,7 +226,8 @@ public class JSONObject {
* <code>"Larry Fine"</code>, then the JSONObject will contain * <code>"Larry Fine"</code>, then the JSONObject will contain
* <code>"name": "Larry Fine"</code>. * <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. * a JSONObject.
*/ */
public JSONObject(Object bean) { 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 * those keys in the object. If a key is not found or not visible, then it
* will not be copied into the new JSONObject. * 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. * 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. * from the object.
*/ */
public JSONObject(Object object, String[] names) { 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 * Construct a JSONObject from a source JSON text string. This is the most
* commonly used JSONObject constructor. * 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; * brace)</small> and ending with <code>}</code> &nbsp;
* <small>(right brace)</small>. * <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. * duplicated key.
*/ */
public JSONObject(String source) throws JSONException { public JSONObject(String source) throws JSONException {
@@ -272,9 +281,12 @@ public class JSONObject {
/** /**
* Construct a JSONObject from a ResourceBundle. * Construct a JSONObject from a ResourceBundle.
* *
* @param baseName The ResourceBundle base name. * @param baseName
* @param locale The Locale to load the ResourceBundle for. * The ResourceBundle base name.
* @throws JSONException If any JSONExceptions are detected. * @param locale
* The Locale to load the ResourceBundle for.
* @throws JSONException
* If any JSONExceptions are detected.
*/ */
public JSONObject(String baseName, Locale locale) throws JSONException { public JSONObject(String baseName, Locale locale) throws JSONException {
this(); this();
@@ -314,7 +326,8 @@ public class JSONObject {
* Produce a string from a double. The string "null" will be returned if the * Produce a string from a double. The string "null" will be returned if the
* number is not finite. * number is not finite.
* *
* @param d A double. * @param d
* A double.
* @return A String. * @return A String.
*/ */
public static String doubleToString(double d) { public static String doubleToString(double d) {
@@ -381,9 +394,11 @@ public class JSONObject {
/** /**
* Produce a string from a Number. * Produce a string from a Number.
* *
* @param number A Number * @param number
* A Number
* @return A String. * @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 { public static String numberToString(Number number) throws JSONException {
if(number == null) { if(number == null) {
@@ -411,7 +426,8 @@ public class JSONObject {
* allowing JSON text to be delivered in HTML. In JSON text, a string cannot * allowing JSON text to be delivered in HTML. In JSON text, a string cannot
* contain a control character or an unescaped quote or backslash. * 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. * @return A String correctly formatted for insertion in a JSON text.
*/ */
public static String quote(String string) { 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 * Try to convert a string into a number, boolean, or null. If the string
* can't be converted, return the string. * can't be converted, return the string.
* *
* @param string A String. * @param string
* A String.
* @return A simple JSON value. * @return A simple JSON value.
*/ */
public static Object stringToValue(String string) { 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. * Throw an exception if the object is a NaN or infinite number.
* *
* @param o The object to test. * @param o
* @throws JSONException If o is a non-finite number. * The object to test.
* @throws JSONException
* If o is a non-finite number.
*/ */
public static void testValidity(Object o) throws JSONException { public static void testValidity(Object o) throws JSONException {
if(o != null) { if(o != null) {
@@ -572,12 +591,14 @@ public class JSONObject {
* <p> * <p>
* Warning: This method assumes that the data structure is acyclical. * 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 * @return a printable, displayable, transmittable representation of the
* object, beginning with <code>{</code>&nbsp;<small>(left * object, beginning with <code>{</code>&nbsp;<small>(left
* brace)</small> and ending with <code>}</code>&nbsp;<small>(right * brace)</small> and ending with <code>}</code>&nbsp;<small>(right
* brace)</small>. * 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 { public static String valueToString(Object value) throws JSONException {
if(value == null || value.equals(null)) { 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 * 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. * 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 * @return The wrapped value
*/ */
public static Object wrap(Object object) { 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, * will be the same as using put. But if multiple values are accumulated,
* then the result will be like append. * then the result will be like append.
* *
* @param key A key string. * @param key
* @param value An object to be accumulated under the key. * A key string.
* @param value
* An object to be accumulated under the key.
* @return this. * @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 { public JSONObject accumulate(String key, Object value) throws JSONException {
testValidity(value); testValidity(value);
@@ -740,10 +765,13 @@ public class JSONObject {
* JSONArray containing the value parameter. If the key was already * JSONArray containing the value parameter. If the key was already
* associated with a JSONArray, then the value parameter is appended to it. * associated with a JSONArray, then the value parameter is appended to it.
* *
* @param key A key string. * @param key
* @param value An object to be accumulated under the key. * A key string.
* @param value
* An object to be accumulated under the key.
* @return this. * @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. * the key is not a JSONArray.
*/ */
public JSONObject append(String key, Object value) throws JSONException { public JSONObject append(String key, Object value) throws JSONException {
@@ -762,9 +790,11 @@ public class JSONObject {
/** /**
* Get the value object associated with a key. * 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. * @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 { public Object get(String key) throws JSONException {
if(key == null) { if(key == null) {
@@ -780,10 +810,13 @@ public class JSONObject {
/** /**
* Get the enum value associated with a key. * Get the enum value associated with a key.
* *
* @param clazz The type of enum to retrieve. * @param clazz
* @param key A key string. * The type of enum to retrieve.
* @param key
* A key string.
* @return The enum value associated with the key * @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. * to an enum.
*/ */
public <E extends Enum<E>> E getEnum(Class<E> clazz, String key) throws JSONException { 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. * Get the boolean value associated with a key.
* *
* @param key A key string. * @param key
* A key string.
* @return The truth. * @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". * "false".
*/ */
public boolean getBoolean(String key) throws JSONException { public boolean getBoolean(String key) throws JSONException {
@@ -818,9 +853,11 @@ public class JSONObject {
/** /**
* Get the BigInteger value associated with a key. * Get the BigInteger value associated with a key.
* *
* @param key A key string. * @param key
* A key string.
* @return The numeric value. * @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. * to BigInteger.
*/ */
public BigInteger getBigInteger(String key) throws JSONException { public BigInteger getBigInteger(String key) throws JSONException {
@@ -836,9 +873,11 @@ public class JSONObject {
/** /**
* Get the BigDecimal value associated with a key. * Get the BigDecimal value associated with a key.
* *
* @param key A key string. * @param key
* A key string.
* @return The numeric value. * @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. * to BigDecimal.
*/ */
public BigDecimal getBigDecimal(String key) throws JSONException { public BigDecimal getBigDecimal(String key) throws JSONException {
@@ -854,9 +893,11 @@ public class JSONObject {
/** /**
* Get the double value associated with a key. * Get the double value associated with a key.
* *
* @param key A key string. * @param key
* A key string.
* @return The numeric value. * @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. * object and cannot be converted to a number.
*/ */
public double getDouble(String key) throws JSONException { public double getDouble(String key) throws JSONException {
@@ -872,9 +913,11 @@ public class JSONObject {
/** /**
* Get the int value associated with a key. * Get the int value associated with a key.
* *
* @param key A key string. * @param key
* A key string.
* @return The integer value. * @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. * to an integer.
*/ */
public int getInt(String key) throws JSONException { public int getInt(String key) throws JSONException {
@@ -890,9 +933,11 @@ public class JSONObject {
/** /**
* Get the JSONArray value associated with a key. * 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. * @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 { public JSONArray getJSONArray(String key) throws JSONException {
Object object = this.get(key); Object object = this.get(key);
@@ -905,9 +950,11 @@ public class JSONObject {
/** /**
* Get the JSONObject value associated with a key. * 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. * @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 { public JSONObject getJSONObject(String key) throws JSONException {
Object object = this.get(key); Object object = this.get(key);
@@ -920,9 +967,11 @@ public class JSONObject {
/** /**
* Get the long value associated with a key. * Get the long value associated with a key.
* *
* @param key A key string. * @param key
* A key string.
* @return The long value. * @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. * to a long.
*/ */
public long getLong(String key) throws JSONException { public long getLong(String key) throws JSONException {
@@ -938,9 +987,11 @@ public class JSONObject {
/** /**
* Get the string associated with a key. * Get the string associated with a key.
* *
* @param key A key string. * @param key
* A key string.
* @return A string which is the value. * @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 { public String getString(String key) throws JSONException {
Object object = this.get(key); Object object = this.get(key);
@@ -953,7 +1004,8 @@ public class JSONObject {
/** /**
* Determine if the JSONObject contains a specific key. * 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. * @return true if the key exists in the JSONObject.
*/ */
public boolean has(String key) { 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 * 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. * an Integer, Long, Double, or Float, then add one to it.
* *
* @param key A key string. * @param key
* A key string.
* @return this. * @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. * Integer, Long, Double, or Float.
*/ */
public JSONObject increment(String key) throws JSONException { 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 * Determine if the value associated with the key is null or if there is no
* value. * 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 * @return true if there is no value associated with the key or if the value
* is the JSONObject.NULL object. * is the JSONObject.NULL object.
*/ */
@@ -1050,7 +1105,8 @@ public class JSONObject {
/** /**
* Get an optional value associated with a key. * 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. * @return An object which is the value, or null if there is no value.
*/ */
public Object opt(String key) { public Object opt(String key) {
@@ -1060,8 +1116,10 @@ public class JSONObject {
/** /**
* Get the enum value associated with a key. * Get the enum value associated with a key.
* *
* @param clazz The type of enum to retrieve. * @param clazz
* @param key A key string. * The type of enum to retrieve.
* @param key
* A key string.
* @return The enum value associated with the key or null if not found * @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) { 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. * Get the enum value associated with a key.
* *
* @param clazz The type of enum to retrieve. * @param clazz
* @param key A key string. * The type of enum to retrieve.
* @param defaultValue The default in case the value is not found * @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 * @return The enum value associated with the key or defaultValue if the
* value is not found or cannot be assigned to clazz * 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 * 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". * 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. * @return The truth.
*/ */
public boolean optBoolean(String key) { 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 * defaultValue if there is no such key, or if it is not a Boolean or the
* String "true" or "false" (case insensitive). * String "true" or "false" (case insensitive).
* *
* @param key A key string. * @param key
* @param defaultValue The default. * A key string.
* @param defaultValue
* The default.
* @return The truth. * @return The truth.
*/ */
public boolean optBoolean(String key, boolean defaultValue) { 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 * 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. * 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. * @return An object which is the value.
*/ */
public double optDouble(String key) { 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 * 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. * string, an attempt will be made to evaluate it as a number.
* *
* @param key A key string. * @param key
* @param defaultValue The default. * A key string.
* @param defaultValue
* The default.
* @return An object which is the value. * @return An object which is the value.
*/ */
public BigInteger optBigInteger(String key, BigInteger defaultValue) { 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 * 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. * string, an attempt will be made to evaluate it as a number.
* *
* @param key A key string. * @param key
* @param defaultValue The default. * A key string.
* @param defaultValue
* The default.
* @return An object which is the value. * @return An object which is the value.
*/ */
public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) { 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 * 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. * string, an attempt will be made to evaluate it as a number.
* *
* @param key A key string. * @param key
* @param defaultValue The default. * A key string.
* @param defaultValue
* The default.
* @return An object which is the value. * @return An object which is the value.
*/ */
public double optDouble(String key, double defaultValue) { 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 * 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. * 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. * @return An object which is the value.
*/ */
public int optInt(String key) { 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, * 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. * an attempt will be made to evaluate it as a number.
* *
* @param key A key string. * @param key
* @param defaultValue The default. * A key string.
* @param defaultValue
* The default.
* @return An object which is the value. * @return An object which is the value.
*/ */
public int optInt(String key, int defaultValue) { 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 * 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. * 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. * @return A JSONArray which is the value.
*/ */
public JSONArray optJSONArray(String key) { public JSONArray optJSONArray(String key) {
@@ -1240,7 +1315,8 @@ public class JSONObject {
* Get an optional JSONObject associated with a key. It returns null if * 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. * 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. * @return A JSONObject which is the value.
*/ */
public JSONObject optJSONObject(String key) { 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 * 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. * 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. * @return An object which is the value.
*/ */
public long optLong(String key) { 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, * 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. * an attempt will be made to evaluate it as a number.
* *
* @param key A key string. * @param key
* @param defaultValue The default. * A key string.
* @param defaultValue
* The default.
* @return An object which is the value. * @return An object which is the value.
*/ */
public long optLong(String key, long defaultValue) { 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, * if there is no such key. If the value is not a string and is not null,
* then it is converted to a string. * then it is converted to a string.
* *
* @param key A key string. * @param key
* A key string.
* @return A string which is the value. * @return A string which is the value.
*/ */
public String optString(String key) { public String optString(String key) {
@@ -1294,8 +1374,10 @@ public class JSONObject {
* Get an optional string associated with a key. It returns the defaultValue * Get an optional string associated with a key. It returns the defaultValue
* if there is no such key. * if there is no such key.
* *
* @param key A key string. * @param key
* @param defaultValue The default. * A key string.
* @param defaultValue
* The default.
* @return A string which is the value. * @return A string which is the value.
*/ */
public String optString(String key, String defaultValue) { public String optString(String key, String defaultValue) {
@@ -1348,10 +1430,13 @@ public class JSONObject {
/** /**
* Put a key/boolean pair in the JSONObject. * Put a key/boolean pair in the JSONObject.
* *
* @param key A key string. * @param key
* @param value A boolean which is the value. * A key string.
* @param value
* A boolean which is the value.
* @return this. * @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 { public JSONObject put(String key, boolean value) throws JSONException {
this.put(key, value ? Boolean.TRUE : Boolean.FALSE); 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 * Put a key/value pair in the JSONObject, where the value will be a
* JSONArray which is produced from a Collection. * JSONArray which is produced from a Collection.
* *
* @param key A key string. * @param key
* @param value A Collection value. * A key string.
* @param value
* A Collection value.
* @return this. * @return this.
* @throws JSONException
*/ */
public JSONObject put(String key, Collection<Object> value) throws JSONException { public JSONObject put(String key, Collection<Object> value) throws JSONException {
this.put(key, new JSONArray(value)); this.put(key, new JSONArray(value));
@@ -1375,10 +1461,13 @@ public class JSONObject {
/** /**
* Put a key/double pair in the JSONObject. * Put a key/double pair in the JSONObject.
* *
* @param key A key string. * @param key
* @param value A double which is the value. * A key string.
* @param value
* A double which is the value.
* @return this. * @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 { public JSONObject put(String key, double value) throws JSONException {
this.put(key, Double.valueOf(value)); this.put(key, Double.valueOf(value));
@@ -1388,10 +1477,13 @@ public class JSONObject {
/** /**
* Put a key/int pair in the JSONObject. * Put a key/int pair in the JSONObject.
* *
* @param key A key string. * @param key
* @param value An int which is the value. * A key string.
* @param value
* An int which is the value.
* @return this. * @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 { public JSONObject put(String key, int value) throws JSONException {
this.put(key, Integer.valueOf(value)); this.put(key, Integer.valueOf(value));
@@ -1401,10 +1493,13 @@ public class JSONObject {
/** /**
* Put a key/long pair in the JSONObject. * Put a key/long pair in the JSONObject.
* *
* @param key A key string. * @param key
* @param value A long which is the value. * A key string.
* @param value
* A long which is the value.
* @return this. * @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 { public JSONObject put(String key, long value) throws JSONException {
this.put(key, Long.valueOf(value)); 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 * Put a key/value pair in the JSONObject, where the value will be a
* JSONObject which is produced from a Map. * JSONObject which is produced from a Map.
* *
* @param key A key string. * @param key
* @param value A Map value. * A key string.
* @param value
* A Map value.
* @return this. * @return this.
* @throws JSONException
*/ */
public JSONObject put(String key, Map<String, Object> value) throws JSONException { public JSONObject put(String key, Map<String, Object> value) throws JSONException {
this.put(key, new JSONObject(value)); 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 * 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. * key will be removed from the JSONObject if it is present.
* *
* @param key A key string. * @param key
* @param value An object which is the value. It should be of one of these * 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, * types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
* String, or the JSONObject.NULL object. * String, or the JSONObject.NULL object.
* @return this. * @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 { public JSONObject put(String key, Object value) throws JSONException {
if(key == null) { 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 * are both non-null, and only if there is not already a member with that
* name. * name.
* *
* @param key string * @param key
* @param value object * string
* @param value
* object
* @return this. * @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 { public JSONObject putOnce(String key, Object value) throws JSONException {
if(key != null && value != null) { 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 * Put a key/value pair in the JSONObject, but only if the key and the value
* are both non-null. * are both non-null.
* *
* @param key A key string. * @param key
* @param value An object which is the value. It should be of one of these * 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, * types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
* String, or the JSONObject.NULL object. * String, or the JSONObject.NULL object.
* @return this. * @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 { public JSONObject putOpt(String key, Object value) throws JSONException {
if(key != null && value != null) { if(key != null && value != null) {
@@ -1490,7 +1595,8 @@ public class JSONObject {
/** /**
* Remove a name and its value, if present. * 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 * @return The value that was associated with the name, or null if there was
* no value. * no value.
*/ */
@@ -1502,7 +1608,8 @@ public class JSONObject {
* Determine if two JSONObjects are similar. They must contain the same set * Determine if two JSONObjects are similar. They must contain the same set
* of names which must be associated with similar values. * 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 * @return true if they are equal
*/ */
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @SuppressWarnings("BooleanMethodIsAlwaysInverted")
@@ -1543,10 +1650,12 @@ public class JSONObject {
* Produce a JSONArray containing the values of the members of this * Produce a JSONArray containing the values of the members of this
* JSONObject. * 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. * the sequence of the values in the result.
* @return A JSONArray of values. * @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 { public JSONArray toJSONArray(JSONArray names) throws JSONException {
if(names == null || names.length() == 0) { if(names == null || names.length() == 0) {
@@ -1585,12 +1694,14 @@ public class JSONObject {
* <p> * <p>
* Warning: This method assumes that the data structure is acyclical. * 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 * @return a printable, displayable, portable, transmittable representation
* of the object, beginning with <code>{</code>&nbsp;<small>(left * of the object, beginning with <code>{</code>&nbsp;<small>(left
* brace)</small> and ending with <code>}</code>&nbsp;<small>(right * brace)</small> and ending with <code>}</code>&nbsp;<small>(right
* brace)</small>. * 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 { public String toString(int indentFactor) throws JSONException {
StringWriter w = new StringWriter(); StringWriter w = new StringWriter();
@@ -1606,7 +1717,6 @@ public class JSONObject {
* Warning: This method assumes that the data structure is acyclical. * Warning: This method assumes that the data structure is acyclical.
* *
* @return The writer. * @return The writer.
* @throws JSONException
*/ */
public Writer write(Writer writer) throws JSONException { public Writer write(Writer writer) throws JSONException {
return this.write(writer, 0, 0); return this.write(writer, 0, 0);
@@ -1619,7 +1729,6 @@ public class JSONObject {
* Warning: This method assumes that the data structure is acyclical. * Warning: This method assumes that the data structure is acyclical.
* *
* @return The writer. * @return The writer.
* @throws JSONException
*/ */
Writer write(Writer writer, int indentFactor, int indent) throws JSONException { Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
try { try {
@@ -1689,7 +1798,8 @@ public class JSONObject {
/** /**
* A Null object is equal to the null value and to itself. * 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 * @return true if the object parameter is the JSONObject.NULL object or
* null. * null.
*/ */

View File

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

View File

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

View File

@@ -87,7 +87,8 @@ public class XML {
* &quot; <small>(double quote)</small> is replaced by &amp;quot; * &quot; <small>(double quote)</small> is replaced by &amp;quot;
* </pre> * </pre>
* *
* @param string The string to be escaped. * @param string
* The string to be escaped.
* @return The escaped string. * @return The escaped string.
*/ */
public static String escape(String string) { public static String escape(String string) {
@@ -110,7 +111,8 @@ public class XML {
* Throw an exception if the string contains whitespace. Whitespace is not * Throw an exception if the string contains whitespace. Whitespace is not
* allowed in tagNames and attributes. * allowed in tagNames and attributes.
* *
* @param string A string. * @param string
* A string.
*/ */
public static void noSpace(String string) throws JSONException { public static void noSpace(String string) throws JSONException {
int i, length = string.length(); int i, length = string.length();
@@ -127,9 +129,12 @@ public class XML {
/** /**
* Scan the content following the named tag, attaching it to the context. * Scan the content following the named tag, attaching it to the context.
* *
* @param x The XMLTokener containing the source string. * @param x
* @param context The JSONObject that will include the new material. * The XMLTokener containing the source string.
* @param name The tag name. * @param context
* The JSONObject that will include the new material.
* @param name
* The tag name.
* @return true if the close tag is processed. * @return true if the close tag is processed.
*/ */
private static boolean parse(XMLTokener x, JSONObject context, String name) throws JSONException { private static boolean parse(XMLTokener x, JSONObject context, String name) throws JSONException {
@@ -297,7 +302,8 @@ public class XML {
* convert plus forms, octal forms, hex forms, or E forms lacking decimal * convert plus forms, octal forms, hex forms, or E forms lacking decimal
* points. * points.
* *
* @param string A String. * @param string
* A String.
* @return A simple JSON value. * @return A simple JSON value.
*/ */
public static Object stringToValue(String string) { public static Object stringToValue(String string) {
@@ -348,7 +354,8 @@ public class XML {
* "content" member. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> * "content" member. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code>
* are ignored. * are ignored.
* *
* @param string The source string. * @param string
* The source string.
* @return A JSONObject containing the structured data from the XML string. * @return A JSONObject containing the structured data from the XML string.
*/ */
public static JSONObject toJSONObject(String string) throws JSONException { public static JSONObject toJSONObject(String string) throws JSONException {
@@ -363,7 +370,8 @@ public class XML {
/** /**
* Convert a JSONObject into a well-formed, element-normal XML string. * Convert a JSONObject into a well-formed, element-normal XML string.
* *
* @param object A JSONObject. * @param object
* A JSONObject.
* @return A string. * @return A string.
*/ */
public static String toString(Object object) throws JSONException { public static String toString(Object object) throws JSONException {
@@ -373,8 +381,10 @@ public class XML {
/** /**
* Convert a JSONObject into a well-formed, element-normal XML string. * Convert a JSONObject into a well-formed, element-normal XML string.
* *
* @param object A JSONObject. * @param object
* @param tagName The optional name of the enclosing tag. * A JSONObject.
* @param tagName
* The optional name of the enclosing tag.
* @return A string. * @return A string.
*/ */
public static String toString(Object object, String tagName) throws JSONException { public static String toString(Object object, String tagName) throws JSONException {

View File

@@ -46,7 +46,8 @@ public class XMLTokener extends JSONTokener {
/** /**
* Construct an XMLTokener from a string. * Construct an XMLTokener from a string.
* *
* @param s A source string. * @param s
* A source string.
*/ */
public XMLTokener(String s) { public XMLTokener(String s) {
super(s); super(s);
@@ -56,7 +57,8 @@ public class XMLTokener extends JSONTokener {
* Get the text in the CDATA block. * Get the text in the CDATA block.
* *
* @return The string up to the <code>]]&gt;</code>. * @return The string up to the <code>]]&gt;</code>.
* @throws JSONException If the <code>]]&gt;</code> is not found. * @throws JSONException
* If the <code>]]&gt;</code> is not found.
*/ */
public String nextCDATA() throws JSONException { public String nextCDATA() throws JSONException {
char c; char c;
@@ -115,9 +117,11 @@ public class XMLTokener extends JSONTokener {
* Return the next entity. These entities are translated to Characters: * Return the next entity. These entities are translated to Characters:
* <code>&amp; &apos; &gt; &lt; &quot;</code>. * <code>&amp; &apos; &gt; &lt; &quot;</code>.
* *
* @param ampersand An ampersand character. * @param ampersand
* An ampersand character.
* @return A Character or an entity String if the entity is not recognized. * @return A Character or an entity String if the entity is not recognized.
* @throws JSONException If missing ';' in XML entity. * @throws JSONException
* If missing ';' in XML entity.
*/ */
public Object nextEntity(char ampersand) throws JSONException { public Object nextEntity(char ampersand) throws JSONException {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -143,7 +147,8 @@ public class XMLTokener extends JSONTokener {
* @return Syntax characters (<code>< > / = ! ?</code>) are returned as * @return Syntax characters (<code>< > / = ! ?</code>) are returned as
* Character, and strings and names are returned as Boolean. We * Character, and strings and names are returned as Boolean. We
* don't care what the values actually are. * don't care what the values actually are.
* @throws JSONException If a string is not properly closed or if the XML is badly * @throws JSONException
* If a string is not properly closed or if the XML is badly
* structured. * structured.
*/ */
public Object nextMeta() throws JSONException { public Object nextMeta() throws JSONException {
@@ -201,7 +206,8 @@ public class XMLTokener extends JSONTokener {
* string wrapped in single quotes or double quotes, or it may be a name. * string wrapped in single quotes or double quotes, or it may be a name.
* *
* @return a String or a Character. * @return a String or a Character.
* @throws JSONException If the XML is not well formed. * @throws JSONException
* If the XML is not well formed.
*/ */
public Object nextToken() throws JSONException { public Object nextToken() throws JSONException {
char c; char c;
@@ -282,7 +288,8 @@ public class XMLTokener extends JSONTokener {
* Skip characters until past the requested string. If it is not found, we * Skip characters until past the requested string. If it is not found, we
* are left at the end of the source with a result of false. * are left at the end of the source with a result of false.
* *
* @param to A string to skip past. * @param to
* A string to skip past.
*/ */
public boolean skipPast(String to) throws JSONException { public boolean skipPast(String to) throws JSONException {
boolean b; boolean b;

View File

@@ -68,8 +68,10 @@ public class Mantle {
/** /**
* Create a new mantle * Create a new mantle
* *
* @param dataFolder the data folder * @param dataFolder
* @param worldHeight the world's height (in blocks) * the data folder
* @param worldHeight
* the world's height (in blocks)
*/ */
@BlockCoordinates @BlockCoordinates
public Mantle(File dataFolder, int worldHeight) { public Mantle(File dataFolder, int worldHeight) {
@@ -89,9 +91,12 @@ public class Mantle {
/** /**
* Get the file for a region * Get the file for a region
* *
* @param folder the folder * @param folder
* @param x the x coord * the folder
* @param z the z coord * @param x
* the x coord
* @param z
* the z coord
* @return the file * @return the file
*/ */
public static File fileForRegion(File folder, int x, int z) { public static File fileForRegion(File folder, int x, int z) {
@@ -101,8 +106,10 @@ public class Mantle {
/** /**
* Get the file for the given region * Get the file for the given region
* *
* @param folder the data folder * @param folder
* @param key the region key * the data folder
* @param key
* the region key
* @return the file * @return the file
*/ */
public static File fileForRegion(File folder, Long key) { public static File fileForRegion(File folder, Long key) {
@@ -116,8 +123,10 @@ public class Mantle {
/** /**
* Get the long value representing a chunk or region coordinate * Get the long value representing a chunk or region coordinate
* *
* @param x the x * @param x
* @param z the z * the x
* @param z
* the z
* @return the value * @return the value
*/ */
public static Long key(int x, int z) { public static Long key(int x, int z) {
@@ -127,10 +136,14 @@ public class Mantle {
/** /**
* Raise a flag if it is lowered currently, If the flag was raised, execute the runnable * Raise a flag if it is lowered currently, If the flag was raised, execute the runnable
* *
* @param x the chunk x * @param x
* @param z the chunk z * the chunk x
* @param flag the flag to raise * @param z
* @param r the runnable to fire if the flag is now raised (and was previously lowered) * the chunk z
* @param flag
* the flag to raise
* @param r
* the runnable to fire if the flag is now raised (and was previously lowered)
*/ */
@ChunkCoordinates @ChunkCoordinates
public void raiseFlag(int x, int z, MantleFlag flag, Runnable r) { public void raiseFlag(int x, int z, MantleFlag flag, Runnable r) {
@@ -144,9 +157,12 @@ public class Mantle {
* Obtain a cached writer which only contains cached chunks. * Obtain a cached writer which only contains cached chunks.
* This avoids locking on regions when writing to lots of chunks * This avoids locking on regions when writing to lots of chunks
* *
* @param x the x chunk * @param x
* @param z the z chunk * the x chunk
* @param radius the radius chunks * @param z
* the z chunk
* @param radius
* the radius chunks
* @return the writer * @return the writer
*/ */
@ChunkCoordinates @ChunkCoordinates
@@ -157,10 +173,14 @@ public class Mantle {
/** /**
* Lower a flag if it is raised. If the flag was lowered (meaning it was previously raised), execute the runnable * Lower a flag if it is raised. If the flag was lowered (meaning it was previously raised), execute the runnable
* *
* @param x the chunk x * @param x
* @param z the chunk z * the chunk x
* @param flag the flag to lower * @param z
* @param r the runnable that is fired if the flag was raised but is now lowered * the chunk z
* @param flag
* the flag to lower
* @param r
* the runnable that is fired if the flag was raised but is now lowered
*/ */
@ChunkCoordinates @ChunkCoordinates
public void lowerFlag(int x, int z, MantleFlag flag, Runnable r) { public void lowerFlag(int x, int z, MantleFlag flag, Runnable r) {
@@ -178,10 +198,14 @@ public class Mantle {
/** /**
* Flag or unflag a chunk * Flag or unflag a chunk
* *
* @param x the chunk x * @param x
* @param z the chunk z * the chunk x
* @param flag the flag * @param z
* @param flagged should it be set to flagged or not * the chunk z
* @param flag
* the flag
* @param flagged
* should it be set to flagged or not
*/ */
@ChunkCoordinates @ChunkCoordinates
public void flag(int x, int z, MantleFlag flag, boolean flagged) { public void flag(int x, int z, MantleFlag flag, boolean flagged) {
@@ -195,8 +219,10 @@ public class Mantle {
/** /**
* Check very quickly if a tectonic plate exists via cached or the file system * Check very quickly if a tectonic plate exists via cached or the file system
* *
* @param x the x region coordinate * @param x
* @param z the z region coordinate * the x region coordinate
* @param z
* the z region coordinate
* @return true if it exists * @return true if it exists
*/ */
@RegionCoordinates @RegionCoordinates
@@ -208,11 +234,16 @@ public class Mantle {
/** /**
* Iterate data in a chunk * Iterate data in a chunk
* *
* @param x the chunk x * @param x
* @param z the chunk z * the chunk x
* @param type the type of data to iterate * @param z
* @param iterator the iterator (x,y,z,data) -> do stuff * the chunk z
* @param <T> the type of data to iterate * @param type
* the type of data to iterate
* @param iterator
* the iterator (x,y,z,data) -> do stuff
* @param <T>
* the type of data to iterate
*/ */
@ChunkCoordinates @ChunkCoordinates
public <T> void iterateChunk(int x, int z, Class<T> type, Consumer4<Integer, Integer, Integer, T> iterator) { public <T> void iterateChunk(int x, int z, Class<T> type, Consumer4<Integer, Integer, Integer, T> iterator) {
@@ -226,9 +257,12 @@ public class Mantle {
/** /**
* Does this chunk have a flag on it? * Does this chunk have a flag on it?
* *
* @param x the x * @param x
* @param z the z * the x
* @param flag the flag to test * @param z
* the z
* @param flag
* the flag to test
* @return true if it's flagged * @return true if it's flagged
*/ */
@ChunkCoordinates @ChunkCoordinates
@@ -248,11 +282,16 @@ public class Mantle {
* reading & writing other regions. Hyperlocks are slow sync, but in multicore * reading & writing other regions. Hyperlocks are slow sync, but in multicore
* environments, they drastically speed up loading & saving large counts of plates * environments, they drastically speed up loading & saving large counts of plates
* *
* @param x the block's x coordinate * @param x
* @param y the block's y coordinate * the block's x coordinate
* @param z the block's z coordinate * @param y
* @param t the data to set at the block * the block's y coordinate
* @param <T> the type of data (generic method) * @param z
* the block's z coordinate
* @param t
* the data to set at the block
* @param <T>
* the type of data (generic method)
*/ */
@BlockCoordinates @BlockCoordinates
public <T> void set(int x, int y, int z, T t) { public <T> void set(int x, int y, int z, T t) {
@@ -296,11 +335,16 @@ public class Mantle {
* reading & writing other regions. Hyperlocks are slow sync, but in multicore * reading & writing other regions. Hyperlocks are slow sync, but in multicore
* environments, they drastically speed up loading & saving large counts of plates * environments, they drastically speed up loading & saving large counts of plates
* *
* @param x the block's x coordinate * @param x
* @param y the block's y coordinate * the block's x coordinate
* @param z the block's z coordinate * @param y
* @param t the class representing the type of data being requested * the block's y coordinate
* @param <T> the type assumed from the provided class * @param z
* the block's z coordinate
* @param t
* the class representing the type of data being requested
* @param <T>
* the type assumed from the provided class
* @return the returned result (or null) if it doesnt exist * @return the returned result (or null) if it doesnt exist
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -370,7 +414,8 @@ public class Mantle {
* Save & unload regions that have not been used for more than the * Save & unload regions that have not been used for more than the
* specified amount of milliseconds * specified amount of milliseconds
* *
* @param idleDuration the duration * @param idleDuration
* the duration
*/ */
public synchronized void trim(long idleDuration) { public synchronized void trim(long idleDuration) {
if(closed.get()) { if(closed.get()) {
@@ -410,8 +455,10 @@ public class Mantle {
* This retreives a future of the Tectonic Plate at the given coordinates. * This retreives a future of the Tectonic Plate at the given coordinates.
* All methods accessing tectonic plates should go through this method * All methods accessing tectonic plates should go through this method
* *
* @param x the region x * @param x
* @param z the region z * the region x
* @param z
* the region z
* @return the future of a tectonic plate. * @return the future of a tectonic plate.
*/ */
@RegionCoordinates @RegionCoordinates
@@ -450,8 +497,10 @@ public class Mantle {
* This retreives a future of the Tectonic Plate at the given coordinates. * This retreives a future of the Tectonic Plate at the given coordinates.
* All methods accessing tectonic plates should go through this method * All methods accessing tectonic plates should go through this method
* *
* @param x the region x * @param x
* @param z the region z * the region x
* @param z
* the region z
* @return the future of a tectonic plate. * @return the future of a tectonic plate.
*/ */
@RegionCoordinates @RegionCoordinates

View File

@@ -19,7 +19,6 @@
package com.volmit.iris.util.mantle; package com.volmit.iris.util.mantle;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.engine.EnginePanic;
import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.function.Consumer4; import com.volmit.iris.util.function.Consumer4;
import com.volmit.iris.util.matter.IrisMatter; import com.volmit.iris.util.matter.IrisMatter;
@@ -48,7 +47,8 @@ public class MantleChunk {
/** /**
* Create a mantle chunk * Create a mantle chunk
* *
* @param sectionHeight the height of the world in sections (blocks >> 4) * @param sectionHeight
* the height of the world in sections (blocks >> 4)
*/ */
@ChunkCoordinates @ChunkCoordinates
public MantleChunk(int sectionHeight, int x, int z) { public MantleChunk(int sectionHeight, int x, int z) {
@@ -65,10 +65,14 @@ public class MantleChunk {
/** /**
* Load a mantle chunk from a data stream * Load a mantle chunk from a data stream
* *
* @param sectionHeight the height of the world in sections (blocks >> 4) * @param sectionHeight
* @param din the data input * the height of the world in sections (blocks >> 4)
* @throws IOException shit happens * @param din
* @throws ClassNotFoundException shit happens * the data input
* @throws IOException
* shit happens
* @throws ClassNotFoundException
* shit happens
*/ */
public MantleChunk(int sectionHeight, DataInputStream din) throws IOException, ClassNotFoundException { public MantleChunk(int sectionHeight, DataInputStream din) throws IOException, ClassNotFoundException {
this(sectionHeight, din.readByte(), din.readByte()); this(sectionHeight, din.readByte(), din.readByte());
@@ -104,7 +108,8 @@ public class MantleChunk {
/** /**
* Check if a section exists (same as get(section) != null) * Check if a section exists (same as get(section) != null)
* *
* @param section the section (0 - (worldHeight >> 4)) * @param section
* the section (0 - (worldHeight >> 4))
* @return true if it exists * @return true if it exists
*/ */
@ChunkCoordinates @ChunkCoordinates
@@ -115,7 +120,8 @@ public class MantleChunk {
/** /**
* Get thje matter at the given section or null if it doesnt exist * Get thje matter at the given section or null if it doesnt exist
* *
* @param section the section (0 - (worldHeight >> 4)) * @param section
* the section (0 - (worldHeight >> 4))
* @return the matter or null if it doesnt exist * @return the matter or null if it doesnt exist
*/ */
@ChunkCoordinates @ChunkCoordinates
@@ -135,7 +141,8 @@ public class MantleChunk {
/** /**
* Delete the matter from the given section * Delete the matter from the given section
* *
* @param section the section (0 - (worldHeight >> 4)) * @param section
* the section (0 - (worldHeight >> 4))
*/ */
@ChunkCoordinates @ChunkCoordinates
public void delete(int section) { public void delete(int section) {
@@ -145,7 +152,8 @@ public class MantleChunk {
/** /**
* Get or create a new matter section at the given section * Get or create a new matter section at the given section
* *
* @param section the section (0 - (worldHeight >> 4)) * @param section
* the section (0 - (worldHeight >> 4))
* @return the matter * @return the matter
*/ */
@ChunkCoordinates @ChunkCoordinates
@@ -163,8 +171,10 @@ public class MantleChunk {
/** /**
* Write this chunk to a data stream * Write this chunk to a data stream
* *
* @param dos the stream * @param dos
* @throws IOException shit happens * the stream
* @throws IOException
* shit happens
*/ */
public void write(DataOutputStream dos) throws IOException { public void write(DataOutputStream dos) throws IOException {
dos.writeByte(x); dos.writeByte(x);

View File

@@ -54,7 +54,8 @@ public class TectonicPlate {
/** /**
* Create a new tectonic plate * Create a new tectonic plate
* *
* @param worldHeight the height of the world * @param worldHeight
* the height of the world
*/ */
public TectonicPlate(int worldHeight, int x, int z) { public TectonicPlate(int worldHeight, int x, int z) {
this.sectionHeight = worldHeight >> 4; this.sectionHeight = worldHeight >> 4;
@@ -66,10 +67,14 @@ public class TectonicPlate {
/** /**
* Load a tectonic plate from a data stream * Load a tectonic plate from a data stream
* *
* @param worldHeight the height of the world * @param worldHeight
* @param din the data input * the height of the world
* @throws IOException shit happens yo * @param din
* @throws ClassNotFoundException real shit bro * the data input
* @throws IOException
* shit happens yo
* @throws ClassNotFoundException
* real shit bro
*/ */
public TectonicPlate(int worldHeight, DataInputStream din) throws IOException, ClassNotFoundException { public TectonicPlate(int worldHeight, DataInputStream din) throws IOException, ClassNotFoundException {
this(worldHeight, din.readInt(), din.readInt()); this(worldHeight, din.readInt(), din.readInt());
@@ -95,8 +100,10 @@ public class TectonicPlate {
/** /**
* Check if a chunk exists in this plate or not (same as get(x, z) != null) * Check if a chunk exists in this plate or not (same as get(x, z) != null)
* *
* @param x the chunk relative x (0-31) * @param x
* @param z the chunk relative z (0-31) * the chunk relative x (0-31)
* @param z
* the chunk relative z (0-31)
* @return true if the chunk exists * @return true if the chunk exists
*/ */
@ChunkCoordinates @ChunkCoordinates
@@ -107,8 +114,10 @@ public class TectonicPlate {
/** /**
* Get a chunk at the given coordinates or null if it doesnt exist * Get a chunk at the given coordinates or null if it doesnt exist
* *
* @param x the chunk relative x (0-31) * @param x
* @param z the chunk relative z (0-31) * the chunk relative x (0-31)
* @param z
* the chunk relative z (0-31)
* @return the chunk or null if it doesnt exist * @return the chunk or null if it doesnt exist
*/ */
@ChunkCoordinates @ChunkCoordinates
@@ -128,8 +137,10 @@ public class TectonicPlate {
/** /**
* Delete a chunk from this tectonic plate * Delete a chunk from this tectonic plate
* *
* @param x the chunk relative x (0-31) * @param x
* @param z the chunk relative z (0-31) * the chunk relative x (0-31)
* @param z
* the chunk relative z (0-31)
*/ */
@ChunkCoordinates @ChunkCoordinates
public void delete(int x, int z) { public void delete(int x, int z) {
@@ -139,8 +150,10 @@ public class TectonicPlate {
/** /**
* Get a tectonic plate, or create one and insert it & return it if it diddnt exist * Get a tectonic plate, or create one and insert it & return it if it diddnt exist
* *
* @param x the chunk relative x (0-31) * @param x
* @param z the chunk relative z (0-31) * the chunk relative x (0-31)
* @param z
* the chunk relative z (0-31)
* @return the chunk (read or created & inserted) * @return the chunk (read or created & inserted)
*/ */
@ChunkCoordinates @ChunkCoordinates
@@ -163,8 +176,10 @@ public class TectonicPlate {
/** /**
* Write this tectonic plate to file * Write this tectonic plate to file
* *
* @param file the file to writeNodeData it to * @param file
* @throws IOException shit happens * the file to writeNodeData it to
* @throws IOException
* shit happens
*/ */
public void write(File file) throws IOException { public void write(File file) throws IOException {
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
@@ -179,8 +194,10 @@ public class TectonicPlate {
/** /**
* Write this tectonic plate to a data stream * Write this tectonic plate to a data stream
* *
* @param dos the data output * @param dos
* @throws IOException shit happens * the data output
* @throws IOException
* shit happens
*/ */
public void write(DataOutputStream dos) throws IOException { public void write(DataOutputStream dos) throws IOException {
dos.writeInt(x); dos.writeInt(x);

View File

@@ -38,7 +38,8 @@ public class Average {
/** /**
* Create an average holder * Create an average holder
* *
* @param size the size of entries to keep * @param size
* the size of entries to keep
*/ */
public Average(int size) { public Average(int size) {
values = new double[size]; values = new double[size];
@@ -53,7 +54,8 @@ public class Average {
/** /**
* Put a value into the average (rolls over if full) * Put a value into the average (rolls over if full)
* *
* @param i the value * @param i
* the value
*/ */
public void put(double i) { public void put(double i) {

View File

@@ -142,7 +142,8 @@ public enum Direction {
* Get the directional value from the given byte from common directional blocks * Get the directional value from the given byte from common directional blocks
* (MUST BE BETWEEN 0 and 5 INCLUSIVE) * (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 * @return the direction or null if the byte is outside of the inclusive range
* 0-5 * 0-5
*/ */

View File

@@ -33,7 +33,8 @@ public class FinalInteger extends Wrapper<Integer> {
/** /**
* Add to this value * Add to this value
* *
* @param i the number to add to this value (value = value + i) * @param i
* the number to add to this value (value = value + i)
*/ */
public void add(int i) { public void add(int i) {
set(get() + i); set(get() + i);
@@ -42,7 +43,8 @@ public class FinalInteger extends Wrapper<Integer> {
/** /**
* Subtract from this value * Subtract from this value
* *
* @param i the number to subtract from this value (value = value - i) * @param i
* the number to subtract from this value (value = value - i)
*/ */
public void sub(int i) { public void sub(int i) {
set(get() - i); set(get() - i);

View File

@@ -88,11 +88,16 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
/** /**
* Returns the linear combination of the given coefficients with the nodes adjacent to baseIndex. * Returns the linear combination of the given coefficients with the nodes adjacent to baseIndex.
* *
* @param baseIndex node index * @param baseIndex
* @param f1 coefficient for baseIndex-1 * node index
* @param f2 coefficient for baseIndex * @param f1
* @param f3 coefficient for baseIndex+1 * coefficient for baseIndex-1
* @param f4 coefficient for baseIndex+2 * @param f2
* coefficient for baseIndex
* @param f3
* coefficient for baseIndex+1
* @param f4
* coefficient for baseIndex+2
* @return linear combination of nodes[n-1..n+2] with f1..4 * @return linear combination of nodes[n-1..n+2] with f1..4
*/ */
private Vector linearCombination(int baseIndex, double f1, double f2, double f3, double f4) { private Vector linearCombination(int baseIndex, double f1, double f2, double f3, double f4) {
@@ -107,7 +112,8 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
/** /**
* Retrieves a node. Indexes are clamped to the valid range. * Retrieves a node. Indexes are clamped to the valid range.
* *
* @param index node index to retrieve * @param index
* node index to retrieve
* @return nodes[clamp(0, nodes.length - 1)] * @return nodes[clamp(0, nodes.length - 1)]
*/ */
private Vector retrieve(int index) { private Vector retrieve(int index) {

View File

@@ -52,11 +52,16 @@ public class M {
* <br/> * <br/>
* would return 10 * would return 10
* *
* @param amin the resulting minimum * @param amin
* @param amax the resulting maximum * the resulting minimum
* @param bmin the initial minimum * @param amax
* @param bmax the initial maximum * the resulting maximum
* @param b the initial value * @param bmin
* the initial minimum
* @param bmax
* the initial maximum
* @param b
* the initial value
* @return the resulting value * @return the resulting value
*/ */
public static double rangeScale(double amin, double amax, double bmin, double bmax, double b) { public static double rangeScale(double amin, double amax, double bmin, double bmax, double b) {
@@ -68,9 +73,12 @@ public class M {
* <p> * <p>
* If from = 0 and to = 100 and at = 25 then it would return 0.25 * If from = 0 and to = 100 and at = 25 then it would return 0.25
* *
* @param from the from * @param from
* @param to the to * the from
* @param at the at * @param to
* the to
* @param at
* the at
* @return the percent * @return the percent
*/ */
public static double lerpInverse(double from, double to, double at) { public static double lerpInverse(double from, double to, double at) {
@@ -80,9 +88,12 @@ public class M {
/** /**
* Linear interpolation from a to b where f is the percent across * Linear interpolation from a to b where f is the percent across
* *
* @param a the first pos (0) * @param a
* @param b the second pos (1) * the first pos (0)
* @param f the percent * @param b
* the second pos (1)
* @param f
* the percent
* @return the value * @return the value
*/ */
public static double lerp(double a, double b, double f) { public static double lerp(double a, double b, double f) {
@@ -92,10 +103,14 @@ public class M {
/** /**
* Bilinear interpolation * Bilinear interpolation
* *
* @param a the first point (0, 0) * @param a
* @param b the second point (1, 0) * the first point (0, 0)
* @param c the third point (0, 1) * @param b
* @param d the fourth point (1, 1) * the second point (1, 0)
* @param c
* the third point (0, 1)
* @param d
* the fourth point (1, 1)
* @return the bilerped value * @return the bilerped value
*/ */
public static double bilerp(double a, double b, double c, double d, double x, double y) { public static double bilerp(double a, double b, double c, double d, double x, double y) {
@@ -105,17 +120,28 @@ public class M {
/** /**
* Trilinear interpolation * Trilinear interpolation
* *
* @param a the first point (0, 0, 0) * @param a
* @param b the second point (1, 0, 0) * the first point (0, 0, 0)
* @param c the third point (0, 0, 1) * @param b
* @param d the fourth point (1, 0, 1) * the second point (1, 0, 0)
* @param e the fifth point (0, 1, 0) * @param c
* @param f the sixth point (1, 1, 0) * the third point (0, 0, 1)
* @param g the seventh point (0, 1, 1) * @param d
* @param h the eighth point (1, 1, 1) * the fourth point (1, 0, 1)
* @param x the x * @param e
* @param y the y * the fifth point (0, 1, 0)
* @param z the z * @param f
* the sixth point (1, 1, 0)
* @param g
* the seventh point (0, 1, 1)
* @param h
* the eighth point (1, 1, 1)
* @param x
* the x
* @param y
* the y
* @param z
* the z
* @return the trilerped value * @return the trilerped value
*/ */
public static double trilerp(double a, double b, double c, double d, double e, double f, double g, double h, double x, double y, double z) { public static double trilerp(double a, double b, double c, double d, double e, double f, double g, double h, double x, double y, double z) {
@@ -125,9 +151,12 @@ public class M {
/** /**
* Clip a value * Clip a value
* *
* @param value the value * @param value
* @param min the min * the value
* @param max the max * @param min
* the min
* @param max
* the max
* @return the clipped value * @return the clipped value
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -138,7 +167,8 @@ public class M {
/** /**
* Get true or false based on random percent * Get true or false based on random percent
* *
* @param d between 0 and 1 * @param d
* between 0 and 1
* @return true if true * @return true if true
*/ */
public static boolean r(Double d) { public static boolean r(Double d) {
@@ -154,8 +184,10 @@ public class M {
* Get the ticks per second from a time in nanoseconds, the rad can be used for * Get the ticks per second from a time in nanoseconds, the rad can be used for
* multiple ticks * multiple ticks
* *
* @param ns the time in nanoseconds * @param ns
* @param rad the radius of the time * the time in nanoseconds
* @param rad
* the radius of the time
* @return the ticks per second in double form * @return the ticks per second in double form
*/ */
public static double tps(long ns, int rad) { public static double tps(long ns, int rad) {
@@ -165,7 +197,8 @@ public class M {
/** /**
* Get the number of ticks from a time in nanoseconds * Get the number of ticks from a time in nanoseconds
* *
* @param ns the nanoseconds * @param ns
* the nanoseconds
* @return the amount of ticks * @return the amount of ticks
*/ */
public static double ticksFromNS(long ns) { public static double ticksFromNS(long ns) {
@@ -175,8 +208,10 @@ public class M {
/** /**
* Get a random int from to (inclusive) * Get a random int from to (inclusive)
* *
* @param f the from * @param f
* @param t the to * the from
* @param t
* the to
* @return the value * @return the value
*/ */
public static int irand(int f, int t) { public static int irand(int f, int t) {
@@ -186,8 +221,10 @@ public class M {
/** /**
* Get a random float from to (inclusive) * Get a random float from to (inclusive)
* *
* @param f the from * @param f
* @param t the to * the from
* @param t
* the to
* @return the value * @return the value
*/ */
public static float frand(float f, float t) { public static float frand(float f, float t) {
@@ -197,8 +234,10 @@ public class M {
/** /**
* Get a random double from to (inclusive) * Get a random double from to (inclusive)
* *
* @param f the from * @param f
* @param t the to * the from
* @param t
* the to
* @return the value * @return the value
*/ */
public static double drand(double f, double t) { public static double drand(double f, double t) {
@@ -226,7 +265,8 @@ public class M {
/** /**
* Fast sin function * Fast sin function
* *
* @param a the number * @param a
* the number
* @return the sin * @return the sin
*/ */
public static float sin(float a) { public static float sin(float a) {
@@ -236,7 +276,8 @@ public class M {
/** /**
* Fast cos function * Fast cos function
* *
* @param a the number * @param a
* the number
* @return the cos * @return the cos
*/ */
public static float cos(float a) { public static float cos(float a) {
@@ -246,7 +287,8 @@ public class M {
/** /**
* Fast tan function * Fast tan function
* *
* @param a the number * @param a
* the number
* @return the tan * @return the tan
*/ */
public static float tan(float a) { public static float tan(float a) {
@@ -275,7 +317,8 @@ public class M {
/** /**
* Smallest number * Smallest number
* *
* @param doubles the numbers * @param doubles
* the numbers
* @return the smallest one * @return the smallest one
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -298,11 +341,15 @@ public class M {
* makes the expression (4x1)/2 == 2. Keep note that you must use 0-9, you * makes the expression (4x1)/2 == 2. Keep note that you must use 0-9, you
* cannot skip, or start at a number other than 0. * cannot skip, or start at a number other than 0.
* *
* @param expression the expression with variables * @param expression
* @param args the arguments/variables * the expression with variables
* @param args
* the arguments/variables
* @return the resulting double value * @return the resulting double value
* @throws ScriptException ... gg * @throws ScriptException
* @throws IndexOutOfBoundsException learn to count * ... gg
* @throws IndexOutOfBoundsException
* learn to count
*/ */
public static double evaluate(String expression, Double... args) throws ScriptException, IndexOutOfBoundsException { public static double evaluate(String expression, Double... args) throws ScriptException, IndexOutOfBoundsException {
for(int i = 0; i < args.length; i++) { for(int i = 0; i < args.length; i++) {
@@ -319,9 +366,11 @@ public class M {
/** /**
* Evaluates an expression using javascript engine and returns the double * Evaluates an expression using javascript engine and returns the double
* *
* @param expression the mathimatical expression * @param expression
* the mathimatical expression
* @return the double result * @return the double result
* @throws ScriptException ... gg * @throws ScriptException
* ... gg
*/ */
public static double evaluate(String expression) throws ScriptException { public static double evaluate(String expression) throws ScriptException {
ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngineManager mgr = new ScriptEngineManager();
@@ -333,9 +382,12 @@ public class M {
/** /**
* is the number "is" within from-to * is the number "is" within from-to
* *
* @param from the lower end * @param from
* @param to the upper end * the lower end
* @param is the check * @param to
* the upper end
* @param is
* the check
* @return true if its within * @return true if its within
*/ */
public static boolean within(int from, int to, int is) { public static boolean within(int from, int to, int is) {
@@ -354,7 +406,8 @@ public class M {
/** /**
* Get the amount of days past since the epoch time (1970 jan 1 utc) * Get the amount of days past since the epoch time (1970 jan 1 utc)
* *
* @param ms the time in milliseconds * @param ms
* the time in milliseconds
* @return the epoch days * @return the epoch days
*/ */
private static long epochDays(long ms) { private static long epochDays(long ms) {

View File

@@ -28,14 +28,16 @@ public interface PathInterpolation {
* Sets nodes to be used by subsequent calls to * Sets nodes to be used by subsequent calls to
* {@link #getPosition(double)} and the other methods. * {@link #getPosition(double)} and the other methods.
* *
* @param nodes the nodes * @param nodes
* the nodes
*/ */
void setNodes(List<INode> nodes); void setNodes(List<INode> nodes);
/** /**
* Gets the result of f(position). * Gets the result of f(position).
* *
* @param position the position to interpolate * @param position
* the position to interpolate
* @return the result * @return the result
*/ */
Vector getPosition(double position); Vector getPosition(double position);
@@ -43,7 +45,8 @@ public interface PathInterpolation {
/** /**
* Gets the result of f'(position). * Gets the result of f'(position).
* *
* @param position the position to interpolate * @param position
* the position to interpolate
* @return the result * @return the result
*/ */
Vector get1stDerivative(double position); Vector get1stDerivative(double position);
@@ -53,8 +56,10 @@ public interface PathInterpolation {
* That means it calculates the arc length (in meters) between positionA * That means it calculates the arc length (in meters) between positionA
* and positionB. * and positionB.
* *
* @param positionA lower limit * @param positionA
* @param positionB upper limit * lower limit
* @param positionB
* upper limit
* @return the arc length * @return the arc length
*/ */
double arcLength(double positionA, double positionB); double arcLength(double positionA, double positionB);
@@ -62,7 +67,8 @@ public interface PathInterpolation {
/** /**
* Get the segment position. * Get the segment position.
* *
* @param position the position * @param position
* the position
* @return the segment position * @return the segment position
*/ */
int getSegment(double position); int getSegment(double position);

View File

@@ -30,9 +30,12 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3d from the specified xyz coordinates. * Constructs and initializes a Point3d from the specified xyz coordinates.
* *
* @param x the x coordinate * @param x
* @param y the y coordinate * the x coordinate
* @param z the z coordinate * @param y
* the y coordinate
* @param z
* the z coordinate
*/ */
public Point3d(double x, double y, double z) { public Point3d(double x, double y, double z) {
super(x, y, z); super(x, y, z);
@@ -42,7 +45,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3d from the array of length 3. * Constructs and initializes a Point3d from the array of length 3.
* *
* @param p the array of length 3 containing xyz in order * @param p
* the array of length 3 containing xyz in order
*/ */
public Point3d(double[] p) { public Point3d(double[] p) {
super(p); super(p);
@@ -52,7 +56,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3d from the specified Point3d. * Constructs and initializes a Point3d from the specified Point3d.
* *
* @param p1 the Point3d containing the initialization x y z data * @param p1
* the Point3d containing the initialization x y z data
*/ */
public Point3d(Point3d p1) { public Point3d(Point3d p1) {
super(p1); super(p1);
@@ -62,7 +67,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3d from the specified Point3f. * Constructs and initializes a Point3d from the specified Point3f.
* *
* @param p1 the Point3f containing the initialization x y z data * @param p1
* the Point3f containing the initialization x y z data
*/ */
public Point3d(Point3f p1) { public Point3d(Point3f p1) {
super(p1); super(p1);
@@ -72,7 +78,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3d from the specified Tuple3f. * Constructs and initializes a Point3d from the specified Tuple3f.
* *
* @param t1 the Tuple3f containing the initialization x y z data * @param t1
* the Tuple3f containing the initialization x y z data
*/ */
public Point3d(Tuple3f t1) { public Point3d(Tuple3f t1) {
super(t1); super(t1);
@@ -82,7 +89,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3d from the specified Tuple3d. * Constructs and initializes a Point3d from the specified Tuple3d.
* *
* @param t1 the Tuple3d containing the initialization x y z data * @param t1
* the Tuple3d containing the initialization x y z data
*/ */
public Point3d(Tuple3d t1) { public Point3d(Tuple3d t1) {
super(t1); super(t1);
@@ -100,7 +108,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
/** /**
* Returns the square of the distance between this point and point p1. * Returns the square of the distance between this point and point p1.
* *
* @param p1 the other point * @param p1
* the other point
* @return the square of the distance * @return the square of the distance
*/ */
public final double distanceSquared(Point3d p1) { public final double distanceSquared(Point3d p1) {
@@ -116,7 +125,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
/** /**
* Returns the distance between this point and point p1. * Returns the distance between this point and point p1.
* *
* @param p1 the other point * @param p1
* the other point
* @return the distance * @return the distance
*/ */
public final double distance(Point3d p1) { public final double distance(Point3d p1) {
@@ -134,7 +144,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
* point p1. The L-1 distance is equal to: * point p1. The L-1 distance is equal to:
* abs(x1-x2) + abs(y1-y2) + abs(z1-z2). * abs(x1-x2) + abs(y1-y2) + abs(z1-z2).
* *
* @param p1 the other point * @param p1
* the other point
* @return the L-1 distance * @return the L-1 distance
*/ */
public final double distanceL1(Point3d p1) { public final double distanceL1(Point3d p1) {
@@ -148,7 +159,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
* point p1. The L-infinite distance is equal to * point p1. The L-infinite distance is equal to
* MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)]. * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)].
* *
* @param p1 the other point * @param p1
* the other point
* @return the L-infinite distance * @return the L-infinite distance
*/ */
public final double distanceLinf(Point3d p1) { public final double distanceLinf(Point3d p1) {
@@ -163,7 +175,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
* Multiplies each of the x,y,z components of the Point4d parameter * Multiplies each of the x,y,z components of the Point4d parameter
* by 1/w and places the projected values into this point. * by 1/w and places the projected values into this point.
* *
* @param p1 the source Point4d, which is not modified * @param p1
* the source Point4d, which is not modified
*/ */
public final void project(Point4d p1) { public final void project(Point4d p1) {
double oneOw; double oneOw;

View File

@@ -31,9 +31,12 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3f from the specified xyz coordinates. * Constructs and initializes a Point3f from the specified xyz coordinates.
* *
* @param x the x coordinate * @param x
* @param y the y coordinate * the x coordinate
* @param z the z coordinate * @param y
* the y coordinate
* @param z
* the z coordinate
*/ */
public Point3f(float x, float y, float z) { public Point3f(float x, float y, float z) {
super(x, y, z); super(x, y, z);
@@ -43,7 +46,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3f from the array of length 3. * Constructs and initializes a Point3f from the array of length 3.
* *
* @param p the array of length 3 containing xyz in order * @param p
* the array of length 3 containing xyz in order
*/ */
public Point3f(float[] p) { public Point3f(float[] p) {
super(p); super(p);
@@ -53,7 +57,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3f from the specified Point3f. * Constructs and initializes a Point3f from the specified Point3f.
* *
* @param p1 the Point3f containing the initialization x y z data * @param p1
* the Point3f containing the initialization x y z data
*/ */
public Point3f(Point3f p1) { public Point3f(Point3f p1) {
super(p1); super(p1);
@@ -63,7 +68,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3f from the specified Point3d. * Constructs and initializes a Point3f from the specified Point3d.
* *
* @param p1 the Point3d containing the initialization x y z data * @param p1
* the Point3d containing the initialization x y z data
*/ */
public Point3f(Point3d p1) { public Point3f(Point3d p1) {
super(p1); super(p1);
@@ -73,7 +79,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3f from the specified Tuple3f. * Constructs and initializes a Point3f from the specified Tuple3f.
* *
* @param t1 the Tuple3f containing the initialization x y z data * @param t1
* the Tuple3f containing the initialization x y z data
*/ */
public Point3f(Tuple3f t1) { public Point3f(Tuple3f t1) {
super(t1); super(t1);
@@ -83,7 +90,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
/** /**
* Constructs and initializes a Point3f from the specified Tuple3d. * Constructs and initializes a Point3f from the specified Tuple3d.
* *
* @param t1 the Tuple3d containing the initialization x y z data * @param t1
* the Tuple3d containing the initialization x y z data
*/ */
public Point3f(Tuple3d t1) { public Point3f(Tuple3d t1) {
super(t1); super(t1);
@@ -102,7 +110,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
* Computes the square of the distance between this point and * Computes the square of the distance between this point and
* point p1. * point p1.
* *
* @param p1 the other point * @param p1
* the other point
* @return the square of the distance * @return the square of the distance
*/ */
public final float distanceSquared(Point3f p1) { public final float distanceSquared(Point3f p1) {
@@ -118,7 +127,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
/** /**
* Computes the distance between this point and point p1. * Computes the distance between this point and point p1.
* *
* @param p1 the other point * @param p1
* the other point
* @return the distance * @return the distance
*/ */
public final float distance(Point3f p1) { public final float distance(Point3f p1) {
@@ -136,7 +146,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
* point p1. The L-1 distance is equal to: * point p1. The L-1 distance is equal to:
* abs(x1-x2) + abs(y1-y2) + abs(z1-z2). * abs(x1-x2) + abs(y1-y2) + abs(z1-z2).
* *
* @param p1 the other point * @param p1
* the other point
* @return the L-1 distance * @return the L-1 distance
*/ */
public final float distanceL1(Point3f p1) { public final float distanceL1(Point3f p1) {
@@ -149,7 +160,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
* point p1. The L-infinite distance is equal to * point p1. The L-infinite distance is equal to
* MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)]. * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)].
* *
* @param p1 the other point * @param p1
* the other point
* @return the L-infinite distance * @return the L-infinite distance
*/ */
public final float distanceLinf(Point3f p1) { public final float distanceLinf(Point3f p1) {
@@ -164,7 +176,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
* Multiplies each of the x,y,z components of the Point4f parameter * Multiplies each of the x,y,z components of the Point4f parameter
* by 1/w and places the projected values into this point. * by 1/w and places the projected values into this point.
* *
* @param p1 the source Point4f, which is not modified * @param p1
* the source Point4f, which is not modified
*/ */
public final void project(Point4f p1) { public final void project(Point4f p1) {
float oneOw; float oneOw;

View File

@@ -31,10 +31,14 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point4d from the specified xyzw coordinates. * Constructs and initializes a Point4d from the specified xyzw coordinates.
* *
* @param x the x coordinate * @param x
* @param y the y coordinate * the x coordinate
* @param z the z coordinate * @param y
* @param w the w coordinate * the y coordinate
* @param z
* the z coordinate
* @param w
* the w coordinate
*/ */
public Point4d(double x, double y, double z, double w) { public Point4d(double x, double y, double z, double w) {
super(x, y, z, w); super(x, y, z, w);
@@ -44,7 +48,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
* Constructs and initializes a Point4d from the coordinates contained * Constructs and initializes a Point4d from the coordinates contained
* in the array. * in the array.
* *
* @param p the array of length 4 containing xyzw in order * @param p
* the array of length 4 containing xyzw in order
*/ */
public Point4d(double[] p) { public Point4d(double[] p) {
super(p); super(p);
@@ -54,7 +59,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point4d from the specified Point4d. * Constructs and initializes a Point4d from the specified Point4d.
* *
* @param p1 the Point4d containing the initialization x y z w data * @param p1
* the Point4d containing the initialization x y z w data
*/ */
public Point4d(Point4d p1) { public Point4d(Point4d p1) {
super(p1); super(p1);
@@ -64,7 +70,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point4d from the specified Point4f. * Constructs and initializes a Point4d from the specified Point4f.
* *
* @param p1 the Point4f containing the initialization x y z w data * @param p1
* the Point4f containing the initialization x y z w data
*/ */
public Point4d(Point4f p1) { public Point4d(Point4f p1) {
super(p1); super(p1);
@@ -74,7 +81,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point4d from the specified Tuple4f. * Constructs and initializes a Point4d from the specified Tuple4f.
* *
* @param t1 the Tuple4f containing the initialization x y z w data * @param t1
* the Tuple4f containing the initialization x y z w data
*/ */
public Point4d(Tuple4f t1) { public Point4d(Tuple4f t1) {
super(t1); super(t1);
@@ -84,7 +92,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
/** /**
* Constructs and initializes a Point4d from the specified Tuple4d. * Constructs and initializes a Point4d from the specified Tuple4d.
* *
* @param t1 the Tuple4d containing the initialization x y z w data * @param t1
* the Tuple4d containing the initialization x y z w data
*/ */
public Point4d(Tuple4d t1) { public Point4d(Tuple4d t1) {
super(t1); super(t1);
@@ -97,7 +106,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
* components of tuple t1. The w component of this point * components of tuple t1. The w component of this point
* is set to 1. * is set to 1.
* *
* @param t1 the tuple to be copied * @param t1
* the tuple to be copied
* @since vecmath 1.2 * @since vecmath 1.2
*/ */
public Point4d(Tuple3d t1) { public Point4d(Tuple3d t1) {
@@ -118,7 +128,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
* components of tuple t1. The w component of this point * components of tuple t1. The w component of this point
* is set to 1. * is set to 1.
* *
* @param t1 the tuple to be copied * @param t1
* the tuple to be copied
* @since vecmath 1.2 * @since vecmath 1.2
*/ */
public final void set(Tuple3d t1) { public final void set(Tuple3d t1) {
@@ -132,7 +143,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
/** /**
* Returns the square of the distance between this point and point p1. * Returns the square of the distance between this point and point p1.
* *
* @param p1 the first point * @param p1
* the first point
* @return the square of distance between this point and point p1 * @return the square of distance between this point and point p1
*/ */
public final double distanceSquared(Point4d p1) { public final double distanceSquared(Point4d p1) {
@@ -149,7 +161,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
/** /**
* Returns the distance between this point and point p1. * Returns the distance between this point and point p1.
* *
* @param p1 the first point * @param p1
* the first point
* @return the distance between these this point and point p1. * @return the distance between these this point and point p1.
*/ */
public final double distance(Point4d p1) { public final double distance(Point4d p1) {
@@ -168,7 +181,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
* point p1. The L-1 distance is equal to: * point p1. The L-1 distance is equal to:
* abs(x1-x2) + abs(y1-y2) + abs(z1-z2) + abs(w1-w2). * abs(x1-x2) + abs(y1-y2) + abs(z1-z2) + abs(w1-w2).
* *
* @param p1 the other point * @param p1
* the other point
* @return the L-1 distance * @return the L-1 distance
*/ */
public final double distanceL1(Point4d p1) { public final double distanceL1(Point4d p1) {
@@ -181,7 +195,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
* point p1. The L-infinite distance is equal to * point p1. The L-infinite distance is equal to
* MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)]. * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)].
* *
* @param p1 the other point * @param p1
* the other point
* @return the L-infinite distance * @return the L-infinite distance
*/ */
public final double distanceLinf(Point4d p1) { public final double distanceLinf(Point4d p1) {
@@ -197,7 +212,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
* by 1/w, places the projected values into this point, and places * by 1/w, places the projected values into this point, and places
* a 1 as the w parameter of this point. * a 1 as the w parameter of this point.
* *
* @param p1 the source Point4d, which is not modified * @param p1
* the source Point4d, which is not modified
*/ */
public final void project(Point4d p1) { public final void project(Point4d p1) {
double oneOw; double oneOw;

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