Package org.mctourney.autoreferee

Examples of org.mctourney.autoreferee.AutoRefMatch$MatchReportSaver


  // restrict item pickup by referees
  @EventHandler(priority=EventPriority.HIGHEST)
  public void refereePickup(PlayerPickupItemEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getPlayer().getWorld());
    if (match != null && match.getCurrentState().inProgress()
      && !match.isPlayer(event.getPlayer())) event.setCancelled(true);
  }
View Full Code Here


  // restrict item pickup by referees
  @EventHandler(priority=EventPriority.HIGHEST)
  public void refereeDrop(PlayerDropItemEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getPlayer().getWorld());
    if (match != null && match.getCurrentState().inProgress()
      && !match.isPlayer(event.getPlayer())) event.setCancelled(true);

    if (PlayerUtil.hasClientMod(event.getPlayer())) event.setCancelled(true);
  }
View Full Code Here

  }

  @EventHandler
  public void toolUsage(PlayerInteractEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getPlayer().getWorld());
    if (match == null) return;

    Block block;

    // this event is not an "item" event
    if (!event.hasItem()) return;

    // get type id of the event and check if its one of our tools
    ToolAction action = ToolAction.fromMaterial(event.getMaterial());
    if (action == null) return;

    // get which action to perform
    switch (action)
    {
      // this is the tool built for setting win conditions
      case TOOL_WINCOND:

        if (match.getCurrentState().inProgress()) return;

        // if there is no block involved in this event, nothing
        if (!event.hasBlock()) return;
        block = event.getClickedBlock();

        // if the player doesn't have configure permissions, nothing
        if (!event.getPlayer().hasPermission("autoreferee.configure")) return;

        for (AutoRefTeam team : match.getTeams())
        {
          boolean canBuild = !team.hasFlag(block.getLocation(), AutoRefRegion.Flag.NO_BUILD);
          boolean canEnter = !team.hasFlag(block.getLocation(), AutoRefRegion.Flag.NO_ENTRY);
          if (canBuild && canEnter) team.addGoal(new BlockGoal(team, block));
        }

        break;

      // this is the tool built for setting start mechanisms
      case TOOL_STARTMECH:

        if (match.getCurrentState().inProgress()) return;

        // if there is no block involved in this event, nothing
        if (!event.hasBlock()) return;

        // if the player doesn't have configure permissions, nothing
        if (!event.getPlayer().hasPermission("autoreferee.configure")) return;

        // determine who owns the region that the clicked block is in
        block = event.getClickedBlock();

        // get the start mechanism
        AutoRefMatch.StartMechanism sm = match.toggleStartMech(block);

        if (sm != null) event.getPlayer().sendMessage(ChatColor.RED +
          "" + sm + ChatColor.RESET + " is a start mechanism.");
        else
        {
          String coords = LocationUtil.toBlockCoords(block.getLocation());
          event.getPlayer().sendMessage(ChatColor.RED + "" +
            coords + ChatColor.RESET + " is NOT a start mechanism.");
        }

        break;

      case SPECTATOR_CYCLE:

        // this tool only valid for spectators
        if (!match.isSpectator(event.getPlayer())) return;

        switch (event.getAction())
        {
          case LEFT_CLICK_AIR:
          case LEFT_CLICK_BLOCK:
            match.getSpectator(event.getPlayer()).cyclePrevPlayer();
            break;

          case RIGHT_CLICK_AIR:
          case RIGHT_CLICK_BLOCK:
            match.getSpectator(event.getPlayer()).cycleNextPlayer();
            break;

          default: break;
        }
        break;
View Full Code Here

  }

  @EventHandler
  public void toolUsage(PlayerInteractEntityEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getPlayer().getWorld());
    if (match == null) return;

    // this event is not an "item" event
    ItemStack item = event.getPlayer().getItemInHand();
    if (item == null) return;

    // get type id of the event and check if its one of our tools
    ToolAction action = ToolAction.fromMaterial(item.getType());
    if (action == null) return;

    // get which action to perform
    switch (action)
    {
      // this is the tool built for protecting entities
      case TOOL_PROTECT:

        if (match.getCurrentState().inProgress()) return;

        // if there is no entity involved in this event, nothing
        if (event.getRightClicked() == null) return;

        // if the player doesn't have configure permissions, nothing
        if (!event.getPlayer().hasPermission("autoreferee.configure")) return;

        // entity name
        String ename = String.format("%s @ %s", event.getRightClicked().getType().getName(),
          LocationUtil.toBlockCoords(event.getRightClicked().getLocation()));

        // save the entity's unique id
        UUID uid; match.toggleProtection(uid = event.getRightClicked().getUniqueId());
        match.broadcast(ChatColor.RED + ename + ChatColor.RESET + " is " +
          (match.isProtected(uid) ? "" : "not ") + "a protected entity");


        break;

      // this isn't one of our tools...
View Full Code Here

  public void blockInteract(PlayerInteractEvent event)
  {
    Player player = event.getPlayer();
    Location loc = event.getClickedBlock().getLocation();

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

    if (match.isSpectator(player))
    {
      if (!match.isReferee(player) && match.getCurrentState().inProgress())
        event.setCancelled(true);

      Material type = event.getClickedBlock().getType();

      if (PressurePlate.class.isAssignableFrom(type.getData()) && event.getAction().equals(Action.PHYSICAL)
        && match.getCurrentState().inProgress()) { event.setCancelled(true); return; }

      if (event.getClickedBlock().getState() instanceof InventoryHolder
        && event.getAction() == Action.RIGHT_CLICK_BLOCK && match.getCurrentState().inProgress()
        && !event.getPlayer().isSneaking())
      {
        InventoryHolder invh = (InventoryHolder) event.getClickedBlock().getState();
        Inventory inv = invh.getInventory(), newinv;
View Full Code Here

    if (match != null) sender.sendMessage(plugin.getName() +
      " already initialized for " + match.getMapName() + ".");
    else
    {
      World world = plugin.getSenderWorld(sender);
      plugin.addMatch(match = new AutoRefMatch(world, false));

      match.saveWorldConfiguration();
      match.setCurrentState(MatchStatus.NONE);

      sender.sendMessage(ChatColor.GREEN + AutoReferee.CFG_FILENAME + " generated.");
View Full Code Here

  {
    Player player = event.getPlayer();
    inventoryChange(player);
    healthArmorChange(player);

    AutoRefMatch match = plugin.getMatch(event.getRespawnLocation().getWorld());
    if (match != null && match.getRespawnMode() == RespawnMode.BEDS_ONLY)
      if (player.getBedSpawnLocation() == null)
      {
        match.eliminatePlayer(player);
        event.setRespawnLocation(match.getSpectatorSpawn());
      }
  }
View Full Code Here

  }

  @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
  public void itemCraft(CraftItemEvent event)
  {
    AutoRefMatch match = plugin.getMatch(event.getWhoClicked().getWorld());
    if (match == null) return;

    if (!(event.getWhoClicked() instanceof Player)) return;
    AutoRefTeam team = plugin.getTeam((Player) event.getWhoClicked());

    BlockData recipeTarget = BlockData.fromItemStack(event.getRecipe().getResult());
    if (team != null && !team.canCraft(recipeTarget)) event.setCancelled(true);

    // if this is on the blacklist, cancel
    if (!match.canCraft(recipeTarget)) event.setCancelled(true);
  }
View Full Code Here

    @Override
    public void run()
    {
      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

  public void commandBlockCommandEvent(ServerCommandEvent event)
  {
    if (!(event.getSender() instanceof BlockCommandSender)) return;
    Block commandBlock = ((BlockCommandSender) event.getSender()).getBlock();

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

    if (event.getCommand().startsWith("say"))
    {
      match.broadcast(ChatColor.DARK_GRAY + "" + ChatColor.ITALIC + "[@] " +
        ChatColor.RESET + event.getCommand().substring(3).trim());
      event.setCommand(""); return;
    }
  }
View Full Code Here

TOP

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

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.