Getting DeathDrops and Changing Their ID's

Discussion in 'Spigot Plugin Development' started by fujiboy4, Jun 4, 2015.

Thread Status:
Not open for further replies.
  1. Hello, this is sort of a complicated question. But here we go, I want this to work somewhat like mineplex's death, where the items explode out of the player when they die. And instead of red_dye I would like to use Redstone_Blocks. (To prevent stacking with ID's) And then the items would disappear afterward.


    Thanks
     
  2. and your issue is?
     
  3. How to make it... :p

    If you are wondering why I've been asking a whole bunch of questions it's because I'm making a HUGE minigame.
     
  4. Code (Text):

    @EventHandler
        public void onDeath(PlayerDeathEvent e) {
            final Player p = e.getEntity();

            e.getDrops().set(10, new ItemStack(Material.REDSTONE_BLOCK));
            respawn(p);

        }
    Respawn Method
    Code (Text):

    private void respawn(Player p) {
            p.getWorld().strikeLightningEffect(p.getLocation());
            reset(p);
            p.setHealth(20);
            p.setFoodLevel(20);
            p.setGameMode(GameMode.SPECTATOR);
            p.sendMessage("§cSSM> You have died.  You will respawn in 10 seconds...");

            Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {

                @Override
                public void run() {

                    p.sendMessage("§aSSM> You have respawned.  Go get em! ;)");
                    p.playSound(p.getLocation(), Sound.IRONGOLEM_HIT, 10, 2);
                    p.setGameMode(GameMode.ADVENTURE);
                    if (spider.hasPlayer(p)) {
                        spider.respawn(p);
                    }
                    if (skeleton.hasPlayer(p)) {
                        skeleton.respawn(p);
                    }
                    if (creeper.hasPlayer(p)) {
                        creeper.respawn(p);
                    }

                }
            }, 200L);
        }
     
    Reset Method
    Code (Text):
    private void reset(Player p) {
            p.getInventory().clear();
            p.getInventory().setHelmet(null);
            p.getInventory().setBoots(null);
            p.getInventory().setChestplate(null);
            p.getInventory().setLeggings(null);
            p.removePotionEffect(PotionEffectType.SPEED);
            p.removePotionEffect(PotionEffectType.SLOW);
            p.removePotionEffect(PotionEffectType.FAST_DIGGING);
            p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
            p.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
            p.removePotionEffect(PotionEffectType.HEAL);
            p.removePotionEffect(PotionEffectType.HARM);
            p.removePotionEffect(PotionEffectType.JUMP);
            p.removePotionEffect(PotionEffectType.CONFUSION);
            p.removePotionEffect(PotionEffectType.REGENERATION);
            p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
            p.removePotionEffect(PotionEffectType.FIRE_RESISTANCE);
            p.removePotionEffect(PotionEffectType.WATER_BREATHING);
            p.removePotionEffect(PotionEffectType.INVISIBILITY);
            p.removePotionEffect(PotionEffectType.BLINDNESS);
            p.removePotionEffect(PotionEffectType.NIGHT_VISION);
            p.removePotionEffect(PotionEffectType.HUNGER);
            p.removePotionEffect(PotionEffectType.WEAKNESS);
            p.removePotionEffect(PotionEffectType.POISON);
            p.removePotionEffect(PotionEffectType.WITHER);
            p.removePotionEffect(PotionEffectType.SATURATION);
            p.removePotionEffect(PotionEffectType.HEALTH_BOOST);
        }
     
  5. use: players.getActivePotionEffects().clear(); instead
     
  6. Nope, don't do that! :)

    getActivePotionEffects just returns a new List, clearing it will do nothing. You can however iterate over that list and remove each potion effect individually for some cleaner and slightly more efficient code.

    EDIT: That said, OP- what part of this isn't working how you'd like? I don't see a specific question...
     
  7. Um.. clearing the potion effects isn't really my problem.....
     
  8. Spawning 10 blocks will do nothing. Try making a for loop that will drop a new block with a different name like nopick1 and nopickup2 etc that should stop then from stacking. Then on the pickup method check it the name contains nopickup etc.
     
  9. Sorry it was not really explained or good made. U can loop through active potion effects and remove them.
     
  10. Use:
    for(PotionEffect effect: player.getActivePotionEffects())
    player.removePotionEffect(effect); this will just remove all potion effects that are active
     
    • Useful Useful x 1
  11. Playerdeathevent >GetDrops.Clear them > Spawn the new drops > Happy Face
     
    • Like Like x 1
  12. I know how to spawn the items... But I'm pretty sure they only drop from the players direction... How would I make it so it would go all around the player?
     
    • Useful Useful x 1
  13. Use a random and add and minus the number to the location?
     
    • Useful Useful x 1
  14. OK this is some of my code.

    Code (Text):
    final Item grenade = world.dropItemNaturally(p.getLocation(),
                                new ItemStack(Material.REDSTONE_BLOCK));
    But .... it would allow me to do this:

    Code (Text):
    final Item grenade = world.dropItemNaturally(p.getLocation().getX() + 1,
                                new ItemStack(Material.REDSTONE_BLOCK));
     
  15. Where you trying to go with this?
     
  16. I actually figured it out. Thanks for helping! :)
     
Thread Status:
Not open for further replies.