Java 类org.bukkit.block.BrewingStand 实例源码

项目:ExilePearl    文件:PlayerListener.java   
/**
 * Updates the pearl holder
 * @param pearl The pearl to update
 * @param holder The pearl holder
 * @param event The event
 */
private void updatePearlHolder(ExilePearl pearl, InventoryHolder holder, Cancellable event) {

    if (holder instanceof Chest) {
        updatePearl(pearl, (Chest)holder);
    } else if (holder instanceof DoubleChest) {
        updatePearl(pearl, (Chest) ((DoubleChest) holder).getLeftSide());
    } else if (holder instanceof Furnace) {
        updatePearl(pearl, (Furnace) holder);
    } else if (holder instanceof Dispenser) {
        updatePearl(pearl, (Dispenser) holder);
    } else if (holder instanceof Dropper) {
        updatePearl(pearl, (Dropper) holder);
    } else if (holder instanceof Hopper) {
        updatePearl(pearl, (Hopper) holder);
    } else if (holder instanceof BrewingStand) {
        updatePearl(pearl, (BrewingStand) holder);
    } else if (holder instanceof Player) {
        updatePearl(pearl, (Player) holder);
    }else {
        event.setCancelled(true);
    }
}
项目:McMMOPlus    文件:AlchemyBrewTask.java   
@Override
public void run() {
    if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND) {
        if (Alchemy.brewingStandMap.containsKey(location)) {
            Alchemy.brewingStandMap.remove(location);
        }

        this.cancel();

        return;
    }

    brewTimer -= brewSpeed;

    // Vanilla potion brewing completes when BrewingTime == 1
    if (brewTimer < Math.max(brewSpeed, 2)) {
        this.cancel();
        finish();
    }
    else {
        ((BrewingStand) brewingStand).setBrewingTime((int) brewTimer);
    }
}
项目:Transport-Pipes    文件:ContainerBlockUtils.java   
public TransportPipesContainer createContainerFromBlock(Block block) {
    if (block.getState() instanceof Furnace) {
        return new FurnaceContainer(block);
    } else if (block.getState() instanceof BrewingStand) {
        return new BrewingStandContainer(block);
    } else if (block.getState() instanceof InventoryHolder) {
        return new SimpleInventoryContainer(block);
    }
    return null;
}
项目:NeverLag    文件:WorldInfo.java   
public WorldInfo(World world) {
    this.worldName = world.getName();
    this.totalOnline = world.getPlayers().size();
    for (Entity entity : world.getEntities()) {
        this.totalEntity++;
        if (entity instanceof Animals) {
            this.totalAnimals++;
        } else if (entity instanceof Monster) {
            this.totalMonsters++;
        } else if (entity instanceof Item) {
            this.totalDropItem++;
        }
    }
    for (Chunk loadedChunk : world.getLoadedChunks()) {
        this.totalChunk++;
        for (BlockState tiles : loadedChunk.getTileEntities()) {
            this.totalTiles++;
            if (tiles instanceof Hopper) {
                this.totalHopper++;
            } else if (tiles instanceof Chest) {
                this.totalChest++;
            } else if (tiles instanceof Dispenser) {
                this.totalDispenser++;
            } else if (tiles instanceof Dropper) {
                this.totalDropper++;
            } else if (tiles instanceof BrewingStand) {
                this.totalBrewingStand++;
            }
        }

    }
}
项目:HCFCore    文件:PotionLimitListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBrew(BrewEvent event) {
    /*
     * if (!testValidity(event.getContents().getContents())) { event.setCancelled(true); event.getContents().getHolder().setBrewingTime(EMPTY_BREW_TIME); }
     */

    // *** Version that works with a Spigot version that does not
    // *** have a BrewEvent#getResults() method:

    BrewerInventory inventory = event.getContents();
    ItemStack[] contents = inventory.getContents();
    int length = contents.length;
    ItemStack[] cloned = new ItemStack[length];
    for (int i = 0; i < length; i++) {
        ItemStack previous = contents[i];
        cloned[i] = (previous == null ? null : previous.clone());
    }

    BrewingStand stand = inventory.getHolder();
    Bukkit.getScheduler().runTask(HCF.getPlugin(), () -> {
        if (!testValidity(inventory.getContents())) {
            stand.setBrewingTime(EMPTY_BREW_TIME);
            inventory.setContents(cloned);
        }
    });

}
项目:HCFCore    文件:PotionLimitListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBrew(BrewEvent event) {
    /*
     * if (!testValidity(event.getContents().getContents())) { event.setCancelled(true); event.getContents().getHolder().setBrewingTime(EMPTY_BREW_TIME); }
     */

    // *** Version that works with a Spigot version that does not
    // *** have a BrewEvent#getResults() method:

    BrewerInventory inventory = event.getContents();
    ItemStack[] contents = inventory.getContents();
    int length = contents.length;
    ItemStack[] cloned = new ItemStack[length];
    for (int i = 0; i < length; i++) {
        ItemStack previous = contents[i];
        cloned[i] = (previous == null ? null : previous.clone());
    }

    BrewingStand stand = inventory.getHolder();
    Bukkit.getScheduler().runTask(HCF.getPlugin(), () -> {
        if (!testValidity(inventory.getContents())) {
            stand.setBrewingTime(EMPTY_BREW_TIME);
            inventory.setContents(cloned);
        }
    });

}
项目:BukkitOldCombatMechanics    文件:ModuleOldBrewingStand.java   
@EventHandler
public void onBrew(BrewEvent e) {
    Block block = e.getBlock();

    if(isEnabled(block.getWorld()) && block.getType().equals(Material.BREWING_STAND)) //Just in case...
        ((BrewingStand) block.getState()).setFuelLevel(20);
}
项目:iZenith-PVP    文件:BrewListener.java   
public BrewListener() {
    tagged = new ArrayList<BrewingStand>();
    Bukkit.getScheduler().scheduleSyncRepeatingTask(Util.getMain(), new Runnable(){

        @Override
        public void run() {
            for(BrewingStand stand : tagged){
                stand.setFuelLevel(20);
                stand.update();
            }
        }

    },100l,100l);
}
项目:iZenith-PVP    文件:BrewListener.java   
@EventHandler
public void onBrewingStandInteract(PlayerInteractEvent e) {
    if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType().equals(Material.BREWING_STAND)) {
        BrewingStand stand = (BrewingStand) e.getClickedBlock().getState();
        if(!tagged.contains(stand))
            tagged.add(stand);
    }
}
项目:SyncChest    文件:SyncManager.java   
public Inventory getInventory(Location loc) {

if (loc.getBlock().getState() instanceof MainChest) {
    return ((MainChest) loc.getBlock().getState()).getInventory();
}

if (loc.getBlock().getState() instanceof RelatedChest) {
    return ((RelatedChest) loc.getBlock().getState()).getInventory();
}

if (loc.getBlock().getState() instanceof Chest) {
    return ((Chest) loc.getBlock().getState()).getInventory();
}

if (loc.getBlock().getState() instanceof DoubleChest) {
    return ((DoubleChest) loc.getBlock().getState()).getInventory();
}

if (loc.getBlock().getState() instanceof BrewingStand) {
    return ((BrewingStand) loc.getBlock().getState()).getInventory();
}

if (loc.getBlock().getState() instanceof Dispenser) {
    return ((Dispenser) loc.getBlock().getState()).getInventory();
}

if (loc.getBlock().getState() instanceof Dropper) {
    return ((Dropper) loc.getBlock().getState()).getInventory();
}
return null;
   }
项目:McMMOPlus    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryDragEvent(InventoryDragEvent event) {
    Inventory inventory = event.getInventory();

    if (!(inventory instanceof BrewerInventory)) {
        return;
    }

    InventoryHolder holder = inventory.getHolder();

    if (!(holder instanceof BrewingStand)) {
        return;
    }

    HumanEntity whoClicked = event.getWhoClicked();

    if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.secondaryAbilityEnabled(whoClicked, SecondaryAbility.CONCOCTIONS)) {
        return;
    }

    if (!event.getInventorySlots().contains(Alchemy.INGREDIENT_SLOT)) {
        return;
    }

    ItemStack cursor = event.getCursor();
    ItemStack ingredient = ((BrewerInventory) inventory).getIngredient();

    if (AlchemyPotionBrewer.isEmpty(ingredient) || ingredient.isSimilar(cursor)) {
        Player player = (Player) whoClicked;

        if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
            // Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
            AlchemyPotionBrewer.scheduleCheck(player, (BrewingStand) holder);
            return;
        }

        event.setCancelled(true);
        AlchemyPotionBrewer.scheduleUpdate(inventory);
    }
}
项目:McMMOPlus    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    Inventory inventory = event.getDestination();

    if (!(inventory instanceof BrewerInventory)) {
        return;
    }

    InventoryHolder holder = inventory.getHolder();

    if (!(holder instanceof BrewingStand)) {
        return;
    }

    ItemStack item = event.getItem();

    if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
        AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
    }
}
项目:BetonQuest    文件:PotionObjective.java   
@EventHandler
public void onIngredientPut(InventoryClickEvent event) {
    if (event.getInventory().getType() != InventoryType.BREWING)
        return;
    if (event.getRawSlot() == 3 || event.getClick().equals(ClickType.SHIFT_LEFT)) {
        String playerID = PlayerConverter.getID((Player) event.getWhoClicked());
        if (!containsPlayer(playerID))
            return;
        locations.put(((BrewingStand) event.getInventory().getHolder()).getLocation(), playerID);
    }
}
项目:Uranium    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:ProtocolSupportLegacySupport    文件:BrewingStandFuelHandler.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBrewingClick(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
        return;
    }

    ItemStack itemstack = event.getItem();
    if ((itemstack == null) || (itemstack.getType() != Material.BLAZE_POWDER)) {
        return;
    }
    itemstack = itemstack.clone();

    Block clicked = event.getClickedBlock();
    BlockState state = clicked.getState();
    if (!(state instanceof BrewingStand)) {
        return;
    }
    BrewingStand stand = (BrewingStand) state;

    ItemStack existing = stand.getInventory().getFuel();
    if (existing != null) {
        existing = existing.clone();
    }

    PlayerInventory inventory = event.getPlayer().getInventory();
    switch (event.getHand()) {
        case HAND: {
            inventory.setItemInMainHand(existing);
            break;
        }
        case OFF_HAND: {
            inventory.setItemInOffHand(existing);
            break;
        }
        default: {
            throw new IllegalArgumentException("Unexpected hand slot in interaction: " + event.getHand());
        }
    }
    stand.getInventory().setFuel(itemstack);
    event.setCancelled(true);
}
项目:Transport-Pipes    文件:BrewingStandContainer.java   
public BrewingStandContainer(Block block) {
    super(block);
    this.cachedChunk = block.getChunk();
    this.cachedBrewingStand = (BrewingStand) block.getState();
    this.cachedInv = cachedBrewingStand.getInventory();
}
项目:Transport-Pipes    文件:BrewingStandContainer.java   
@Override
public void updateBlock() {
    this.cachedChunk = block.getChunk();
    this.cachedBrewingStand = ((BrewingStand) block.getState());
    this.cachedInv = cachedBrewingStand.getInventory();
}
项目:ThermosRebased    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:Thermos    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:KCauldron    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:CauldronGit    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:Cauldron-Old    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:Cauldron-Reloaded    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:FFoKC    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:CraftBukkit    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:Craftbukkit    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:Almura-Server    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:Tweakkit-Server    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:Cauldron    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:McMMOPlus    文件:AlchemyBrewTask.java   
public void cancelBrew() {
    this.cancel();

    ((BrewingStand) brewingStand).setBrewingTime(-1);
    Alchemy.brewingStandMap.remove(location);
}
项目:McMMOPlus    文件:AlchemyBrewCheckTask.java   
public AlchemyBrewCheckTask(Player player, BrewingStand brewingStand) {
    this.player = player;
    this.brewingStand = brewingStand;
    this.oldInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
}
项目:McMMOPlus    文件:AlchemyPotionBrewer.java   
public static void scheduleCheck(Player player, BrewingStand brewingStand) {
    new AlchemyBrewCheckTask(player, brewingStand).runTask(mcMMO.p);
}
项目:McMMOPlus    文件:McMMOPlayerBrewEvent.java   
public BrewingStand getBrewingStand() {
    return (BrewingStand) brewingStand;
}
项目:McMMOPlus    文件:BlockListener.java   
/**
 * Monitor BlockBreak events.
 *
 * @param event The event to monitor
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
    if (event instanceof FakeBlockBreakEvent) {
        return;
    }

    BlockState blockState = event.getBlock().getState();
    Location location = blockState.getLocation();

    if (!BlockUtils.shouldBeWatched(blockState)) {
        return;
    }

    /* ALCHEMY - Cancel any brew in progress for that BrewingStand */
    if (blockState instanceof BrewingStand && Alchemy.brewingStandMap.containsKey(location)) {
        Alchemy.brewingStandMap.get(location).cancelBrew();
    }

    Player player = event.getPlayer();

    if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
        return;
    }

    McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
    ItemStack heldItem = player.getItemInHand();

    /* HERBALISM */
    if (BlockUtils.affectedByGreenTerra(blockState)) {
        HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();

        /* Green Terra */
        if (herbalismManager.canActivateAbility()) {
            mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
        }

        /*
         * We don't check the block store here because herbalism has too many unusual edge cases.
         * Instead, we check it inside the drops handler.
         */
        if (SkillType.HERBALISM.getPermissions(player)) {
            herbalismManager.herbalismBlockCheck(blockState);
        }
    }

    /* MINING */
    else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && SkillType.MINING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
        MiningManager miningManager = mcMMOPlayer.getMiningManager();
        miningManager.miningBlockCheck(blockState);
    }

    /* WOOD CUTTING */
    else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
        WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();

        if (woodcuttingManager.canUseTreeFeller(heldItem)) {
            woodcuttingManager.processTreeFeller(blockState);
        }
        else {
            woodcuttingManager.woodcuttingBlockCheck(blockState);
        }
    }

    /* EXCAVATION */
    else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && SkillType.EXCAVATION.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
        ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
        excavationManager.excavationBlockCheck(blockState);

        if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
            excavationManager.gigaDrillBreaker(blockState);
        }
    }

    /* Remove metadata from placed watched blocks */
    mcMMO.getPlaceStore().setFalse(blockState);
}
项目:Pore    文件:PoreBrewerInventory.java   
@Override
public BrewingStand getHolder() {
    throw new NotImplementedException("TODO");
}
项目:CardinalPGM    文件:ObserverModule.java   
@EventHandler
public void onInteraction(PlayerInteractEvent event) {
    if (testObserver(event.getPlayer())) {
        event.setCancelled(true);
        if ((event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) && (event.getPlayer().getInventory().getItemInMainHand() != null && event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.WRITTEN_BOOK))){
            event.setUseInteractedBlock(Event.Result.DENY);
            event.setUseItemInHand(Event.Result.ALLOW);
        }
        if (event.getClickedBlock() != null && !event.getPlayer().isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (event.getClickedBlock().getType().equals(Material.CHEST) || event.getClickedBlock().getType().equals(Material.TRAPPED_CHEST)) {
                Inventory chest = Bukkit.createInventory(null, ((Chest) event.getClickedBlock().getState()).getInventory().getSize());
                for (int i = 0; i < ((Chest) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    chest.setItem(i, ((Chest) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(chest);
            }
            if (event.getClickedBlock().getType().equals(Material.FURNACE) || event.getClickedBlock().getType().equals(Material.BURNING_FURNACE)) {
                Inventory furnace = Bukkit.createInventory(null, InventoryType.FURNACE);
                for (int i = 0; i < ((Furnace) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    furnace.setItem(i, ((Furnace) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(furnace);
            }
            if (event.getClickedBlock().getType().equals(Material.DISPENSER)) {
                Inventory dispenser = Bukkit.createInventory(null, InventoryType.DISPENSER);
                for (int i = 0; i < ((Dispenser) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    dispenser.setItem(i, ((Dispenser) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(dispenser);
            }
            if (event.getClickedBlock().getType().equals(Material.DROPPER)) {
                Inventory dropper = Bukkit.createInventory(null, InventoryType.DROPPER);
                for (int i = 0; i < ((Dropper) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    dropper.setItem(i, ((Dropper) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(dropper);
            }
            if (event.getClickedBlock().getType().equals(Material.HOPPER)) {
                Inventory hopper = Bukkit.createInventory(null, InventoryType.HOPPER);
                for (int i = 0; i < ((Hopper) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    hopper.setItem(i, ((Hopper) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(hopper);
            }
            if (event.getClickedBlock().getType().equals(Material.BREWING_STAND)) {
                Inventory brewingStand = Bukkit.createInventory(null, InventoryType.BREWING);
                for (int i = 0; i < ((BrewingStand) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    brewingStand.setItem(i, ((BrewingStand) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(brewingStand);
            }
            if (event.getClickedBlock().getType().equals(Material.BEACON)) {
                Inventory beacon = Bukkit.createInventory(null, InventoryType.BEACON);
                for (int i = 0; i < ((Beacon) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    beacon.setItem(i, ((Beacon) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(beacon);
            }
        }
    }
}
项目:SpigotSource    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:Craft-city    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:MCPBukkit    文件:CraftInventoryBrewer.java   
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
项目:BukkitOldCombatMechanics    文件:ModuleOldBrewingStand.java   
@EventHandler
public void onInventoryOpen(InventoryOpenEvent e) {
    if(!isEnabled(e.getPlayer().getWorld())) return;

    Inventory inv = e.getInventory();

    if(inv == null) return;

    Location loc = null;

    try{
    loc = inv.getLocation();
    }
    catch(Exception ignored){}

    if(loc == null) return;

    Block block = loc.getBlock();

    if(!block.getType().equals(Material.BREWING_STAND)) return;

    BrewingStand stand = (BrewingStand) block.getState();

    stand.setFuelLevel(20);

    stand.update();

}