org.bukkit.block.data.type.WallSign Java Examples
The following examples show how to use
org.bukkit.block.data.type.WallSign.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onSignChanged(SignChangeEvent e) { if (e.isCancelled() || e.getPlayer() == null || !plugin.getWorldManager().isSkyAssociatedWorld(e.getPlayer().getWorld()) || !e.getLines()[0].equalsIgnoreCase("[usb]") || e.getLines()[1].trim().isEmpty() || !e.getPlayer().hasPermission("usb.island.signs.place") || !(e.getBlock().getType() == SkyBlockMenu.WALL_SIGN_MATERIAL) || !(e.getBlock().getState() instanceof Sign) ) { return; } Sign sign = (Sign) e.getBlock().getState(); if(sign.getBlock().getState().getBlockData() instanceof WallSign) { WallSign data = (WallSign) sign.getBlock().getState().getBlockData(); BlockFace attached = data.getFacing().getOppositeFace(); Block wallBlock = sign.getBlock().getRelative(attached); if (isChest(wallBlock)) { logic.addSign(sign, e.getLines(), (Chest) wallBlock.getState()); } } }
Example #2
Source File: BukkitHandler1_13.java From AreaShop with GNU General Public License v3.0 | 6 votes |
@Override public BlockFace getSignFacing(Block block) { if (block == null) { return null; } BlockState blockState = block.getState(); if (blockState == null) { return null; } BlockData blockData = blockState.getBlockData(); if (blockData == null) { return null; } if(blockData instanceof WallSign) { return ((WallSign) blockData).getFacing(); } else if(blockData instanceof Sign) { return ((Sign) blockData).getRotation(); } return null; }
Example #3
Source File: BukkitHandler1_13.java From AreaShop with GNU General Public License v3.0 | 6 votes |
@Override public boolean setSignFacing(Block block, BlockFace facing) { if (block == null || facing == null) { return false; } BlockState blockState = block.getState(); if (blockState == null) { return false; } BlockData blockData = blockState.getBlockData(); if (blockData == null) { return false; } if(blockData instanceof WallSign) { ((WallSign) blockData).setFacing(facing); } else if(blockData instanceof Sign) { ((Sign) blockData).setRotation(facing); } else { return false; } block.setBlockData(blockData); return true; }
Example #4
Source File: BukkitHandler1_13.java From AreaShop with GNU General Public License v3.0 | 6 votes |
@Override public Block getSignAttachedTo(Block block) { if (block == null) { return null; } BlockState blockState = block.getState(); if (blockState == null) { return null; } org.bukkit.block.data.BlockData blockData = blockState.getBlockData(); if (blockData == null) { return null; } if(blockData instanceof WallSign) { return block.getRelative(((WallSign) blockData).getFacing().getOppositeFace()); } else if(blockData instanceof Sign) { return block.getRelative(BlockFace.DOWN); } return null; }
Example #5
Source File: ShopManager.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
/** * Create a shop use Shop and Info object. * * @param shop The shop object * @param info The info object */ public void createShop(@NotNull Shop shop, @NotNull Info info) { Player player = Bukkit.getPlayer(shop.getOwner()); if (player == null) { throw new IllegalStateException("The owner creating the shop is offline or not exist"); } ShopCreateEvent shopCreateEvent = new ShopCreateEvent(shop, player); if (Util.fireCancellableEvent(shopCreateEvent)) { Util.debugLog("Cancelled by plugin"); return; } if (info.getSignBlock() != null && autoSign) { if (Util.isAir(info.getSignBlock().getType()) || info.getSignBlock().getType() == Material.WATER) { info.getSignBlock().setType(Util.getSignMaterial()); BlockState bs = info.getSignBlock().getState(); if (info.getSignBlock().getType() == Material.WATER && (bs.getBlockData() instanceof Waterlogged)) { Waterlogged waterable = (Waterlogged) bs.getBlockData(); waterable.setWaterlogged(true); // Looks like sign directly put in water } if (bs.getBlockData() instanceof WallSign) { WallSign signBlockDataType = (WallSign) bs.getBlockData(); BlockFace bf = info.getLocation().getBlock().getFace(info.getSignBlock()); if (bf != null) { signBlockDataType.setFacing(bf); bs.setBlockData(signBlockDataType); } } else { plugin.getLogger().warning("Sign material " + bs.getType().name() + " not a WallSign, make sure you using correct sign material."); } bs.update(true); } else { if (!plugin.getConfig().getBoolean("shop.allow-shop-without-space-for-sign")) { MsgUtil.sendMessage(player, MsgUtil.getMessage("failed-to-put-sign", player)); Util.debugLog("Sign cannot placed cause no enough space(Not air block)"); return; } } } //load the shop finally shop.onLoad(); //first init shop.setSignText(); //sync add to prevent compete issue addShop(shop.getLocation().getWorld().getName(), shop); //save to database plugin.getDatabaseHelper().createShop( shop, null, e -> Bukkit.getScheduler().runTask(plugin, () -> { //also remove from memory when failed shop.delete(true); plugin.getLogger().warning("Shop create failed, trying to auto fix the database..."); boolean backupSuccess = Util.backupDatabase(); if (backupSuccess) { plugin.getDatabaseHelper().removeShop(shop); } else { plugin.getLogger().warning("Failed to backup the database, all changes will revert after a reboot."); } })); }