Solved The left-hand side of the assignment must be a variable (Error)

Discussion in 'Plugin Development' started by 123ang, Jul 12, 2014.

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

    123ang

    I have written this code but it's giving me a error saying "The left-hand side of the assignment must be a variable."

    Here is my code:

    Code:java
    1. @EventHandler
    2. public void onInventoryClick(InventoryClickEvent e) {
    3. Player player = (Player) e.getWhoClicked();
    4. if (!e.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
    5. if (e.getCurrentItem().getItemMeta() == null) return;
    6. if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Stick Recipe")) {
    7. e.setCancelled(true);
    8. if (e.getWhoClicked().getInventory().contains(Material.GOLD_NUGGET)){
    9. e.getWhoClicked().getInventory().remove(new ItemStack(Material.GOLD_NUGGET, 1));
    10. } else (player.sendMessage("no");
    11.  
    12. }
    13. e.getWhoClicked().closeInventory();
    14. }


    The line that gets the error is this line:

    Code:java
    1. } else (player.sendMessage("no");


    Please help!
     
  2. Offline

    Dealyise

    123ang
    Your Code
    Code:java
    1. } else (player.sendMessage("no");


    My fix:
    Code:java
    1. } else {player.sendMessage("no");


    :)
     
    123ang likes this.
  3. Offline

    ZodiacTheories

    Dealyise 123ang

    Correct me if I am wrong, but you could do this:

    Code:java
    1. } else player.sendMessage("no");
     
    Dealyise likes this.
  4. Offline

    123ang

    Dealyise thanks for the fast response, worked perfectly!
     
    Dealyise likes this.
  5. Offline

    Dealyise


    ZodiacTheories You could do that, yes, but with brackets it's easier to read (my opinion).
     
  6. Offline

    ZodiacTheories

    123ang

    *Cough, cough* :p

    Only joking
     
  7. Offline

    123ang

    ZodiacTheories likes this.
  8. Offline

    ZodiacTheories

    Dealyise

    Well we all have different opinions :p
     
Thread Status:
Not open for further replies.

Share This Page