This commit is contained in:
Jesse Boyd 2017-09-18 14:45:44 +10:00
parent 917d3f332d
commit 27d9baa7bc
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
5 changed files with 49 additions and 28 deletions

View File

@ -1,7 +1,9 @@
package com.boydti.fawe.bukkit.wrapper;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.wrapper.state.AsyncSign;
import com.boydti.fawe.object.FaweQueue;
import com.sk89q.worldedit.blocks.BlockID;
import java.util.Collection;
import java.util.List;
import org.bukkit.Chunk;
@ -168,6 +170,12 @@ public class AsyncBlock implements Block {
@Override
public BlockState getState() {
int combined = queue.getCombinedId4Data(x, y, z, 0);
switch (FaweCache.getId(combined)) {
case BlockID.SIGN_POST:
case BlockID.WALL_SIGN:
return new AsyncSign(this, combined);
}
return new AsyncBlockState(this);
}

View File

@ -21,8 +21,11 @@ public class AsyncBlockState implements BlockState {
private final AsyncBlock block;
public AsyncBlockState(AsyncBlock block) {
this(block, block.queue.getCombinedId4Data(block.x, block.y, block.z, 0));
}
public AsyncBlockState(AsyncBlock block, int combined) {
this.block = block;
int combined = block.queue.getCombinedId4Data(block.x, block.y, block.z, 0);
this.id = (short) (combined >> 4);
this.data = (byte) (combined & 0xF);
if (FaweCache.hasNBT(id)) {

View File

@ -10,8 +10,8 @@ import java.util.Map;
import org.bukkit.block.Sign;
public class AsyncSign extends AsyncBlockState implements Sign {
public AsyncSign(AsyncBlock block) {
super(block);
public AsyncSign(AsyncBlock block, int combined) {
super(block, combined);
}
@Override

View File

@ -110,18 +110,23 @@ public class DefaultMaskParser extends FaweParser<Mask> {
}
}
if (mask == null) {
try {
context.setPreferringWildcard(true);
context.setRestricted(false);
BaseBlock block = worldEdit.getBlockFactory().parseFromInput(command, context);
if (pe.and) {
mask = new BlockMask(extent, block);
} else {
blocks.add(block);
continue;
if (command.startsWith("[")) {
int end = command.lastIndexOf(']');
mask = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context);
} else {
try {
context.setPreferringWildcard(true);
context.setRestricted(false);
BaseBlock block = worldEdit.getBlockFactory().parseFromInput(command, context);
if (pe.and) {
mask = new BlockMask(extent, block);
} else {
blocks.add(block);
continue;
}
} catch (NoMatchException e) {
throw new NoMatchException(e.getMessage() + " See: //masks");
}
} catch (NoMatchException e) {
throw new NoMatchException(e.getMessage() + " See: //masks");
}
}
}

View File

@ -84,20 +84,25 @@ public class HashTagPatternParser extends FaweParser<Pattern> {
}
}
if (pattern == null) {
int percentIndex = command.indexOf('%');
if (percentIndex != -1) { // Legacy percent pattern
chance = Expression.compile(command.substring(0, percentIndex)).evaluate();
command = command.substring(percentIndex + 1);
if (!entry.getValue().isEmpty()) {
if (!command.isEmpty()) command += " ";
command += StringMan.join(entry.getValue(), " ");
}
pattern = parseFromInput(command, context);
} else { // legacy block pattern
try {
pattern = worldEdit.getBlockFactory().parseFromInput(command, context);
} catch (NoMatchException e) {
throw new NoMatchException(e.getMessage() + " See: //patterns");
if (command.startsWith("[")) {
int end = command.lastIndexOf(']');
pattern = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context);
} else {
int percentIndex = command.indexOf('%');
if (percentIndex != -1) { // Legacy percent pattern
chance = Expression.compile(command.substring(0, percentIndex)).evaluate();
command = command.substring(percentIndex + 1);
if (!entry.getValue().isEmpty()) {
if (!command.isEmpty()) command += " ";
command += StringMan.join(entry.getValue(), " ");
}
pattern = parseFromInput(command, context);
} else { // legacy block pattern
try {
pattern = worldEdit.getBlockFactory().parseFromInput(command, context);
} catch (NoMatchException e) {
throw new NoMatchException(e.getMessage() + " See: //patterns");
}
}
}
}