Beispiel #1
0
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player) {
     if (GameState.getState() == GameState.ENDING || GameState.getState() == GameState.LOBBY) {
       e.setCancelled(true);
     }
   }
 }
Beispiel #2
0
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Location loc =
        new Location(
            e.getTo().getWorld(),
            (int) e.getTo().getX(),
            (int) e.getTo().getY(),
            (int) e.getTo().getZ());
    if (Main.getInstance().redSpawnArea.contains(loc)) {
      Bukkit.getPluginManager().callEvent(new AreaWalkEvent(Area.RED_SPAWN, p));
    }
    if (Main.getInstance().blueSpawnArea.contains(loc)) {
      Bukkit.getPluginManager().callEvent(new AreaWalkEvent(Area.BLUE_SPAWN, p));
    }
    if (Main.getInstance().blockspawnAreas.contains(loc)) {
      Bukkit.getPluginManager().callEvent(new AreaWalkEvent(getArea(loc), p));
    }
    if (blockManager.canPickUpBlock(p)) {
      blockManager.pickUpBlock(p);
    }
    if (canGetNeededBlock(p)) {
      if (p.getGameMode() == GameMode.SURVIVAL) {
        gameManager.setCarrying(p, nexusManager.getCurrentNexusColor());
        String[] data = neededBlockMaterial.split(";");
        neededBlock
            .getBlock()
            .setTypeIdAndData(Integer.valueOf(data[0]), Byte.valueOf(data[1]), false);
        neededBlock = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);

        Bukkit.broadcastMessage(
            Color.np(
                "&6The needed block was picked up by the "
                    + teamManager.getTeam(p).getTeamName()
                    + "&6 team!"));
      }
    }
    if ((int) e.getFrom().getX() != (int) e.getTo().getX()
        || (int) e.getFrom().getZ() != (int) e.getTo().getZ()
        || (int) e.getFrom().getY() != (int) e.getTo().getY()) {
      if (getTurret(loc) != null) {
        Bukkit.getPluginManager().callEvent(new TurretWalkEvent(p, getTurret(loc)));
      }
      if (isInTurret(p)) {
        Turret t = getTurret(p);
        if (t.containsUser()) {
          e.getPlayer().teleport(e.getFrom());
        }
      }
    }
    if ((int) e.getFrom().getX() != (int) e.getTo().getX()
        || (int) e.getFrom().getZ() != (int) e.getTo().getZ()) {
      if (!released || stunned.contains(p.getName())) {
        if (GameState.getState() == GameState.INGAME) {
          e.getPlayer().teleport(e.getFrom());
        }
      }
    }
  }
Beispiel #3
0
 @EventHandler
 public void onTurretWalk(TurretWalkEvent e) {
   if (GameState.getState() == GameState.INGAME) {
     if (!e.isOccupied()) {
       e.getTurret().setUser(e.getPlayer());
       e.getPlayer().sendMessage(Color.np("&aYou entered a turret. To leave, press shift."));
     } else {
       e.getPlayer().sendMessage(Color.np("&7That turret is already occupied!"));
     }
   }
 }
Beispiel #4
0
  @EventHandler
  public void onAreaWalk(AreaWalkEvent e) {
    if (GameState.getState() != GameState.ENDING) {
      Player p = e.getPlayer();
      Area a = e.getArea();

      if (p.getGameMode() == GameMode.SURVIVAL) {
        if (a != null) {
          if (e.isBlockSpawn()) {
            int block = nexusManager.getColor(a);
            if (GameManager.getCarrying(p) == nexusManager.getCurrentNexusColor()) {
              if (block != nexusManager.getCurrentNexusColor()) {
                if (!blockManager.isTaken(a)) {
                  Bukkit.broadcastMessage(
                      Color.np(
                          "&6The "
                              + teamManager.getTeam(p).getTeamName()
                              + " &6team has dropped the needed block. It has been brought back to it's original location."));
                  nexusManager
                      .getNeededBlockArea()
                      .getBlockSpawnBlock()
                      .getBlock()
                      .setTypeIdAndData(159, (byte) nexusManager.getCurrentNexusColor(), false);
                  blockManager.forcePickUpBlock(p, a);
                  isPickedUp = false;
                }
              }
            } else if (!blockManager.isTaken(a)) {
              blockManager.forcePickUpBlock(p, a);
            }

            if (nexusManager.getColor(e.getArea()) == nexusManager.getCurrentNexusColor()) {
              if (!isPickedUp) {
                Bukkit.broadcastMessage(
                    Color.np(
                        "&6The "
                            + teamManager.getTeam(p).getTeamName()
                            + " &6team has picked up the needed block!"));
                a.getBlockSpawnBlock().getBlock().setType(Material.AIR);
                if (GameManager.getCarrying(p) != 0
                    && GameManager.getCarrying(p) != nexusManager.getCurrentNexusColor()) {
                  blockManager.resetBlock(a.getBlockSpawnBlock(), a);
                }
                GameManager.setCarrying(p, nexusManager.getCurrentNexusColor());
                isPickedUp = true;
              }
            }
          } else {
            Team spawn = getTeam(a);
            int carrying = gameManager.getCarrying(p);
            if (spawn == teamManager.getTeam(p)) {
              if (carrying == nexusManager.getCurrentNexusColor()) {
                Bukkit.broadcastMessage(
                    Color.np(
                        "&6The "
                            + spawn.getTeamName()
                            + " &6team has brought the block to their base first!"));
                GameManager.addPoint(spawn);
                gameManager.setCarrying(p, 0);
                nexusManager.generateNewNexus();
              } else {
                if (carrying != 0) {
                  GameManager.addPoint(teamManager.getTeam(p).getOpposite());
                  GameManager.setCarrying(p, 0);
                  Bukkit.broadcastMessage(
                      Color.np(
                          "&cThe "
                              + spawn.getTeamName()
                              + " &cteam has brought the wrong block to their base!"));
                }
              }
            } else {
              if (GameManager.getCarrying(p) == nexusManager.getCurrentNexusColor()) {
                Bukkit.broadcastMessage(
                    Color.np(
                        "&cThe "
                            + spawn.getOpposite().getTeamName()
                            + " &cteam has brought the block to the wrong base!"));
                GameManager.addPoint(spawn);
                gameManager.setCarrying(p, 0);
                nexusManager.generateNewNexus();
              }
            }
          }
        }
      }
    }
  }