예제 #1
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. :(");
  }
예제 #2
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerDeath(PlayerDeathEvent e) {
   e.setDroppedExp(0);
   PlayerDetails p = getPlayerDetails(e.getEntity());
   if (p == null) // make way for hacky plugins!
   return;
   p.setHealth(0);
   p.giveMana = false;
 }
예제 #3
0
파일: death.java 프로젝트: Scrik/nbtkits
 @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);
   }
 }
예제 #4
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);
    }
  }
예제 #5
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()));
     }
   }
 }
예제 #6
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);
    }
  }
예제 #7
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);
    }
  }