Package org.mctourney.autoreferee

Examples of org.mctourney.autoreferee.AutoRefTeam


public class FindPlayerTest
{
  @Test
  public void testNameLookup()
  {
    AutoRefTeam team = new AutoRefTeam();

    AutoRefPlayer p1 = new AutoRefPlayer("jcll"    , null);
    AutoRefPlayer p2 = new AutoRefPlayer("nosrepa" , null);
    AutoRefPlayer p3 = new AutoRefPlayer("coestar" , null);
    AutoRefPlayer p4 = new AutoRefPlayer("dewtroid", null);
    AutoRefPlayer pX = new AutoRefPlayer("jcllpony", null);

    team.addPlayer(p1);
    team.addPlayer(p2);

    Assert.assertNull(team.getPlayer("c"));
    Assert.assertNull(team.getPlayer("jcp"));

    team.addPlayer(p3);
    team.addPlayer(p4);

    Assert.assertEquals(p1, team.getPlayer("jc"));
    Assert.assertEquals(p2, team.getPlayer("nos"));
    Assert.assertEquals(p3, team.getPlayer("c"));

    Assert.assertNull(team.getPlayer("dewtroid!"));
  }
View Full Code Here


      else tplocation = match.getLastTeleportLocation();
      tplocation = TeleportationUtil.locationTeleport(tplocation);
    }
    else if (options.hasOption('s'))
    {
      AutoRefTeam team = match.getTeam(options.getOptionValue('s'));
      if (team != null) tplocation = team.getSpawnLocation();
      else tplocation = match.getWorld().getSpawnLocation();
      tplocation = TeleportationUtil.locationTeleport(tplocation);
    }
    else if (options.hasOption('o'))
    {
      AutoRefTeam team = match.getTeam(options.getOptionValue('o'));
      if (team != null) tplocation = team.getLastObjectiveLocation();
      else tplocation = match.getLastObjectiveLocation();
      tplocation = TeleportationUtil.locationTeleport(tplocation);
    }
    else if (options.hasOption('v'))
    {
      AutoRefTeam team = match.getTeam(options.getOptionValue('v'));
      if (team != null) tplocation = team.getVictoryMonumentLocation();
      tplocation = TeleportationUtil.locationTeleport(tplocation);
    }
    else if (options.hasOption('r'))
    {
      tplocation = match.getSpectator(player).prevLocation();
View Full Code Here

  public boolean setTeamName(CommandSender sender, AutoRefMatch match, String[] args, CommandLine options)
  {
    if (match == null) return false;

    // get the team with the specified name
    AutoRefTeam team = match.getTeam(args[0]);
    if (team == null)
    {
      sender.sendMessage(ChatColor.DARK_GRAY + args[0] +
        ChatColor.RESET + " is not a valid team.");
      sender.sendMessage("Teams are " + match.getTeamList());
    }
    else team.setName(args[1]);
    return true;
  }
View Full Code Here

  public boolean swapTeams(CommandSender sender, AutoRefMatch match, String[] args, CommandLine options)
  {
    if (match == null) return false;

    AutoRefTeam team1 = match.getTeam(args[0]);
    AutoRefTeam team2 = match.getTeam(args[1]);

    if (team1 == null)
    {
      sender.sendMessage(ChatColor.DARK_GRAY + args[0] +
        ChatColor.RESET + " is not a valid team.");
View Full Code Here

  public boolean setScore(CommandSender sender, AutoRefMatch match, String[] args, CommandLine options)
  {
    if (match == null || !match.getCurrentState().inProgress()) return false;

    // get the named team
    AutoRefTeam team = match.getTeam(args[0]);
    if (team == null) return false;

    // find the named goal for this team
    ScoreDummyGoal goal = null;
    for (ScoreDummyGoal dgoal : team.getTeamGoals(ScoreDummyGoal.class))
      if (args[1].equalsIgnoreCase(dgoal.getName())) goal = dgoal;
    if (goal == null) return false;

    try
    {
      // go ahead and set the goal to the new score
      goal.setScore(Double.parseDouble(args[2]));

      // update objectives and recheck win conditions
      team.updateObjectives();
      match.checkWinConditions();
    }
    catch (NumberFormatException e) {  }

    return true;
View Full Code Here

      return true;
    }

    if (args.length > 0)
    {
      AutoRefTeam team = match.getTeam(args[0]);
      Set<BlockData> searching = ObjectiveExhaustion.startSearch(team, plugin);
      if (searching != null && !searching.isEmpty())
      {
        StringBuilder sb = new StringBuilder(ChatColor.YELLOW + "Search started for team ");
        sb.append(team.getDisplayName()).append(ChatColor.RESET).append(ChatColor.YELLOW);
        sb.append(" for the blocks ");
        for (BlockData bd : searching)
          sb.append(bd.getDisplayName()).append(", ");
        sender.sendMessage(sb.toString());
      } else
View Full Code Here

      newmatch.setStartTime(match.getStartTime());
      newmatch.setCurrentState(match.getCurrentState());

      for (Player p : match.getWorld().getPlayers())
      {
        AutoRefTeam team = match.getPlayerTeam(p);
        if (team != null)
        {
          AutoRefTeam newteam = newmatch.getTeam(team.getDefaultName());
          newteam.join(p, Reason.AUTOMATIC, true);
        }

        // teleport the player to location in new map
        Location loc = p.getLocation();
        loc.setWorld(newmatch.getWorld());
View Full Code Here

    {
      transcript.write(transcriptEventHTML(match, e));
      if (e.getType() != TranscriptEvent.EventType.MATCH_END) endEvent = e;
    }

    AutoRefTeam win = match.getWinningTeam();
    String winningTeam = (win == null) ? "??" :
      String.format("<span class='team team-%s'>%s</span>",
        getTag(win), ChatColor.stripColor(win.getDisplayName()));

    Set<String> refList = Sets.newHashSet();
    for (Player pl : match.getReferees())
      refList.add(String.format("<span class='referee'>%s</span>", pl.getName()));
View Full Code Here

    // if there is no match, or the plugin is running in auto-mode, quit
    if (match == null) return false;
    boolean isref = sender.hasPermission("autoreferee.referee");

    // get the target team
    AutoRefTeam team = args.length > 0 ? match.getTeam(args[0]) :
      match.getArbitraryTeam();

    if (team == null)
    {
      // team name is invalid. let the player know
View Full Code Here

      match.setRefereeReady(rstate);
    }
    else
    {
      AutoRefTeam team = match.getPlayerTeam(player);
      if (team != null) team.setReady(rstate);
    }

    match.checkTeamsStart();
    return true;
  }
View Full Code Here

TOP

Related Classes of org.mctourney.autoreferee.AutoRefTeam

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.