PlayerMoveEvent for kits

Discussion in 'Plugin Development' started by Fhbgsdhkfbl, Apr 23, 2014.

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

    Fhbgsdhkfbl

    Hey bukkit forums, Im trying to figure this out, if a player doesn't have either of these two kits (shark and poseidon), it stills gives the potion effects when in water
    if you can help me, I'd appreciate it!
    Events:
    Code:
    @EventHandler
        public void onPlayerShark(PlayerMoveEvent e) {
            Player p = e.getPlayer();
            Material mat = e.getPlayer().getLocation().getBlock().getType();
            if (mat == Material.WATER || mat == Material.STATIONARY_WATER) {
                if (shark.contains(p.getName())) {
                    p.addPotionEffect(new PotionEffect(
                            PotionEffectType.INCREASE_DAMAGE, 200, 0, true));
                    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200,
                            0, true));
                    p.addPotionEffect(new PotionEffect(
                            PotionEffectType.DAMAGE_RESISTANCE, 200, 0, true));
                }
                if (mat != Material.WATER || mat != Material.STATIONARY_WATER) {
                }
    
            }
        }
        @EventHandler
        public void onPlayerPoseidon(PlayerMoveEvent e) {
            Player p = e.getPlayer();
            Material mat = e.getPlayer().getLocation().getBlock().getType();
            if (mat == Material.WATER || mat == Material.STATIONARY_WATER) {
                if (poseidon.contains(p.getName())) {
                    p.addPotionEffect(new PotionEffect(
                            PotionEffectType.INCREASE_DAMAGE, 200, 0, true));
                    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200,
                            0, true));
                    p.addPotionEffect(new PotionEffect(
                            PotionEffectType.DAMAGE_RESISTANCE, 200, 0, true));
                }
                if (mat != Material.WATER || mat != Material.STATIONARY_WATER) {
                }
    
            }
        }
     
  2. Offline

    raGan.

    Quite simple, these 2
    Code:
    shark.contains(p.getName())
    poseidon.contains(p.getName())
    are returning true. You need to figure out why that happens. unfortunately it can't be figured out from the code you provided.

    By the way, have you considered merging these methods into single one? There's a lot of duplicate code.
    Code:
    if(shark.contains(p.getName()) || poseidon.contains(p.getName())) {...
     
  3. Offline

    Quackster

    A tip in future is to use player.getUniqueId().toString(); instead of player.getName(); as there is a new UUID format for Minecraft 1.9 which will give users the ability to change their names but their unique id will always stay the same.
     
Thread Status:
Not open for further replies.

Share This Page