Solved User specific boolean command

Discussion in 'Plugin Development' started by MYCRAFTisbest, Jun 1, 2013.

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

    MYCRAFTisbest

    Hello. I just could never seem to figure this one out.
    I am trying to make a command that will create a Boolean value that only applies to the person who entered the command. I want to do this so I can allow players to turn torches on and off by typing a command, allowing them to hold a torch without light.

    Code:
    @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
        public  void onPlayerMove(PlayerMoveEvent evt) {
            Location loc = evt.getPlayer().getLocation();
            World w = loc.getWorld();
            Player p = evt.getPlayer();
                   
                    //if (enabled(null)) return; {
                          if (p.hasPermission("RWtl.allow"))
                            {
                       
                    loc.setY(loc.getY() - 1);
                   
                   
                    //Added this bit in to make the torch still work while jumping or falling.
                    while (w.getBlockAt(loc).getType()==Material.AIR)
                    {
                        loc.setY(loc.getY() - 1);
                    }
                    while (w.getBlockAt(loc).getTypeId()== 8)
                    {
                        loc.setY(loc.getY() - 1);
                    }
                    while (w.getBlockAt(loc).getTypeId()== 9)
                    {
                        loc.setY(loc.getY() - 1);
                    }
                    while (w.getBlockAt(loc).getTypeId()== 10)
                    {
                        loc.setY(loc.getY() - 1);
                    }
                    while (w.getBlockAt(loc).getTypeId()== 11)
                    {
                        loc.setY(loc.getY() - 1);
                    }
                    while (w.getBlockAt(loc).getType()==Material.FENCE)
                    {
                        loc.setY(loc.getY() - 1);
                    }
                    while (w.getBlockAt(loc).getType()==Material.NETHER_FENCE)
                    {
                        loc.setY(loc.getY() - 1);
                    }
                    while (w.getBlockAt(loc).getType()==Material.BED)
                    {
                        loc.setY(loc.getY() - 1);
                    }
                    while (w.getBlockAt(loc).getType()==Material.LEVER)
                    {
                        loc.setY(loc.getY() - 1);
                    }
    ECT.
    Similarly to how the code only runs when the player has the permission, I want to allow the player to be able to start/stop the code using a command that only applies to the person who typed it (preferably /torch [or] /torch (on/off)).

    Thanks for the help.
     
  2. Offline

    GodzOfMadness

    MYCRAFTisbest Create an ArrayList<String> and if they are not in it then add them and enable, else remove them and disable.
     
  3. Offline

    minecraft124_

    Or use a HashMap<String,Boolean>
     
  4. Offline

    MYCRAFTisbest

    Thanks. Why didn't I think of that? :p

    Already set up ArrayList, but thanks for helping anyway.
     
Thread Status:
Not open for further replies.

Share This Page