Package com.tommytony.war

Examples of com.tommytony.war.Team


    if (attacker != null && defender != null && attacker instanceof Player && defender instanceof Player) {
      // only let adversaries (same warzone, different team) attack each other
      Player a = (Player) attacker;
      Player d = (Player) defender;
      Warzone attackerWarzone = Warzone.getZoneByPlayerName(a.getName());
      Team attackerTeam = Team.getTeamByPlayerName(a.getName());
      Warzone defenderWarzone = Warzone.getZoneByPlayerName(d.getName());
      Team defenderTeam = Team.getTeamByPlayerName(d.getName());
     
      if ((attackerTeam != null && defenderTeam != null && attackerTeam != defenderTeam && attackerWarzone == defenderWarzone)
          || (attackerTeam != null && defenderTeam != null && attacker.getEntityId() == defender.getEntityId())) {
       
        LoadoutSelection defenderLoadoutState = defenderWarzone.getLoadoutSelections().get(d.getName());
        if (defenderLoadoutState != null && defenderLoadoutState.isStillInSpawn()) {
          War.war.badMsg(a, "pvp.target.spawn");
          event.setCancelled(true);
          return;
        }
       
        LoadoutSelection attackerLoadoutState = attackerWarzone.getLoadoutSelections().get(a.getName());
        if (attackerLoadoutState != null && attackerLoadoutState.isStillInSpawn()) {
          War.war.badMsg(a, "pvp.self.spawn");
          event.setCancelled(true);
          return;
        }
       
        // Make sure none of them are locked in by respawn timer
        if (defenderWarzone.isRespawning(d)) {
          War.war.badMsg(a, "pvp.target.respawn");
          event.setCancelled(true);
          return;
        } else if (attackerWarzone.isRespawning(a)) {
          War.war.badMsg(a, "pvp.self.respawn");
          event.setCancelled(true);
          return;
        }
       
        if (!attackerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.PVPINZONE)) {
          // spleef-like, non-pvp, zone
          event.setCancelled(true);
          return;
        }

        // Detect death, prevent it and respawn the player
        if (event.getDamage() >= d.getHealth()) {
          if (defenderWarzone.getReallyDeadFighters().contains(d.getName())) {
            // don't re-kill a dead person       
            return;
          }
          WarPlayerDeathEvent event1 = new WarPlayerDeathEvent(defenderWarzone, d, a, event.getCause());
          War.war.getServer().getPluginManager().callEvent(event1);
          if (!defenderWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
            // fast respawn, don't really die
            event.setCancelled(true);
          }
          if (d == a) {
            defenderWarzone.handleSuicide(d);
          } else {
            defenderWarzone.handleKill(a, d, event.getDamager());
          }
        } else if (defenderWarzone.isBombThief(d.getName()) && d.getLocation().distance(a.getLocation()) < 2) {
          // Close combat, close enough to detonate         
          Bomb bomb = defenderWarzone.getBombForThief(d.getName());
                   
          // Kill the bomber
          WarPlayerDeathEvent event1 = new WarPlayerDeathEvent(defenderWarzone, d, null, event.getCause());
          War.war.getServer().getPluginManager().callEvent(event1);
          defenderWarzone.handleDeath(d);
         
          if (defenderWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
            // and respawn him and remove from deadmen (cause realdeath + handleDeath means no respawn and getting queued up for onPlayerRespawn)
            defenderWarzone.getReallyDeadFighters().remove(d.getName());
            defenderWarzone.respawnPlayer(defenderTeam, d);
          }
         
          // Blow up bomb
          if (!defenderWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)) {
            defenderWarzone.getWorld().createExplosion(a.getLocation(), 2F);
          }

          // bring back tnt
          bomb.getVolume().resetBlocks();
          bomb.addBombBlocks();
         
          // Notify everyone
          for (Team t : defenderWarzone.getTeams()) {
            t.sendAchievement(attackerTeam.getKind().getColor() + a.getName() + ChatColor.YELLOW + " made ",
                defenderTeam.getKind().getColor() + d.getName() + ChatColor.YELLOW + " blow up!", new ItemStack(Material.TNT), 10000);
            t.teamcast("pvp.kill.bomb", attackerTeam.getKind().getColor() + a.getName() + ChatColor.WHITE,
                defenderTeam.getKind().getColor() + d.getName() + ChatColor.WHITE);
          }
        }
      } else if (attackerTeam != null && defenderTeam != null && attackerTeam == defenderTeam && attackerWarzone == defenderWarzone && attacker.getEntityId() != defender.getEntityId()) {
        // same team, but not same person
        if (attackerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.FRIENDLYFIRE)) {
View Full Code Here


    // pass pvp-damage
    if (event instanceof EntityDamageByEntityEvent) {     
      this.handlerAttackDefend((EntityDamageByEntityEvent) event);
    } else  {
      Team team = Team.getTeamByPlayerName(player.getName());
     
      if (zone != null && team != null) {
        LoadoutSelection playerLoadoutState = zone.getLoadoutSelections().get(player.getName());
        if (team.isSpawnLocation(player.getLocation())
            && playerLoadoutState != null && playerLoadoutState.isStillInSpawn()) {
          // don't let a player still in spawn get damaged
          event.setCancelled(true);
        } else if (event.getDamage() >= player.getHealth()) {
          if (zone.getReallyDeadFighters().contains(player.getName())) {
View Full Code Here

    }

    Player player = (Player) entity;
    Warzone zone = Warzone.getZoneByPlayerName(player.getName());
    if (zone != null) {
      Team team = Team.getTeamByPlayerName(player.getName());
      if ((event.getRegainReason() == RegainReason.EATING
          || event.getRegainReason() != RegainReason.SATIATED )
        && team.getTeamConfig().resolveBoolean(TeamConfig.NOHUNGER)) {
        // noHunger setting means you can't auto-heal with full hunger bar (use saturation instead to control how fast you get hungry)
        event.setCancelled(true);
      } else if (event.getRegainReason() == RegainReason.REGEN) {
        // disable peaceful mode regen
        event.setCancelled(true);
View Full Code Here

      return;
    }
   
    Player player = (Player) event.getEntity();
    Warzone zone = Warzone.getZoneByPlayerName(player.getName());
    Team team = Team.getTeamByPlayerName(player.getName());
    if (zone != null && team.getTeamConfig().resolveBoolean(TeamConfig.NOHUNGER)){
      event.setCancelled(true);
    }
  }
View Full Code Here

    if (zone != null) {
      event.getDrops().clear();
      if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
        // catch the odd death that gets away from us when usually intercepting and preventing deaths
        zone.handleDeath(player);
        Team team = Team.getTeamByPlayerName(player.getName());
        if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DEATHMESSAGES)) {
          zone.broadcast("pvp.death.other", team.getKind().getColor() + player.getName());
        }
        War.war.getLogger().log(Level.WARNING, "We missed the death of player {0} - something went wrong.", player.getName());
      } else {
        event.setDeathMessage("");
      }
View Full Code Here

    if (event.getEntityType() == EntityType.EGG) {
      LivingEntity shooter = event.getEntity().getShooter();
      if (shooter instanceof Player) {
        Player player = (Player) shooter;
        Warzone zone = Warzone.getZoneByPlayerName(player.getName());
        Team team = Team.getTeamByPlayerName(player.getName());
        if (zone != null) {
          if (War.war.getKillstreakReward().getAirstrikePlayers().remove(player.getName())) {
            event.getEntity().setMetadata("warAirstrike", new FixedMetadataValue(War.war, true));
            zone.broadcast("zone.airstrike", team.getKind().getColor() + player.getName() + ChatColor.WHITE);
          }
        }
      }
    }
  }
View Full Code Here

    Block block = event.getBlock();
    if (player == null || block == null) {
      return;
    }

    Team team = Team.getTeamByPlayerName(player.getName());
    Warzone zone = Warzone.getZoneByLocation(player);
    // Monument capturing
    if (team != null && block != null && zone != null
        && zone.isMonumentCenterBlock(block)
        && team.getKind().isTeamBlock(block.getState())) {
      Monument monument = zone.getMonumentFromCenterBlock(block);
      if (monument != null && !monument.hasOwner()) {
        monument.capture(team);
        if (War.war.isSpoutServer()) {
          for (Player p : team.getPlayers()) {
            SpoutPlayer sp = SpoutManager.getPlayer(p);
            if (sp.isSpoutCraftEnabled()) {
                      sp.sendNotification(
                          SpoutDisplayer.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
                          SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
                          team.getKind().getMaterial(),
                          team.getKind().getData(),
                          10000);
            }
          }
        }
        zone.broadcast("zone.monument.capture", monument.getName(), team.getName());
        event.setCancelled(false);
        return; // important otherwise cancelled down a few line by isImportantblock
      } else {
        War.war.badMsg(player, "zone.monument.badblock");
        cancelAndKeepItem(event);
        return;
      }
    }

    boolean isZoneMaker = War.war.isZoneMaker(player);
    // prevent build in important parts
    if (zone != null
        && (zone.isImportantBlock(block) || zone.isOpponentSpawnPeripheryBlock(team, block))
        && (!isZoneMaker || (isZoneMaker && team != null))) {
      War.war.badMsg(player, "build.denied.location");
      cancelAndKeepItem(event);
      return;
    }

    // protect warzone lobbies
    for (Warzone wz : War.war.getWarzones()) {
      if (wz.getLobby() != null && wz.getLobby().getVolume() != null && wz.getLobby().getVolume().contains(block)) {
        War.war.badMsg(player, "build.denied.location");
        cancelAndKeepItem(event);
        return;
      }
    }

    // protect the hub
    if (War.war.getWarHub() != null && War.war.getWarHub().getVolume().contains(block)) {
      War.war.badMsg(player, "build.denied.location");
      cancelAndKeepItem(event);
      return;
    }

    // buildInZonesOnly
    if (zone == null && War.war.getWarConfig().getBoolean(WarConfig.BUILDINZONESONLY) && !War.war.canBuildOutsideZone(player)) {
      if (!War.war.getWarConfig().getBoolean(WarConfig.DISABLEBUILDMESSAGE)) {
        War.war.badMsg(player, "build.denied.outside");
      }
      cancelAndKeepItem(event);
      return;
    }

    // can't place a block of your team's color
    if (team != null && block.getType() == team.getKind().getMaterial() && block.getState().getData() == team.getKind().getBlockData()) {
      War.war.badMsg(player, "build.denied.teamblock");
      cancelAndKeepItem(event);
      return;
    }

    // a flag thief can't drop his flag
    if (team != null && zone != null && zone.isFlagThief(player.getName())) {
      War.war.badMsg(player, "drop.flag.disabled");
      cancelAndKeepItem(event);
      return;
    }
   
    // a bomb thief can't drop his bomb
    if (team != null && zone != null && zone.isBombThief(player.getName())) {
      War.war.badMsg(player, "drop.bomb.disabled");
      cancelAndKeepItem(event);
      return;
    }
   
    // a cake thief can't drop his cake
    if (team != null && zone != null && zone.isCakeThief(player.getName())) {
      War.war.badMsg(player, "drop.cake.disabled");
      cancelAndKeepItem(event);
      return;
    }

    // unbreakableZoneBlocks
    if (zone != null && (zone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)
        || (team != null && !team.getTeamConfig().resolveBoolean(TeamConfig.PLACEBLOCK)))
        && (!isZoneMaker || (isZoneMaker && team != null))) {
      // if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks)
      War.war.badMsg(player, "build.denied.zone.place");
      cancelAndKeepItem(event);
      return;
    }

    if (team != null && !team.canModify(block.getType())) {
      War.war.badMsg(player, "build.denied.zone.type");
      cancelAndKeepItem(event);
      return;
    }
  }
View Full Code Here

 
  @EventHandler
  public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
    if (War.war.isLoaded() && event.isSneaking()) {
      Warzone playerWarzone = Warzone.getZoneByLocation(event.getPlayer());
      Team playerTeam = Team.getTeamByPlayerName(event.getPlayer().getName());
      if (playerWarzone != null && playerTeam != null && playerTeam.getInventories().resolveLoadouts().keySet().size() > 1 && playerTeam.isSpawnLocation(event.getPlayer().getLocation())) {
        if (playerWarzone.getLoadoutSelections().keySet().contains(event.getPlayer().getName())
            && playerWarzone.getLoadoutSelections().get(event.getPlayer().getName()).isStillInSpawn()) {
          LoadoutSelection selection = playerWarzone.getLoadoutSelections().get(event.getPlayer().getName());
          List<Loadout> loadouts = new ArrayList<Loadout>(playerTeam.getInventories().resolveNewLoadouts());
          for (Iterator<Loadout> it = loadouts.iterator(); it.hasNext();) {
            Loadout ldt = it.next();
            if (ldt.getName().equals("first") ||
                (ldt.requiresPermission() && !event.getPlayer().hasPermission(ldt.getPermission()))) {
              it.remove();
View Full Code Here

      return;
    } else if (deadZone == null) {
      // Player is not a 'really' dead player, nothing to do here
      return;
    }
    Team team = playingZone.getPlayerTeam(event.getPlayer().getName());
    Validate.notNull(team, String.format(
        "Failed to find a team for player %s in warzone %s on respawn.",
        event.getPlayer().getName(), playingZone.getName()));
    playingZone.getReallyDeadFighters().remove(event.getPlayer().getName());
    event.setRespawnLocation(team.getRandomSpawn());
    playingZone.respawnPlayer(team, event.getPlayer());
  }
View Full Code Here

  @EventHandler
  public void onPlayerTeleport(final PlayerTeleportEvent event) {
    if (War.war.isLoaded()) {
      Warzone playerWarzone = Warzone.getZoneByPlayerName(event.getPlayer().getName());
      Team playerTeam = Team.getTeamByPlayerName(event.getPlayer().getName());
      if (playerWarzone != null) {
        if (!playerWarzone.getVolume().contains(event.getTo())) {
          // Prevent teleporting out of the warzone
          if (!playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
            War.war.badMsg(event.getPlayer(), "Use /leave (or /war leave) to exit the zone.");
View Full Code Here

TOP

Related Classes of com.tommytony.war.Team

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.