Solved Cropstate help

Discussion in 'Plugin Development' started by Kassestral, Jun 5, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Kassestral

    How can I make it so the Material.Crop will only spring on a fully grown wheat.
    Code:java
    1. package com.kassestral.plugins.ilevel.skills;
    2.  
    3. import org.bukkit.Material;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.block.BlockBreakEvent;
    8.  
    9. import com.kassestral.plugins.ilevel.Main;
    10. import com.kassestral.plugins.ilevel.Processor;
    11.  
    12. public class Farming implements Listener{
    13.  
    14. private static Main plugin;
    15. public Farming(Main Plugin){
    16. Farming.plugin = Plugin;
    17. }
    18.  
    19. @EventHandler
    20. public void onCropCollect(BlockBreakEvent e){
    21.  
    22. Material block = e.getBlock().getType();
    23. Player p = e.getPlayer();
    24. String level = "Farming";
    25.  
    26. if(block.equals(Material.CROPS)){
    27. Processor.addXP(p, level, plugin.getConfig().getInt("Farming.wheat"));
    28. }
    29. if(block.equals(Material.MELON_BLOCK)){
    30. Processor.addXP(p, level, plugin.getConfig().getInt("Farming.melon"));
    31. }
    32. if(block.equals(Material.SUGAR_CANE_BLOCK)){
    33. Processor.addXP(p, level, plugin.getConfig().getInt("Farming.sugar_cane"));
    34. }
    35. if(block.equals(Material.PUMPKIN)){
    36. Processor.addXP(p, level, plugin.getConfig().getInt("Farming.pumpkin"));
    37. }
    38. }
    39. }
     
  2. Offline

    Arkel

  3. Offline

    fireblast709

  4. Offline

    Kassestral

    Arkel
    But how can I get if the crop is made from carrots, potatoes or wheat?

    fireblast709 I still don't understand how I get what the type of crop is, I got the state of fully grown, but no understanding of how to define it as either carrot, potato, wheat

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 30, 2016
  5. Offline

    fireblast709

  6. Offline

    Kassestral

    fireblast709
    oh lol, so what is carrots/potatoes?
     
  7. Offline

    fireblast709

    Kassestral Material.CARROT and Material.POTATO as it seems
     
    NathanWolf likes this.
  8. Offline

    NathanWolf

  9. Offline

    Kassestral

    fireblast709
    Hey thanks figured it out! thanks
     
Thread Status:
Not open for further replies.

Share This Page