Skip to content
Permalink
Browse files

Enforce type on item add for Bridge/Door

  • Loading branch information...
me4502 committed May 7, 2019
1 parent 38acda8 commit 4cecc6e7597398249f064c486aad74b4ccf06c04
@@ -33,6 +33,7 @@
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockType;
@@ -131,6 +132,12 @@ public void onRightClick(SignClickEvent event) {
}
addBlocks(sign, CraftBookBukkitUtil.toChangedSign(getFarSign(event.getClickedBlock())), amount);

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

if (!(event.getPlayer().getGameMode() == GameMode.CREATIVE))
if (event.getPlayer().getItemInHand().getAmount() <= amount)
event.getPlayer().setItemInHand(new ItemStack(Material.AIR, 0));
@@ -33,6 +33,7 @@
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockType;
@@ -131,6 +132,12 @@ public void onRightClick(SignClickEvent event) {
}
addBlocks(sign, CraftBookBukkitUtil.toChangedSign(getFarSign(event.getClickedBlock())), amount);

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

if (!(event.getPlayer().getGameMode() == GameMode.CREATIVE))
if (event.getPlayer().getItemInHand().getAmount() <= amount)
event.getPlayer().setItemInHand(new ItemStack(Material.AIR, 0));

0 comments on commit 4cecc6e

Please sign in to comment.
You can’t perform that action at this time.