Package org.mctourney.autoreferee

Examples of org.mctourney.autoreferee.AutoRefPlayer


  public void healthArmorChange(Entity entity)
  {
    AutoRefMatch match = plugin.getMatch(entity.getWorld());
    if (match != null && entity.getType() == EntityType.PLAYER)
    {
      AutoRefPlayer apl = match.getPlayer((Player) entity);
      if (apl != null) plugin.getServer().getScheduler()
        .runTask(plugin, new HealthArmorChangeTask(apl));
    }
  }
View Full Code Here


    {
      int crafted = countItemInInventory() - this.count;
      AutoRefMatch match = plugin.getMatch(player.getWorld());
      if (match == null || !match.getCurrentState().inProgress()) return;

      AutoRefPlayer apl = match.getPlayer((Player) player);
      AchievementPoints ach = AchievementPoints.getEquipmentCraft(type);
      if (apl != null) apl.addPoints(ach, crafted / this.size);
    }
View Full Code Here

    // leave the team, if necessary
    AutoRefTeam team = plugin.getTeam(player);
    if (team != null) match.messageReferees("player", player.getName(), "logout");
    if (team != null && !match.getCurrentState().inProgress()) team.leave(player);

    AutoRefPlayer apl = match.getPlayer(player);
    if (apl != null && player.getLocation() != null)
      apl.setLastLogoutLocation(player.getLocation());

    // if this player was damaged recently (during the match), notify
    if (match.getCurrentState().inProgress() && apl != null && !apl.isDead() && apl.wasDamagedRecently())
    {
      String message = apl.getDisplayName() + ChatColor.GRAY + " logged out during combat " +
        String.format("with %2.1f hearts remaining", apl.getPlayer().getHealth() / 2.0);
      for (Player ref : match.getReferees(true)) ref.sendMessage(message);
    }
  }
View Full Code Here

    HumanEntity he = event.getPlayer();
    if (!(he instanceof Player)) return;
    Player pl = (Player) he;

    AutoRefMatch match = plugin.getMatch(pl.getWorld());
    AutoRefPlayer apl = match == null ? null : match.getPlayer(pl);

    if (match == null || apl == null)
    { return; }
    if (apl.getTeam() == null)
    { return; }

    InventoryHolder holder = event.getInventory().getHolder();

    if (holder == pl)
    { apl.clearActiveInventoryInfo(); return; }

    String holderDescription;
    Location location;
    if (holder instanceof BlockState)
    {
      BlockState h = (BlockState) holder;
      location = h.getLocation();
      holderDescription = h.getType().toString();
    }
    else if (holder instanceof DoubleChest)
    {
      DoubleChest c = (DoubleChest) holder;
      location = c.getLocation();
      holderDescription = "double chest";
    }
    else if (holder instanceof Entity)
    {
      Entity e = (Entity) holder;
      location = e.getLocation();
      holderDescription = e.getType().toString();
    }
    else
    {
      holderDescription = "unknown container";
      location = pl.getLocation();
    }

    apl.setActiveInventoryInfo(apl.getCarrying(), location, holderDescription);
  }
View Full Code Here

    HumanEntity he = event.getPlayer();
    if (!(he instanceof Player)) return;
    Player pl = (Player) he;

    AutoRefMatch match = plugin.getMatch(pl.getWorld());
    AutoRefPlayer apl = match == null ? null : match.getPlayer(pl);

    if (match == null || apl == null)
    { return; }
    if (apl.getTeam() == null)
    { return; }

    GoalsInventorySnapshot before = apl.getBeforeOpeningInventorySnapshot();
    GoalsInventorySnapshot snap = apl.getCarrying();

    if (before == null)
    { return; }

    MapDifference<BlockData, Integer> diff = before.getDiff(snap);
    if (diff.areEqual())
    { return; }

    GoalsInventorySnapshot droppedOff = GoalsInventorySnapshot.fromDiff(diff, true);
    GoalsInventorySnapshot pickedUp = GoalsInventorySnapshot.fromDiff(diff, false);

    if (!droppedOff.isEmpty() && !pickedUp.isEmpty())
    {
      match.addEvent(new TranscriptEvent(match,
          TranscriptEvent.EventType.OBJECTIVE_DETAIL, String.format(
          // {player} has dropped off {snap} and picked up {snap} from a {container} (@ {loc})
          "%s has dropped off %s and picked up %s from a %s (@ %s)", apl.getDisplayName(),
          droppedOff, pickedUp, apl.getInventoryDescription(),
          LocationUtil.toBlockCoords(apl.getInventoryLocation())),
          apl.getInventoryLocation(), unpack2(droppedOff, pickedUp, apl)
      ));
    }
    else if (!droppedOff.isEmpty())
    {
      match.addEvent(new TranscriptEvent(match,
          TranscriptEvent.EventType.OBJECTIVE_DETAIL, String.format(
          // {player} has dropped off {snap} in a {container} (@ {loc})
          "%s has dropped off %s in a %s (@ %s)", apl.getDisplayName(),
          droppedOff, apl.getInventoryDescription(),
          LocationUtil.toBlockCoords(apl.getInventoryLocation())),
          apl.getInventoryLocation(), unpack(droppedOff, apl)
      ));
    }
    else if (!pickedUp.isEmpty())
    {
      match.addEvent(new TranscriptEvent(match,
          TranscriptEvent.EventType.OBJECTIVE_DETAIL, String.format(
          // {player} has picked up {snap} from a {container} (@ {loc})
          "%s has picked up %s from a %s (@ %s)", apl.getDisplayName(),
          pickedUp, apl.getInventoryDescription(),
          LocationUtil.toBlockCoords(apl.getInventoryLocation())),
          apl.getInventoryLocation(), unpack(pickedUp, apl)
      ));
    }
    apl.clearActiveInventoryInfo();
  }
View Full Code Here

  {
    Player pl = event.getPlayer();
    Block block = event.getBlock();

    AutoRefMatch match = plugin.getMatch(block.getWorld());
    AutoRefPlayer apl = match == null ? null : match.getPlayer(pl);

    if (match == null || apl == null)
    { return; }
    if (apl.getTeam() == null)
    { return; }

    for (Map.Entry<BlockData, AutoRefGoal> entry :
        apl.getTeam().getGoalsByObjective().entrySet())
    {
      BlockData b = entry.getKey();
      AutoRefGoal g = entry.getValue();
      if (b.matchesBlock(block))
      {
        if (g.getItemStatus() != AutoRefGoal.ItemStatus.TARGET
            && g.isSatisfied(match)) {
          match.addEvent(new TranscriptEvent(match,
              TranscriptEvent.EventType.OBJECTIVE_PLACED, String.format(
              "%s has placed the %s on the Victory Monument!",
              apl.getDisplayName(), b.getDisplayName()), block.getLocation(), apl, b
          ));
        } else {
          // TranscriptEvent.ObjectiveDetailType.PLACE
          match.addEvent(new TranscriptEvent(match,
              TranscriptEvent.EventType.OBJECTIVE_DETAIL, String.format(
              // {player} has placed a {goal} block (@ {loc})
              "%s has placed a %s block (@ %s)", apl.getDisplayName(),
              b.getDisplayName(),
              LocationUtil.toBlockCoords(block.getLocation())),
              block.getLocation(), apl, b
          ));
        }
View Full Code Here

  {
    Player pl = event.getPlayer();
    Block block = event.getBlock();

    AutoRefMatch match = plugin.getMatch(block.getWorld());
    AutoRefPlayer apl = match == null ? null : match.getPlayer(pl);

    if (match == null || apl == null)
    { return; }
    if (apl.getTeam() == null)
    { return; }

    checkContainerBreak(block, apl.getTeam().getObjectives(), match,
        apl.getDisplayName());
    for (BlockData b : apl.getTeam().getObjectives())
    {
      if (b.matchesBlock(block))
      {
        // TranscriptEvent.ObjectiveDetailType.BREAK_PLAYER
        match.addEvent(new TranscriptEvent(match,
            TranscriptEvent.EventType.OBJECTIVE_DETAIL, String.format(
            // {player} has broken a {goal} block (@ {loc})
            "%s has broken a %s block (@ %s)", apl.getDisplayName(),
            b.getDisplayName(),
            LocationUtil.toBlockCoords(block.getLocation())), block
            .getLocation(), apl, b
        ));
      }
View Full Code Here

    { return; }

    BlockData item = new BlockData(event.getItemDrop().getItemStack());

    AutoRefMatch match = plugin.getMatch(pl.getWorld());
    AutoRefPlayer apl = match == null ? null : match.getPlayer(pl);

    if (match == null || apl == null)
    { return; }
    if (apl.getTeam() == null)
    { return; }

    for (BlockData b : apl.getTeam().getObjectives())
    {
      if (b.equals(item))
      {
        GoalsInventorySnapshot droppedItems = new GoalsInventorySnapshot(event.getItemDrop().getItemStack(), b);
        match.addEvent(new TranscriptEvent(match,
            TranscriptEvent.EventType.OBJECTIVE_DETAIL, String.format(
              // {player} has tossed {snap} (@ {loc})
              "%s has tossed %s (@ %s)", apl.getDisplayName(),
              droppedItems, LocationUtil.toBlockCoords(pl.getLocation())),
            pl.getLocation(), apl, b
        ));

        if (apl.hasActiveInventoryInfo())
        {
          apl.getBeforeOpeningInventorySnapshot().subtractInPlace(droppedItems);
        }
      }
    }
  }
View Full Code Here

        dropSkipPlayers.remove(pl);
      }
    });

    AutoRefMatch match = plugin.getMatch(pl.getWorld());
    AutoRefPlayer apl = match == null ? null : match.getPlayer(pl);

    if (match == null || apl == null)
    { return; }
    if (apl.getTeam() == null)
    { return; }

    GoalsInventorySnapshot snapshot = GoalsInventorySnapshot
        .fromItemsAndGoals(ev.getDrops(), apl.getTeam().getObjectives());

    if (snapshot.isEmpty())
    { return; }

    match.addEvent(new TranscriptEvent(
            match,
            TranscriptEvent.EventType.OBJECTIVE_DETAIL,
            // {player} has dropped {snap} when dying (@ {loc})
            String.format("%s has dropped %s when dying (@ %s)",
                apl.getDisplayName(), snapshot, LocationUtil.toBlockCoords(
                    apl.getLocation())
            ),
            apl.getLocation(), unpack(snapshot, apl, apl.getKiller())
        )
    );
    apl.clearActiveInventoryInfo();
  }
View Full Code Here

    { return; }

    BlockData item = new BlockData(event.getItem().getItemStack());

    AutoRefMatch match = plugin.getMatch(pl.getWorld());
    AutoRefPlayer apl = match == null ? null : match.getPlayer(pl);

    if (match == null || apl == null)
    { return; }
    if (apl.getTeam() == null)
    { return; }

    for (BlockData b : apl.getTeam().getObjectives())
    {
      if (b.equals(item))
      {
        GoalsInventorySnapshot pickupItems = new GoalsInventorySnapshot(event.getItem().getItemStack(), b);
        match.addEvent(new TranscriptEvent(match,
            TranscriptEvent.EventType.OBJECTIVE_DETAIL, String.format(
              // {player} has picked up {snap} (@ {loc})
              "%s has picked up %s (@ %s)", apl.getDisplayName(),
              pickupItems, LocationUtil.toBlockCoords(pl.getLocation())),
            pl.getLocation(), apl, b
        ));

        if (apl.hasActiveInventoryInfo())
        {
          apl.getBeforeOpeningInventorySnapshot().addInPlace(pickupItems);
        }

        untrackItem(event.getItem());
      }
    }
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.