Package org.mctourney.autoreferee

Examples of org.mctourney.autoreferee.AutoRefPlayer


  @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"));
View Full Code Here


  {
    // if there is no match, quit
    if (match == null) return false;

    Player player = (Player) sender;
    AutoRefPlayer target = args.length > 0 ? match.getPlayer(args[0])
      : match.getNearestPlayer(player.getLocation());

    // if there is a target, show an inventory
    if (target != null)
    {
      // if -p, show previous target's inventory
      if (options.hasOption('p')) target.showSavedInventory(player);
      else target.showInventory(player);
    }

    return true;
  }
View Full Code Here

    Location tplocation = null;
    String targetcoords = "";

    if (options.hasOption('b'))
    {
      AutoRefPlayer apl = match.getPlayer(options.getOptionValue('b'));
      Location bedloc = apl == null ? null : apl.getBedLocation();
      if (bedloc == null)
      {
        player.sendMessage(apl.getDisplayName() + ChatColor.DARK_GRAY + " does not have a bed set.");
        return true;
      }
      else tplocation = TeleportationUtil.blockTeleport(bedloc);
    }
    else if (options.hasOption('d'))
    {
      AutoRefPlayer apl = match.getPlayer(options.getOptionValue('d'));
      if (apl != null) tplocation = apl.getLastDeathLocation();
      else tplocation = match.getLastDeathLocation();

      targetcoords = "(" + LocationUtil.toBlockCoords(tplocation) + ")";
      tplocation = TeleportationUtil.locationTeleport(tplocation);
    }
    else if (options.hasOption('l'))
    {
      AutoRefPlayer apl = match.getPlayer(options.getOptionValue('l'));
      if (apl != null) tplocation = apl.getLastLogoutLocation();
      else tplocation = match.getLastLogoutLocation();
      tplocation = TeleportationUtil.locationTeleport(tplocation);
    }
    else if (options.hasOption('t'))
    {
      AutoRefPlayer apl = match.getPlayer(options.getOptionValue('t'));
      if (apl != null) tplocation = apl.getLastTeleportLocation();
      else tplocation = match.getLastTeleportLocation();
      tplocation = TeleportationUtil.locationTeleport(tplocation);
    }
    else if (options.hasOption('s'))
    {
View Full Code Here

    // get the kit with this name (case sensitive)
    PlayerKit kit = match.getKit(args[0]);
    if (kit == null) { sender.sendMessage("Not a valid kit: " + args[0]); return true; }

    // get the receiver
    AutoRefPlayer apl = match.getPlayer(args[1]);
    if (apl == null) { sender.sendMessage("Not a valid player: " + args[1]); return true; }

    kit.giveTo(apl);
    sender.sendMessage("Gave kit " + ChatColor.GOLD + kit.getName() +
      ChatColor.RESET + " to player " + apl.getDisplayName());
    return true;
  }
View Full Code Here

    int rank = 0;
    StringWriter playerstats = new StringWriter();
    for (AutoRefPlayer apl : players)
    {
      // get nemesis of this player
      AutoRefPlayer nms = Collections.max(players, new NemesisComparator(apl));
      if (nms != null && nms.getTeam() != null && nms.getTeam() == apl.getTeam()) nms = null;

      playerstats.write(String.format("<tr><td>%d</td><td>%s</td>",
        ++rank, playerHTML(apl)));
      playerstats.write(String.format("<td>%d (%d)</td><td>%d</td><td>%s</td>",
        apl.getKills(), apl.getAssists(), apl.getDeathCount(), apl.getExtendedAccuracyInfo()));
View Full Code Here

    for (Object actor : e.getActors())
    {
      if (actor instanceof AutoRefPlayer)
      {
        AutoRefPlayer apl = (AutoRefPlayer) actor;
        tagdata += String.format(" data-player='%s'", apl.getName());
      }

      if (actor instanceof BlockData)
      {
        BlockData bd = (BlockData) actor;
        int mat = bd.getMaterial().getId();
        int data = bd.getData();

        m = m.replaceAll(bd.getName(), String.format(
          "<span class='block mat-%d data-%d'>%s</span>",
            mat, data, bd.getName()));
      }
    }

    for (AutoRefPlayer apl : match.getPlayers())
      if (m.contains(apl.getName()))
    {
      m = m.replaceAll(apl.getName(), playerHTML(apl));
      rowClasses.add("type-player-event");
      rowClasses.add("player-" + getTag(apl));
    }

    String coords = LocationUtil.toBlockCoords(e.getLocation());
View Full Code Here

    Location locUnder = event.getTo().clone().add(0.0, -0.1, 0.0);
    int blockUnder = match.getWorld().getBlockTypeIdAt(locUnder);
    boolean onGround = (blockUnder != Material.AIR.getId());

    AutoRefPlayer apl = match.getPlayer(player);
    if (apl == null)
    {
      // if the player is not on a team and has left the start area, teleport back
      if (!match.isSpectator(player) && !match.inStartRegion(event.getTo()) && onGround)
      {
        player.teleport(match.getWorldSpawn());
        player.setFallDistance(0.0f);
      }
      return;
    }

    AutoRefTeam team = apl.getTeam();
    if (team == null) return;

    // announce region (for cosmetic regions)
    for (AutoRefRegion reg : team.getRegions())
      if (reg.getName() != null && reg.isEnterEvent(event)) reg.announceRegion(apl);

    double fallspeed = event.getFrom().getY() - event.getTo().getY();
    Location exit = apl.getExitLocation();

    // don't bother if the player isn't in survival mode
    if (player.getGameMode() != GameMode.SURVIVAL
      || match.inStartRegion(event.getTo())) return;

    // if a player leaves the start region...
    if (!match.inStartRegion(event.getTo()))
    {
      if (match.getCurrentState().inProgress())
      {
        // if they are leaving the start region, clear everything
        if (match.inStartRegion(event.getFrom()) && !apl.isActive()) apl.reset();

        // one way or another, the player is now active
        apl.setActive();
      }

      else if (match.getCurrentState().isBeforeMatch())
      { if (onGround) apl.die(null, false); return; }
    }

    // if they have left their region, mark their exit location
    if (!team.canEnter(event.getTo(), 0.3) && !player.isSleeping())
    {
      // player is sneaking off the edge and not in freefall
      if (player.isSneaking() && team.canEnter(event.getTo()) && fallspeed < FREEFALL_THRESHOLD);

      // if there is no exit position, set the exit position
      else if (exit == null) apl.setExitLocation(player.getLocation());

      // if there is an exit position and they aren't falling, kill them
      else if (exit != null && fallspeed < FREEFALL_THRESHOLD && onGround)
        apl.die(AutoRefPlayer.VOID_DEATH, true);
    }

    // player inside region
    else
    {
      // if there is an exit location
      if (exit != null)
      {
        // if the player traveled too far through the void, kill them
        if (player.getLocation().distance(exit) > SAFE_TRAVEL_DISTANCE)
          apl.die(AutoRefPlayer.VOID_DEATH, true);

        // reset exit location since player in region
        apl.setExitLocation(null);
      }
    }
  }
View Full Code Here

    if (match == null || match.getCurrentState() == MatchStatus.NONE) return;

    if (event.getEntityType() == EntityType.ENDER_PEARL)
    {
      Player player = (Player) event.getEntity().getShooter();
      AutoRefPlayer apl = match.getPlayer(player);

      if (apl != null && apl.getTeam().hasFlag(player.getLocation(), Flag.NO_ENTRY))
      {
        String msg = ChatColor.DARK_GRAY + apl.getDisplayName() +
          ChatColor.DARK_GRAY + " has thrown an enderpearl while out of bounds.";
        for (Player ref : match.getReferees()) ref.sendMessage(msg);
      }
    }
  }
View Full Code Here

    // if the match isn't currently in progress, a player should
    // not be allowed to place or destroy blocks anywhere
    if (!match.getCurrentState().inProgress()) return false;

    // if the player is not in their lane, they shouldn't be allowed to interact
    AutoRefPlayer apl = match.getPlayer(player);
    if (apl == null || apl.getExitLocation() != null) return false;

    // seems okay!
    return true;
  }
View Full Code Here

    if (match == null) return;

    if (!validPlayer(player))
    { event.setCancelled(true); return; }

    AutoRefPlayer apl = match.getPlayer(player);
    if (apl != null && apl.getTeam().hasFlag(b, AutoRefRegion.Flag.NO_BUILD, false))
    { event.setCancelled(true); return; }
  }
View Full Code Here

TOP

Related Classes of org.mctourney.autoreferee.AutoRefPlayer

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.