Java Code Examples for org.bukkit.Material#BUCKET

The following examples show how to use org.bukkit.Material#BUCKET . 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: PlayerEvents.java    From uSkyBlock with GNU General Public License v3.0 7 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onClickOnObsidian(final PlayerInteractEvent event) {
    if (!plugin.getWorldManager().isSkyWorld(event.getPlayer().getWorld())) {
        return;
    }
    long now = System.currentTimeMillis();
    Player player = event.getPlayer();
    PlayerInventory inventory = player.getInventory();
    Block block = event.getClickedBlock();
    Long lastClick = obsidianClick.get(player.getUniqueId());
    if (lastClick != null && (lastClick + OBSIDIAN_SPAM) >= now) {
        plugin.notifyPlayer(player, tr("\u00a74You can only convert obsidian once every 10 seconds"));
        return;
    }
    if (Settings.extras_obsidianToLava && plugin.playerIsOnIsland(player)
            && plugin.getWorldManager().isSkyWorld(player.getWorld())
            && event.getAction() == Action.RIGHT_CLICK_BLOCK
            && player.getItemInHand() != null
            && player.getItemInHand().getType() == Material.BUCKET
            && block != null
            && block.getType() == Material.OBSIDIAN
            && !testForObsidian(block)) {
        if (inventory.firstEmpty() != -1) {
            obsidianClick.put(player.getUniqueId(), now);
            player.sendMessage(tr("\u00a7eChanging your obsidian back into lava. Be careful!"));
            inventory.removeItem(new ItemStack(Material.BUCKET, 1));
            inventory.addItem(new ItemStack(Material.LAVA_BUCKET, 1));
            player.updateInventory();
            block.setType(Material.AIR);
            event.setCancelled(true); // Don't execute the click anymore (since that would re-place the lava).
        } else {
            player.sendMessage(tr("\u00a7eYour inventory must have another empty space!"));
        }
    }
}
 
Example 2
Source File: Materials.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
static boolean isBucket(Material bucket) {
  return bucket == Material.BUCKET
      || bucket == Material.LAVA_BUCKET
      || bucket == Material.WATER_BUCKET
      || bucket == Material.MILK_BUCKET;
}
 
Example 3
Source File: Materials.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static boolean isBucket(Material bucket) {
    return bucket == Material.BUCKET || bucket == Material.LAVA_BUCKET || bucket == Material.WATER_BUCKET || bucket == Material.MILK_BUCKET;
}
 
Example 4
Source File: MilkingTaskType.java    From Quests with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMilk(PlayerInteractEntityEvent event) {
    if (!(event.getRightClicked() instanceof Cow) || (event.getPlayer().getItemInHand().getType() != Material.BUCKET)) {
        return;
    }

    Player player = event.getPlayer();

    QPlayer qPlayer = QuestsAPI.getPlayerManager().getPlayer(player.getUniqueId(), true);
    QuestProgressFile questProgressFile = qPlayer.getQuestProgressFile();

    for (Quest quest : super.getRegisteredQuests()) {
        if (questProgressFile.hasStartedQuest(quest)) {
            QuestProgress questProgress = questProgressFile.getQuestProgress(quest);

            for (Task task : quest.getTasksOfType(super.getType())) {
                TaskProgress taskProgress = questProgress.getTaskProgress(task.getId());

                if (taskProgress.isCompleted()) {
                    continue;
                }

                int cowsNeeded = (int) task.getConfigValue("amount");

                int progressMilked;
                if (taskProgress.getProgress() == null) {
                    progressMilked = 0;
                } else {
                    progressMilked = (int) taskProgress.getProgress();
                }

                taskProgress.setProgress(progressMilked + 1);

                if (((int) taskProgress.getProgress()) >= cowsNeeded) {
                    taskProgress.setCompleted(true);
                }
            }
        }
    }
}
 
Example 5
Source File: NewItemShop.java    From BedwarsRel with GNU General Public License v3.0 4 votes vote down vote up
private void handleCategoryInventoryClick(InventoryClickEvent ice, Game game, Player player) {

    int catSize = this.getCategoriesSize(player);
    int sizeCategories = this.getInventorySize(catSize) + 9;
    int rawSlot = ice.getRawSlot();

    if (rawSlot >= this.getInventorySize(catSize) && rawSlot < sizeCategories) {
      ice.setCancelled(true);
      if (ice.getCurrentItem().getType() == Material.SLIME_BALL) {
        this.changeToOldShop(game, player);
        return;
      }

      if (ice.getCurrentItem().getType() == Material.BUCKET) {
        game.getPlayerSettings(player).setOneStackPerShift(false);
        player.playSound(player.getLocation(), SoundMachine.get("CLICK", "UI_BUTTON_CLICK"),
            Float.valueOf("1.0"), Float.valueOf("1.0"));
        this.openCategoryInventory(player);
        return;
      } else if (ice.getCurrentItem().getType() == Material.LAVA_BUCKET) {
        game.getPlayerSettings(player).setOneStackPerShift(true);
        player.playSound(player.getLocation(), SoundMachine.get("CLICK", "UI_BUTTON_CLICK"),
            Float.valueOf("1.0"), Float.valueOf("1.0"));
        this.openCategoryInventory(player);
        return;
      }

    }

    if (rawSlot >= sizeCategories) {
      if (ice.isShiftClick()) {
        ice.setCancelled(true);
        return;
      }

      ice.setCancelled(false);
      return;
    }

    MerchantCategory clickedCategory = this.getCategoryByMaterial(ice.getCurrentItem().getType());
    if (clickedCategory == null) {
      if (ice.isShiftClick()) {
        ice.setCancelled(true);
        return;
      }

      ice.setCancelled(false);
      return;
    }

    this.openBuyInventory(clickedCategory, player, game);
  }