Package com.sk89q.craftbook

Examples of com.sk89q.craftbook.ChangedSign


    @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
    public void onSelfTriggerPing(SelfTriggerPingEvent event) {

        if(SignUtil.isSign(event.getBlock())) {
            ChangedSign sign = BukkitUtil.toChangedSign(event.getBlock());
            if(sign.getLine(1).equals("[Area]")) {
                isValidArea(sign); //Perform a conversion,
                sign.update(false);
            }
        }
    }
View Full Code Here


        if (!allowRedstone) return;
        if (!SignUtil.isSign(event.getBlock())) return;

        boolean save = false;

        ChangedSign sign = BukkitUtil.toChangedSign(event.getBlock());

        if (!sign.getLine(1).equals("[Area]") && !sign.getLine(1).equals("[SaveArea]")) return;

        // check if the namespace and area exists
        if(!isValidArea(sign)) return;

        save = sign.getLine(1).equals("[SaveArea]");

        // toggle the area
        toggle(event.getBlock(), sign, save);
    }
View Full Code Here

        Types type = null;

        if (SignUtil.isSign(sign)) {

            ChangedSign s = BukkitUtil.toChangedSign(sign);
            if (s.getLine(1).equals("[Crush]") && Types.isEnabled(Types.CRUSH))
                type = Types.CRUSH;
            else if (s.getLine(1).equals("[SuperSticky]") && Types.isEnabled(Types.SUPERSTICKY))
                type = Types.SUPERSTICKY;
            else if (s.getLine(1).equals("[Bounce]") && Types.isEnabled(Types.BOUNCE))
                type = Types.BOUNCE;
            else if (s.getLine(1).equals("[SuperPush]") && Types.isEnabled(Types.SUPERPUSH))
                type = Types.SUPERPUSH;
        }

        return type;
    }
View Full Code Here

            Bukkit.getServer().getScheduler().runTask(CraftBookPlugin.inst(), new Runnable() {

                @Override
                public void run () {

                    ChangedSign sign = new ChangedSign((Sign) event.getBlock().getState(), event.getLines());

                    //WorldEdit offset/radius tools.
                    ICUtil.parseSignFlags(player, sign);

                    try {
                        factory.verify(sign);
                        factory.checkPlayer(sign, player);
                    } catch (ICVerificationException e) {
                        player.printError(e.getMessage());
                        event.getBlock().breakNaturally();
                        return;
                    }

                    IC ic = registration.getFactory().create(sign);
                    ic.load();

                    sign.setLine(1, "[" + registration.getId() + "]" + suffix);
                    if (!shortHand)
                        sign.setLine(0, ic.getSignTitle());

                    sign.update(false);

                    if (ic instanceof SelfTriggeredIC && (event.getLine(1).trim().toUpperCase(Locale.ENGLISH).endsWith("S") || ((SelfTriggeredIC) ic).isAlwaysST()))
                        CraftBookPlugin.inst().getSelfTriggerManager().registerSelfTrigger(block.getLocation());

                    player.print("You've created " + registration.getId() + ": " + ic.getTitle() + ".");
View Full Code Here

                    types.add(new Tuple2<Types, Block>(type, sign));
            }
        }

        for(Tuple2<Types, Block> tups : types) {
            ChangedSign signState = BukkitUtil.toChangedSign(tups.b);

            switch (tups.a) {
                case CRUSH:
                    if (event.getNewCurrent() > event.getOldCurrent()) {
                        crush(event.getBlock(), piston, signState);
View Full Code Here

        if(!EventUtil.passesFilter(event)) return;

        if(!SignUtil.isSign(event.getBlock())) return;

        ChangedSign sign = BukkitUtil.toChangedSign(event.getBlock());

        if(!sign.getLine(1).equals("[Cook]")) return;

        CraftBookPlugin.inst().getSelfTriggerManager().registerSelfTrigger(event.getBlock().getLocation());
    }
View Full Code Here

        if(!EventUtil.passesFilter(event)) return;

        if(!SignUtil.isSign(event.getBlock())) return;

        ChangedSign sign = BukkitUtil.toChangedSign(event.getBlock());

        if(!sign.getLine(1).equals("[Cook]")) return;

        event.setHandled(true);

        int lastTick = 0, oldTick;

        try {
            lastTick = Math.max(0, Integer.parseInt(sign.getLine(2).trim()));
        } catch (Exception e) {
            sign.setLine(2, String.valueOf(0));
            sign.update(false);
        }
        oldTick = lastTick;
        Block b = SignUtil.getBackBlock(event.getBlock());
        Block fire = b.getRelative(0, 1, 0);
        Block cb = b.getRelative(0, 2, 0);
        if (cb.getType() == Material.CHEST) {
            if (fire.getType() == Material.FIRE) {
                Chest chest = (Chest) cb.getState();
                List<ItemStack> items;
                if(cookingPotOres)
                    items = ItemUtil.getRawMaterials(chest.getInventory());
                else
                    items = ItemUtil.getRawFood(chest.getInventory());

                if(items.size() == 0) return;

                if(lastTick < 500) {
                    lastTick = cookingPotSuperFast ? lastTick + getMultiplier(sign) : lastTick + Math.min(getMultiplier(sign), 5);
                    if(getMultiplier(sign) > 0)
                        decreaseMultiplier(sign, 1);
                }
                if (lastTick >= 50) {
                    for (ItemStack i : items) {

                        if (!ItemUtil.isStackValid(i)) continue;
                        ItemStack cooked = ItemUtil.getCookedResult(i);
                        if (cooked == null) {
                            if (cookingPotOres)
                                cooked = ItemUtil.getSmeletedResult(i);
                            if (cooked == null) continue;
                        }
                        if (chest.getInventory().addItem(cooked).isEmpty()) {
                            ItemStack toRemove = i.clone();
                            toRemove.setAmount(1);
                            chest.getInventory().removeItem(toRemove);
                            chest.update();
                            lastTick -= 50;
                            break;
                        }
                    }
                }
            } else
                lastTick = 0;
        }

        if(oldTick != lastTick) {
            sign.setLine(2, String.valueOf(lastTick));
            sign.update(false);
        }
    }
View Full Code Here

        if(!EventUtil.passesFilter(event)) return;

        if(event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) return;

        ChangedSign sign = event.getSign();

        if(!sign.getLine(1).equals("[Cook]")) return;

        CraftBookPlugin.inst().getSelfTriggerManager().registerSelfTrigger(event.getClickedBlock().getLocation());

        LocalPlayer p = CraftBookPlugin.inst().wrapPlayer(event.getPlayer());

        if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            Block b = SignUtil.getBackBlock(event.getClickedBlock());
            Block cb = b.getRelative(0, 2, 0);
            if (cb.getType() == Material.CHEST) {
                Player player = event.getPlayer();
                if(!player.hasPermission("craftbook.mech.cook.refuel")) {
                    if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
                        p.printError("mech.restock-permission");
                    event.setCancelled(true);
                    return;
                }
                if(!ProtectionUtil.canUse(event.getPlayer(), event.getClickedBlock().getLocation(), event.getBlockFace(), event.getAction())) {
                    if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
                        p.printError("area.use-permissions");
                    return;
                }
                if (ItemUtil.isStackValid(player.getItemInHand()) && Ingredients.isIngredient(player.getItemInHand().getType())) {
                    Material itemID = player.getItemInHand().getType();
                    increaseMultiplier(sign, Ingredients.getTime(itemID));
                    if (player.getItemInHand().getAmount() <= 1) {
                        player.setItemInHand(null);
                    } else {
                        player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
                    }
                    if(itemID == Material.LAVA_BUCKET && !cookingPotDestroyBuckets)
                        player.getInventory().addItem(new ItemStack(Material.BUCKET, 1));
                    p.print("mech.cook.add-fuel");
                    event.setCancelled(true);
                } else if (cookingPotSignOpen) {
                    player.openInventory(((Chest) cb.getState()).getBlockInventory());
                    event.setCancelled(true);
                }
            }

            if(sign.hasChanged())
                sign.update(false);
        } else {
            event.getPlayer().setFireTicks(getMultiplier(sign)+40);
            LocalPlayer player = CraftBookPlugin.inst().wrapPlayer(event.getPlayer());
            player.printError("mech.cook.ouch");
        }
View Full Code Here

        if(!EventUtil.passesFilter(event)) return;

        if(!SignUtil.isSign(event.getBlock())) return;

        ChangedSign sign = BukkitUtil.toChangedSign(event.getBlock());

        if(!sign.getLine(1).equals("[Cook]")) return;

        CraftBookPlugin.inst().getSelfTriggerManager().unregisterSelfTrigger(event.getBlock().getLocation(), UnregisterReason.BREAK);
    }
View Full Code Here

        if(!SignUtil.isSign(event.getBlock())) return;

        if(!EventUtil.passesFilter(event)) return;

        ChangedSign sign = BukkitUtil.toChangedSign(event.getBlock());

        if(!sign.getLine(1).equals("[Cook]")) return;

        CraftBookPlugin.inst().getSelfTriggerManager().registerSelfTrigger(event.getBlock().getLocation());

        if (event.isOn() && !event.isMinor())
            increaseMultiplier(sign, event.getNewCurrent() - event.getOldCurrent());

        if(sign.hasChanged())
            sign.update(false);
    }
View Full Code Here

TOP

Related Classes of com.sk89q.craftbook.ChangedSign

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.