Package org.mctourney.autoreferee

Examples of org.mctourney.autoreferee.AutoRefMatch


  @EventHandler(priority=EventPriority.MONITOR)
  public void playerQuit(PlayerQuitEvent event)
  {
    Player player = event.getPlayer();
    AutoRefMatch match = plugin.getMatch(player.getWorld());
    if (match == null) return;

    // 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


  @EventHandler(priority=EventPriority.HIGHEST)
  public void signCommand(PlayerInteractEvent event)
  {
    Player player = event.getPlayer();
    AutoRefMatch match = plugin.getMatch(player.getWorld());

    if (event.hasBlock() && event.getClickedBlock().getState() instanceof Sign)
    {
      String[] lines = ((Sign) event.getClickedBlock().getState()).getLines();
      if (lines[0] == null || !"[AutoReferee]".equals(lines[0])) return;

      if (match != null && match.getCurrentState().isBeforeMatch() &&
        match.inStartRegion(event.getClickedBlock().getLocation()))
      {
        // execute the command on the sign (and hope like hell that AutoReferee picks it up)
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
          player.performCommand(ChatColor.stripColor(lines[1] + " " + lines[2]).trim());
        event.setCancelled(true);
View Full Code Here

  @EventHandler(priority=EventPriority.HIGHEST)
  public void changeGamemode(PlayerGameModeChangeEvent event)
  {
    Player player = event.getPlayer();
    AutoRefMatch match = plugin.getMatch(player.getWorld());

    // if there is a match currently in progress on this world...
    if (match != null && !match.isPracticeMode() &&
      match.getCurrentState().inProgress())
    {
      // cancel the gamemode change if the player is a participant
      if (event.getNewGameMode() == GameMode.CREATIVE &&
        match.isPlayer(player) && !player.hasPermission("autoreferee.admin"))
      {
        player.sendMessage(ChatColor.RED +
          "Cannot change gamemode outside of practice mode!");
        event.setCancelled(true);
      }
View Full Code Here

  public void bedBreak(BlockBreakEvent event)
  {
    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 && match.getCurrentState().inProgress()
      && match.getRespawnMode() == RespawnMode.BEDS_ONLY && block.getType() == Material.BED_BLOCK)
        match.new BedUpdateTask(apl).runTask(plugin);
  }
View Full Code Here

  @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
  public void bedExplode(EntityExplodeEvent event)
  {
    Entity ent = event.getEntity();
    AutoRefMatch match = plugin.getMatch(ent.getWorld());
    boolean bedBroke = false;

    for (Block b : event.blockList())
      if (b.getType() == Material.BED_BLOCK) bedBroke = true;

    if (match != null && match.getCurrentState().inProgress()
      && match.getRespawnMode() == RespawnMode.BEDS_ONLY && bedBroke)
        match.new BedUpdateTask(ent).runTask(plugin);
  }
View Full Code Here

  // ----------------- START WINCONDITION -----------------------

  private void _checkWinConditions(BlockEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getBlock().getWorld());
    if (match != null) match.checkWinConditions();
  }
View Full Code Here

    if (match != null) match.checkWinConditions();
  }

  private void _checkWinConditions(EntityEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getEntity().getWorld());
    if (match != null) match.checkWinConditions();
  }
View Full Code Here

  { _checkWinConditions(event); }

  @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
  public void checkWinConditions(BlockFromToEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getBlock().getWorld());
    if (match != null) for (AutoRefTeam team : match.getTeams())
      for (CoreGoal goal : team.getTeamGoals(CoreGoal.class))
        goal.checkSatisfied(event);

    // typical win condition check as well
    _checkWinConditions(event);
View Full Code Here

  // ------------------ END WINCONDITION ------------------------

  @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
  public void blockBreak(BlockBreakEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getBlock().getWorld());
    if (match != null) match.checkWinConditions();
  }
View Full Code Here

  @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
  public void blockInteract(PlayerInteractEvent event)
  {
    if (event.hasBlock())
    {
      AutoRefMatch match = plugin.getMatch(event.getClickedBlock().getWorld());
      if (match != null) match.checkWinConditions();
    }
  }
View Full Code Here

TOP

Related Classes of org.mctourney.autoreferee.AutoRefMatch

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.