コード例 #1
0
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent event) {
   Player player = event.getEntity().getPlayer();
   if (event.getDeathMessage().contains("died")) {
     if (purple == true) {
       event.setDeathMessage(
           player.getName() + " was killed by " + ChatColor.DARK_PURPLE + "the purple lords");
     } else if (black == true) {
       event.setDeathMessage(
           player.getName() + " was killed by " + ChatColor.GRAY + "the darkness");
     } else {
       event.setDeathMessage(player.getName() + " was killed by an admin");
     }
     return;
   }
 }
コード例 #2
0
  @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);
    }
  }
コード例 #3
0
  @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());
    }
  }
コード例 #4
0
 /** Handles player death events, removes the death message. */
 @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
 public void onPlayerDeath(PlayerDeathEvent event) {
   String playerName = event.getEntity().getName();
   if (ultimateGames.getPlayerManager().isPlayerInArena(playerName)) {
     Arena arena = ultimateGames.getPlayerManager().getPlayerArena(playerName);
     arena.getGame().getGamePlugin().onPlayerDeath(arena, event);
     event.setDeathMessage("");
   }
 }
コード例 #5
0
ファイル: PlayerListeners.java プロジェクト: ShootGame/Arcade
  @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();
    }
  }
コード例 #6
0
  @EventHandler
  public void onEntityDeath(PlayerDeathEvent e) {
    if (e.getEntity() instanceof Player) {
      Player p = (Player) e.getEntity();

      int id = gm.getPlayerGameId(p);
      if (id != -1) {
        gm.getPlayerClass(p).PlayerDeath();

        gm.getGame(id).killPlayer(p, e.getDeathMessage());
        e.setDeathMessage(null);
      }
    }
  }
コード例 #7
0
	@EventHandler(priority = EventPriority.LOWEST)
	public void onPlayerDeathEvent(final PlayerDeathEvent event)
	{
		final User user = ess.getUser(event.getEntity());
		if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
		{
			user.setLastLocation();
			user.sendMessage(_("backAfterDeath"));
		}
		if (!ess.getSettings().areDeathMessagesEnabled())
		{
			event.setDeathMessage("");
		}
	}
コード例 #8
0
ファイル: PlayerDeathListener.java プロジェクト: Neder/TF2
 @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()));
     }
   }
 }
コード例 #9
0
  @EventHandler
  public void onPlayerDeath(PlayerDeathEvent event) {

    if (event.getEntity().getKiller() != null) {
      Player player = event.getEntity();
      Player attacker = event.getEntity().getKiller();

      NovaPlayer novaPlayer = plugin.getPlayerManager().getPlayer(player);
      NovaPlayer novaPlayerAttacker = plugin.getPlayerManager().getPlayer(attacker);

      String tag1 = "";
      String tag2 = "";
      String tagscheme = plugin.getConfig().getString("guild.tag");
      tagscheme = StringUtils.replace(tagscheme, "{RANK}", "");

      if (novaPlayer.hasGuild()) {
        tag1 = StringUtils.replace(tagscheme, "{TAG}", novaPlayer.getGuild().getTag());
      }

      if (novaPlayerAttacker.hasGuild()) {
        tag2 = StringUtils.replace(tagscheme, "{TAG}", novaPlayerAttacker.getGuild().getTag());
      }

      HashMap<String, String> vars = new HashMap<>();
      vars.put("PLAYER1", player.getName());
      vars.put("PLAYER2", attacker.getName());
      vars.put("TAG1", tag1);
      vars.put("TAG2", tag2);
      plugin.getMessageManager().broadcastMessage("broadcast.pvp.killed", vars);

      if (novaPlayer.hasGuild()) {
        NovaGuild guildVictim = plugin.getGuildManager().getGuildByPlayer(novaPlayer);
        guildVictim.takePoints(plugin.getConfig().getInt("guild.deathpoints"));
      }

      if (novaPlayerAttacker.hasGuild()) {
        NovaGuild guildAttacker = plugin.getGuildManager().getGuildByPlayer(novaPlayerAttacker);
        guildAttacker.addPoints(plugin.getConfig().getInt("guild.killpoints"));
      }

      // disable death message
      event.setDeathMessage(null);
    }
  }
コード例 #10
0
ファイル: GameListener.java プロジェクト: YoloxPanda/Skywars
 @EventHandler(priority = EventPriority.HIGH)
 public void onPlayerDeath(PlayerDeathEvent event) {
   GamePlayer killed = PlayerManager.getPlayer(event.getEntity());
   if (killed.getGame() == null) {
     return;
   }
   event.setDeathMessage("");
   killed.incrementStatistic(Stats.Deaths);
   killed.leaveGame();
   if (event.getEntity().getKiller() != null) {
     GamePlayer killer = PlayerManager.getPlayer(event.getEntity().getKiller());
     killer.incrementStatistic(Stats.Kills);
     killed
         .getGame()
         .broadcast(
             Language.PlayerKilled.getMsg()
                 .replace("{Player}", event.getEntity().getName())
                 .replace("{Killer}", killer.getName()));
   } else {
     killed
         .getGame()
         .broadcast(Language.PlayerDied.getMsg().replace("{Player}", event.getEntity().getName()));
   }
 }
コード例 #11
0
  @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);
    }
  }
コード例 #12
0
  @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);
    }
  }
コード例 #13
0
  @EventHandler(ignoreCancelled = true)
  public void onPlayerDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    event.getDeathMessage();
    DamageCause deathCause = player.getLastDamageCause().getCause();

    if (player.getKiller() != null && getSettingsManager().isPvpDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.pvp", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("wolf")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.wolf", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("ocelot")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.ocelot", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("pigman")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.pigzombie", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("zombie")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.zombie", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("skeleton")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.skeleton", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("cave spider")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.cavespider", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("spider")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.spider", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("silverfish")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.silverfish", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("slime")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.slime", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("blew up")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.creeper", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("enderman")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.enderman", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("ghast")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.ghast", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("blaze")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.blaze", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("ender dragon")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.enderdragon", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("wither skeleton")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.witch", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("wither")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("monsters.wither", player);
      event.setDeathMessage(null);
    } else if (event.getDeathMessage().toLowerCase().contains("anvil")
        && getSettingsManager().isMonsterDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.anvil", player);
      event.setDeathMessage(null);
    } else if (deathCause == DamageCause.DROWNING
        && getSettingsManager().isNaturalDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.drowning", player);
      event.setDeathMessage(null);
    } else if (deathCause == DamageCause.SUFFOCATION
        && getSettingsManager().isNaturalDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.suffocation", player);
      event.setDeathMessage(null);
    } else if (deathCause == DamageCause.SUICIDE
        && getSettingsManager().isNaturalDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.suicide", player);
      event.setDeathMessage(null);
    } else if (deathCause == DamageCause.FALL
        && getSettingsManager().isNaturalDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.fall", player);
      event.setDeathMessage(null);
    } else if (deathCause == DamageCause.VOID
        && getSettingsManager().isNaturalDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.void", player);
      event.setDeathMessage(null);
    } else if (deathCause == DamageCause.LAVA
        && getSettingsManager().isNaturalDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.lava", player);
      event.setDeathMessage(null);
    } else if (deathCause == DamageCause.FIRE
        && getSettingsManager().isNaturalDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.fire", player);
      event.setDeathMessage(null);
    } else if (deathCause == DamageCause.CONTACT
        && getSettingsManager().isNaturalDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.cactus", player);
      event.setDeathMessage(null);
    } else if (deathCause == DamageCause.WITHER
        && getSettingsManager().isNaturalDeathTranslationEnabled()) {
      Localisation.sendGlobalMessage("deaths.wither", player);
      event.setDeathMessage(null);
    }
  }