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

项目:QuarSK    文件:SExprBeaconEffects.java   
@Nullable
@Override
protected PotionEffect[] get(Event e) {
    Block b = beacon.getSingle(e);
    if (b == null) {
        return null;
    }
    if (b.getType() == Material.BEACON) {
        return new PotionEffect[]{isPrimary
            ? ((Beacon) b.getState()).getPrimaryEffect()
            : ((Beacon) b.getState()).getSecondaryEffect()};
    }
    return null;
}
项目:QuarSK    文件:SExprBeaconEffects.java   
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode changeMode) {
    Block b = beacon.getSingle(e);
    if (b == null) {
        return;
    }
    if (b.getType() == Material.BEACON) {
        Beacon state = ((Beacon) b.getState());
        switch (changeMode) {
            case SET:
                if (isPrimary) {
                    state.setPrimaryEffect((PotionEffectType) delta[0]);
                } else {
                    state.setSecondaryEffect((PotionEffectType) delta[0]);
                }
                break;
            case DELETE:
            case RESET:
                if (isPrimary) {
                    state.setPrimaryEffect(null);
                } else {
                    state.setSecondaryEffect(null);
                }
                break;
        }
        state.update(true, false);
    }
}
项目:QuarSK    文件:ExprEntitiesInRange.java   
@Nullable
@Override
protected LivingEntity[] get(Event e) {
    Block b = beacon.getSingle(e);
    if (b == null) {
        return null;
    }
    if (b.getType() == Material.BEACON) {
        Beacon state = (Beacon) b.getState();
        return state.getEntitiesInRange().toArray(new LivingEntity[state.getEntitiesInRange().size()]);
    }
    return null;
}
项目:QuarSK    文件:ExprBeaconTier.java   
@Override
public Number convert(Block b) {
    if (b.getState() instanceof Beacon) {
        return ((Beacon) b.getState()).getTier();
    }
    return null;
}
项目: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);
            }
        }
    }
}