Setting a boolen to true and false

Discussion in 'Plugin Development' started by wydgabriel, Jan 20, 2014.

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

    wydgabriel

    Well, at start of my plugin , I declared a boolean:

    boolean podetp = false;

    1 thing = podetp is always true;

    How can i change it to false?
    I tried to put:
    podetp = false;
    podetp = true
    trought commands but it dont works.
    Can someone help me?
     
  2. Offline

    Rocoty

    Show...your...code...please
     
  3. Offline

    wydgabriel

    Code:
      if (commandLabel.equalsIgnoreCase("gladiador")) {
          if (podetp = false) {
            Player p = (Player)sender;
            Location eua = Bukkit.getWorld("fullpvp").getSpawnLocation();
            p.teleport(eua);
      } else {
                Player p = (Player)sender;
                p.sendMessage("nao");
             
          }
         
      }
        if (commandLabel.equalsIgnoreCase("podetp")) {
          this.podetp = true;
        }
        if (commandLabel.equalsIgnoreCase("notp")) {
          this.podetp = false;
        }
    In this code, when i try to teleport, it always send me ''nao'' , even if i type ''/notp'' , actually to make podetp = false
     
  4. Offline

    Rocoty

    is this in the main class or a separate command executor? Do you instantiate this class more than once? Can you show the entire main class?
     
  5. Offline

    wydgabriel

    Code:
    public class Medieval extends JavaPlugin
      implements Listener
    {
      public Plugin plugin;
      public Random rand = new Random();
      private HashMap<String, List<ItemStack>> armadura = new HashMap();
        protected static Giant Giant;
    protected static Zombie gi;
    boolean podetp = false;
     
      public void onDisable()
    and then the codes.
    The boolean is there
     
  6. Offline

    Rocoty

    Ah...common mistake...boolean evaluation in if-statements should be done with ==, not =. With = you are assigning it to false.
     
  7. Offline

    wydgabriel

    So , I put boolean podetp == true ?
    Because its giving me error...
    Damn i'm so freaking noob at coding

    GOT IT, GOT IT.
    ITS WORKING PERFECTLY.
    THANKS FOR THE HELP MAN :D

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

    HyrulesLegend

Thread Status:
Not open for further replies.

Share This Page