Examples of Team


Examples of com.tommytony.war.Team

      this.badMsg("command.console");
      return true;
    }

    Player player = (Player) this.getSender();
    Team playerTeam = Team.getTeamByPlayerName(player.getName());
    if (playerTeam == null) {
      return false;
    }

    if (this.args.length < 1) {
      if (playerTeam.isInTeamChat(player)) {
        playerTeam.removeTeamChatPlayer(player);
        this.msg("team.chat.disable");
      } else {
        playerTeam.addTeamChatPlayer(player);
        this.msg("team.chat.enable");
      }
      return true;
    }

    StringBuilder teamMessage = new StringBuilder();
    for (String part : this.args) {
      teamMessage.append(part).append(' ');
    }
    playerTeam.sendTeamChatMessage(player, teamMessage.toString());
    return true;
  }
View Full Code Here

Examples of com.tommytony.war.Team

              Location teamLocation = new Location(world, teamX, teamY, teamZ, teamYaw, 0);
              teamSpawns.add(teamLocation);
            }
          }
 
          Team team = new Team(teamName, TeamKind.teamKindFromString(teamName), teamSpawns, warzone);
          warzone.getTeams().add(team);
         
          if (warzoneRootSection.contains(teamInfoPrefix + "flag")) {
            int flagX = warzoneRootSection.getInt(teamInfoPrefix + "flag.x");
            int flagY = warzoneRootSection.getInt(teamInfoPrefix + "flag.y");
            int flagZ = warzoneRootSection.getInt(teamInfoPrefix + "flag.z");
            int flagYaw = warzoneRootSection.getInt(teamInfoPrefix + "flag.yaw");
            Location flagLocation = new Location(world, flagX, flagY, flagZ, flagYaw, 0);
            team.setTeamFlag(flagLocation);
          }
         
          String teamConfigPrefix = "team." + teamName + ".config";
          if (warzoneRootSection.contains(teamConfigPrefix)) {
            // team specific config
            ConfigurationSection teamConfigSection = warzoneRootSection.getConfigurationSection(teamConfigPrefix);
            team.getTeamConfig().loadFrom(teamConfigSection);
          } else if (warzoneRootSection.contains(teamConfigPrefix.toLowerCase())) {
            // try lowercase instead
            ConfigurationSection teamConfigSection = warzoneRootSection.getConfigurationSection(teamConfigPrefix.toLowerCase());
            team.getTeamConfig().loadFrom(teamConfigSection);
          }
         
          // LIFEPOOL INITIALIZATION HERE
          team.setRemainingLives(team.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
         
          String teamLoadoutPrefix = "team." + teamName + ".loadout";
          if (warzoneRootSection.contains(teamLoadoutPrefix)) {
            // team specific loadouts
            ConfigurationSection loadoutsSection = warzoneRootSection.getConfigurationSection(teamLoadoutPrefix);
            team.getInventories().setLoadouts(LoadoutYmlMapper.fromConfigToLoadouts(loadoutsSection, new HashMap<String, HashMap<Integer, ItemStack>>()));
          } else if (warzoneRootSection.contains(teamLoadoutPrefix.toLowerCase())) {
            // try lowercase instead
            ConfigurationSection loadoutsSection = warzoneRootSection.getConfigurationSection(teamLoadoutPrefix.toLowerCase());
            team.getInventories().setLoadouts(LoadoutYmlMapper.fromConfigToLoadouts(loadoutsSection, new HashMap<String, HashMap<Integer, ItemStack>>()));
          }
         
          String teamRewardPrefix = "team." + teamName + ".reward";
          if (warzoneRootSection.contains(teamRewardPrefix)) {
            // team specific reward
            ConfigurationSection rewardsSection = warzoneRootSection.getConfigurationSection(teamRewardPrefix);
            HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
            LoadoutYmlMapper.fromConfigToLoadout(rewardsSection, reward, "default");
            warzone.getDefaultInventories().setReward(reward);
          } else if (warzoneRootSection.contains(teamRewardPrefix.toLowerCase())) {
            // try lowercase instead
            ConfigurationSection rewardsSection = warzoneRootSection.getConfigurationSection(teamRewardPrefix.toLowerCase());
            HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
            LoadoutYmlMapper.fromConfigToLoadout(rewardsSection, reward, "default");
            warzone.getDefaultInventories().setReward(reward);
          }
        }
      }
      Connection connection = null;
      try {
        connection = ZoneVolumeMapper.getZoneConnection(warzone.getVolume(), warzone.getName(), warzone.getWorld());
      } catch (SQLException e) {
        War.war.getLogger().log(Level.WARNING, "Failed to load warzone structures volume", e);
      }
      // monument blocks
      for (Monument monument : warzone.getMonuments()) {
        try {
          monument.setVolume(warzone.loadStructure(monument.getName(), connection));
        } catch (SQLException e) {
          War.war.getLogger().log(Level.WARNING, "Failed to load warzone structures volume", e);
        }
      }
     
      // bomb blocks
      for (Bomb bomb : warzone.getBombs()) {
        try {
          bomb.setVolume(warzone.loadStructure("bomb-" + bomb.getName(), connection));
        } catch (SQLException e) {
          War.war.getLogger().log(Level.WARNING, "Failed to load warzone structures volume", e);
        }
      }
     
      // cake blocks
      for (Cake cake : warzone.getCakes()) {
        try {
          cake.setVolume(warzone.loadStructure("cake-" + cake.getName(), connection));
        } catch (SQLException e) {
          War.war.getLogger().log(Level.WARNING, "Failed to load warzone structures volume", e);
        }
      }
     
      // team spawn blocks
      for (Team team : warzone.getTeams()) {
        for (Location teamSpawn : team.getTeamSpawns()) {
          try {
            team.setSpawnVolume(teamSpawn, warzone.loadStructure(team.getName() + team.getTeamSpawns().indexOf(teamSpawn), connection));
          } catch (SQLException e) {
            War.war.getLogger().log(Level.WARNING, "Failed to load warzone structures volume", e);
          }
        }
        if (team.getTeamFlag() != null) {
          try {
            team.setFlagVolume(warzone.loadStructure(team.getName() + "flag", connection));
          } catch (SQLException e) {
            War.war.getLogger().log(Level.WARNING, "Failed to load warzone structures volume", e);
          }
        }
      }
View Full Code Here

Examples of com.tommytony.war.Team

    }
  }

  private void handleBreakOrDamage(Player player, Block block, Cancellable event) {
    Warzone warzone = Warzone.getZoneByLocation(player);
    Team team = Team.getTeamByPlayerName(player.getName());
    boolean isZoneMaker = War.war.isZoneMaker(player);

    if (warzone != null && team == null && !isZoneMaker) {
      // can't actually destroy blocks in a warzone if not part of a team
      War.war.badMsg(player, "build.denied.zone.outside");
      event.setCancelled(true);
      return;
    }
    // monument's center is destroyed
    if (team != null && block != null && warzone != null && warzone.isMonumentCenterBlock(block)) {
      Monument monument = warzone.getMonumentFromCenterBlock(block);
      if (monument.hasOwner()) {
        Team ownerTeam = monument.getOwnerTeam();
        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 + "freed by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
                          ownerTeam.getKind().getMaterial(),
                          ownerTeam.getKind().getData(),
                          10000);
            }
          }
        }
        warzone.broadcast("zone.monument.lose", ownerTeam.getName(), monument.getName());
        monument.uncapture();
      }
      event.setCancelled(false);
      return;
    }
    // changes in parts of important areas
    if (warzone != null && warzone.isImportantBlock(block) && (!isZoneMaker || (isZoneMaker && team != null))) {
      // breakage of spawn
      if (team != null && team.isSpawnLocation(block.getLocation())) {
        // let team members loot one block the spawn for monument captures
        if (player.getInventory().containsAtLeast(team.getKind().getBlockHead(), 1)) {
          War.war.badMsg(player, "build.denied.zone.multteam", team.getName());
          event.setCancelled(true);
          return;
        } else {
          event.setCancelled(false); // very important, otherwise could get cancelled but unbreakableZoneBlocks further down
          return;
        }
      }
      // stealing of flag
      if (team != null && warzone.isEnemyTeamFlagBlock(team, block)) {
        if (warzone.isFlagThief(player.getName())) {
          // detect audacious thieves
          War.war.badMsg(player, "zone.stealextra.flag");
        } else if (warzone.isBombThief(player.getName()) || warzone.isCakeThief(player.getName())) {
          War.war.badMsg(player, "zone.stealextra.other");
        } else {
          Team lostFlagTeam = warzone.getTeamForFlagBlock(block);
          if (lostFlagTeam.getPlayers().size() != 0) {
            // player just broke the flag block of other team: cancel to avoid drop, give player the block, set block to air
            ItemStack teamKindBlock = lostFlagTeam.getKind().getBlockHead();
            player.getInventory().clear();
            player.getInventory().addItem(teamKindBlock);
            warzone.addFlagThief(lostFlagTeam, player.getName());
            block.setType(Material.AIR);
            for (Team t : warzone.getTeams()) {
              t.teamcast("zone.steal.flag.broadcast", team.getKind().getColor() + player.getName() + ChatColor.WHITE, lostFlagTeam.getName());
              if (t.getName().equals(lostFlagTeam.getName())) {
                if (War.war.isSpoutServer()) {
                  for (Player p : t.getPlayers()) {
                    SpoutPlayer sp = SpoutManager.getPlayer(p);
                    if (sp.isSpoutCraftEnabled()) {
                              sp.sendNotification(
                                  SpoutDisplayer.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " stole"),
                                  SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "your flag!"),
                                  lostFlagTeam.getKind().getMaterial(),
                                  lostFlagTeam.getKind().getData(),
                                  5000);
                    }
                  }
                }
                t.teamcast("zone.steal.flag.prevent", team.getKind().getColor() + player.getName() + ChatColor.WHITE, team.getName());
              }
            }
            War.war.msg(player, "zone.steal.flag.notice", lostFlagTeam.getName());
          } else {
            War.war.msg(player, "zone.steal.flag.empty", lostFlagTeam.getName());
          }
        }
        event.setCancelled(true);
        return;
      } else if (team != null && warzone.isBombBlock(block)) {
View Full Code Here

Examples of com.tommytony.war.Team

import org.kitteh.tag.PlayerReceiveNameTagEvent;

public class WarTagListener implements Listener {
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onNameTag(PlayerReceiveNameTagEvent event) {
    Team team = Team.getTeamByPlayerName(event.getNamedPlayer().getName());
    if (team != null) {
      ChatColor teamColor = team.getKind().getColor();
      event.setTag(teamColor + event.getNamedPlayer().getName());
    }
  }
View Full Code Here

Examples of com.tommytony.war.Team

  @EventHandler
  public void onPlayerDropItem(final PlayerDropItemEvent event) {
    if (War.war.isLoaded()) {
      Player player = event.getPlayer();
      Team team = Team.getTeamByPlayerName(player.getName());
      if (team != null) {
        Warzone zone = Warzone.getZoneByPlayerName(player.getName());

        if (zone.isFlagThief(player.getName())) {
          // a flag thief can't drop his flag
          War.war.badMsg(player, "drop.flag.disabled");
          event.setCancelled(true);
        } else if (zone.isBombThief(player.getName())) {
          // a bomb thief can't drop his bomb
          War.war.badMsg(player, "drop.bomb.disabled");
          event.setCancelled(true);
        } else if (zone.isCakeThief(player.getName())) {
          // a cake thief can't drop his cake
          War.war.badMsg(player, "drop.cake.disabled");
          event.setCancelled(true);
        } else if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.NODROPS)) {
          War.war.badMsg(player, "drop.item.disabled");
          event.setCancelled(true);
        } else {
          Item item = event.getItemDrop();
          if (item != null) {
            ItemStack itemStack = item.getItemStack();
            if (itemStack != null && team.getKind().isTeamItem(itemStack)) {
              // Can't drop your team's kind block
              War.war.badMsg(player, "drop.team", team.getName());
              event.setCancelled(true);
              return;
            }

            if (zone.isNearWall(player.getLocation()) && itemStack != null) {
View Full Code Here

Examples of com.tommytony.war.Team

  private static final int MINIMUM_TEAM_BLOCKS = 1;
  @EventHandler
  public void onPlayerPickupItem(final PlayerPickupItemEvent event) {
    if (War.war.isLoaded()) {
      Player player = event.getPlayer();
      Team team = Team.getTeamByPlayerName(player.getName());
      if (team != null) {
        Warzone zone = Warzone.getZoneByPlayerName(player.getName());

        if (zone.isFlagThief(player.getName())) {
          // a flag thief can't pick up anything
          event.setCancelled(true);
        } else {
          Item item = event.getItem();
          if (item != null) {
            ItemStack itemStack = item.getItemStack();
            if (itemStack != null && team.getKind().isTeamItem(itemStack) &&
                player.getInventory().containsAtLeast(team.getKind().getBlockHead(), MINIMUM_TEAM_BLOCKS)) {
              // Can't pick up a second precious block
              event.setCancelled(true);
            }
          }
        }
View Full Code Here

Examples of com.tommytony.war.Team

  @EventHandler
  public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
    if (War.war.isLoaded()) {
      Player player = event.getPlayer();
      Team talkingPlayerTeam = Team.getTeamByPlayerName(player.getName());
      if (talkingPlayerTeam != null) {
        String msg = event.getMessage();
        String[] split = msg.split(" ");
        if (!War.war.isWarAdmin(player) && split.length > 0 && split[0].startsWith("/")) {
          String command = split[0].substring(1);
View Full Code Here

Examples of com.tommytony.war.Team

      if (zone != null && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.ENDER_CHEST && !zone.getWarzoneConfig().getBoolean(WarzoneConfig.ALLOWENDER)) {
        event.setCancelled(true);
        War.war.badMsg(player, "use.ender");
      }
      Team team = Team.getTeamByPlayerName(player.getName());
      if (zone != null && team != null && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && team.getTeamConfig().resolveBoolean(TeamConfig.XPKILLMETER)) {
        event.setCancelled(true);
        War.war.badMsg(player, "use.enchant");
        if (zone.getAuthors().contains(player.getName())) {
          War.war.badMsg(player, "use.xpkillmeter");
        }
      }
      if (zone != null && team != null && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.ANVIL && team.getTeamConfig().resolveBoolean(TeamConfig.XPKILLMETER)) {
        event.setCancelled(true);
        War.war.badMsg(player, "use.anvil");
        if (zone.getAuthors().contains(player.getName())) {
          War.war.badMsg(player, "use.xpkillmeter");
        }
View Full Code Here

Examples of com.tommytony.war.Team

    ZoneLobby locLobby = ZoneLobby.getLobbyByLocation(playerLoc);

    boolean isMaker = War.war.isZoneMaker(player);

    // Zone walls
    Team currentTeam = Team.getTeamByPlayerName(player.getName());
    Warzone playerWarzone = Warzone.getZoneByPlayerName(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
    boolean protecting = false;
    if (currentTeam != null) {
      if (playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.GLASSWALLS)) {
        protecting = playerWarzone.protectZoneWallAgainstPlayer(player);
      }
    } else {
      Warzone nearbyZone = War.war.zoneOfZoneWallAtProximity(playerLoc);
      if (nearbyZone != null && nearbyZone.getWarzoneConfig().getBoolean(WarzoneConfig.GLASSWALLS) && !isMaker) {
        protecting = nearbyZone.protectZoneWallAgainstPlayer(player);
      }
    }

    if (!protecting) {
      // zone makers still need to delete their walls
      // make sure to delete any wall guards as you leave
      for (Warzone zone : War.war.getWarzones()) {
        zone.dropZoneWallGuardIfAny(player);
      }
    }

    // Warzone lobby gates
    if (locLobby != null && currentTeam == null && locLobby.isInAnyGate(playerLoc)) {
      Warzone zone = locLobby.getZone();
      Team locTeamGate = locLobby.getTeamGate(playerLoc);
      if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED) || zone.isReinitializing()) {
        War.war.badMsg(player, "join.disabled");
        event.setTo(zone.getTeleport());
      } else if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.JOINMIDBATTLE) && zone.isEnoughPlayers()) {
        War.war.badMsg(player, "join.progress");
        event.setTo(zone.getTeleport());
      } else if (zone.isFull()) {
        War.war.badMsg(player, "join.full.all");
        event.setTo(zone.getTeleport());
      } else if (zone.isFull(player)) {
        War.war.badMsg(player, "join.permission.all");
        event.setTo(zone.getTeleport());
      } else if (locTeamGate != null && locTeamGate.isFull()) {
        War.war.badMsg(player, "join.full.single", locTeamGate.getName());
        event.setTo(zone.getTeleport());
      } else if (locTeamGate != null && !War.war.canPlayWar(player, locTeamGate)) {
        War.war.badMsg(player, "join.permission.single", locTeamGate.getName());
        event.setTo(zone.getTeleport());
      } else if (zone.getLobby().isAutoAssignGate(playerLoc)) {
        zone.autoAssign(player);
      } else if (locTeamGate != null) {
        zone.assign(player, locTeamGate);
      }
      return;
    } else if (locLobby != null && currentTeam == null
        && locLobby.isInWarHubLinkGate(playerLoc)
        && War.war.getWarHub() != null) {
      War.war.msg(player, "warhub.teleport");
      event.setTo(War.war.getWarHub().getLocation());
      return;
    }

    // Warhub zone gates
    WarHub hub = War.war.getWarHub();
    if (hub != null && hub.getVolume().contains(player.getLocation())) {
      Warzone zone = hub.getDestinationWarzoneForLocation(playerLoc);
      if (zone != null && zone.getTeleport() != null) {
        if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.AUTOJOIN)
            && zone.getTeams().size() >= 1 && currentTeam == null) {
          if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED) || zone.isReinitializing()) {
            War.war.badMsg(player, "join.disabled");
            event.setTo(hub.getLocation());
          } else if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.JOINMIDBATTLE) && zone.isEnoughPlayers()) {
            War.war.badMsg(player, "join.progress");
            event.setTo(hub.getLocation());
          } else if (zone.isFull()) {
            War.war.badMsg(player, "join.full.all");
            event.setTo(hub.getLocation());
          } else if (zone.isFull(player)) {
            War.war.badMsg(player, "join.permission.all");
            event.setTo(hub.getLocation());
          } else {
            zone.autoAssign(player);
          }
          return;
        }
        event.setTo(zone.getTeleport());
        War.war.msg(player, "zone.teleport", zone.getName());
        return;
      }
    }

    boolean isLeaving = playerWarzone != null && playerWarzone.getLobby().isLeavingZone(playerLoc);
    Team playerTeam = Team.getTeamByPlayerName(player.getName());
    if (isLeaving) { // already in a team and in warzone, leaving
      // same as leave
      if (playerTeam != null) {
        boolean atSpawnAlready = playerTeam.isSpawnLocation(playerLoc);
        if (!atSpawnAlready) {
          playerWarzone.handlePlayerLeave(player, playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.AUTOJOIN) ?
              War.war.getWarHub().getLocation() : playerWarzone.getTeleport(), event, true);
          return;
        }
        return;
      }
    }

    if (playerWarzone != null) {
      // Player belongs to a warzone team but is outside: he snuck out or is at spawn and died
      if (locZone == null && playerTeam != null && playerWarzone.getLobby() != null && !playerWarzone.getLobby().getVolume().contains(playerLoc) && !isLeaving) {
        List<BlockFace> nearestWalls = playerWarzone.getNearestWalls(playerLoc);
        if (!playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
          War.war.badMsg(player, "zone.leavenotice");
        }
        if(nearestWalls != null && nearestWalls.size() > 0) {
          // First, try to bump the player back in
          int northSouthMove = 0;
          int eastWestMove = 0;
          int upDownMove = 0;
          int moveDistance = 1;
         
          if (nearestWalls.contains(Direction.NORTH())) {
            // move south
            northSouthMove += moveDistance;
          } else if (nearestWalls.contains(Direction.SOUTH())) {
            // move north
            northSouthMove -= moveDistance;
          }
         
          if (nearestWalls.contains(Direction.EAST())) {
            // move west
            eastWestMove += moveDistance;
          } else if (nearestWalls.contains(Direction.WEST())) {
            // move east
            eastWestMove -= moveDistance;
          }
         
          if (nearestWalls.contains(BlockFace.UP)) {
            upDownMove -= moveDistance;
          } else if (nearestWalls.contains(BlockFace.DOWN)) {
            // fell off the map, back to spawn (still need to drop objects)
            playerWarzone.dropAllStolenObjects(event.getPlayer(), false);
            playerWarzone.respawnPlayer(event, playerTeam, event.getPlayer());
            return;
         
         
          event.setTo(new Location(playerLoc.getWorld(),
                      playerLoc.getX() + northSouthMove,
                      playerLoc.getY() + upDownMove,
                      playerLoc.getZ() + eastWestMove,
                      playerLoc.getYaw(),
                      playerLoc.getPitch()));
          return;
         
          // Otherwise, send him to spawn (first make sure he drops his flag/cake/bomb to prevent auto-cap and as punishment)
        } else {
          playerWarzone.dropAllStolenObjects(event.getPlayer(), false);
          playerWarzone.respawnPlayer(event, playerTeam, event.getPlayer());
          return;
        }
      }
           
      LoadoutSelection loadoutSelectionState = playerWarzone.getLoadoutSelections().get(player.getName());
      FlagReturn flagReturn = playerTeam.getTeamConfig().resolveFlagReturn();
      if (!playerTeam.isSpawnLocation(playerLoc)) {
        if (!playerWarzone.isEnoughPlayers() && loadoutSelectionState != null && loadoutSelectionState.isStillInSpawn()) {
          // Be sure to keep only players that just respawned locked inside the spawn for minplayer/minteams restrictions - otherwise
          // this will conflict with the can't-renter-spawn bump just a few lines below 
          War.war.badMsg(player, "zone.spawn.minplayers", playerWarzone.getWarzoneConfig().getInt(WarzoneConfig.MINPLAYERS),
              playerWarzone.getWarzoneConfig().getInt(WarzoneConfig.MINTEAMS));
          event.setTo(playerTeam.getRandomSpawn());
          return;
        }
        if (playerWarzone.isRespawning(player)) {
          int rt = playerTeam.getTeamConfig().resolveInt(TeamConfig.RESPAWNTIMER);
          War.war.badMsg(player, "zone.spawn.timer", rt);
          event.setTo(playerTeam.getRandomSpawn());
          return;
        }
        if (playerWarzone.isReinitializing()) {
          // don't let players wander about outside spawns during reset
          // (they could mess up the blocks that have already been reset
          // before the start of the new battle)
          War.war.msg(player, "zone.battle.reset");
          event.setTo(playerTeam.getRandomSpawn());
          return;
        }
      } else if (loadoutSelectionState != null && !loadoutSelectionState.isStillInSpawn()
          && !playerWarzone.isCakeThief(player.getName())
          && (flagReturn.equals(FlagReturn.BOTH) || flagReturn.equals(FlagReturn.SPAWN))
          && !playerWarzone.isFlagThief(player.getName())) {
       
        // player is in spawn, but has left already: he should NOT be let back in - kick him out gently
        // if he sticks around too long.
        // (also, be sure you aren't preventing the flag or cake from being captured)
//        if (!CantReEnterSpawnJob.getPlayersUnderSuspicion().contains(player.getName())) {
//          CantReEnterSpawnJob job = new CantReEnterSpawnJob(player, playerTeam);
//          War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job, 12);
//        }
        return;
      }

      // Monuments
      if (playerTeam != null && playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam) && player.getHealth() < 20 && player.getHealth() > 0 // don't heal the dead
          && this.random.nextInt(7) == 3) { // one chance out of many of getting healed
        int currentHp = (int) player.getHealth();
        int newHp = Math.min(20, currentHp + locZone.getWarzoneConfig().getInt(WarzoneConfig.MONUMENTHEAL));

        player.setHealth(newHp);
        double heartNum = ((double) newHp - currentHp) / 2;
        War.war.msg(player, "zone.monument.voodoo", heartNum);
        return;
      }

      // Flag capture
      if (playerWarzone.isFlagThief(player.getName())) {
       
        // smoky
        if (System.currentTimeMillis() % 13 == 0) {
          playerWarzone.getWorld().playEffect(player.getLocation(), Effect.POTION_BREAK, playerTeam.getKind().getPotionEffectColor());
        }
       
        // Make sure game ends can't occur simultaneously.
        // See Warzone.handleDeath() for details.
        boolean inSpawn = playerTeam.isSpawnLocation(player.getLocation());
        boolean inFlag = (playerTeam.getFlagVolume() != null && playerTeam.getFlagVolume().contains(player.getLocation()));

        if (playerTeam.getTeamConfig().resolveFlagReturn().equals(FlagReturn.BOTH)) {
          if (!inSpawn && !inFlag) {
            return;
          }
        } else if (playerTeam.getTeamConfig().resolveFlagReturn().equals(FlagReturn.SPAWN)) {
          if (inFlag) {
            War.war.badMsg(player, "zone.flagreturn.spawn");
            return;
          } else if (!inSpawn) {
            return;
          }
        } else if (playerTeam.getTeamConfig().resolveFlagReturn().equals(FlagReturn.FLAG)) {
          if (inSpawn) {
            War.war.badMsg(player, "zone.flagreturn.flag");
            return;
          } else if (!inFlag) {
            return;
          }
        }
       
        if (!playerTeam.getPlayers().contains(player)) {
          // Make sure player is still part of team, game may have ended while waiting)
          // Ignore the scorers that happened immediately after the game end.
          return;
        }

        if (playerWarzone.isTeamFlagStolen(playerTeam) && playerTeam.getTeamConfig().resolveBoolean(TeamConfig.FLAGMUSTBEHOME)) {
          War.war.badMsg(player, "zone.flagreturn.deadlock");
        } else {
          // flags can be captured at own spawn or own flag pole
          if (playerWarzone.isReinitializing()) {
            // Battle already ended or interrupted
            playerWarzone.respawnPlayer(event, playerTeam, player);
          } else {
            // All good - proceed with scoring
            playerTeam.addPoint();
            Team victim = playerWarzone.getVictimTeamForFlagThief(player.getName());
           
            // Notify everyone
            for (Team t : playerWarzone.getTeams()) {
              if (War.war.isSpoutServer()) {
                for (Player p : t.getPlayers()) {
                  SpoutPlayer sp = SpoutManager.getPlayer(p);
                  if (sp.isSpoutCraftEnabled()) {
                            sp.sendNotification(
                                SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
                                SpoutDisplayer.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
                                victim.getKind().getMaterial(),
                                victim.getKind().getData(),
                                10000);
                  }
                }
              }
              t.teamcast("zone.flagcapture.broadcast", playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE,
                  victim.getName(), playerTeam.getName());
            }
           
            // Detect win conditions
            if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
              if (playerWarzone.hasPlayerState(player.getName())) {
                playerWarzone.restorePlayerState(player);
              }
              playerWarzone.handleScoreCapReached(playerTeam.getName());
              event.setTo(playerWarzone.getTeleport());
            } else {
              // just added a point
              victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
              victim.initializeTeamFlag();
             
              playerWarzone.respawnPlayer(event, playerTeam, player);
              playerTeam.resetSign();
              playerWarzone.getLobby().resetTeamGateSign(playerTeam);
            }
          }
         
          playerWarzone.removeFlagThief(player.getName());
         
          return;
        }
      }
     
      // Bomb detonation
      if (playerWarzone.isBombThief(player.getName())) {
        // smoky
        playerWarzone.getWorld().playEffect(player.getLocation(), Effect.SMOKE, 0);
       
        // Make sure game ends can't occur simultaneously.
        // Not thread safe. See Warzone.handleDeath() for details.
        boolean inEnemySpawn = false;
        Team victim = null;
        for (Team team : playerWarzone.getTeams()) {
          if (team != playerTeam
              && team.isSpawnLocation(player.getLocation())
              && team.getPlayers().size() > 0) {
            inEnemySpawn = true;
            victim = team;
            break;
          }
        }
       
        if (inEnemySpawn && playerTeam.getPlayers().contains(player)) {
          // Made sure player is still part of team, game may have ended while waiting.
          // Ignored the scorers that happened immediately after the game end.
          Bomb bomb = playerWarzone.getBombForThief(player.getName());
         
          // Boom!
          if (!playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)) {
            // Don't blow up if warzone is unbreakable
            playerWarzone.getWorld().createExplosion(player.getLocation(), 2F);
          }
         
          if (playerWarzone.isReinitializing()) {
            // Battle already ended or interrupted
            playerWarzone.respawnPlayer(event, playerTeam, player);
          } else {
            // All good - proceed with scoring
            playerTeam.addPoint();
           
            // Notify everyone
            for (Team t : playerWarzone.getTeams()) {
              if (War.war.isSpoutServer()) {
                for (Player p : t.getPlayers()) {
                  SpoutPlayer sp = SpoutManager.getPlayer(p);
                  if (sp.isSpoutCraftEnabled()) {
                            sp.sendNotification(
                                SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " blew up "),
                                SpoutDisplayer.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + "'s spawn!"),
                                victim.getKind().getMaterial(),
                                victim.getKind().getData(),
                                10000);
                  }
                }
              }
              t.teamcast("zone.bomb.broadcast", playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE,
                  victim.getName(), playerTeam.getName());
            }
           
            // Detect win conditions
            if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
              if (playerWarzone.hasPlayerState(player.getName())) {
                playerWarzone.restorePlayerState(player);
              }
              playerWarzone.handleScoreCapReached(playerTeam.getName());
              event.setTo(playerWarzone.getTeleport());
            } else {
              // just added a point
             
              // restore bombed team's spawn
              for (Volume spawnVolume : victim.getSpawnVolumes().values()) {
                spawnVolume.resetBlocks();
              }
              victim.initializeTeamSpawns();
             
              // bring back tnt
              bomb.getVolume().resetBlocks();
              bomb.addBombBlocks();
             
View Full Code Here

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
TOP
Copyright © 2018 www.massapi.com. 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.