Package com.tommytony.war

Examples of com.tommytony.war.Team


     
      // border in color of team
      GenericGradient teamGradient = new GenericGradient();
      teamGradient.setAnchor(WidgetAnchor.TOP_LEFT);
     
      Team team = Team.getTeamByPlayerName(playerName);
     
      Color spoutColor = new Color(250.0F, 250.0F, 250.0F, 1.0F);
      if (team != null) {
        spoutColor = team.getKind().getSpoutColor();
      }
      spoutColor.setAlpha(0.5F);
     
      teamGradient.setY(2 + LINE_HEIGHT_WITH_MARGIN);
      teamGradient.setTopColor(spoutColor);
View Full Code Here


       * they shouldn't have enabled killstreaks in the warzone anyway.
       */
      return;
    }
    final Warzone zone = Warzone.getZoneByPlayerName(player.getName());
    final Team playerTeam = Team.getTeamByPlayerName(player.getName());
    Validate.notNull(zone, "Cannot reward player if they are not in a warzone");
    Validate.notNull(playerTeam, "Cannot reward player if they are not in a team");
    if (section.contains(Integer.toString(kills))) {
      ConfigurationSection killSection = section.getConfigurationSection(Integer.toString(kills));
      if (killSection.contains("message")) {
        final String playerName = playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE;
        final String message = ChatColor.translateAlternateColorCodes('&', MessageFormat.format(killSection.getString("message"), playerName));
        for (Team team : zone.getTeams()) {
          team.teamcast(message);
        }
      }
      if (killSection.contains("privmsg")) {
        War.war.msg(player, ChatColor.translateAlternateColorCodes('&', killSection.getString("privmsg")));
      }
      if (killSection.contains("reward.health")) {
        double health = player.getHealth() + killSection.getInt("reward.health");
        player.setHealth(health > 20 ? 20 : health); // Grant up to full health only
      }
      if (killSection.contains("reward.items")) {
        for (Object obj : killSection.getList("reward.items")) {
          if (obj instanceof ItemStack) {
            player.getInventory().addItem((ItemStack) obj);
          }
        }
      }
      if (killSection.contains("reward.xp") && !playerTeam.getTeamConfig().resolveBoolean(TeamConfig.XPKILLMETER)) {
        // Will not work if XPKILLMETER is enabled
        player.setLevel(player.getLevel() + killSection.getInt("reward.xp"));
      }
      if (killSection.contains("reward.points")) {
        for (int i = 0; i < killSection.getInt("reward.points"); i++) {
          playerTeam.addPoint();
        }
        // Detect win conditions
        if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
          player.getServer().getScheduler().runTaskLater(War.war, new Runnable() {
            public void run() {
              zone.handleScoreCapReached(playerTeam.getName());
            }
          }, 1L);
        } else {
          // just added a point
          playerTeam.resetSign();
          zone.getLobby().resetTeamGateSign(playerTeam);
        }
      }
      if (killSection.getBoolean("reward.airstrike")) {
        this.airstrikePlayers.add(player.getName());
View Full Code Here

    Player player = null;
    CommandSender commandSender = this.getSender();
    boolean isFirstParamWarzone = false;
    boolean wantsToPrint = false;
   
    Team team = null;

    if (this.args.length == 0) {
      return false;
    } else {
      if (!this.args[0].contains(":")) {
        // warzone name maybe in first place
        Warzone zoneByName = Warzone.getZoneByName(this.args[0]);
        if (zoneByName != null) {
          zone = zoneByName;
          isFirstParamWarzone = true;
        } else if (this.args[0].equals("-p") || this.args[0].equals("print")) {
          wantsToPrint = true;
        }
      }

      if (this.getSender() instanceof Player) {
        player = (Player) commandSender;

        if (zone == null) {
          // zone not found, is he standing in it?
          Warzone zoneByLoc = Warzone.getZoneByLocation(player);
          ZoneLobby lobbyByLoc = ZoneLobby.getLobbyByLocation(player);
          if (zoneByLoc == null && lobbyByLoc != null) {
            zoneByLoc = lobbyByLoc.getZone();
          }
          if (zoneByLoc != null) {
            zone = zoneByLoc;
          }
        }
       
        team = Team.getTeamByPlayerName(player.getName());
      }

      if (zone == null) {
        // No warzone found, whatever the mean, escape
        return false;
      }
     
      if (isFirstParamWarzone) {
        if (this.args.length == 1) {
          // Only one param: the warzone name - pritn usage
          return false;
        }
        // More than one param: the arguments need to be shifted
        String[] newargs = new String[this.args.length - 1];
        for (int i = 1; i < this.args.length; i++) {
          newargs[i - 1] = this.args[i];
        }
        this.args = newargs;
      }

      // args have been shifted if needed
      if (this.args.length > 0) {
        TeamKind kind = TeamKind.teamKindFromString(this.args[0]);
        Team teamByName = zone.getTeamByKind(kind);
       
        if (team == null && teamByName == null) {
          // Team not found
          this.badMsg("No such team. Use /teams.");
          return true;
View Full Code Here

      return false;
    } else if (!this.isSenderAuthorOfZone(zone)) {
      return true;
    }

    Team teamFlagTeam = null;
    for (Team team : zone.getTeams()) {
      if (team.getName().startsWith(this.args[0].toLowerCase())) {
        teamFlagTeam = team;
      }
    }
    if (teamFlagTeam != null) {
      teamFlagTeam.deleteTeamFlag();
     
      WarzoneYmlMapper.save(zone);
      this.msg(teamFlagTeam.getName() + " flag removed.");
      War.war.log(this.getSender().getName() + " deleted team " + teamFlagTeam.getName() + " flag in warzone " + zone.getName(), Level.INFO);
    } else {
      this.badMsg("No such team flag.");
    }

    return true;
View Full Code Here

    } else if (!this.isSenderAuthorOfZone(zone)) {
      return true;
    }

    TeamKind kind = TeamKind.teamKindFromString(this.args[0]);
    Team team = zone.getTeamByKind(kind);
    if (team == null) {
      // no such team yet
      this.msg("Place the team spawn first.");
    } else if (team.getFlagVolume() == null) {
      // new team flag
      team.setTeamFlag(player.getLocation());
      Location playerLoc = player.getLocation();
      player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ()));
      this.msg("Team " + team.getName() + " flag added here.");
      WarzoneYmlMapper.save(zone);
      War.war.log(this.getSender().getName() + " created team " + team.getName() + " flag in warzone " + zone.getName(), Level.INFO);
    } else {
      // relocate flag
      team.getFlagVolume().resetBlocks();
      team.setTeamFlag(player.getLocation());
      Location playerLoc = player.getLocation();
      player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ() + 1));
      this.msg("Team " + team.getName() + " flag moved.");
      WarzoneYmlMapper.save(zone);
      War.war.log(this.getSender().getName() + " moved team " + team.getName() + " flag in warzone " + zone.getName(), Level.INFO);
    }

    return true;
  }
View Full Code Here

      this.autoAssignGate = lobbyMiddleWallBlock.getLocation();
    } else {
      this.autoAssignGate = null;
      for (int doorIndex = 0; doorIndex < this.warzone.getTeams().size(); doorIndex++) {
        // 0 at center, 1 to the left, 2 to the right, 3 to the left, etc
        Team team = this.warzone.getTeams().get(doorIndex);
        if (this.warzone.getTeams().size() % 2 == 0) {
          // even number of teams
          if (doorIndex % 2 == 0) {
            this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getRelative(rightSide, doorIndex * 2 + 2).getLocation());
          } else {
            this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getRelative(leftSide, doorIndex * 2).getLocation());
          }

        } else {
          if (doorIndex == 0) {
            this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getLocation());
          } else if (doorIndex % 2 == 0) {
            this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getRelative(rightSide, doorIndex * 2).getLocation());
          } else {
            this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getRelative(leftSide, doorIndex * 2 + 2).getLocation());
          }
        }
      }
    }
    this.warHubLinkGate = lobbyMiddleWallBlock.getRelative(this.wall, 9).getLocation();
View Full Code Here

            }
          }
         
          // check for thieves without their treasure in their hands
          if (zone.isFlagThief(player.getName())) {
            Team victim = zone.getVictimTeamForFlagThief(player.getName());
            player.setItemInHand(null);
            player.getInventory().addItem(victim.getKind().getBlockData().toItemStack(2240));
          } else if (zone.isBombThief(player.getName())) {
            player.setItemInHand(null);
            player.getInventory().addItem(new ItemStack(Material.TNT, 2240));
          } else if (zone.isCakeThief(player.getName())) {
            player.setItemInHand(null);
View Full Code Here

    TeamKind teamKind = TeamKind.teamKindFromString(this.args[0]);
   
    if (teamKind == null) {
      return false;
    } else {
      Team existingTeam = zone.getTeamByKind(teamKind);
      if (existingTeam != null) {
        // add additional spawn
        existingTeam.addTeamSpawn(player.getLocation());
        this.msg("Additional spawn added for team " + existingTeam.getName() + ". Use /deleteteam " + existingTeam.getName() + " to remove all spawns.");
        War.war.log(this.getSender().getName() + " moved team " + existingTeam.getName() + " in warzone " + zone.getName(), Level.INFO);
      } else {
        // new team (use default TeamKind name for now)
        Team newTeam = new Team(teamKind.toString(), teamKind, Collections.<Location>emptyList(), zone);
        newTeam.setRemainingLives(newTeam.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
        zone.getTeams().add(newTeam);
        if (zone.getLobby() != null) {
          zone.getLobby().setLocation(zone.getTeleport());
          zone.getLobby().initialize();
        }
        newTeam.addTeamSpawn(player.getLocation());
        this.msg("Team " + newTeam.getName() + " created with spawn here.");
        War.war.log(this.getSender().getName() + " created team " + newTeam.getName() + " in warzone " + zone.getName(), Level.INFO);
      }
    }

    WarzoneYmlMapper.save(zone);
View Full Code Here

            try {
              original.renameTo(modified);
            } catch (Exception ignored) {
            }

            Team team = new Team(teamStrSplit[0], TeamKind.teamKindFromString(teamStrSplit[0]), Arrays.asList(teamLocation), warzone);
            team.setRemainingLives(warzone.getTeamDefaultConfig().resolveInt(TeamConfig.LIFEPOOL));
            warzone.getTeams().add(team);
          }
        }
      }

      // teamFlags
      String teamFlagsStr = warzoneConfig.getString("teamFlags");
      if (teamFlagsStr != null && !teamFlagsStr.equals("")) {
        String[] teamFlagsSplit = teamFlagsStr.split(";");
        for (String teamFlagStr : teamFlagsSplit) {
          if (teamFlagStr != null && !teamFlagStr.equals("")) {
            String[] teamFlagStrSplit = teamFlagStr.split(",");
            Team team = warzone.getTeamByKind(TeamKind.teamKindFromString(teamFlagStrSplit[0]));
            if (team != null) {
              int teamFlagX = Integer.parseInt(teamFlagStrSplit[1]);
              int teamFlagY = Integer.parseInt(teamFlagStrSplit[2]);
              int teamFlagZ = Integer.parseInt(teamFlagStrSplit[3]);
              Location teamFlagLocation = new Location(world, teamFlagX, teamFlagY, teamFlagZ);
              if (teamFlagStrSplit.length > 4) {
                int yaw = Integer.parseInt(teamFlagStrSplit[4]);
                teamFlagLocation.setYaw(yaw);
              }
              team.setTeamFlag(teamFlagLocation); // this may screw things up
            }
          }
        }
      }

      // lobby
      String lobbyStr = warzoneConfig.getString("lobby");

      warzoneConfig.close();

      if (createNewVolume) {
        ZoneVolume zoneVolume = new ZoneVolume(warzone.getName(), world, warzone); // VolumeMapper.loadZoneVolume(warzone.getName(), warzone.getName(), war, warzone.getWorld(), warzone);
        warzone.setVolume(zoneVolume);
      }

      // monument blocks
      for (Monument monument : warzone.getMonuments()) {
        try {
          monument.setVolume(VolumeMapper.loadVolume(monument.getName(), warzone.getName(), world));
        } catch (SQLException e) {
          War.war.getLogger().log(Level.WARNING, "Failed to load some ambiguous old volume", e);
        }
      }

      // team spawn blocks
      for (Team team : warzone.getTeams()) {
        for (Location spawnLocation : team.getTeamSpawns()) {
          try {
            team.setSpawnVolume(spawnLocation, VolumeMapper.loadVolume(team.getName() + "0", warzone.getName(), world));
          } catch (SQLException e) {
            War.war.getLogger().log(Level.WARNING, "Failed to load some ambiguous old volume", e);
          }
        }
        if (team.getTeamFlag() != null) {
          try {
            team.setFlagVolume(VolumeMapper.loadVolume(team.getName() + "flag", warzone.getName(), world));
          } catch (SQLException e) {
            War.war.getLogger().log(Level.WARNING, "Failed to load some ambiguous old volume", e);
          }
        }
      }
View Full Code Here

      return false;
    } else if (!this.isSenderAuthorOfZone(zone)) {
      return true;
    }

    Team team = zone.getTeamByKind(TeamKind.teamKindFromString(this.args[0]));
    if (team != null) {
      if (team.getFlagVolume() != null) {
        team.getFlagVolume().resetBlocks();
      }
      for (Volume spawnVolume : team.getSpawnVolumes().values()) {
        spawnVolume.resetBlocks();
      }
      zone.getTeams().remove(team);
      if (zone.getLobby() != null) {
        zone.getLobby().setLocation(zone.getTeleport());
        zone.getLobby().initialize();
      }
      WarzoneYmlMapper.save(zone);
      this.msg("Team " + team.getName() + " removed.");
      War.war.log(this.getSender().getName() + " deleted team " + team.getName() + " in warzone " + zone.getName(), Level.INFO);
    } else {
      this.badMsg("No such team.");
    }

    return true;
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.