How to put a player in vanish

Discussion in 'Plugin Help/Development/Requests' started by Glenjendary, Sep 20, 2016.

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

    Glenjendary

    Hey, I was wondering how to put a player in vanish. I have Bukkit.jar and essentials.jar in my referenced libraries but no clue where to find .setVanish (if thats even a thing) please help.
     
  2. @Glenjendary
    If you're using the essentials API you can just do "user.setVanished()".
     
  3. Offline

    Glenjendary

    When I set it to User.setVanished(true); it comes up in Eclipse with the error : Cannot make a static reference to the non-static method setVanished(boolean) from the type User
     
    Last edited: Sep 21, 2016
  4. Offline

    timtower Administrator Administrator Moderator

    @Glenjendary Because you need to get the Essentials version of the player first.
     
  5. Offline

    Glenjendary

    @timtower

    What do you mean, please elaborate.
     
  6. Offline

    timtower Administrator Administrator Moderator

  7. @Glenjendary
    You need to do it on a user object, not as a static method. You can get an Essentials User object by using "Essentials.getUser()".
     
  8. Offline

    Glenjendary

    Here is my code
    Code:
    package com.glen.msstaff.commands;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    import com.earth2me.essentials.User;
    
    
    
    public class Smode implements CommandExecutor {
    
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
                String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage("Fuck off you console user!");
                return false;
            }
               
            Player player = (Player) sender; //Makes the player the sender
            Location l = new Location(player.getWorld(), 0, 1, 0); //Sets location to teleport to
           
            User.setVanished(true);
            player.sendMessage(ChatColor.GREEN + "You have entered Staff Mode!"); //Sends player a message
            player.teleport(l); //Teleports player
           
       
           
            return true;
        }
    }
    
     
  9. Offline

    timtower Administrator Administrator Moderator

    @Glenjendary And what is User in this case? Not the player at least.
    It isn't a player from Essentials.
    Get an instance of the User object.
     
  10. Offline

    Glenjendary

    So I do :

    User p = new Essentials.getUser();
    p.setVanished(true);

    ?
     
  11. Offline

    timtower Administrator Administrator Moderator

    @Glenjendary I don't think that that would get a user when it doesn't have parameters.
     
  12. Offline

    Glenjendary

    Everything I try fails :/ I'm really stuck here, any more hints you can give out?
     
  13. Offline

    Glenjendary

    @bwfcwalshy I should have said, I already tried that after @timtower told me to add a parameter, it gave me these errors in Eclipse :

    1. Essentials.getUser cannot be resolved to a type.
    2. Player cannot be resolved to a variable.

    The code I used being :
    Code:
    package com.glen.msstaff.commands;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    import com.earth2me.essentials.User;
    
    
    
    
    
    
    public class Smode implements CommandExecutor {
    
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
                String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage("Fuck off you console user!");
                return false;
            }
              
          
            User p = new Essentials.getUser(Player);
            Player player = (Player) sender; //Makes the player the sender
            Location l = new Location(player.getWorld(), 0, 1, 0); //Sets location to teleport to
          
            p.setVanished(true);
            player.sendMessage(ChatColor.GREEN + "You have entered Staff Mode!"); //Sends player a message
            player.teleport(l); //Teleports player
          
      
          
            return true;
        }
    }
    
     
  14. @Glenjendary
    You need to pass in the Player Object as a parameter.
     
  15. @Glenjendary Please learn Java. Remove the new from the Essentials.getUser line. You didn't pass the Player object. That location is going to go to X: 0 Y: 1 Z: 0 You know that right?
     
Thread Status:
Not open for further replies.

Share This Page