Solved Help with hashmap

Discussion in 'Spigot Plugin Development' started by Nosmakos, May 13, 2016.

  1. i have a problem with my scheduler with potions for example if i got infected it adds player uuid and after 5 seconds it does infection to the player but if i leave before the infection work and log in if 5 seconds past i don't get the effects but im still in the uuid btw. I think it wont work because when i log out the hit thing is removed so It doesn't know if the entity got hit. I have to save both entities and check them but im not sure how i think its hashmap but i never used hashmap before any ideas how to do that?

    Code (Text):
        public void onDeath(PlayerDeathEvent e) {
            Player player = e.getEntity();
        public void onZombieHitPlayer(final EntityDamageByEntityEvent e) {
            if (((e.getDamager() instanceof Zombie)) && ((e.getEntity() instanceof Player))) {
                Player player = (Player) e.getEntity();
                if (!this.effects.contains(player.getPlayer().getUniqueId())){
                    final int wither = this.getConfig().getInt("ZombieHitEffects.InfectionEffect");
                    final int nausea = this.getConfig().getInt("ZombieHitEffects.NauseaEffect");
                    final int blindness = this.getConfig().getInt("ZombieHitEffects.BlindnessEffect");
                    final int slowness = this.getConfig().getInt("ZombieHitEffects.SlownessEffect");
                    final int weakness = this.getConfig().getInt("ZombieHitEffects.WeaknessEffect");
                    e.getEntity().sendMessage(ChatColor.RED + "You just got bited! You have to find a cure before you die by infection. Use the cure when you get infected!");
                    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
                        public void run(){
                                ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, wither, 1));
                                ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, slowness, 1));
                                ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, nausea, 5));
                                ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindness, 1));
                                ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, weakness, 1));
                    }, 100L);
  2. I think that you could just register an join event and check if player is on the list..
  3. DO you even know what he is trying to do?
    • Like Like x 1
    • Agree Agree x 1
  4. not working as i said scheduler and arraylist is working is just not checking if player got hitted by the entity when he left because it has a task for a few seconds and if i get hit after those seconds i take effects and if i leave before i get the effects and join the seconds not working with the effects
  5. //SOLVED!
    I didnt need a hashmap and i don't that was necessary so i just added an event with playerjoinevent and i checked if player was on the list to add the effects and make a scheduler for the seconds to be happend.