Package org.mctourney.autoreferee

Examples of org.mctourney.autoreferee.AutoRefMatch$BedUpdateTask


  @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
  public void blockFall(EntityChangeBlockEvent event)
  {
    // if this isn't a match, skip it
    AutoRefMatch match = plugin.getMatch(event.getBlock().getWorld());
    if (match == null) return;

    Block block = event.getBlock();
    if (event.getEntityType() == EntityType.FALLING_BLOCK)
    {
      for (AutoRefRegion reg : match.getRegions())
        if (reg.is(AutoRefRegion.Flag.NO_BUILD) && reg.containsBlock(block))
        { event.setCancelled(true); return; }
    }
  }
View Full Code Here


  public void blockBreak(BlockBreakEvent event)
  {
    Player player = event.getPlayer();
    Block b = event.getBlock();

    AutoRefMatch match = plugin.getMatch(b.getWorld());
    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

      event.getBlockClicked().getRelative(event.getBlockFace()));
  }

  public void blockEvent(Cancellable event, Player player, Block block)
  {
    AutoRefMatch match = plugin.getMatch(block.getWorld());
    if (match == null) return;

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

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

      return true;
    }

    sender.sendMessage(ChatColor.DARK_GRAY +
      "Preparing a new copy of " + map.getVersionString());
    AutoRefMatch newmatch = AutoRefMap.createMatch(map, null);

    if (map.equals(match.getMap()) && options.hasOption('x'))
    {
      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());
        p.teleport(loc);
      }
    }
    else for (Player p : match.getWorld().getPlayers()) newmatch.joinMatch(p);

    match.destroy(MatchUnloadEvent.Reason.COMMAND);
    return true;
  }
View Full Code Here

  public void blockInteract(PlayerInteractEvent event)
  {
    Player player = event.getPlayer();
    Block block = event.getClickedBlock();

    AutoRefMatch match = plugin.getMatch(block.getWorld());
    if (match == null) return;

    if (match.isPlayer(player))
    {
      AutoRefPlayer apl = match.getPlayer(player);
      boolean noaccess = apl.getTeam().hasFlag(block, Flag.NO_ACCESS);

      if (!match.getPlayer(player).isInsideLane() || (noaccess && !event.isBlockInHand()))
      { event.setCancelled(true); return; }

      if (match.isStartMechanism(block) && !match.getStartMechanism(block).canFlip(match))
      { event.setCancelled(true); return; }

      if (!validPlayer(player))
      { event.setCancelled(true); return; }
View Full Code Here

      // if this player cannot be found, skip
      Player invited = plugin.getServer().getPlayer(args[i]);
      if (invited == null) continue;

      // if this player is already busy competing in a match, skip
      AutoRefMatch m = plugin.getMatch(invited.getWorld());
      if (m != null && m.isPlayer(invited) && m.getCurrentState().inProgress()) continue;

      // otherwise, let's drag them in (no asking)
      match.joinMatch(invited);
    }
View Full Code Here

  public void entityInteract(PlayerInteractEntityEvent event)
  {
    Player player = event.getPlayer();
    Location loc = event.getRightClicked().getLocation();

    AutoRefMatch match = plugin.getMatch(loc.getWorld());
    if (match == null) return;

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

    AutoRefPlayer apl = match.getPlayer(player);
    if (apl != null)
    {
      if (!apl.isInsideLane() || apl.getTeam().hasFlag(loc, Flag.NO_ACCESS))
      { event.setCancelled(true); return; }
    }
View Full Code Here

  }

  @EventHandler(priority=EventPriority.HIGHEST)
  public void creatureSpawn(CreatureSpawnEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getEntity().getWorld());
    if (match == null || match.getCurrentState() == MatchStatus.NONE) return;

    if (event.getSpawnReason() == SpawnReason.SPAWNER_EGG)
    {
      Player spawner = null;
      double distance = Double.POSITIVE_INFINITY;

      // get the player who spawned this entity
      Location loc = event.getEntity().getLocation();
      for (Player pl : event.getEntity().getWorld().getPlayers())
      {
        double d = loc.distanceSquared(pl.getLocation());
        if (d < distance && pl.getItemInHand() != null &&
          pl.getItemInHand().getType() == Material.MONSTER_EGG)
        { spawner = pl; distance = d; }
      }

      // if the player who spawned this creature can configure...
      if (spawner != null && spawner.hasPermission("autoreferee.configure")
        && spawner.getGameMode() == GameMode.CREATIVE) return;
    }

    if (event.getEntityType() == EntityType.SLIME &&
      event.getSpawnReason() == SpawnReason.NATURAL)
    { event.setCancelled(true); return; }

    // if the match hasn't started, cancel
    if (!match.getCurrentState().inProgress())
    { event.setCancelled(true); return; }

    // if this is a spawners-only region and its a non-spawner spawn, cancel
    // note: spawning rules for silverfish are a bit of a special case, so allow them
    if (match.hasFlag(event.getLocation(), AutoRefRegion.Flag.SPAWNERS_ONLY) &&
      event.getSpawnReason() != SpawnReason.SPAWNER && event.getEntityType() != EntityType.SILVERFISH)
    { event.setCancelled(true); return; }

    // if this is a safe zone, cancel
    if (match.hasFlag(event.getLocation(), AutoRefRegion.Flag.SAFE))
    { event.setCancelled(true); return; }
  }
View Full Code Here

    // if distance is too small to matter, forget about it
    double dsq = fm.distanceSquared(to);
    if (dsq <= SAFE_TRAVEL_DISTANCE * SAFE_TRAVEL_DISTANCE) return;

    AutoRefMatch match = plugin.getMatch(to.getWorld());
    if (match == null || match.getCurrentState() == MatchStatus.NONE) return;

    // get the player that teleported
    AutoRefPlayer apl = match.getPlayer(pl);
    if (apl == null) return;
    apl.setLastTeleportLocation(to);

    // generate message regarding the teleport event
    String bedrock = BlockGoal.blockInRange(BlockData.BEDROCK, to, 5) != null ? " (near bedrock)" : "";
    String message = apl.getDisplayName() + ChatColor.GRAY + " has teleported @ " +
      LocationUtil.toBlockCoords(to) + bedrock + (reason != null ? " " + reason : "");

    boolean excludeStreamers = dsq <= LONG_TELE_DISTANCE * LONG_TELE_DISTANCE;
    for (Player ref : match.getReferees(excludeStreamers)) ref.sendMessage(message);
  }
View Full Code Here

  public void playerTeleport(PlayerTeleportEvent event)
  {
    // just to be safe? (apparently Bukkit lets you teleport a player to null)
    if (event.getTo() == null) return;

    AutoRefMatch match = plugin.getMatch(event.getTo().getWorld());
    if (match == null || match.getCurrentState() == MatchStatus.NONE) return;

    AutoRefPlayer apl = match.getPlayer(event.getPlayer());
    if (apl == null) return;

    playerMove(event);
    switch (event.getCause())
    {
View Full Code Here

TOP

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

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.