Solved FIXED MAY DELETE

Discussion in 'Plugin Development' started by Zyu, Oct 5, 2015.

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

    Zyu

    Okay thing is i don't know how to disable pvp i know i need make a onDamageEvent but I'm not sure how to integrate it or make it where others can't attack disguised players too.


    CODE:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
            if (cmd.getName().equalsIgnoreCase("creeper")) {
                if (sender.hasPermission("vip.use")) {
                    final Player player = (Player)sender;
                    final Entity en = (Entity) sender;
                    Disguise creeper = new MobDisguise(DisguiseType.CREEPER, false);
                    DisguiseAPI.disguiseToAll(en, creeper);
                    FlagWatcher flagwatcher = creeper.getWatcher();
                    flagwatcher.setCustomName(player.getDisplayName());
                    flagwatcher.setCustomNameVisible(true);
                    sender.sendMessage(ChatColor.GOLD + "You have been disguised as a creeper for 5 minutes!");
                    Bukkit.getScheduler().runTaskLater((plugin), new Runnable(){public void run() {
                            DisguiseAPI.undisguiseToAll((Entity) en);
                        }
                       
                    }, 200);
                    return true;
                }
                else {
     
    Last edited: Oct 5, 2015
  2. Offline

    mcdorli

    @Zyu
    You just need to set up a listener for ondamageEvent and player interact event( if you want tk make it double-sided), and check if the player is disguises, if yes, set do event.setCancelled(true), and done? So, in what do you need more help?
     
  3. Offline

    Zyu

    i know that but how can i integrate it to just the disguised players. Im using lib disguises FYI
     
  4. Offline

    mcdorli

    Isn't there "setdiguised()" method in the player class...*runs trough javadoc*...oh yes..why not use player.hidePlayer(), player.showPlayer(), player.canSee()?
     
  5. Offline

    Zyu

    Code:
    public class AntiPVP implements Listener {
       
        private HashMap<UUID, Integer> incombat = new HashMap<UUID, Integer>();
       
        @EventHandler
        public void setinCombat(Player p) {
            if ((DisguiseAPI.isDisguised(p))) {
                DisguiseAPI.undisguiseToAll(p);
            }
        }
       
        @EventHandler
        public void ondisguise(UndisguiseEvent e) {
            if ((this.incombat.containsKey(((Player) e).getPlayer().getUniqueId())))
                e.setCancelled(true);
        }
    
       
    }
    
    This doesn't work, i might be skipping out on something
     
  6. Offline

    mcdorli

    What was the problem?
     
  7. Online

    timtower Administrator Administrator Moderator

    @Zyu No need to edit your posts. Just say that you solved it with your solution.
     
  8. Offline

    Binner_Done

    The moderators wont delete this post because others MAY be experiencing the same problem so rather than going through everything to solve it they can just be pointed to this thread (Or others(
     
Thread Status:
Not open for further replies.

Share This Page