Merge pull request #19 from IronApollo/master

Fix for '//mask ?' resulting in pattern error
Fixes CommandSuggestionEvent 
Update FaweLocalBlockQueue to support Plotsquared restrictions
This commit is contained in:
NotMyFault
2018-11-14 07:41:42 +01:00
committed by GitHub
4 changed files with 28 additions and 18 deletions

View File

@ -8,10 +8,15 @@ import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.List;
// TODO FIXME
@ -61,15 +66,14 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override
public boolean setBlock(int x, int y, int z, int id, int data) {
return false;
// return IMP.setBlock(x, y, z, (short) id, (byte) data);
return IMP.setBlock(x, y, z, LegacyMapper.getInstance().getBlockFromLegacy(id, data));
}
@Override
public PlotBlock getBlock(int x, int y, int z) {
// int combined = IMP.getCombinedId4Data(x, y, z);
// return PlotBlock.get(FaweCache.getId(combined), FaweCache.getData(combined));
return null;
int combined = IMP.getCombinedId4Data(x, y, z);
com.sk89q.worldedit.world.block.BlockState state = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combined);
return PlotBlock.get(state.getInternalBlockTypeId(), state.getInternalPropertiesId());
}
private BaseBiome biome;
@ -78,15 +82,14 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override
public boolean setBiome(int x, int z, String biome) {
// if (!StringMan.isEqual(biome, lastBiome)) {
// if (reg == null) {
// World weWorld = IMP.getWEWorld();
// reg = weWorld.getWorldData().getBiomeRegistry();
// }
// List<BaseBiome> biomes = reg.getBiomes();
// lastBiome = biome;
// this.biome = Biomes.findBiomeByName(biomes, biome, reg);
// }
if (!StringMan.isEqual(biome, lastBiome)) {
if (reg == null) {
reg = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS).getRegistries().getBiomeRegistry();
}
List<BaseBiome> biomes = reg.getBiomes();
lastBiome = biome;
this.biome = Biomes.findBiomeByName(biomes, biome, reg);
}
return IMP.setBiome(x, z, this.biome);
}

View File

@ -86,7 +86,7 @@ public class DefaultMaskParser extends FaweParser<Mask> {
if (charMask && input.charAt(0) == '=') {
return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
}
if (char0 == '#') {
if (char0 == '#' || char0 == '?') {
throw new SuggestInputParseException(new NoMatchException("Unknown mask: " + full + ", See: //masks"), full,
() -> {
if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());