Exemplo n.º 1
0
 @EventHandler
 public void onPlayerFall(EntityDamageEvent event) {
   if (!(event.getEntity() instanceof Player)) {
     return;
   }
   if (event.getCause() != EntityDamageEvent.DamageCause.FALL) {
     return;
   }
   GamePlayer gamePlayer = PlayerManager.getPlayer(event.getEntity());
   if (gamePlayer.getGame() != null && !gamePlayer.getGame().isFallDamage()) {
     event.setCancelled(true);
   }
 }
Exemplo n.º 2
0
  @EventHandler
  public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
    if (event.getPlayer().isOp()) {
      return;
    }
    GamePlayer gamePlayer = PlayerManager.getPlayer(event.getPlayer());
    if (gamePlayer.getGame() == null) {
      return;
    }

    if (!allowedCommands.contains(event.getMessage().split(" ")[0])) {
      event.getPlayer().sendMessage(Language.CommandsInArena.getMsg());
      event.setCancelled(true);
    }
  }
Exemplo n.º 3
0
 @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()));
   }
 }
Exemplo n.º 4
0
 @EventHandler
 public void onPlayerMove(PlayerInteractEvent event) {
   final Material material = Material.STONE_PLATE;
   if (event.getClickedBlock() == null || !event.getClickedBlock().getType().equals(material)) {
     return;
   }
   final GamePlayer player = PlayerManager.getPlayer(event.getPlayer());
   if (player.getGame() != null) {
     return;
   }
   Bukkit.getScheduler()
       .runTask(
           Skywars.getProvidingPlugin(Skywars.class),
           new Runnable() {
             @Override
             public void run() {
               GameManager.getInstance().getAvailable().addPlayer(player);
             }
           });
 }