Minor code tweaks

This commit is contained in:
MattBDev
2019-12-09 14:43:53 -05:00
parent 7760631751
commit 07b6942690
12 changed files with 160 additions and 130 deletions

View File

@ -24,7 +24,7 @@ import java.util.regex.Matcher;
* A block bucket is a container of block types, where each block
* has a specified chance of being randomly picked
*/
@EqualsAndHashCode(of={"input"}) @SuppressWarnings({"unused", "WeakerAccess"})
@EqualsAndHashCode(of = {"input"}) @SuppressWarnings({"unused", "WeakerAccess"})
public final class BlockBucket implements ConfigurationSerializable {
private boolean compiled;
@ -78,7 +78,7 @@ public final class BlockBucket implements ConfigurationSerializable {
private void addBlock(@NonNull final BlockState block, double chance) {
if (chance == -1) chance = 1;
String prefix = input.length() == 0 ? "" : ",";
input.append(prefix).append(chance + "%" + prefix);
input.append(prefix).append(chance).append("%").append(prefix);
this.compiled = false;
}
@ -116,7 +116,7 @@ public final class BlockBucket implements ConfigurationSerializable {
this.single = BlockUtil.get(string);
this.pattern = new BlockPattern(single);
return;
} catch (Exception ignore) {}
} catch (Exception ignore) { }
}
for (int i = 0; i < blocksStr.length; i++) {
String entry = blocksStr[i];
@ -163,7 +163,7 @@ public final class BlockBucket implements ConfigurationSerializable {
return ImmutableMap.of("blocks", this.toString());
}
@Getter @EqualsAndHashCode @RequiredArgsConstructor private final static class Range {
@Getter @EqualsAndHashCode @RequiredArgsConstructor private static final class Range {
private final int min;
private final int max;

View File

@ -34,15 +34,15 @@ public class Location implements Cloneable, Comparable<Location> {
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getZ() {
return this.z;
}
public void setX(int x) {
this.x = x;
this.blockVector3 = BlockVector3.at(x, y, z);
@ -105,6 +105,10 @@ public class Location implements Cloneable, Comparable<Location> {
return area != null && area.getPlotAbs(this) == null;
}
/**
* Checks if anyone owns a plot at the current location.
* @return true if the location is a road, not a plot area, or if the plot is unclaimed.
*/
public boolean isUnownedPlotArea() {
PlotArea area = getPlotArea();
return area != null && area.getOwnedPlotAbs(this) == null;

View File

@ -117,7 +117,7 @@ public abstract class PlotArea {
}
/**
* Returns the region for this PlotArea or a CuboidRegion encompassing
* Returns the region for this PlotArea, or a CuboidRegion encompassing
* the whole world if none exists.
*
* @return CuboidRegion
@ -627,7 +627,7 @@ public abstract class PlotArea {
this.meta.put(key, value);
}
@NotNull public <T> T getMeta(@Nullable final String key, @NotNull final T def) {
@NotNull public <T> T getMeta(@NotNull final String key, @NotNull final T def) {
final Object v = getMeta(key);
return v == null ? def : (T) v;
}
@ -637,7 +637,8 @@ public abstract class PlotArea {
* <br>
* For persistent metadata use the flag system
*/
@Nullable public Object getMeta(@NotNull final String key) {
@Nullable
public Object getMeta(@NotNull final String key) {
if (this.meta != null) {
return this.meta.get(key);
}

View File

@ -16,6 +16,7 @@ import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAre
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@ -100,7 +101,7 @@ public abstract class EventUtil {
}
}
public boolean checkPlayerBlockEvent(PlotPlayer player, PlayerBlockEventType type,
public boolean checkPlayerBlockEvent(PlotPlayer player, @NotNull PlayerBlockEventType type,
Location location, BlockType blockType, boolean notifyPerms) {
PlotArea area = location.getPlotArea();
assert area != null;

View File

@ -5,6 +5,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
@ -14,13 +15,13 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
public final BlockState[][][] result;
private final int width;
private final int length;
private final int area;
@Deprecated private final int area;
private final BlockVector3 bot;
private final BlockVector3 top;
public ChunkBlockQueue(BlockVector3 bot, BlockVector3 top, boolean biomes) {
super(null, new Location(null, 0, 0, 0), new Location(null, 15, 255, 15));
this.width = top.getX() - bot.getX()+ 1;
this.width = top.getX() - bot.getX() + 1;
this.length = top.getZ() - bot.getZ() + 1;
this.area = width * length;
this.result = new BlockState[256][][];
@ -70,7 +71,9 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
return true;
}
@Override public BlockState getBlock(int x, int y, int z) {
@Override
@Nullable
public BlockState getBlock(int x, int y, int z) {
BlockState[][] blocksY = result[y];
if (blocksY != null) {
BlockState[] blocksYZ = blocksY[z];
@ -81,7 +84,9 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
return null;
}
@Override public String getWorld() {
@Override
@Nullable
public String getWorld() {
return null;
}