Beispiel #1
0
 @EventHandler
 public void onDeath(PlayerDeathEvent event) {
   if (isFilly(event.getEntity())) {
     ArrayList<ItemStack> removeMe = new ArrayList<ItemStack>();
     for (ItemStack is : event.getDrops()) {
       if (is.getType() == Material.WRITTEN_BOOK) {
         BookMeta bm = (BookMeta) is.getItemMeta();
         if ((bm.hasAuthor() && bm.getAuthor().equals("TheQueenOfPink"))
             && (bm.hasTitle() && bm.getTitle().equals("MineLittlePony.se Handbook"))) {
           removeMe.add(is);
         }
       }
     }
     event.getDrops().removeAll(removeMe);
   }
 }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerKilled(PlayerDeathEvent event) {
   // players don't drop leather armor or iron swords on death
   List<ItemStack> drops = event.getDrops();
   for (int i = 0; i < drops.size(); i++)
     if (!isAllowedToDrop(drops.get(i).getType())) drops.remove(i--);
 }
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent e) {
   Iterator<ItemStack> it = e.getDrops().iterator();
   while (it.hasNext()) {
     if (isSoulbound(it.next())) it.remove();
   }
 }
  public static PlayerDeathEvent callPlayerDeathEvent(
      EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) {
    BukkitPlayer entity = (BukkitPlayer) getBukkitEntity(victim);
    PlayerDeathEvent event =
        new PlayerDeathEvent(entity, drops, victim.experienceValue, 0, deathMessage);
    org.bukkit.World world = entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    /*victim.keepLevel = event.getKeepLevel();
    victim.newLevel = event.getNewLevel();
    victim.newTotalExp = event.getNewTotalExp();
    victim.expToDrop = event.getDroppedExp();
    victim.newExp = event.getNewExp();*/

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
      if (stack == null || stack.getType() == Material.AIR) continue;

      if (stack instanceof BukkitItemStack) {
        // Use the internal item to preserve possible data.
        victim.dropItemWithOffset(stack.getTypeId(), stack.getAmount(), 0.0F);
      } else {
        world.dropItemNaturally(entity.getLocation(), stack);
      }
    }

    return event;
  }
 @EventHandler(priority = EventPriority.MONITOR)
 public void onDeathEvent(PlayerDeathEvent event) {
   Player player = event.getEntity();
   if (!plugin.isSkyWorld(player.getWorld())) {
     return;
   }
   if (!visitorsCanDrop && !plugin.playerIsOnIsland(player) && !plugin.playerIsInSpawn(player)) {
     event.getDrops().clear();
     plugin.notifyPlayer(player, "\u00a7eVisitors can't drop items!");
     return;
   }
   // Take over the drop, since Bukkit don't do this in a Metadatable format.
   for (ItemStack stack : event.getDrops()) {
     addDropInfo(player, stack);
   }
 }
  @EventHandler(priority = EventPriority.LOWEST)
  public void onPlayerDeath(PlayerDeathEvent event) {
    EntityDamageEvent ede = event.getEntity().getLastDamageCause();

    if ((ede != null) && (ede.getCause() != null) && (ede.getCause() == DamageCause.LAVA)) {
      Player player = event.getEntity();
      Location loc = player.getLocation();
      LavaTrain lT = LavaTrain.getLavaTrain(loc.getBlock());
      if (lT != null) {
        event.setDeathMessage(
            player.getName() + " died swimming in " + lT.getPlayer().getName() + "'s lava train");
      }
    }

    if (ede instanceof BendingDamageEvent) {
      Player player = event.getEntity();
      BendingDamageEvent bede = (BendingDamageEvent) ede;
      if (bede.getAbility() == null) {
        event.setDeathMessage(player.getName() + " died from unknown bending");
      } else {
        event.setDeathMessage(
            ChatColor.DARK_RED
                + player.getName()
                + ChatColor.RESET
                + " died from "
                + ChatColor.DARK_GREEN
                + bede.getAbility().getPlayer().getName()
                + ChatColor.RESET
                + "'s "
                + PluginTools.getColor(Settings.getColor(bede.getAbility().getElement()))
                + bede.getAbility().getName());
      }
    }

    // Fireblade & Suffocate
    List<ItemStack> toRemove = new LinkedList<ItemStack>();
    for (ItemStack item : event.getDrops()) {
      if (Suffocate.isTempHelmet(item)) {
        toRemove.add(item);
      }
    }
    event.getDrops().removeAll(toRemove);

    if (EntityTools.isGrabed(event.getEntity())) {
      EntityTools.unGrab(event.getEntity());
    }
  }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerDied(final PlayerDeathEvent event) {
   // Check if there's a game in progress
   if (GameSetupHandler.isGameInProgress()) {
     // Create a new player death event and call it via the handler
     GamePlayerDeathEvent playerDeathEvent = new GamePlayerDeathEvent(event);
     CustomEventHandler.handleGamePlayerDeathEvent(playerDeathEvent);
   }
   event.getDrops().clear();
 }
Beispiel #8
0
  @EventHandler
  public void onDeath(PlayerDeathEvent e) {
    Player p = (Player) e.getEntity();

    if (adminMode.contains(p.getName())) {
      adminMode.remove(p.getName());
      respawn.add(p.getName());
      e.getDrops().clear();
    }
  }
Beispiel #9
0
 @EventHandler
 public void onDeath(PlayerDeathEvent e) throws IOException {
   Player p = e.getEntity();
   if (p.hasPermission("kits.deathinv")) {
     InventoryNBTSer.setInv(p, plugin.folder);
     e.getDrops().clear();
   }
   if (p.hasPermission("kits.deathexp")) {
     e.setDroppedExp(0);
   }
 }
Beispiel #10
0
  @EventHandler
  public void onPlayerDeath(PlayerDeathEvent event) {
    if (plugin.isBattleNight(event.getEntity())) return;

    boolean filledDeathChest = false;
    boolean filledSpawnChest = false;

    int originalDrops = event.getDrops().size();

    if (event.getDrops().isEmpty() && event.getDroppedExp() == 0) return;
    Player player = (Player) event.getEntity();

    int exp = player.getTotalExperience();

    LinkedList<ItemStack> toRemove = saveToDeathChest(player);
    filledDeathChest = !toRemove.isEmpty();

    if (exp != player.getTotalExperience()) {
      event.setDroppedExp(0);
    }

    for (ItemStack item : toRemove) event.getDrops().remove(item);

    if (event.getDrops().isEmpty()
        && (event.getDroppedExp() == 0 || plugin.getConfigManager().getEXPMulti() == 0)) return;

    if (!event.getDrops().isEmpty() || player.getTotalExperience() != 0) {
      toRemove = plugin.interactSpawnContainerController().createSpawnContainer(player);

      if (plugin.getConfigManager().getSpawnContainerUsage().equals(SpawnSign.class)
          && player.getTotalExperience() != exp) event.setDroppedExp(0);

      if (toRemove != null) {
        filledSpawnChest = !toRemove.isEmpty();

        for (ItemStack item : toRemove) event.getDrops().remove(item);
      }
    }

    if (event.getDrops().size() > 0 && filledDeathChest) {
      int maxTransfer = plugin.getChestContainer().getMaxTransferLimit(player);
      if (originalDrops > maxTransfer)
        player.sendMessage(
            ChatColor.RED
                + "Only "
                + maxTransfer
                + " items could be transfered. The rest is dropped at your death location.");
      else
        player.sendMessage(
            ChatColor.RED
                + "Your total inventory did not fit in the box. The rest items were dropped at your death location.");
    }

    if (!filledDeathChest && !filledSpawnChest && simplePermissionUse(player))
      player.sendMessage(ChatColor.RED + "You don't have a Chest set yet. Sorry for you. :(");
  }
Beispiel #11
0
  @EventHandler
  public void onPlayerDeath(PlayerDeathEvent e) {
    if (e.getDeathMessage() == null) {
      return;
    } else if (e.getDeathMessage().endsWith(" died")) {
      e.setDeathMessage(null);
    }

    if (Arcade.getMatches().getStatus() != ArcadeMatchStatus.RUNNING) {
      e.getDrops().clear();
    }
  }
 // <Index = 3>
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent event) {
   Player att = event.getEntity().getKiller();
   String pName = event.getEntity().getName();
   if (att instanceof Player && att.getEntityId() != event.getEntity().getEntityId()) {
     String aName = att.getName();
     SQL.addKill(aName);
     SQL.addMoney(aName, SQL.getMoney(pName) > SQL.getMoney(aName) ? 10 : 5);
     ScoreboardHandler.addKill(aName);
   }
   SQL.addDeath(pName);
   event.getDrops().clear();
 }
Beispiel #13
0
  @EventHandler(priority = EventPriority.HIGHEST)
  private void onDeath(PlayerDeathEvent evt) {
    evt.getDrops().clear();

    final Player player = evt.getEntity().getPlayer();
    final PlayerDataClass playerData =
        plugin.getPlayerHandler().findPlayer(player.getDisplayName());

    if (playerData != null) {

      setUnscoped(player, playerData);

      plugin.getPlayerLocationListener().removePlayerFromPoint(playerData);

      if (evt.getEntity().getKiller() != null) {
        Player killer = evt.getEntity().getKiller();
        PlayerDataClass killerData = plugin.getPlayerHandler().findPlayer(killer.getDisplayName());

        playerData.setDeaths(playerData.getDeaths() + 1);
        if (killer != null) {
          killerData.setKills(killerData.getKills() + 1);
        }
      }
      if (playerData.getType().equals("spy") && playerData.getDisguised() != null) {
        playerData.setDisguised(null);
      }

      if (player.isDead()) {
        player.setHealth(20);
      }

      plugin
          .getServer()
          .getScheduler()
          .scheduleSyncDelayedTask(
              plugin,
              new Runnable() {
                public void run() {
                  if (plugin.getPlayerHandler().findPlayer(player.getDisplayName()) != null) {
                    plugin.getLogger().info("Respawning: " + player.getName());
                    plugin.getPlayerHandler().spawnPlayer(playerData);
                    TagAPI.refreshPlayer(player);
                  }
                }
              },
              5L);
    } else {
      plugin.getGameManager().teleportToSpawn(player);
    }
  }
  @EventHandler(priority = EventPriority.MONITOR)
  public void onDeath(PlayerDeathEvent e) {
    final Player ent = (Player) e.getEntity();
    Player killer = (Player) e.getEntity().getKiller();
    if (ArenaManager.getInstance().getPlayerArena(e.getEntity()) != null) {
      Arena a =
          ArenaManager.getInstance()
              .getArena(ArenaManager.getInstance().getPlayerArena(e.getEntity()));

      e.getDrops().clear();
      e.setDeathMessage(null);
      e.setDroppedExp(0);
      if (a.getArenaState() != ArenaState.STARTED) {
        return;
      }

      a.removeLevel(ent);

      // TODO: Death message.
      e.setDeathMessage(
          UGunGame.getInstance().prefix + "§e" + ent.getName() + " killed by " + killer.getName());

      MessageManager.good(killer, "You got §6" + a.getCfg().getInt("arena.money.add") + " §aUGP!");
      MessageManager.bad(ent, "You lost §6" + a.getCfg().getInt("arena.money.remove") + " §cUGP!");

      ScoreboardStats.addMoney(a, killer);
      ScoreboardStats.removeMoney(a, ent);
      ScoreboardStats.createScoreboard(killer);
      ScoreboardStats.createScoreboard(ent);
    }

    if (killer == null) {
      return;
    }

    if (ArenaManager.getInstance().getPlayerArena(killer) != null) {
      Arena a =
          ArenaManager.getInstance().getArena(ArenaManager.getInstance().getPlayerArena(killer));
      if (a.getArenaState() != ArenaState.STARTED) {
        return;
      }

      killer.getInventory().clear();
      killer.getInventory().setArmorContents(null);
      a.addLevel(killer);
    }
  }
Beispiel #15
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onDeath(PlayerDeathEvent e) {
   final Player damaged = e.getEntity();
   final GamePlayer gDamaged = GameUtilities.getUtilities().getGamePlayer(damaged);
   if (gDamaged.isIngame()) {
     e.getDrops().clear();
     e.setDeathMessage(null);
     e.setDroppedExp(0);
     if (gDamaged.getPlayerLastDamagedBy() == null) {
       Bukkit.getServer().getPluginManager().callEvent(new TF2DeathEvent(damaged, damaged));
     } else {
       Bukkit.getServer()
           .getPluginManager()
           .callEvent(new TF2DeathEvent(damaged, gDamaged.getPlayerLastDamagedBy().getPlayer()));
     }
   }
 }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerDeath(PlayerDeathEvent event) {
   List<ItemStack> items = event.getDrops();
   List<ItemStack> removeAll = new ArrayList();
   List<ItemStack> addAll = new ArrayList();
   amount = items.size();
   for (int y = 0; y < amount; y++) {
     ItemStack item = items.get(y);
     if (item.getTypeId() == 30175
         || item.getTypeId() == 30176
         || item.getTypeId() == 30177
         || item.getTypeId() == 30178) {
       removeAll.add(item);
       addAll.add(new ItemStack(30150));
     }
   }
   items.removeAll(removeAll);
   items.addAll(addAll);
 }
  @ArenaEventHandler(bukkitPriority = org.bukkit.event.EventPriority.MONITOR)
  public void onPlayerDeath(ArenaPlayerDeathEvent event) {
    final ArenaPlayer target = event.getPlayer();
    if (state == MatchState.ONCANCEL || state == MatchState.ONCOMPLETE) {
      return;
    }
    final ArenaTeam t = event.getTeam();

    Integer nDeaths = t.addDeath(target);
    boolean exiting = event.isExiting() || !respawns || nDeaths >= nLivesPerPlayer;
    event.setExiting(exiting);
    final boolean trueDeath = event.getPlayerDeathEvent() != null;
    if (nLivesPerPlayer != ArenaSize.MAX) {
      int curLives = nLivesPerPlayer - nDeaths;
      SEntry e = scoreboard.getEntry(target.getPlayer());
      if (e != null) scoreboard.setEntryNameSuffix(e, curLives <= 1 ? "" : "&4(" + curLives + ")");
    }
    if (trueDeath) {
      PlayerDeathEvent pde = event.getPlayerDeathEvent();
      if (cancelExpLoss) pde.setKeepLevel(true);

      /// Handle Drops from bukkitEvent
      if (clearsInventoryOnDeath || keepsInventory) { // / clear the drops
        try {
          pde.getDrops().clear();
        } catch (Exception e) {
          if (!Defaults.DEBUG_VIRTUAL) Log.printStackTrace(e);
        }
      } else if (woolTeams) { /// Get rid of the wool from teams so it doesnt drop
        final int index = t.getIndex();
        ItemStack teamHead = TeamUtil.getTeamHead(index);
        List<ItemStack> items = pde.getDrops();
        for (ItemStack is : items) {
          if (is.getType() == teamHead.getType()
              && is.getDurability() == teamHead.getDurability()) {
            final int amt = is.getAmount();
            if (amt > 1) is.setAmount(amt - 1);
            else is.setType(Material.AIR);
            break;
          }
        }
      }
      /// If keepInventory is specified, but not restoreAll, then we have a case
      /// where we need to give them back the current Inventory they have on them
      /// even if they log out
      if (keepsInventory) {
        boolean restores =
            getParams().hasOptionAt(MatchState.ONLEAVE, TransitionOption.RESTOREITEMS);
        /// Restores and exiting, means clear their match inventory so they won't
        /// get their match and their already stored inventory
        if (restores && exiting) {
          psc.clearMatchItems(target);
        } else { /// keep their current inv
          psc.storeMatchItems(target);
        }
      }
      /// We can't let them just sit on the respawn screen... schedule them to lose
      /// We will cancel this onRespawn
      final ArenaMatch am = this;
      Integer timer = deathTimer.get(target.getName());
      if (timer != null) {
        Bukkit.getScheduler().cancelTask(timer);
      }
      timer =
          Bukkit.getScheduler()
              .scheduleSyncDelayedTask(
                  BattleArena.getSelf(),
                  new Runnable() {
                    @Override
                    public void run() {
                      PerformTransition.transition(am, MatchState.ONCOMPLETE, target, t, true);
                      checkAndHandleIfTeamDead(t);
                    }
                  },
                  15 * 20L);
      deathTimer.put(target.getName(), timer);
    }
    if (exiting) {
      PerformTransition.transition(this, MatchState.ONCOMPLETE, target, t, true);
      checkAndHandleIfTeamDead(t);
    }
  }
  @EventHandler
  public void on(PlayerDeathEvent e) {

    final Player toter = e.getEntity();

    e.setDeathMessage("");
    e.setDroppedExp(0);
    e.setKeepInventory(false);

    for (ItemStack stack : e.getDrops()) {

      if (stack.getType() == Material.LEATHER_HELMET
          || stack.getType() == Material.LEATHER_CHESTPLATE
          || stack.getType() == Material.LEATHER_LEGGINGS
          || stack.getType() == Material.LEATHER_BOOTS
          || stack.getType() == Material.NETHER_STAR) {
        e.getDrops().remove(stack.getType());
      }
    }

    PlayerDataClass pDCtoter = Global.re.read(toter.getUniqueId().toString());
    pDCtoter.Tode += 1;
    StatsWriter.write(pDCtoter, toter.getUniqueId().toString());

    if (e.getEntity().getKiller() instanceof Player) {

      Player killer = (Player) e.getEntity().getKiller();
      double dhealth = ((Damageable) killer).getHealth();
      String shealth = String.valueOf(dhealth / 2);
      shealth = shealth.substring(0, shealth.indexOf(".") + 2);

      for (Player all : Bukkit.getOnlinePlayers())
        all.sendMessage(
            Devathlon.prefix
                + toter.getDisplayName()
                + " §7wurde von "
                + killer.getDisplayName()
                + " §7[§e"
                + shealth
                + "❤§7] §7getötet");

      PlayerDataClass pDCkiller = Global.re.read(killer.getUniqueId().toString());
      pDCkiller.Toetungen += 1;
      pDCkiller.Punkte += 25;
      killer.sendMessage(Devathlon.prefix + "§e+ 25 Punkte");
      StatsWriter.write(pDCkiller, killer.getUniqueId().toString());

    } else {

      for (Player all : Bukkit.getOnlinePlayers())
        all.sendMessage(Devathlon.prefix + toter.getDisplayName() + " §7ist gestorben");
    }

    if (Global.team1.contains(toter)) {
      Global.pointsteam1 -= 5;
    } else if (Global.team2.contains(toter)) {
      Global.pointsteam2 -= 5;
    }

    if (Global.team1.contains(toter)) {
      if (Global.pointsteam2 >= Global.points) {
        spec(toter);
        for (Player all : Bukkit.getOnlinePlayers())
          all.sendMessage(
              Devathlon.prefix
                  + "§cTeam Rot §7besitzt noch §e"
                  + Global.team1.size()
                  + " §7Spieler");

        if (Global.team1.size() == 0) {

          for (Player all : Bukkit.getOnlinePlayers())
            all.sendMessage(Devathlon.prefix + "§9Team Blau §ahat gewonnen");

          for (Player t2 : Global.team2) {
            PlayerDataClass pDCt2 = Global.re.read(t2.getUniqueId().toString());
            pDCt2.SpieleGewonnen += 1;
            pDCt2.Punkte += 125;
            StatsWriter.write(pDCt2, t2.getUniqueId().toString());
            t2.sendMessage(Devathlon.prefix + "§e+ 125 Punkte");
          }

          Devathlon.Timer = 16;
          Devathlon.Status = GameStatus.Restarting;
        }
        return;
      }
    }

    if (Global.team2.contains(toter)) {
      if (Global.pointsteam1 >= Global.points) {
        spec(toter);
        for (Player all : Bukkit.getOnlinePlayers())
          all.sendMessage(
              Devathlon.prefix
                  + "§9Team Blau §7besitzt noch §e"
                  + Global.team2.size()
                  + " §7Spieler");

        if (Global.team2.size() == 0) {
          for (Player all : Bukkit.getOnlinePlayers())
            all.sendMessage(Devathlon.prefix + "§cTeam Rot §ahat gewonnen");

          for (Player t1 : Global.team1) {
            PlayerDataClass pDCt1 = Global.re.read(t1.getUniqueId().toString());
            pDCt1.SpieleGewonnen += 1;
            pDCt1.Punkte += 125;
            StatsWriter.write(pDCt1, t1.getUniqueId().toString());
            t1.sendMessage(Devathlon.prefix + "§e+ 125 Punkte");
          }

          Devathlon.Timer = 16;
          Devathlon.Status = GameStatus.Restarting;
        }
        return;
      }
    }

    toter.sendMessage(
        Devathlon.prefix
            + "§3Du konntest respawnen, da das gegnerische Team noch keine "
            + Global.points
            + " Punkte erreicht hat");

    Bukkit.getScheduler()
        .runTaskLater(
            plugin,
            new Runnable() {

              @Override
              public void run() {
                toter.spigot().respawn();
                if (Global.team1.contains(toter)) {
                  toter.teleport(OreBattle_Command.getLocation("spawn1", true));
                  Devathlon.team1(toter);
                } else if (Global.team2.contains(toter)) {
                  toter.teleport(OreBattle_Command.getLocation("spawn2", true));
                  Devathlon.team2(toter);
                }
              }
            },
            30L);

    // Grace
    Global.grace.add(toter);

    if (Global.gracetime != 0) {
      toter.sendMessage(
          Devathlon.prefix
              + "§cDeine Schutzzeit endet in §7[§e"
              + Global.gracetime
              + "§7] §cSekunden");

      Bukkit.getScheduler()
          .runTaskLater(
              plugin,
              new Runnable() {

                @Override
                public void run() {
                  Global.grace.remove(toter);
                  toter.sendMessage(Devathlon.prefix + "§cDeine Schutzzeit ist vorbei!");
                }
              },
              20L * Global.gracetime);
    }
  }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerDie(PlayerDeathEvent pde) {
    final Player player = pde.getEntity();
    Game game = Main.getInstance().getGameManager().getGameOfPlayer(player);

    if (game == null) {
      return;
    }

    if (game.getState() == GameState.RUNNING) {
      pde.setDroppedExp(0);
      pde.setDeathMessage(null);

      if (!Main.getInstance().getBooleanConfig("player-drops", false)) {
        pde.getDrops().clear();
      }

      try {
        if (!Main.getInstance().isSpigot()) {
          Class<?> clazz = null;
          try {
            clazz =
                Class.forName(
                    "io.github.yannici.bedwars.Com."
                        + Main.getInstance().getCurrentVersion()
                        + ".PerformRespawnRunnable");
          } catch (ClassNotFoundException ex) {
            clazz = Class.forName("io.github.yannici.bedwars.Com.Fallback.PerformRespawnRunnable");
          }

          BukkitRunnable respawnRunnable =
              (BukkitRunnable) clazz.getDeclaredConstructor(Player.class).newInstance(player);
          respawnRunnable.runTaskLater(Main.getInstance(), 20L);
        } else {
          new BukkitRunnable() {

            @Override
            public void run() {
              player.spigot().respawn();
            }
          }.runTaskLater(Main.getInstance(), 20L);
        }

      } catch (Exception e) {
        e.printStackTrace();
      }

      try {
        pde.getClass().getMethod("setKeepInventory", new Class<?>[] {boolean.class});
        pde.setKeepInventory(false);
      } catch (Exception ex) {
        player.getInventory().clear();
      }

      Player killer = player.getKiller();
      if (killer == null) {
        killer = game.getPlayerDamager(player);
      }

      game.getCycle().onPlayerDies(player, killer);
    }
  }
Beispiel #20
0
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent event) {
   for (ItemStack drop : event.getDrops()) {
     plugin.items.put(drop, Config.persistSeconds);
   }
 }