Exemplo n.º 1
0
 @EventHandler
 public void onPlayerPlaceBlock(BlockPlaceEvent e) {
   int id = gm.getPlayerGameId(e.getPlayer());
   if (id != -1) {
     if (gm.getGame(id).getState() == State.INGAME)
       gm.getPlayerClass(e.getPlayer()).PlayerPlaceBlock(e.getBlock());
   }
 }
Exemplo n.º 2
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void teleportHandler(PlayerTeleportEvent e) {
   int game = GameManager.getInstance().getPlayerGameId(e.getPlayer());
   if (game != -1) {
     Game g = GameManager.getInstance().getGame(game);
     if (g.getState() == State.LOBBY) {
       e.setCancelled(true);
     }
   }
 }
Exemplo n.º 3
0
  @EventHandler
  public void onMove(PlayerMoveEvent e) {
    Player p = e.getPlayer();

    int id = gm.getPlayerGameId(p);
    if (id != -1) {
      Game g = gm.getGame(id);
      if (g.getState() == Game.State.INGAME) g.getPlayerClass(p).PlayerMove();
    }
  }
Exemplo n.º 4
0
 @EventHandler
 public void onEntityDeath(EntityShootBowEvent e) {
   if (e.getEntity() instanceof Player) {
     Player p = (Player) e.getEntity();
     int game = GameManager.getInstance().getPlayerGameId(p);
     if (game != -1) {
       gm.getGame(game).getPlayerClass(p).PlayerShootArrow(e.getProjectile());
     }
   }
 }
Exemplo n.º 5
0
  @EventHandler
  public void onEntityDamaged(EntityDamageEvent e) {
    if (e.getEntity() instanceof Player) {
      Player p = (Player) e.getEntity();
      int game = GameManager.getInstance().getPlayerGameId(p);
      if (game != -1) {
        Game g = gm.getGame(game);
        if (g.getState() == Game.State.INGAME) {

          g.getPlayerClass(p).PlayerDamaged();
        }
      }
    }
  }
Exemplo n.º 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);
      }
    }
  }
Exemplo n.º 7
0
  @EventHandler
  public void onInteract(PlayerInteractEvent e) {
    Player p = e.getPlayer();

    int id = gm.getPlayerGameId(p);
    if (id != -1) {
      Game g = gm.getGame(id);
      if (g.getState() == Game.State.INGAME) {
        if (e.getPlayer().getItemInHand().getType() == Material.DIAMOND_AXE) {
          g.getPlayerClass(p).Smash();
        } else {
          g.getPlayerClass(p).PlayerInteract(e.getAction());
        }
      }
      // e.setCancelled(true);
    }
  }
Exemplo n.º 8
0
 @EventHandler
 public void onEntityDamaged(EntityDamageByEntityEvent e) {
   try {
     Player victim = null;
     Player attacker = null;
     if (e.getEntity() instanceof Player) {
       victim = (Player) e.getEntity();
     }
     if (e.getDamager() instanceof Player) {
       attacker = (Player) e.getDamager();
     }
     if (victim != null && attacker != null) {
       if (gm.getPlayerGameId(victim) != -1 && gm.getPlayerGameId(attacker) != -1) {
         gm.getPlayerClass(victim).PlayerDamaged();
         gm.getPlayerClass(attacker).PlayerAttack(victim);
       }
     }
   } catch (Exception et) {
   }
 }
Exemplo n.º 9
0
 @EventHandler(priority = EventPriority.LOWEST)
 public void blockFire(BlockIgniteEvent e) {
   System.out.println("lighing");
   final Block b = e.getBlock();
   Bukkit.getScheduler()
       .scheduleSyncDelayedTask(
           GameManager.getInstance().getPlugin(),
           new Runnable() {
             public void run() {
               b.setTypeId(0);
               b.getState().update();
             }
           },
           60);
 }
Exemplo n.º 10
0
 @EventHandler
 public void onEntityRespawn(PlayerRespawnEvent e) {
   final Player p = e.getPlayer();
   Bukkit.getScheduler()
       .scheduleSyncDelayedTask(
           GameManager.getInstance().getPlugin(),
           new Runnable() {
             public void run() {
               int id = gm.getPlayerGameId(p);
               if (id != -1) {
                 gm.getGame(id).spawnPlayer(p);
                 gm.getPlayerClass(p).PlayerSpawn();
               } else {
                 p.teleport(SettingsManager.getInstance().getLobbySpawn());
               }
             }
           },
           1);
 }
Exemplo n.º 11
0
 public PlayerClassEvents() {
   gm = GameManager.getInstance();
 }