Solved Checking if the Crop is fully grown?

Discussion in 'Spigot Plugin Development' started by Distorts, Jun 24, 2016.

  1. Hello, for some reason my name, lore etc doesnt apply to this any ideas?
     
    #1 Distorts, Jun 24, 2016
    Last edited: Jun 24, 2016
  2. For the first "if" statement use "==" when comparing enums not ".equals()".
     
  3. Updated and still doesn't work.
     
  4. Can you post the new code?
     
  5. Here is the whole Event @AKZOMBIE74
    Code (Text):
        @EventHandler
        public void onBlockBreak(BlockBreakEvent e){
            ItemStack wheat = new ItemStack(Material.WHEAT, 1);
            ItemMeta wheatim = wheat.getItemMeta();
            ItemStack shrooms = new ItemStack(Material.RED_MUSHROOM, 1);
            ItemMeta shroomsim = shrooms.getItemMeta();
            ItemStack meth = new ItemStack(Material.NETHER_WARTS, 1);
            ItemMeta methim = shrooms.getItemMeta();
            ItemStack seeds = new ItemStack(Material.SEEDS, getRandom(1,6));
            String a = (ChatColor.GREEN + "Purity Level " + getRandom(1,5));
            wheatim.setDisplayName(ChatColor.GREEN + "Weed");
            wheatim.setLore(Arrays.asList(a));
            wheat.setItemMeta(wheatim);
            shroomsim.setDisplayName(ChatColor.RED + "Shrooms");
            shroomsim.setLore(Arrays.asList(a));
            shrooms.setItemMeta(shroomsim);
            methim.setDisplayName(ChatColor.BLUE + "Meth");
            methim.setLore(Arrays.asList(a));
            meth.setItemMeta(methim);
            Player p = e.getPlayer();
            Location b = e.getBlock().getLocation();
            if(e.getBlock().getType() == Material.CROPS){
                if(Material.CROPS.getData().equals(0x7)){
                    e.setCancelled(true);
                    e.getBlock().setType(Material.AIR);
                    p.getWorld().dropItemNaturally(b, wheat);
                    p.getWorld().dropItemNaturally(b, seeds);
                }

            }
            if(e.getBlock().getType().equals(Material.RED_MUSHROOM)){
                e.setCancelled(true);
                e.getBlock().setType(Material.AIR);
                p.getWorld().dropItemNaturally(b, shrooms);
            }
            if(e.getBlock().getType().equals(Material.NETHER_WARTS)){
                e.setCancelled(true);
                e.getBlock().setType(Material.AIR);
                p.getWorld().dropItemNaturally(b, meth);
            }
        }
     
  6. On this line "if(Material.CROPS.getData().equals(0x7))" replace "Material.CROPS" with "e.getBlock().getData()". Also is there a stacktrace?
     
  7. e.getBlock().getData() is deprecated when i try to do @AKZOMBIE74
    Code (Text):
    if(e.getBlock().getType() == Material.CROPS){
                if(e.getBlock().getData() == 0x7){
                    e.setCancelled(true);
                    e.getBlock().setType(Material.AIR);
                    p.getWorld().dropItemNaturally(b, wheat);
                    p.getWorld().dropItemNaturally(b, seeds);
                }

            }
     
  8. Even if it is deprecated it is still useable. Since I haven't worked much with blocks I don't know the alternative, so all I can tell you is to use the deprecated method.
     
  9. okay that works ! but u have any idea shapeless crafting?
    this for some reason doesnt work

    Code (Text):
        public void onEnable(){
            System.out.println("[Drugs] has been enabled. | Coded by Distorts");
            Events();
            String a = (ChatColor.GREEN + "Purity Level " + getRandom(1,5));
            ItemStack Coke = new ItemStack(Material.SUGAR);
            ItemMeta Cokeim = Coke.getItemMeta();
            Cokeim.setDisplayName(ChatColor.WHITE + "Cocaine");
            Cokeim.setLore(Arrays.asList(a));
            Coke.setItemMeta(Cokeim);
            ShapelessRecipe cocaine = new ShapelessRecipe(Coke);
            cocaine.addIngredient(1, Material.SUGAR_CANE);
            getServer().addRecipe(cocaine);
            if (!Bukkit.getPluginManager().isPluginEnabled("API")) {
                Bukkit.getPluginManager().disablePlugin(this);
            }
        }
     
  10. Make sure the plugin is not being disabled. Before the disable plugin code add a debug message saying the plugin is being disabled to check whether or not the plugin is being disabled. Your shapeless recipe should work.
     
  11. Its not being disabled i have no ideas what is going on tbh