Package org.mctourney.autoreferee

Examples of org.mctourney.autoreferee.AutoRefMatch$ItemElevatorDetectionTask


  public void onPluginMessageReceived(String channel, Player player, byte[] mbytes)
  {
    if (AutoReferee.REFEREE_PLUGIN_CHANNEL.equals(channel)) try
    {
      String message = new String(mbytes, AutoReferee.PLUGIN_CHANNEL_ENC);
      AutoRefMatch match = plugin.getMatch(player.getWorld());

      if (match == null || !match.isSpectator(player)) return;

      String[] parts = message.trim().split("\\|");
      if ("tp".equalsIgnoreCase(parts[0]))
      {
        Location loc = null;
        if ("player".equalsIgnoreCase(parts[1]))
        {
          AutoRefPlayer apl = match.getPlayer(parts[2]);
          if (apl != null)
          {
            if ("player".equalsIgnoreCase(parts[3])) loc = apl.getLocation();
            else if ("death".equalsIgnoreCase(parts[3])) loc = apl.getLastDeathLocation();
            else if ("spawn".equalsIgnoreCase(parts[3])) loc = apl.getBedLocation();
          }
        }
        else if ("team".equalsIgnoreCase(parts[1]))
        {
          AutoRefTeam team = match.getTeam(parts[2]);
          if (team != null)
          {
            if ("vm".equalsIgnoreCase(parts[3])) loc = team.getVictoryMonumentLocation();
            else if ("spawn".equalsIgnoreCase(parts[3])) loc = team.getSpawnLocation();
          }
        }

        // teleport to the location, if any
        loc = TeleportationUtil.locationTeleport(loc);
        if (loc == null) player.sendMessage(ChatColor.DARK_GRAY +
          "You cannot teleport to this location: invalid or unsafe.");
        else
        {
          match.getSpectator(player).setPrevLocation(player.getLocation());
          player.teleport(loc); player.setFlying(true);
        }
      }
      else if ("inventory".equalsIgnoreCase(parts[0]))
      {
        if ("player".equalsIgnoreCase(parts[1]))
        {
          AutoRefPlayer apl = match.getPlayer(parts[2]);
          boolean old = parts.length > 3 && "prev".equalsIgnoreCase(parts[3]);

          // if we are unable to show the inventory, tell the streamer that
          if (apl == null || !apl.showInventory(player, old))
            player.sendMessage(ChatColor.DARK_GRAY + "Cannot show inventory for " + parts[2]);
View Full Code Here


  @EventHandler
  public void channelRegistration(PlayerRegisterChannelEvent event)
  {
    Player pl = event.getPlayer();
    AutoRefMatch match = plugin.getMatch(pl.getWorld());

    if (AutoReferee.REFEREE_PLUGIN_CHANNEL.equals(event.getChannel()) && match != null)
    {
      // if this is a player, complain and force them to quit their team!
      if (match.isPlayer(pl) && !pl.isOp())
      {
        AutoRefPlayer apl = match.getPlayer(pl);
        for (Player ref : match.getReferees(true)) ref.sendMessage(apl.getDisplayName() +
          ChatColor.DARK_GRAY + " attempted to log in with a modified client!");
        match.leaveTeam(pl, true);
      }

      // update a referee with the latest information regarding the match
      if (match.isReferee(pl)) match.updateReferee(pl);
    }
  }
View Full Code Here

  public void entityInteract(PlayerInteractEntityEvent event)
  {
    Player pl = event.getPlayer();
    Entity entity = event.getRightClicked();

    AutoRefMatch match = plugin.getMatch(pl.getWorld());
    if (match != null) match.checkWinConditions();

    if (entity.getType() == EntityType.PLAYER && match != null
      && match.isSpectator(pl) && match.isPlayer((Player) entity))
    {
      AutoRefPlayer a = match.getPlayer((Player) entity);
      a.showInventory(pl);
    }
  }
View Full Code Here

  @EventHandler(priority=EventPriority.HIGHEST)
  public void potionSplash(PotionSplashEvent event)
  {
    World world = event.getEntity().getWorld();
    AutoRefMatch match = plugin.getMatch(world);

    for (LivingEntity living : event.getAffectedEntities())
      if (living.getType() == EntityType.PLAYER)
        if (match != null && !match.isPlayer((Player) living))
          event.setIntensity(living, 0.0);
  }
View Full Code Here

  public void playerRespawn(PlayerRespawnEvent event)
  {
    String name = event.getPlayer().getName();
    if (deadSpectators.containsKey(name))
    {
      AutoRefMatch match = deadSpectators.get(name);
      if (match != null) event.setRespawnLocation(match.getWorldSpawn());
      deadSpectators.remove(name); return;
    }
  }
View Full Code Here

  public void spectatorMove(PlayerMoveEvent event)
  {
    Player player = event.getPlayer();
    World world = player.getWorld();

    AutoRefMatch match = plugin.getMatch(world);
    if (match == null || !match.isSpectator(player)) return;

    AutoRefSpectator spec = match.getSpectator(player);
    boolean pvis = spec.isInvisible();

    double bdistance = Double.MAX_VALUE;
    for (AutoRefPlayer apl : match.getPlayers()) if (apl.isOnline())
    {
      Location ploc = apl.getPlayer().getLocation();
      double dist = ploc.distanceSquared(player.getLocation());
      if (dist < bdistance) { bdistance = dist; }
    }

    // if the spectator should be invisible, change visibility and then redo visibility
    boolean vis = bdistance <= SPECTATOR_VISIBILITY_RADIUS * SPECTATOR_VISIBILITY_RADIUS;
    spec.setInvisible(vis);

    // if the visibility status has changed, reconfigure
    if (pvis != vis) match.setupVisibility(player);
  }
View Full Code Here

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

    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())
View Full Code Here

  @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
  public void enderpearlThrow(ProjectileLaunchEvent event)
  {
    // if the match is not under our control, ignore
    AutoRefMatch match = plugin.getMatch(event.getEntity().getWorld());
    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

  }

  public boolean validPlayer(Player player)
  {
    // if the match is not under our control, allowed
    AutoRefMatch match = plugin.getMatch(player.getWorld());
    if (match == null || match.getCurrentState() == MatchStatus.NONE) return true;

    // if we are in practice mode, whatever...
    if (match.isPracticeMode()) return true;

    Role role = match.getRole(player);

    // if the player is a referee or is flying, nothing is off-limits
    if (role == Role.REFEREE || (match.getCurrentState().inProgress()
      && player.isFlying() && role == Role.PLAYER)) return true;

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

  @EventHandler(priority=EventPriority.MONITOR)
  public void playerPickup(PlayerPickupItemEvent event)
  {
    // if this isn't a match, skip it
    AutoRefMatch match = plugin.getMatch(event.getPlayer().getWorld());
    if (match == null) return;

    if (match.elevatedItem.containsKey(event.getItem().getUniqueId())
      && match.isPlayer(event.getPlayer()))
    {
      String itemname = new BlockData(event.getItem().getItemStack()).getDisplayName();
      String msg = match.getDisplayName(event.getPlayer()) + ChatColor.DARK_GRAY +
        " picked up " + itemname + ChatColor.DARK_GRAY + " from an item elevator.";
      match.setLastNotificationLocation(event.getItem().getLocation());

      for (Player ref : match.getReferees()) ref.sendMessage(msg);
      AutoReferee.log(msg);
    }
  }
View Full Code Here

TOP

Related Classes of org.mctourney.autoreferee.AutoRefMatch$ItemElevatorDetectionTask

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.