mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fixed an error with the debug command and added @NotNull to generator methods
This commit is contained in:
parent
e53ea2377c
commit
4b306d454b
@ -22,6 +22,7 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GenChunk extends ScopedLocalBlockQueue {
|
||||
|
||||
@ -107,7 +108,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
||||
@Override public boolean setBlock(int x, int y, int z, @NotNull Pattern pattern) {
|
||||
return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z));
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,14 @@ import java.util.Map;
|
||||
public class Debug extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if ((args.length > 0) && "player".equalsIgnoreCase(args[1])) {
|
||||
for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) {
|
||||
MainUtil.sendMessage(player,
|
||||
"Key: " + meta.getKey() + " Value: " + meta.getValue().toString() + " , ");
|
||||
if (args.length > 0) {
|
||||
if ("player".equalsIgnoreCase(args[0])) {
|
||||
for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) {
|
||||
MainUtil.sendMessage(player,
|
||||
"Key: " + meta.getKey() + " Value: " + meta.getValue().toString() + " , ");
|
||||
}
|
||||
;
|
||||
}
|
||||
;
|
||||
}
|
||||
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
|
@ -108,6 +108,7 @@ public final class BlockBucket implements ConfigurationSerializable {
|
||||
if (matcher.find()) {
|
||||
String chanceStr = matcher.group("chance");
|
||||
String block = matcher.group("block");
|
||||
//noinspection PointlessNullCheck
|
||||
if (chanceStr != null && block != null && !MathMan.isInteger(block) && MathMan.isInteger(chanceStr)) {
|
||||
String namespace = matcher.group("namespace");
|
||||
string = (namespace == null ? "" : namespace + ":") + block;
|
||||
@ -123,6 +124,7 @@ public final class BlockBucket implements ConfigurationSerializable {
|
||||
Matcher matcher = regex.matcher(entry);
|
||||
if (matcher.find()) {
|
||||
String chanceStr = matcher.group("chance");
|
||||
//noinspection PointlessNullCheck
|
||||
if (chanceStr != null && MathMan.isInteger(chanceStr)) {
|
||||
String[] parts = entry.split(":");
|
||||
parts = Arrays.copyOf(parts, parts.length - 1);
|
||||
|
@ -88,7 +88,7 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
@Override public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
||||
@Override public boolean setBlock(int x, int y, int z, @NotNull Pattern pattern) {
|
||||
return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z));
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class LocalBlockQueue {
|
||||
|
||||
@ -59,7 +60,7 @@ public abstract class LocalBlockQueue {
|
||||
|
||||
public abstract boolean setBlock(final int x, final int y, final int z, final BaseBlock id);
|
||||
|
||||
public boolean setBlock(final int x, final int y, final int z, final Pattern pattern) {
|
||||
public boolean setBlock(final int x, final int y, final int z, @NotNull final Pattern pattern) {
|
||||
return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z));
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,10 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PatternUtil {
|
||||
public static BaseBlock apply(Pattern pattern, int x, int y, int z) {
|
||||
public static BaseBlock apply(@NotNull Pattern pattern, int x, int y, int z) {
|
||||
if (pattern instanceof BlockPattern
|
||||
|| pattern instanceof RandomPattern
|
||||
|| pattern instanceof BlockState
|
||||
@ -44,9 +45,7 @@ public class PatternUtil {
|
||||
context.setPreferringWildcard(false);
|
||||
context.setTryLegacy(true);
|
||||
try {
|
||||
Pattern pattern =
|
||||
WorldEdit.getInstance().getPatternFactory().parseFromInput(input, context);
|
||||
return pattern;
|
||||
return WorldEdit.getInstance().getPatternFactory().parseFromInput(input, context);
|
||||
} catch (InputParseException e) {
|
||||
throw new Command.CommandException(Captions.NOT_VALID_BLOCK, e.getMessage());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user