Vanish plugin

Discussion in 'Plugin Development' started by thekillamon, Dec 10, 2014.

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

    thekillamon

    Hey guys I am trying to make a Vanish plugin and how I want it is so that the person in vanish can't pick up any blocks and can't get in the way of anyone. So for example if someone is digging in a hole and the person in vanish goes down there the player will still be able to dig in a 1x1 hole. so it's like your entity would be taken away
     
  2. Offline

    SuperOriginal

    Player#hidePlayer(player) and PlayerPickupItemEvent
     
  3. Offline

    thekillamon

    ah thanks will that also help with making it so that they can't be interacted with at all?
    sorry I'm just not the best with Java
     
  4. Offline

    BrentHogeling

    @thekillamon You just do the listeners, cancel them out, then add a vanish potion effect, default minecraft stops player and mob interaction so it won't be a problem
     
  5. Offline

    iReD_xBlaDeZ

    @thekillamon maybe add them to something like an arraylist when they do the command and for the events (BlockPlaceEvent, BlockBreakEvent, EntityDamageByEntityEvent, etc..) just check if theyre in the arraylist and cancel the event if they are in the arraylist.
    Code:
    //Example
    
    //boolean here
    if(label.equalsIgnoreCase("vanish")) {
                if(sender instanceof Player) {
                    Player p = (Player) sender;
                    if(vanish.contains(p.getName())) {
                        vanish.add(p.getName());
                    } else {
                        //remove arraylist...
                    }
                }
            }
    And for the events it would go something like this:
    Code:
    @EventHandler
        public void onBlockPlaceDeny(BlockPlaceEvent e) {
            if(e.getPlayer() instanceof Player) {
                Player p = e.getPlayer();
                if(vanish.contains(p.getName())) {
                    //cancel event
                }
            }
        }
     
  6. Offline

    Tommy Raids

    Yeah, just create your own vanish command. I would recommend using an arraylist to store the player in, and use listeners to check if he's in it to cancel an event. For example, let's say you want to cancel not being able to drop blocks while vanished. If your arraylist was called "vanished" or something, then you would do this.

    Code:
    @EventHandler
    public void noDrop(PlayerDropItemEvent e){
    Player p = e.getPlayer();
    //check perms here:
    if(this.vanished.contains(p.getName()){
    if(p.getGameMode() == GameMode.CREATIVE){
        e.setCancelled(true);
      //sending a message is optional.
       p.sendMessage(ChatColor.RED + "No Dropping Blocks while vanished.");
    }else{
    //if p's not vanished or not in gamemode, it will not cancel the event allowing players to drop blocks. You could also just insert a permission up there stating that if he had a certain perm, he could/couldn't drop blocks. (p.hasPermission("perm.perm");
      e.setCancelled(false);
    }
    }
    
    }
     
  7. Offline

    SuperOriginal

    Since when did this thread turn into spoonfeeder central?

    @iReD_xBlaDeZ Why are you checking if e.getPlayer() is a player? Think about it.


    @Tommy Raids The OP never mentioned anything about gamemodes.. And why are you setting an event cancel to false??

    @BrentHogeling why add a potion effect.. hidePlayer() does everything he needs, without pesky particles and entity blocking
     
  8. Offline

    Tommy Raids

    Because I'm a nublet. But I'm just trying to help, I used to be like this. I wasn't exactly spoonfeeding anyone. I just explained an example.
     
  9. Offline

    SuperOriginal

    @Tommy Raids I'm not telling you wrong for helping, but could you tell me the difference between spoonfeeding and your post?
     
  10. Offline

    Tommy Raids

    If I was directly spoonfeeding him, I would've gave him the vanish command.
     
  11. Offline

    SuperOriginal

  12. Offline

    BrentHogeling

    @SuperOriginal 1. I forgot about that method 2. Just because it naturally cancels out mob interaction so I just thought that would be best
     
  13. Offline

    iReD_xBlaDeZ

    I just do it because just that I know there wont be any errors. even though theyre probably wont be any, Thats just my way of reassuring myself :p @SuperOriginal
     
  14. Offline

    mythbusterma

    @iReD_xBlaDeZ

    There 100% certainly will not be an error in any case.
     
    SuperOriginal likes this.
Thread Status:
Not open for further replies.

Share This Page