Skip to content

Commit

Permalink
Fixed Gates not using minified IDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Feb 24, 2019
1 parent 96251fb commit 98ee4db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ && isValidGateBlock(sign, smallSearchSize, heldType.getDefaultState(), false)) {
addBlocks(sign, amount);

if (enforceType) {
sign.setLine(0, player.getItemInHand(HandSide.MAIN_HAND).getType().getId());
BlockType blockType = player.getItemInHand(HandSide.MAIN_HAND).getType().getBlockType();
sign.setLine(0, BlockSyntax.toMinifiedId(blockType));
sign.update(false);
}

Expand Down Expand Up @@ -503,7 +504,7 @@ public BlockState getGateBlock(ChangedSign sign, boolean smallSearchSize) {
}

if(enforceType && gateBlock != null && !gateBlock.getBlockType().getMaterial().isAir()) {
sign.setLine(0, BlockSyntax.toMinifiedId(gateBlock.getBlockType().getFuzzyMatcher()));
sign.setLine(0, BlockSyntax.toMinifiedId(gateBlock.getBlockType()));
sign.update(false);
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/sk89q/craftbook/util/BlockSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
Expand Down Expand Up @@ -87,6 +88,14 @@ public static BlockData getBukkitBlock(String line) {
return BukkitAdapter.adapt(getBlock(line));
}

public static String toMinifiedId(BlockType holder) {
String output = holder.getId();
if (output.startsWith("minecraft:")) {
output = output.substring(10);
}
return output;
}

public static String toMinifiedId(BlockStateHolder holder) {
String output = holder.getAsString();
if (output.startsWith("minecraft:")) {
Expand Down

0 comments on commit 98ee4db

Please sign in to comment.