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