void is an invalid type for the variable onBlockBreak

Discussion in 'Plugin Development' started by dackmaster24, Apr 18, 2015.

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

    dackmaster24

    Code:
    package me.dackmasterYT.GalacticPlugin.main;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.inventory.ItemStack;
    
        public class InventoryFull {
        public InventoryFull (Player player){
        player.sendMessage(ChatColor.DARK_RED + " Warning, Inventory Full!");
      
        @EventHandler
        public void onBlockBreak(BlockBreakEvent event){
            if (event.getPlayer().getInventory().firstEmpty() != -1){
                for(ItemStack item : event.getBlock().getDrops()){
                    event.getPlayer().getInventory().addItem(item);
                }
      
            } else {
                for(ItemStack item : event.getBlock().getDrops()){
                    for (int i=0; i<35; i++) {
                        if (event.getPlayer().getInventory().getItem(i).getAmount()+item.getAmount()<=64) {
                            if (event.getPlayer().getInventory().getItem(i).getType().equals(item.getType())) {
                          
                                event.getPlayer().getInventory().addItem(item);
                                break;
                            }
                        }
                        if (i==34) {
                            event.getPlayer().sendMessage(ChatColor.RED + "Your inventory is full.");
                        }
                    }
                }
            }
    
            event.setCancelled(true);
            event.getBlock().setType(Material.AIR);
        }
    
        }
    
    
    }
    
     
    Last edited: Apr 18, 2015
  2. Invisible

    nverdier

    @dackmaster24 Please put your code in [ code] [ /code] tags, and put your entire log in a pastebin.
     

  3. Your error is, that youre missing a } after the constructor
     
    Last edited: Apr 18, 2015
  4. Offline

    JUSTCAMH

    @FisheyLP Ok, so what is it that happens, what do you want to happen etc. When your asking about these things you need to say what happens, what you want to happen etc.

    EDIT
    Wow. That was repetitive
     
  5. Offline

    mine-care

    Please follow java naming conventions :- )
     
  6. Offline

    S7W

    You forgot to close the 'InventoryFull' void
    Code:
        public InventoryFull (Player player){
        player.sendMessage(ChatColor.DARK_RED + " Warning, Inventory Full!");
    It should be
    Code:
        public InventoryFull (Player player){
        player.sendMessage(ChatColor.DARK_RED + " Warning, Inventory Full!");
    }
    Maybe its private code?
     
  7. Offline

    mine-care

    @S7W Still you have to be "good" coder/programmer no matter the case :p
    Not following java rules in your own projects will not help you remember them for public ones.
     
    ChipDev likes this.
  8. Offline

    RainoBoy97

    You cannot create methods inside a constructor.
     
    ChipDev likes this.
Thread Status:
Not open for further replies.

Share This Page