SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
package org.bukkit.util.noise;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Creates noise using unbiased octaves
|
||||
*/
|
||||
public abstract class OctaveGenerator {
|
||||
@NotNull
|
||||
protected final NoiseGenerator[] octaves;
|
||||
protected double xScale = 1;
|
||||
protected double yScale = 1;
|
||||
protected double zScale = 1;
|
||||
|
||||
protected OctaveGenerator(NoiseGenerator[] octaves) {
|
||||
protected OctaveGenerator(@NotNull NoiseGenerator[] octaves) {
|
||||
this.octaves = octaves;
|
||||
}
|
||||
|
||||
@@ -86,6 +89,7 @@ public abstract class OctaveGenerator {
|
||||
*
|
||||
* @return Clone of the individual octaves
|
||||
*/
|
||||
@NotNull
|
||||
public NoiseGenerator[] getOctaves() {
|
||||
return octaves.clone();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.util.noise;
|
||||
|
||||
import java.util.Random;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Generates noise using the "classic" perlin generator
|
||||
@@ -45,7 +46,7 @@ public class PerlinNoiseGenerator extends NoiseGenerator {
|
||||
*
|
||||
* @param world World to construct this generator for
|
||||
*/
|
||||
public PerlinNoiseGenerator(World world) {
|
||||
public PerlinNoiseGenerator(@NotNull World world) {
|
||||
this(new Random(world.getSeed()));
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ public class PerlinNoiseGenerator extends NoiseGenerator {
|
||||
*
|
||||
* @param rand Random to construct with
|
||||
*/
|
||||
public PerlinNoiseGenerator(Random rand) {
|
||||
public PerlinNoiseGenerator(@NotNull Random rand) {
|
||||
offsetX = rand.nextDouble() * 256;
|
||||
offsetY = rand.nextDouble() * 256;
|
||||
offsetZ = rand.nextDouble() * 256;
|
||||
@@ -123,6 +124,7 @@ public class PerlinNoiseGenerator extends NoiseGenerator {
|
||||
*
|
||||
* @return Singleton
|
||||
*/
|
||||
@NotNull
|
||||
public static PerlinNoiseGenerator getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.util.noise;
|
||||
|
||||
import java.util.Random;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Creates perlin noise through unbiased octaves
|
||||
@@ -14,7 +15,7 @@ public class PerlinOctaveGenerator extends OctaveGenerator {
|
||||
* @param world World to construct this generator for
|
||||
* @param octaves Amount of octaves to create
|
||||
*/
|
||||
public PerlinOctaveGenerator(World world, int octaves) {
|
||||
public PerlinOctaveGenerator(@NotNull World world, int octaves) {
|
||||
this(new Random(world.getSeed()), octaves);
|
||||
}
|
||||
|
||||
@@ -34,11 +35,12 @@ public class PerlinOctaveGenerator extends OctaveGenerator {
|
||||
* @param rand Random object to construct this generator for
|
||||
* @param octaves Amount of octaves to create
|
||||
*/
|
||||
public PerlinOctaveGenerator(Random rand, int octaves) {
|
||||
public PerlinOctaveGenerator(@NotNull Random rand, int octaves) {
|
||||
super(createOctaves(rand, octaves));
|
||||
}
|
||||
|
||||
private static NoiseGenerator[] createOctaves(Random rand, int octaves) {
|
||||
@NotNull
|
||||
private static NoiseGenerator[] createOctaves(@NotNull Random rand, int octaves) {
|
||||
NoiseGenerator[] result = new NoiseGenerator[octaves];
|
||||
|
||||
for (int i = 0; i < octaves; i++) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.util.noise;
|
||||
|
||||
import java.util.Random;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Generates simplex-based noise.
|
||||
@@ -53,7 +54,7 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator {
|
||||
*
|
||||
* @param world World to construct this generator for
|
||||
*/
|
||||
public SimplexNoiseGenerator(World world) {
|
||||
public SimplexNoiseGenerator(@NotNull World world) {
|
||||
this(new Random(world.getSeed()));
|
||||
}
|
||||
|
||||
@@ -71,20 +72,20 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator {
|
||||
*
|
||||
* @param rand Random to construct with
|
||||
*/
|
||||
public SimplexNoiseGenerator(Random rand) {
|
||||
public SimplexNoiseGenerator(@NotNull Random rand) {
|
||||
super(rand);
|
||||
offsetW = rand.nextDouble() * 256;
|
||||
}
|
||||
|
||||
protected static double dot(int g[], double x, double y) {
|
||||
protected static double dot(@NotNull int[] g, double x, double y) {
|
||||
return g[0] * x + g[1] * y;
|
||||
}
|
||||
|
||||
protected static double dot(int g[], double x, double y, double z) {
|
||||
protected static double dot(@NotNull int[] g, double x, double y, double z) {
|
||||
return g[0] * x + g[1] * y + g[2] * z;
|
||||
}
|
||||
|
||||
protected static double dot(int g[], double x, double y, double z, double w) {
|
||||
protected static double dot(@NotNull int[] g, double x, double y, double z, double w) {
|
||||
return g[0] * x + g[1] * y + g[2] * z + g[3] * w;
|
||||
}
|
||||
|
||||
@@ -514,6 +515,7 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator {
|
||||
*
|
||||
* @return Singleton
|
||||
*/
|
||||
@NotNull
|
||||
public static SimplexNoiseGenerator getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.util.noise;
|
||||
|
||||
import java.util.Random;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Creates simplex noise through unbiased octaves
|
||||
@@ -15,7 +16,7 @@ public class SimplexOctaveGenerator extends OctaveGenerator {
|
||||
* @param world World to construct this generator for
|
||||
* @param octaves Amount of octaves to create
|
||||
*/
|
||||
public SimplexOctaveGenerator(World world, int octaves) {
|
||||
public SimplexOctaveGenerator(@NotNull World world, int octaves) {
|
||||
this(new Random(world.getSeed()), octaves);
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ public class SimplexOctaveGenerator extends OctaveGenerator {
|
||||
* @param rand Random object to construct this generator for
|
||||
* @param octaves Amount of octaves to create
|
||||
*/
|
||||
public SimplexOctaveGenerator(Random rand, int octaves) {
|
||||
public SimplexOctaveGenerator(@NotNull Random rand, int octaves) {
|
||||
super(createOctaves(rand, octaves));
|
||||
}
|
||||
|
||||
@@ -117,7 +118,8 @@ public class SimplexOctaveGenerator extends OctaveGenerator {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static NoiseGenerator[] createOctaves(Random rand, int octaves) {
|
||||
@NotNull
|
||||
private static NoiseGenerator[] createOctaves(@NotNull Random rand, int octaves) {
|
||||
NoiseGenerator[] result = new NoiseGenerator[octaves];
|
||||
|
||||
for (int i = 0; i < octaves; i++) {
|
||||
|
||||
Reference in New Issue
Block a user