SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -53,7 +54,7 @@ public class BlockIterator implements Iterator<Block> {
|
||||
* unloaded chunks. A value of 0 indicates no limit
|
||||
*
|
||||
*/
|
||||
public BlockIterator(World world, Vector start, Vector direction, double yOffset, int maxDistance) {
|
||||
public BlockIterator(@NotNull World world, @NotNull Vector start, @NotNull Vector direction, double yOffset, int maxDistance) {
|
||||
this.world = world;
|
||||
this.maxDistance = maxDistance;
|
||||
|
||||
@@ -177,31 +178,31 @@ public class BlockIterator implements Iterator<Block> {
|
||||
|
||||
}
|
||||
|
||||
private boolean blockEquals(Block a, Block b) {
|
||||
private boolean blockEquals(@NotNull Block a, @NotNull Block b) {
|
||||
return a.getX() == b.getX() && a.getY() == b.getY() && a.getZ() == b.getZ();
|
||||
}
|
||||
|
||||
private BlockFace getXFace(Vector direction) {
|
||||
private BlockFace getXFace(@NotNull Vector direction) {
|
||||
return ((direction.getX() > 0) ? BlockFace.EAST : BlockFace.WEST);
|
||||
}
|
||||
|
||||
private BlockFace getYFace(Vector direction) {
|
||||
private BlockFace getYFace(@NotNull Vector direction) {
|
||||
return ((direction.getY() > 0) ? BlockFace.UP : BlockFace.DOWN);
|
||||
}
|
||||
|
||||
private BlockFace getZFace(Vector direction) {
|
||||
private BlockFace getZFace(@NotNull Vector direction) {
|
||||
return ((direction.getZ() > 0) ? BlockFace.SOUTH : BlockFace.NORTH);
|
||||
}
|
||||
|
||||
private double getXLength(Vector direction) {
|
||||
private double getXLength(@NotNull Vector direction) {
|
||||
return Math.abs(direction.getX());
|
||||
}
|
||||
|
||||
private double getYLength(Vector direction) {
|
||||
private double getYLength(@NotNull Vector direction) {
|
||||
return Math.abs(direction.getY());
|
||||
}
|
||||
|
||||
private double getZLength(Vector direction) {
|
||||
private double getZLength(@NotNull Vector direction) {
|
||||
return Math.abs(direction.getZ());
|
||||
}
|
||||
|
||||
@@ -209,15 +210,15 @@ public class BlockIterator implements Iterator<Block> {
|
||||
return direction > 0 ? (position - blockPosition) : (blockPosition + 1 - position);
|
||||
}
|
||||
|
||||
private double getXPosition(Vector direction, Vector position, Block block) {
|
||||
private double getXPosition(@NotNull Vector direction, @NotNull Vector position, @NotNull Block block) {
|
||||
return getPosition(direction.getX(), position.getX(), block.getX());
|
||||
}
|
||||
|
||||
private double getYPosition(Vector direction, Vector position, Block block) {
|
||||
private double getYPosition(@NotNull Vector direction, @NotNull Vector position, @NotNull Block block) {
|
||||
return getPosition(direction.getY(), position.getY(), block.getY());
|
||||
}
|
||||
|
||||
private double getZPosition(Vector direction, Vector position, Block block) {
|
||||
private double getZPosition(@NotNull Vector direction, @NotNull Vector position, @NotNull Block block) {
|
||||
return getPosition(direction.getZ(), position.getZ(), block.getZ());
|
||||
}
|
||||
|
||||
@@ -233,7 +234,7 @@ public class BlockIterator implements Iterator<Block> {
|
||||
* trace. Setting this value above 140 may lead to problems with
|
||||
* unloaded chunks. A value of 0 indicates no limit
|
||||
*/
|
||||
public BlockIterator(Location loc, double yOffset, int maxDistance) {
|
||||
public BlockIterator(@NotNull Location loc, double yOffset, int maxDistance) {
|
||||
this(loc.getWorld(), loc.toVector(), loc.getDirection(), yOffset, maxDistance);
|
||||
}
|
||||
|
||||
@@ -247,7 +248,7 @@ public class BlockIterator implements Iterator<Block> {
|
||||
* by this value
|
||||
*/
|
||||
|
||||
public BlockIterator(Location loc, double yOffset) {
|
||||
public BlockIterator(@NotNull Location loc, double yOffset) {
|
||||
this(loc.getWorld(), loc.toVector(), loc.getDirection(), yOffset, 0);
|
||||
}
|
||||
|
||||
@@ -259,7 +260,7 @@ public class BlockIterator implements Iterator<Block> {
|
||||
* @param loc The location for the start of the ray trace
|
||||
*/
|
||||
|
||||
public BlockIterator(Location loc) {
|
||||
public BlockIterator(@NotNull Location loc) {
|
||||
this(loc, 0D);
|
||||
}
|
||||
|
||||
@@ -274,7 +275,7 @@ public class BlockIterator implements Iterator<Block> {
|
||||
* unloaded chunks. A value of 0 indicates no limit
|
||||
*/
|
||||
|
||||
public BlockIterator(LivingEntity entity, int maxDistance) {
|
||||
public BlockIterator(@NotNull LivingEntity entity, int maxDistance) {
|
||||
this(entity.getLocation(), entity.getEyeHeight(), maxDistance);
|
||||
}
|
||||
|
||||
@@ -286,7 +287,7 @@ public class BlockIterator implements Iterator<Block> {
|
||||
* @param entity Information from the entity is used to set up the trace
|
||||
*/
|
||||
|
||||
public BlockIterator(LivingEntity entity) {
|
||||
public BlockIterator(@NotNull LivingEntity entity) {
|
||||
this(entity, 0);
|
||||
}
|
||||
|
||||
@@ -304,8 +305,8 @@ public class BlockIterator implements Iterator<Block> {
|
||||
*
|
||||
* @return the next Block in the trace
|
||||
*/
|
||||
|
||||
public Block next() {
|
||||
@NotNull
|
||||
public Block next() throws NoSuchElementException {
|
||||
scan();
|
||||
if (currentBlock <= -1) {
|
||||
throw new NoSuchElementException();
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.util;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A vector with a hash function that floors the X, Y, Z components, a la
|
||||
@@ -26,7 +27,7 @@ public class BlockVector extends Vector {
|
||||
*
|
||||
* @param vec The other vector.
|
||||
*/
|
||||
public BlockVector(Vector vec) {
|
||||
public BlockVector(@NotNull Vector vec) {
|
||||
this.x = vec.getX();
|
||||
this.y = vec.getY();
|
||||
this.z = vec.getZ();
|
||||
@@ -108,7 +109,8 @@ public class BlockVector extends Vector {
|
||||
return (BlockVector) super.clone();
|
||||
}
|
||||
|
||||
public static BlockVector deserialize(Map<String, Object> args) {
|
||||
@NotNull
|
||||
public static BlockVector deserialize(@NotNull Map<String, Object> args) {
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double z = 0;
|
||||
|
||||
@@ -9,6 +9,8 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A mutable axis aligned bounding box (AABB).
|
||||
@@ -35,7 +37,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param corner2 the second corner
|
||||
* @return the bounding box
|
||||
*/
|
||||
public static BoundingBox of(Vector corner1, Vector corner2) {
|
||||
@NotNull
|
||||
public static BoundingBox of(@NotNull Vector corner1, @NotNull Vector corner2) {
|
||||
Validate.notNull(corner1, "Corner1 is null!");
|
||||
Validate.notNull(corner2, "Corner2 is null!");
|
||||
return new BoundingBox(corner1.getX(), corner1.getY(), corner1.getZ(), corner2.getX(), corner2.getY(), corner2.getZ());
|
||||
@@ -49,7 +52,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param corner2 the second corner
|
||||
* @return the bounding box
|
||||
*/
|
||||
public static BoundingBox of(Location corner1, Location corner2) {
|
||||
@NotNull
|
||||
public static BoundingBox of(@NotNull Location corner1, @NotNull Location corner2) {
|
||||
Validate.notNull(corner1, "Corner1 is null!");
|
||||
Validate.notNull(corner2, "Corner2 is null!");
|
||||
Validate.isTrue(Objects.equals(corner1.getWorld(), corner2.getWorld()), "Locations from different worlds!");
|
||||
@@ -66,7 +70,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param corner2 the second corner block
|
||||
* @return the bounding box
|
||||
*/
|
||||
public static BoundingBox of(Block corner1, Block corner2) {
|
||||
@NotNull
|
||||
public static BoundingBox of(@NotNull Block corner1, @NotNull Block corner2) {
|
||||
Validate.notNull(corner1, "Corner1 is null!");
|
||||
Validate.notNull(corner2, "Corner2 is null!");
|
||||
Validate.isTrue(Objects.equals(corner1.getWorld(), corner2.getWorld()), "Blocks from different worlds!");
|
||||
@@ -94,7 +99,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param block the block
|
||||
* @return the bounding box
|
||||
*/
|
||||
public static BoundingBox of(Block block) {
|
||||
@NotNull
|
||||
public static BoundingBox of(@NotNull Block block) {
|
||||
Validate.notNull(block, "Block is null!");
|
||||
return new BoundingBox(block.getX(), block.getY(), block.getZ(), block.getX() + 1, block.getY() + 1, block.getZ() + 1);
|
||||
}
|
||||
@@ -108,7 +114,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param z 1/2 the size of the bounding box along the z axis
|
||||
* @return the bounding box
|
||||
*/
|
||||
public static BoundingBox of(Vector center, double x, double y, double z) {
|
||||
@NotNull
|
||||
public static BoundingBox of(@NotNull Vector center, double x, double y, double z) {
|
||||
Validate.notNull(center, "Center is null!");
|
||||
return new BoundingBox(center.getX() - x, center.getY() - y, center.getZ() - z, center.getX() + x, center.getY() + y, center.getZ() + z);
|
||||
}
|
||||
@@ -122,7 +129,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param z 1/2 the size of the bounding box along the z axis
|
||||
* @return the bounding box
|
||||
*/
|
||||
public static BoundingBox of(Location center, double x, double y, double z) {
|
||||
@NotNull
|
||||
public static BoundingBox of(@NotNull Location center, double x, double y, double z) {
|
||||
Validate.notNull(center, "Center is null!");
|
||||
return new BoundingBox(center.getX() - x, center.getY() - y, center.getZ() - z, center.getX() + x, center.getY() + y, center.getZ() + z);
|
||||
}
|
||||
@@ -167,6 +175,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param z2 the second corner's z value
|
||||
* @return this bounding box (resized)
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox resize(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
NumberConversions.checkFinite(x1, "x1 not finite");
|
||||
NumberConversions.checkFinite(y1, "y1 not finite");
|
||||
@@ -216,6 +225,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return the minimum corner as vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector getMin() {
|
||||
return new Vector(minX, minY, minZ);
|
||||
}
|
||||
@@ -252,6 +262,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return the maximum corner vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector getMax() {
|
||||
return new Vector(maxX, maxY, maxZ);
|
||||
}
|
||||
@@ -324,6 +335,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return the center
|
||||
*/
|
||||
@NotNull
|
||||
public Vector getCenter() {
|
||||
return new Vector(this.getCenterX(), this.getCenterY(), this.getCenterZ());
|
||||
}
|
||||
@@ -334,7 +346,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param other the other bounding box
|
||||
* @return this bounding box
|
||||
*/
|
||||
public BoundingBox copy(BoundingBox other) {
|
||||
@NotNull
|
||||
public BoundingBox copy(@NotNull BoundingBox other) {
|
||||
Validate.notNull(other, "Other bounding box is null!");
|
||||
return this.resize(other.getMinX(), other.getMinY(), other.getMinZ(), other.getMaxX(), other.getMaxY(), other.getMaxZ());
|
||||
}
|
||||
@@ -355,6 +368,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param positiveZ the amount of expansion in the positive z direction
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox expand(double negativeX, double negativeY, double negativeZ, double positiveX, double positiveY, double positiveZ) {
|
||||
if (negativeX == 0.0D && negativeY == 0.0D && negativeZ == 0.0D && positiveX == 0.0D && positiveY == 0.0D && positiveZ == 0.0D) {
|
||||
return this;
|
||||
@@ -418,6 +432,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* direction
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox expand(double x, double y, double z) {
|
||||
return this.expand(x, y, z, x, y, z);
|
||||
}
|
||||
@@ -432,7 +447,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param expansion the expansion values
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
public BoundingBox expand(Vector expansion) {
|
||||
@NotNull
|
||||
public BoundingBox expand(@NotNull Vector expansion) {
|
||||
Validate.notNull(expansion, "Expansion is null!");
|
||||
double x = expansion.getX();
|
||||
double y = expansion.getY();
|
||||
@@ -449,6 +465,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param expansion the amount of expansion
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox expand(double expansion) {
|
||||
return this.expand(expansion, expansion, expansion, expansion, expansion, expansion);
|
||||
}
|
||||
@@ -466,6 +483,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param expansion the amount of expansion
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox expand(double dirX, double dirY, double dirZ, double expansion) {
|
||||
if (expansion == 0.0D) return this;
|
||||
if (dirX == 0.0D && dirY == 0.0D && dirZ == 0.0D) return this;
|
||||
@@ -490,7 +508,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param expansion the amount of expansion
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
public BoundingBox expand(Vector direction, double expansion) {
|
||||
@NotNull
|
||||
public BoundingBox expand(@NotNull Vector direction, double expansion) {
|
||||
Validate.notNull(direction, "Direction is null!");
|
||||
return this.expand(direction.getX(), direction.getY(), direction.getZ(), expansion);
|
||||
}
|
||||
@@ -506,7 +525,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param expansion the amount of expansion
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
public BoundingBox expand(BlockFace blockFace, double expansion) {
|
||||
@NotNull
|
||||
public BoundingBox expand(@NotNull BlockFace blockFace, double expansion) {
|
||||
Validate.notNull(blockFace, "Block face is null!");
|
||||
if (blockFace == BlockFace.SELF) return this;
|
||||
|
||||
@@ -526,6 +546,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param dirZ the z direction component
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox expandDirectional(double dirX, double dirY, double dirZ) {
|
||||
return this.expand(dirX, dirY, dirZ, 1.0D);
|
||||
}
|
||||
@@ -540,7 +561,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param direction the direction and magnitude of the expansion
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
public BoundingBox expandDirectional(Vector direction) {
|
||||
@NotNull
|
||||
public BoundingBox expandDirectional(@NotNull Vector direction) {
|
||||
Validate.notNull(direction, "Expansion is null!");
|
||||
return this.expand(direction.getX(), direction.getY(), direction.getZ(), 1.0D);
|
||||
}
|
||||
@@ -554,6 +576,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @return this bounding box (now expanded)
|
||||
* @see #contains(double, double, double)
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox union(double posX, double posY, double posZ) {
|
||||
double newMinX = Math.min(this.minX, posX);
|
||||
double newMinY = Math.min(this.minY, posY);
|
||||
@@ -574,7 +597,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @return this bounding box (now expanded)
|
||||
* @see #contains(double, double, double)
|
||||
*/
|
||||
public BoundingBox union(Vector position) {
|
||||
@NotNull
|
||||
public BoundingBox union(@NotNull Vector position) {
|
||||
Validate.notNull(position, "Position is null!");
|
||||
return this.union(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
@@ -586,7 +610,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @return this bounding box (now expanded)
|
||||
* @see #contains(double, double, double)
|
||||
*/
|
||||
public BoundingBox union(Location position) {
|
||||
@NotNull
|
||||
public BoundingBox union(@NotNull Location position) {
|
||||
Validate.notNull(position, "Position is null!");
|
||||
return this.union(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
@@ -598,7 +623,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param other the other bounding box
|
||||
* @return this bounding box (now expanded)
|
||||
*/
|
||||
public BoundingBox union(BoundingBox other) {
|
||||
@NotNull
|
||||
public BoundingBox union(@NotNull BoundingBox other) {
|
||||
Validate.notNull(other, "Other bounding box is null!");
|
||||
if (this.contains(other)) return this;
|
||||
double newMinX = Math.min(this.minX, other.minX);
|
||||
@@ -618,7 +644,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @return this bounding box (now representing the intersection)
|
||||
* @throws IllegalArgumentException if the bounding boxes don't overlap
|
||||
*/
|
||||
public BoundingBox intersection(BoundingBox other) {
|
||||
@NotNull
|
||||
public BoundingBox intersection(@NotNull BoundingBox other) {
|
||||
Validate.notNull(other, "Other bounding box is null!");
|
||||
Validate.isTrue(this.overlaps(other), "The bounding boxes do not overlap!");
|
||||
double newMinX = Math.max(this.minX, other.minX);
|
||||
@@ -638,6 +665,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param shiftZ the shift in z direction
|
||||
* @return this bounding box (now shifted)
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox shift(double shiftX, double shiftY, double shiftZ) {
|
||||
if (shiftX == 0.0D && shiftY == 0.0D && shiftZ == 0.0D) return this;
|
||||
return this.resize(this.minX + shiftX, this.minY + shiftY, this.minZ + shiftZ,
|
||||
@@ -650,7 +678,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param shift the shift
|
||||
* @return this bounding box (now shifted)
|
||||
*/
|
||||
public BoundingBox shift(Vector shift) {
|
||||
@NotNull
|
||||
public BoundingBox shift(@NotNull Vector shift) {
|
||||
Validate.notNull(shift, "Shift is null!");
|
||||
return this.shift(shift.getX(), shift.getY(), shift.getZ());
|
||||
}
|
||||
@@ -661,7 +690,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param shift the shift
|
||||
* @return this bounding box (now shifted)
|
||||
*/
|
||||
public BoundingBox shift(Location shift) {
|
||||
@NotNull
|
||||
public BoundingBox shift(@NotNull Location shift) {
|
||||
Validate.notNull(shift, "Shift is null!");
|
||||
return this.shift(shift.getX(), shift.getY(), shift.getZ());
|
||||
}
|
||||
@@ -681,7 +711,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param other the other bounding box
|
||||
* @return <code>true</code> if overlapping
|
||||
*/
|
||||
public boolean overlaps(BoundingBox other) {
|
||||
public boolean overlaps(@NotNull BoundingBox other) {
|
||||
Validate.notNull(other, "Other bounding box is null!");
|
||||
return this.overlaps(other.minX, other.minY, other.minZ, other.maxX, other.maxY, other.maxZ);
|
||||
}
|
||||
@@ -697,7 +727,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param max the second corner
|
||||
* @return <code>true</code> if overlapping
|
||||
*/
|
||||
public boolean overlaps(Vector min, Vector max) {
|
||||
public boolean overlaps(@NotNull Vector min, @NotNull Vector max) {
|
||||
Validate.notNull(min, "Min is null!");
|
||||
Validate.notNull(max, "Max is null!");
|
||||
double x1 = min.getX();
|
||||
@@ -742,7 +772,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param position the position
|
||||
* @return <code>true</code> if the bounding box contains the position
|
||||
*/
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(@NotNull Vector position) {
|
||||
Validate.notNull(position, "Position is null!");
|
||||
return this.contains(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
@@ -760,7 +790,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @return <code>true</code> if the bounding box contains the given bounding
|
||||
* box
|
||||
*/
|
||||
public boolean contains(BoundingBox other) {
|
||||
public boolean contains(@NotNull BoundingBox other) {
|
||||
Validate.notNull(other, "Other bounding box is null!");
|
||||
return this.contains(other.minX, other.minY, other.minZ, other.maxX, other.maxY, other.maxZ);
|
||||
}
|
||||
@@ -774,7 +804,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @return <code>true</code> if the bounding box contains the specified
|
||||
* bounding box
|
||||
*/
|
||||
public boolean contains(Vector min, Vector max) {
|
||||
public boolean contains(@NotNull Vector min, @NotNull Vector max) {
|
||||
Validate.notNull(min, "Min is null!");
|
||||
Validate.notNull(max, "Max is null!");
|
||||
double x1 = min.getX();
|
||||
@@ -799,7 +829,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
* @param maxDistance the maximum distance
|
||||
* @return the ray trace hit result, or <code>null</code> if there is no hit
|
||||
*/
|
||||
public RayTraceResult rayTrace(Vector start, Vector direction, double maxDistance) {
|
||||
@Nullable
|
||||
public RayTraceResult rayTrace(@NotNull Vector start, @NotNull Vector direction, double maxDistance) {
|
||||
Validate.notNull(start, "Start is null!");
|
||||
start.checkFinite();
|
||||
Validate.notNull(direction, "Direction is null!");
|
||||
@@ -977,6 +1008,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return the cloned bounding box
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public BoundingBox clone() {
|
||||
try {
|
||||
@@ -986,6 +1018,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
@@ -998,7 +1031,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static BoundingBox deserialize(Map<String, Object> args) {
|
||||
@NotNull
|
||||
public static BoundingBox deserialize(@NotNull Map<String, Object> args) {
|
||||
double minX = 0.0D;
|
||||
double minY = 0.0D;
|
||||
double minZ = 0.0D;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
@@ -26,7 +28,8 @@ public class ChatPaginator {
|
||||
* @param pageNumber The page number to fetch.
|
||||
* @return A single chat page.
|
||||
*/
|
||||
public static ChatPage paginate(String unpaginatedString, int pageNumber) {
|
||||
@NotNull
|
||||
public static ChatPage paginate(@Nullable String unpaginatedString, int pageNumber) {
|
||||
return paginate(unpaginatedString, pageNumber, GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH, CLOSED_CHAT_PAGE_HEIGHT);
|
||||
}
|
||||
|
||||
@@ -39,7 +42,8 @@ public class ChatPaginator {
|
||||
* @param pageHeight The desired number of lines in a page.
|
||||
* @return A single chat page.
|
||||
*/
|
||||
public static ChatPage paginate(String unpaginatedString, int pageNumber, int lineLength, int pageHeight) {
|
||||
@NotNull
|
||||
public static ChatPage paginate(@Nullable String unpaginatedString, int pageNumber, int lineLength, int pageHeight) {
|
||||
String[] lines = wordWrap(unpaginatedString, lineLength);
|
||||
|
||||
int totalPages = lines.length / pageHeight + (lines.length % pageHeight == 0 ? 0 : 1);
|
||||
@@ -60,7 +64,8 @@ public class ChatPaginator {
|
||||
* @param lineLength The length of a line of text.
|
||||
* @return An array of word-wrapped lines.
|
||||
*/
|
||||
public static String[] wordWrap(String rawString, int lineLength) {
|
||||
@NotNull
|
||||
public static String[] wordWrap(@Nullable String rawString, int lineLength) {
|
||||
// A null string is a single line
|
||||
if (rawString == null) {
|
||||
return new String[] {""};
|
||||
@@ -151,7 +156,7 @@ public class ChatPaginator {
|
||||
private int pageNumber;
|
||||
private int totalPages;
|
||||
|
||||
public ChatPage(String[] lines, int pageNumber, int totalPages) {
|
||||
public ChatPage(@NotNull String[] lines, int pageNumber, int totalPages) {
|
||||
this.lines = lines;
|
||||
this.pageNumber = pageNumber;
|
||||
this.totalPages = totalPages;
|
||||
@@ -165,8 +170,8 @@ public class ChatPaginator {
|
||||
return totalPages;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String[] getLines() {
|
||||
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* EulerAngle is used to represent 3 angles, one for each
|
||||
* axis (x, y, z). The angles are in radians
|
||||
@@ -63,6 +65,7 @@ public class EulerAngle {
|
||||
* @param x the angle in radians
|
||||
* @return the resultant EulerAngle
|
||||
*/
|
||||
@NotNull
|
||||
public EulerAngle setX(double x) {
|
||||
return new EulerAngle(x, y, z);
|
||||
}
|
||||
@@ -74,6 +77,7 @@ public class EulerAngle {
|
||||
* @param y the angle in radians
|
||||
* @return the resultant EulerAngle
|
||||
*/
|
||||
@NotNull
|
||||
public EulerAngle setY(double y) {
|
||||
return new EulerAngle(x, y, z);
|
||||
}
|
||||
@@ -85,6 +89,7 @@ public class EulerAngle {
|
||||
* @param z the angle in radians
|
||||
* @return the resultant EulerAngle
|
||||
*/
|
||||
@NotNull
|
||||
public EulerAngle setZ(double z) {
|
||||
return new EulerAngle(x, y, z);
|
||||
}
|
||||
@@ -98,6 +103,7 @@ public class EulerAngle {
|
||||
* @param z the angle to add to the z axis in radians
|
||||
* @return the resultant EulerAngle
|
||||
*/
|
||||
@NotNull
|
||||
public EulerAngle add(double x, double y, double z) {
|
||||
return new EulerAngle(
|
||||
this.x + x,
|
||||
@@ -115,6 +121,7 @@ public class EulerAngle {
|
||||
* @param z the angle to subtract to the z axis in radians
|
||||
* @return the resultant EulerAngle
|
||||
*/
|
||||
@NotNull
|
||||
public EulerAngle subtract(double x, double y, double z) {
|
||||
return add(-x, -y, -z);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -18,7 +20,7 @@ public class FileUtil {
|
||||
* @param outFile the target filename
|
||||
* @return true on success
|
||||
*/
|
||||
public static boolean copy(File inFile, File outFile) {
|
||||
public static boolean copy(@NotNull File inFile, @NotNull File outFile) {
|
||||
if (!inFile.exists()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.bukkit.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Utils for casting number types to other number types
|
||||
*/
|
||||
@@ -24,7 +27,7 @@ public final class NumberConversions {
|
||||
return num * num;
|
||||
}
|
||||
|
||||
public static int toInt(Object object) {
|
||||
public static int toInt(@Nullable Object object) {
|
||||
if (object instanceof Number) {
|
||||
return ((Number) object).intValue();
|
||||
}
|
||||
@@ -37,7 +40,7 @@ public final class NumberConversions {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static float toFloat(Object object) {
|
||||
public static float toFloat(@Nullable Object object) {
|
||||
if (object instanceof Number) {
|
||||
return ((Number) object).floatValue();
|
||||
}
|
||||
@@ -50,7 +53,7 @@ public final class NumberConversions {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double toDouble(Object object) {
|
||||
public static double toDouble(@Nullable Object object) {
|
||||
if (object instanceof Number) {
|
||||
return ((Number) object).doubleValue();
|
||||
}
|
||||
@@ -63,7 +66,7 @@ public final class NumberConversions {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static long toLong(Object object) {
|
||||
public static long toLong(@Nullable Object object) {
|
||||
if (object instanceof Number) {
|
||||
return ((Number) object).longValue();
|
||||
}
|
||||
@@ -76,7 +79,7 @@ public final class NumberConversions {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static short toShort(Object object) {
|
||||
public static short toShort(@Nullable Object object) {
|
||||
if (object instanceof Number) {
|
||||
return ((Number) object).shortValue();
|
||||
}
|
||||
@@ -89,7 +92,7 @@ public final class NumberConversions {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static byte toByte(Object object) {
|
||||
public static byte toByte(@Nullable Object object) {
|
||||
if (object instanceof Number) {
|
||||
return ((Number) object).byteValue();
|
||||
}
|
||||
@@ -110,13 +113,13 @@ public final class NumberConversions {
|
||||
return Math.abs(f) <= Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
public static void checkFinite(double d, String message) {
|
||||
public static void checkFinite(double d, @NotNull String message) {
|
||||
if (!isFinite(d)) {
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkFinite(float d, String message) {
|
||||
public static void checkFinite(float d, @NotNull String message) {
|
||||
if (!isFinite(d)) {
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* The hit result of a ray trace.
|
||||
@@ -22,7 +24,7 @@ public class RayTraceResult {
|
||||
private final BlockFace hitBlockFace;
|
||||
private final Entity hitEntity;
|
||||
|
||||
private RayTraceResult(Vector hitPosition, Block hitBlock, BlockFace hitBlockFace, Entity hitEntity) {
|
||||
private RayTraceResult(@NotNull Vector hitPosition, @Nullable Block hitBlock, @Nullable BlockFace hitBlockFace, @Nullable Entity hitEntity) {
|
||||
Validate.notNull(hitPosition, "Hit position is null!");
|
||||
this.hitPosition = hitPosition.clone();
|
||||
this.hitBlock = hitBlock;
|
||||
@@ -35,7 +37,7 @@ public class RayTraceResult {
|
||||
*
|
||||
* @param hitPosition the hit position
|
||||
*/
|
||||
public RayTraceResult(Vector hitPosition) {
|
||||
public RayTraceResult(@NotNull Vector hitPosition) {
|
||||
this(hitPosition, null, null, null);
|
||||
}
|
||||
|
||||
@@ -45,7 +47,7 @@ public class RayTraceResult {
|
||||
* @param hitPosition the hit position
|
||||
* @param hitBlockFace the hit block face
|
||||
*/
|
||||
public RayTraceResult(Vector hitPosition, BlockFace hitBlockFace) {
|
||||
public RayTraceResult(@NotNull Vector hitPosition, @Nullable BlockFace hitBlockFace) {
|
||||
this(hitPosition, null, hitBlockFace, null);
|
||||
}
|
||||
|
||||
@@ -56,7 +58,7 @@ public class RayTraceResult {
|
||||
* @param hitBlock the hit block
|
||||
* @param hitBlockFace the hit block face
|
||||
*/
|
||||
public RayTraceResult(Vector hitPosition, Block hitBlock, BlockFace hitBlockFace) {
|
||||
public RayTraceResult(@NotNull Vector hitPosition, @Nullable Block hitBlock, @Nullable BlockFace hitBlockFace) {
|
||||
this(hitPosition, hitBlock, hitBlockFace, null);
|
||||
}
|
||||
|
||||
@@ -66,7 +68,7 @@ public class RayTraceResult {
|
||||
* @param hitPosition the hit position
|
||||
* @param hitEntity the hit entity
|
||||
*/
|
||||
public RayTraceResult(Vector hitPosition, Entity hitEntity) {
|
||||
public RayTraceResult(@NotNull Vector hitPosition, @Nullable Entity hitEntity) {
|
||||
this(hitPosition, null, null, hitEntity);
|
||||
}
|
||||
|
||||
@@ -77,7 +79,7 @@ public class RayTraceResult {
|
||||
* @param hitEntity the hit entity
|
||||
* @param hitBlockFace the hit block face
|
||||
*/
|
||||
public RayTraceResult(Vector hitPosition, Entity hitEntity, BlockFace hitBlockFace) {
|
||||
public RayTraceResult(@NotNull Vector hitPosition, @Nullable Entity hitEntity, @Nullable BlockFace hitBlockFace) {
|
||||
this(hitPosition, null, hitBlockFace, hitEntity);
|
||||
}
|
||||
|
||||
@@ -86,6 +88,7 @@ public class RayTraceResult {
|
||||
*
|
||||
* @return a copy of the exact hit position
|
||||
*/
|
||||
@NotNull
|
||||
public Vector getHitPosition() {
|
||||
return hitPosition.clone();
|
||||
}
|
||||
@@ -95,6 +98,7 @@ public class RayTraceResult {
|
||||
*
|
||||
* @return the hit block, or <code>null</code> if not available
|
||||
*/
|
||||
@Nullable
|
||||
public Block getHitBlock() {
|
||||
return hitBlock;
|
||||
}
|
||||
@@ -104,6 +108,7 @@ public class RayTraceResult {
|
||||
*
|
||||
* @return the hit block face, or <code>null</code> if not available
|
||||
*/
|
||||
@Nullable
|
||||
public BlockFace getHitBlockFace() {
|
||||
return hitBlockFace;
|
||||
}
|
||||
@@ -113,6 +118,7 @@ public class RayTraceResult {
|
||||
*
|
||||
* @return the hit entity, or <code>null</code> if not available
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getHitEntity() {
|
||||
return hitEntity;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StringUtil {
|
||||
|
||||
@@ -22,7 +23,8 @@ public class StringUtil {
|
||||
* @throws IllegalArgumentException if originals contains a null element.
|
||||
* <b>Note: the collection may be modified before this is thrown</b>
|
||||
*/
|
||||
public static <T extends Collection<? super String>> T copyPartialMatches(final String token, final Iterable<String> originals, final T collection) throws UnsupportedOperationException, IllegalArgumentException {
|
||||
@NotNull
|
||||
public static <T extends Collection<? super String>> T copyPartialMatches(@NotNull final String token, @NotNull final Iterable<String> originals, @NotNull final T collection) throws UnsupportedOperationException, IllegalArgumentException {
|
||||
Validate.notNull(token, "Search token cannot be null");
|
||||
Validate.notNull(collection, "Collection cannot be null");
|
||||
Validate.notNull(originals, "Originals cannot be null");
|
||||
@@ -48,7 +50,7 @@ public class StringUtil {
|
||||
* @throws NullPointerException if prefix is null
|
||||
* @throws IllegalArgumentException if string is null
|
||||
*/
|
||||
public static boolean startsWithIgnoreCase(final String string, final String prefix) throws IllegalArgumentException, NullPointerException {
|
||||
public static boolean startsWithIgnoreCase(@NotNull final String string, @NotNull final String prefix) throws IllegalArgumentException, NullPointerException {
|
||||
Validate.notNull(string, "Cannot check a null string for a match");
|
||||
if (string.length() < prefix.length()) {
|
||||
return false;
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a mutable vector. Because the components of Vectors are mutable,
|
||||
@@ -84,7 +85,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param vec The other vector
|
||||
* @return the same vector
|
||||
*/
|
||||
public Vector add(Vector vec) {
|
||||
@NotNull
|
||||
public Vector add(@NotNull Vector vec) {
|
||||
x += vec.x;
|
||||
y += vec.y;
|
||||
z += vec.z;
|
||||
@@ -97,7 +99,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param vec The other vector
|
||||
* @return the same vector
|
||||
*/
|
||||
public Vector subtract(Vector vec) {
|
||||
@NotNull
|
||||
public Vector subtract(@NotNull Vector vec) {
|
||||
x -= vec.x;
|
||||
y -= vec.y;
|
||||
z -= vec.z;
|
||||
@@ -110,7 +113,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param vec The other vector
|
||||
* @return the same vector
|
||||
*/
|
||||
public Vector multiply(Vector vec) {
|
||||
@NotNull
|
||||
public Vector multiply(@NotNull Vector vec) {
|
||||
x *= vec.x;
|
||||
y *= vec.y;
|
||||
z *= vec.z;
|
||||
@@ -123,7 +127,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param vec The other vector
|
||||
* @return the same vector
|
||||
*/
|
||||
public Vector divide(Vector vec) {
|
||||
@NotNull
|
||||
public Vector divide(@NotNull Vector vec) {
|
||||
x /= vec.x;
|
||||
y /= vec.y;
|
||||
z /= vec.z;
|
||||
@@ -136,7 +141,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param vec The other vector
|
||||
* @return the same vector
|
||||
*/
|
||||
public Vector copy(Vector vec) {
|
||||
@NotNull
|
||||
public Vector copy(@NotNull Vector vec) {
|
||||
x = vec.x;
|
||||
y = vec.y;
|
||||
z = vec.z;
|
||||
@@ -175,7 +181,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param o The other vector
|
||||
* @return the distance
|
||||
*/
|
||||
public double distance(Vector o) {
|
||||
public double distance(@NotNull Vector o) {
|
||||
return Math.sqrt(NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z));
|
||||
}
|
||||
|
||||
@@ -185,7 +191,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param o The other vector
|
||||
* @return the distance
|
||||
*/
|
||||
public double distanceSquared(Vector o) {
|
||||
public double distanceSquared(@NotNull Vector o) {
|
||||
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
|
||||
}
|
||||
|
||||
@@ -195,7 +201,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param other The other vector
|
||||
* @return angle in radians
|
||||
*/
|
||||
public float angle(Vector other) {
|
||||
public float angle(@NotNull Vector other) {
|
||||
double dot = dot(other) / (length() * other.length());
|
||||
|
||||
return (float) Math.acos(dot);
|
||||
@@ -207,7 +213,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param other The other vector
|
||||
* @return this same vector (now a midpoint)
|
||||
*/
|
||||
public Vector midpoint(Vector other) {
|
||||
@NotNull
|
||||
public Vector midpoint(@NotNull Vector other) {
|
||||
x = (x + other.x) / 2;
|
||||
y = (y + other.y) / 2;
|
||||
z = (z + other.z) / 2;
|
||||
@@ -220,7 +227,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param other The other vector
|
||||
* @return a new midpoint vector
|
||||
*/
|
||||
public Vector getMidpoint(Vector other) {
|
||||
@NotNull
|
||||
public Vector getMidpoint(@NotNull Vector other) {
|
||||
double x = (this.x + other.x) / 2;
|
||||
double y = (this.y + other.y) / 2;
|
||||
double z = (this.z + other.z) / 2;
|
||||
@@ -234,6 +242,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param m The factor
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector multiply(int m) {
|
||||
x *= m;
|
||||
y *= m;
|
||||
@@ -248,6 +257,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param m The factor
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector multiply(double m) {
|
||||
x *= m;
|
||||
y *= m;
|
||||
@@ -262,6 +272,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param m The factor
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector multiply(float m) {
|
||||
x *= m;
|
||||
y *= m;
|
||||
@@ -276,7 +287,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param other The other vector
|
||||
* @return dot product
|
||||
*/
|
||||
public double dot(Vector other) {
|
||||
public double dot(@NotNull Vector other) {
|
||||
return x * other.x + y * other.y + z * other.z;
|
||||
}
|
||||
|
||||
@@ -292,7 +303,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param o The other vector
|
||||
* @return the same vector
|
||||
*/
|
||||
public Vector crossProduct(Vector o) {
|
||||
@NotNull
|
||||
public Vector crossProduct(@NotNull Vector o) {
|
||||
double newX = y * o.z - o.y * z;
|
||||
double newY = z * o.x - o.z * x;
|
||||
double newZ = x * o.y - o.x * y;
|
||||
@@ -315,7 +327,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param o The other vector
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector getCrossProduct(Vector o) {
|
||||
@NotNull
|
||||
public Vector getCrossProduct(@NotNull Vector o) {
|
||||
double x = this.y * o.z - o.y * this.z;
|
||||
double y = this.z * o.x - o.z * this.x;
|
||||
double z = this.x * o.y - o.x * this.y;
|
||||
@@ -327,6 +340,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector normalize() {
|
||||
double length = length();
|
||||
|
||||
@@ -342,6 +356,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector zero() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
@@ -359,7 +374,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param max Maximum vector
|
||||
* @return whether this vector is in the AABB
|
||||
*/
|
||||
public boolean isInAABB(Vector min, Vector max) {
|
||||
public boolean isInAABB(@NotNull Vector min, @NotNull Vector max) {
|
||||
return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z;
|
||||
}
|
||||
|
||||
@@ -370,7 +385,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param radius Sphere radius
|
||||
* @return whether this vector is in the sphere
|
||||
*/
|
||||
public boolean isInSphere(Vector origin, double radius) {
|
||||
public boolean isInSphere(@NotNull Vector origin, double radius) {
|
||||
return (NumberConversions.square(origin.x - x) + NumberConversions.square(origin.y - y) + NumberConversions.square(origin.z - z)) <= NumberConversions.square(radius);
|
||||
}
|
||||
|
||||
@@ -395,6 +410,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* in radians
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector rotateAroundX(double angle) {
|
||||
double angleCos = Math.cos(angle);
|
||||
double angleSin = Math.sin(angle);
|
||||
@@ -416,6 +432,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* in radians
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector rotateAroundY(double angle) {
|
||||
double angleCos = Math.cos(angle);
|
||||
double angleSin = Math.sin(angle);
|
||||
@@ -437,6 +454,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* in radians
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector rotateAroundZ(double angle) {
|
||||
double angleCos = Math.cos(angle);
|
||||
double angleSin = Math.sin(angle);
|
||||
@@ -467,7 +485,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @throws IllegalArgumentException if the provided axis vector instance is
|
||||
* null
|
||||
*/
|
||||
public Vector rotateAroundAxis(Vector axis, double angle) throws IllegalArgumentException {
|
||||
@NotNull
|
||||
public Vector rotateAroundAxis(@NotNull Vector axis, double angle) throws IllegalArgumentException {
|
||||
Preconditions.checkArgument(axis != null, "The provided axis vector was null");
|
||||
|
||||
return rotateAroundNonUnitAxis(axis.isNormalized() ? axis : axis.clone().normalize(), angle);
|
||||
@@ -493,7 +512,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @throws IllegalArgumentException if the provided axis vector instance is
|
||||
* null
|
||||
*/
|
||||
public Vector rotateAroundNonUnitAxis(Vector axis, double angle) throws IllegalArgumentException {
|
||||
@NotNull
|
||||
public Vector rotateAroundNonUnitAxis(@NotNull Vector axis, double angle) throws IllegalArgumentException {
|
||||
Preconditions.checkArgument(axis != null, "The provided axis vector was null");
|
||||
|
||||
double x = getX(), y = getY(), z = getZ();
|
||||
@@ -579,6 +599,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param x The new X component.
|
||||
* @return This vector.
|
||||
*/
|
||||
@NotNull
|
||||
public Vector setX(int x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
@@ -590,6 +611,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param x The new X component.
|
||||
* @return This vector.
|
||||
*/
|
||||
@NotNull
|
||||
public Vector setX(double x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
@@ -601,6 +623,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param x The new X component.
|
||||
* @return This vector.
|
||||
*/
|
||||
@NotNull
|
||||
public Vector setX(float x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
@@ -612,6 +635,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param y The new Y component.
|
||||
* @return This vector.
|
||||
*/
|
||||
@NotNull
|
||||
public Vector setY(int y) {
|
||||
this.y = y;
|
||||
return this;
|
||||
@@ -623,6 +647,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param y The new Y component.
|
||||
* @return This vector.
|
||||
*/
|
||||
@NotNull
|
||||
public Vector setY(double y) {
|
||||
this.y = y;
|
||||
return this;
|
||||
@@ -634,6 +659,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param y The new Y component.
|
||||
* @return This vector.
|
||||
*/
|
||||
@NotNull
|
||||
public Vector setY(float y) {
|
||||
this.y = y;
|
||||
return this;
|
||||
@@ -645,6 +671,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param z The new Z component.
|
||||
* @return This vector.
|
||||
*/
|
||||
@NotNull
|
||||
public Vector setZ(int z) {
|
||||
this.z = z;
|
||||
return this;
|
||||
@@ -656,6 +683,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param z The new Z component.
|
||||
* @return This vector.
|
||||
*/
|
||||
@NotNull
|
||||
public Vector setZ(double z) {
|
||||
this.z = z;
|
||||
return this;
|
||||
@@ -667,6 +695,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param z The new Z component.
|
||||
* @return This vector.
|
||||
*/
|
||||
@NotNull
|
||||
public Vector setZ(float z) {
|
||||
this.z = z;
|
||||
return this;
|
||||
@@ -710,6 +739,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return vector
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public Vector clone() {
|
||||
try {
|
||||
@@ -733,7 +763,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param world The world to link the location to.
|
||||
* @return the location
|
||||
*/
|
||||
public Location toLocation(World world) {
|
||||
@NotNull
|
||||
public Location toLocation(@NotNull World world) {
|
||||
return new Location(world, x, y, z);
|
||||
}
|
||||
|
||||
@@ -745,7 +776,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param pitch The desired pitch.
|
||||
* @return the location
|
||||
*/
|
||||
public Location toLocation(World world, float yaw, float pitch) {
|
||||
@NotNull
|
||||
public Location toLocation(@NotNull World world, float yaw, float pitch) {
|
||||
return new Location(world, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@@ -754,6 +786,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return A block vector.
|
||||
*/
|
||||
@NotNull
|
||||
public BlockVector toBlockVector() {
|
||||
return new BlockVector(x, y, z);
|
||||
}
|
||||
@@ -785,7 +818,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param v2 The second vector.
|
||||
* @return minimum
|
||||
*/
|
||||
public static Vector getMinimum(Vector v1, Vector v2) {
|
||||
@NotNull
|
||||
public static Vector getMinimum(@NotNull Vector v1, @NotNull Vector v2) {
|
||||
return new Vector(Math.min(v1.x, v2.x), Math.min(v1.y, v2.y), Math.min(v1.z, v2.z));
|
||||
}
|
||||
|
||||
@@ -796,7 +830,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
* @param v2 The second vector.
|
||||
* @return maximum
|
||||
*/
|
||||
public static Vector getMaximum(Vector v1, Vector v2) {
|
||||
@NotNull
|
||||
public static Vector getMaximum(@NotNull Vector v1, @NotNull Vector v2) {
|
||||
return new Vector(Math.max(v1.x, v2.x), Math.max(v1.y, v2.y), Math.max(v1.z, v2.z));
|
||||
}
|
||||
|
||||
@@ -806,10 +841,12 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return A random vector.
|
||||
*/
|
||||
@NotNull
|
||||
public static Vector getRandom() {
|
||||
return new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
|
||||
@@ -820,7 +857,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Vector deserialize(Map<String, Object> args) {
|
||||
@NotNull
|
||||
public static Vector deserialize(@NotNull Map<String, Object> args) {
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double z = 0;
|
||||
|
||||
@@ -7,17 +7,18 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class Wrapper<T extends Map<String, ?> & Serializable> implements Serializable {
|
||||
private static final long serialVersionUID = -986209235411767547L;
|
||||
|
||||
final T map;
|
||||
|
||||
static Wrapper<ImmutableMap<String, ?>> newWrapper(ConfigurationSerializable obj) {
|
||||
static Wrapper<ImmutableMap<String, ?>> newWrapper(@NotNull ConfigurationSerializable obj) {
|
||||
return new Wrapper<ImmutableMap<String, ?>>(ImmutableMap.<String, Object>builder().put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(obj.getClass())).putAll(obj.serialize()).build());
|
||||
}
|
||||
|
||||
private Wrapper(T map) {
|
||||
private Wrapper(@NotNull T map) {
|
||||
this.map = map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.util.permissions;
|
||||
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class BroadcastPermissions {
|
||||
private static final String ROOT = "bukkit.broadcast";
|
||||
@@ -9,7 +10,8 @@ public final class BroadcastPermissions {
|
||||
|
||||
private BroadcastPermissions() {}
|
||||
|
||||
public static Permission registerPermissions(Permission parent) {
|
||||
@NotNull
|
||||
public static Permission registerPermissions(@NotNull Permission parent) {
|
||||
Permission broadcasts = DefaultPermissions.registerPermission(ROOT, "Allows the user to receive all broadcast messages", parent);
|
||||
|
||||
DefaultPermissions.registerPermission(PREFIX + "admin", "Allows the user to receive administrative broadcasts", PermissionDefault.OP, broadcasts);
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.util.permissions;
|
||||
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class CommandPermissions {
|
||||
private static final String ROOT = "bukkit.command";
|
||||
@@ -9,7 +10,8 @@ public final class CommandPermissions {
|
||||
|
||||
private CommandPermissions() {}
|
||||
|
||||
public static Permission registerPermissions(Permission parent) {
|
||||
@NotNull
|
||||
public static Permission registerPermissions(@NotNull Permission parent) {
|
||||
Permission commands = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all CraftBukkit commands", parent);
|
||||
|
||||
DefaultPermissions.registerPermission(PREFIX + "help", "Allows the user to view the vanilla help menu", PermissionDefault.TRUE, commands);
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class DefaultPermissions {
|
||||
private static final String ROOT = "craftbukkit";
|
||||
@@ -11,17 +13,20 @@ public final class DefaultPermissions {
|
||||
|
||||
private DefaultPermissions() {}
|
||||
|
||||
public static Permission registerPermission(Permission perm) {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull Permission perm) {
|
||||
return registerPermission(perm, true);
|
||||
}
|
||||
|
||||
public static Permission registerPermission(Permission perm, boolean withLegacy) {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull Permission perm, boolean withLegacy) {
|
||||
Permission result = perm;
|
||||
|
||||
try {
|
||||
Bukkit.getPluginManager().addPermission(perm);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
result = Bukkit.getPluginManager().getPermission(perm.getName());
|
||||
assert result != null;
|
||||
}
|
||||
|
||||
if (withLegacy) {
|
||||
@@ -33,39 +38,46 @@ public final class DefaultPermissions {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Permission registerPermission(Permission perm, Permission parent) {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull Permission perm, @NotNull Permission parent) {
|
||||
parent.getChildren().put(perm.getName(), true);
|
||||
return registerPermission(perm);
|
||||
}
|
||||
|
||||
public static Permission registerPermission(String name, String desc) {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc) {
|
||||
Permission perm = registerPermission(new Permission(name, desc));
|
||||
return perm;
|
||||
}
|
||||
|
||||
public static Permission registerPermission(String name, String desc, Permission parent) {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @NotNull Permission parent) {
|
||||
Permission perm = registerPermission(name, desc);
|
||||
parent.getChildren().put(perm.getName(), true);
|
||||
return perm;
|
||||
}
|
||||
|
||||
public static Permission registerPermission(String name, String desc, PermissionDefault def) {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def) {
|
||||
Permission perm = registerPermission(new Permission(name, desc, def));
|
||||
return perm;
|
||||
}
|
||||
|
||||
public static Permission registerPermission(String name, String desc, PermissionDefault def, Permission parent) {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @NotNull Permission parent) {
|
||||
Permission perm = registerPermission(name, desc, def);
|
||||
parent.getChildren().put(perm.getName(), true);
|
||||
return perm;
|
||||
}
|
||||
|
||||
public static Permission registerPermission(String name, String desc, PermissionDefault def, Map<String, Boolean> children) {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @Nullable Map<String, Boolean> children) {
|
||||
Permission perm = registerPermission(new Permission(name, desc, def, children));
|
||||
return perm;
|
||||
}
|
||||
|
||||
public static Permission registerPermission(String name, String desc, PermissionDefault def, Map<String, Boolean> children, Permission parent) {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @Nullable Map<String, Boolean> children, @NotNull Permission parent) {
|
||||
Permission perm = registerPermission(name, desc, def, children);
|
||||
parent.getChildren().put(perm.getName(), true);
|
||||
return perm;
|
||||
|
||||
Reference in New Issue
Block a user