当前位置: 首页>>代码示例>>Java>>正文


Java Match类代码示例

本文整理汇总了Java中in.twizmwaz.cardinal.match.Match的典型用法代码示例。如果您正苦于以下问题:Java Match类的具体用法?Java Match怎么用?Java Match使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Match类属于in.twizmwaz.cardinal.match包,在下文中一共展示了Match类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: join

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * Join the game.
 *
 * @param cmd  The context of this command.
 * @param team The team to join, if specified.
 */
@Command(aliases = "join", description = "Join the game")
@PlayerCommand
public static void join(CommandContext cmd, @Optional Team team) {
  Player player = (Player) cmd.getSender();
  MatchThread thread = Cardinal.getMatchThread(player);
  Match match = thread.getCurrentMatch();
  CompetitorContainer playing = team;
  if (!match.isFfa()) {
    if (playing == null) {
      playing = Team.getEmptiestTeam(Team.getTeams(Cardinal.getMatch(player)));
    }
  } else {
    playing = SinglePlayerContainer.of(player);
  }
  PlayerContainerData newData = new PlayerContainerData(thread, match, playing);
  PlayerContainerData oldData = PlayerContainerData.of(player);
  Containers.handleStateChangeEvent(player, oldData, newData);
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:25,代码来源:CommandJoin.java

示例2: ScoreboardDisplay

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
ScoreboardDisplay(Match match, CompetitorContainer viewer) {
  this.match = match;
  this.viewer = viewer;
  scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
  //TODO: proper scoreboard name
  objective = scoreboard.registerNewObjective(ChatColor.AQUA + "Objectives", "dummy");
  objective.setDisplaySlot(DisplaySlot.SIDEBAR);
  ScoreModule scoreModule = Cardinal.getModule(ScoreModule.class);
  if (scoreModule.hasScoring(match)) {
    scoreModule.getScores(match).forEach(score -> this.score.getEntries().add(new ScoreScoreboardEntry(this, score)));
    score.getEntries().add(new EmptyScoreboardEntry(this));
  }
  for (Team team : Team.getTeams(match)) {
    ScoreboardGroup group = new ScoreboardGroup();
    if (Team.getTeamShownObjectives(match, team).size() > 0) {
      group.getEntries().add(new TeamName(this, team));
      Team.getTeamShownObjectives(match, team).forEach(
          obj -> group.getEntries().add(getEntryForObjective(obj, team)));
      group.getEntries().add(new EmptyScoreboardEntry(this));
    }
    teams.put(team, group);
  }
  defaultEntry = new EmptyScoreboardEntry(this);
  updatePlayerContainers();
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:26,代码来源:ScoreboardDisplay.java

示例3: loadMatch

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
@Override
public boolean loadMatch(@NonNull Match match) {
  for (Element score : match.getMap().getDocument().getRootElement().getChildren("score")) {
    int limit = Numbers.parseInteger(ParseUtil.getFirstAttribute("limit", score), -1);
    int kill = Numbers.parseInteger(ParseUtil.getFirstAttribute("kills", score), 0);
    int death = Numbers.parseInteger(ParseUtil.getFirstAttribute("deaths", score), 0);
    if (!rules.containsKey(match)) {
      rules.put(match, new ScoreRule(true, limit, kill, death));
    } else {
      errors.add(new ModuleError(this, match.getMap(), new String[]{"Multiple scores found for this map"}, false));
    }
  }
  if (!rules.containsKey(match)) {
    rules.put(match, new ScoreRule(false, -1, 0, 0));
  }
  scores.put(match, Lists.newArrayList());
  Team.getTeams(match).forEach(team -> addScoreModule(match, team));
  return true;
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:20,代码来源:ScoreModule.java

示例4: loadMatch

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
@Override
public boolean loadMatch(@NonNull Match match) {
  Document document = match.getMap().getDocument();
  boolean defaultPresent = false;
  for (Element spawnsElement : document.getRootElement().getChildren("spawns")) {
    for (Element spawnElement : spawnsElement.getChildren("spawn")) {
      Spawn spawn = parseSpawn(match, spawnElement, spawnsElement);
      if (spawn != null) {
        IdModule.get().add(match, null, spawn, true);
        if (spawn.isDefaultSpawn()) {
          defaultPresent = true;
        }
      }
    }
  }
  if (!defaultPresent) {
    errors.add(new ModuleError(this, match.getMap(), new String[]{"No valid default spawn"}, true));
    return false;
  }
  StringBuilder builder = new StringBuilder().append("Spawns loaded : ")
      .append(IdModule.get().getList(match, Spawn.class).size());
  errors.add(new ModuleError(this, match.getMap(), new String[]{builder.toString()}, false));
  return true;
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:25,代码来源:SpawnModule.java

示例5: onBlockUse

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * Filters PlayerInteractEvent (right clicking blocks or triggering pressure plates).
 *
 * <p>Applies to: use<p/>
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockUse(PlayerInteractEvent event) {
  if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
    Match match = Cardinal.getMatch(event.getPlayer());
    if (match == null || !match.hasPlayer(event.getPlayer())) {
      return;
    }
    for (AppliedRegion reg : get(match, ApplyType.USE)) {
      Block evaluating = event.getClickedBlock();

      if (apply(reg, evaluating.getLocation(), event.getPlayer(), event, event, evaluating, event.getPlayer())) {
        if (event.isCancelled()) {
          event.setUseItemInHand(Event.Result.ALLOW);
          event.setUseInteractedBlock(Event.Result.DENY);
          event.setCancelled(false);
        }
        break;
      }
    }
  }
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:27,代码来源:AppliedModule.java

示例6: onBlockDamage

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * Filters BlockDamageEvent, Used for early warnings.
 *
 * <p>Applies to: block and block break<p/>
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
  Match match = Cardinal.getMatch(event.getPlayer());
  if (match == null || !match.hasPlayer(event.getPlayer())) {
    return;
  }
  for (AppliedRegion reg : get(match, ApplyType.BLOCK, ApplyType.BLOCK_BREAK)) {
    Block evaluating = event.getBlock();

    if (apply(reg, evaluating.getLocation(), event.getPlayer(), event, event, evaluating, event.getPlayer())) {
      if (event.isCancelled()) {
        event.setCancelled(false);
      }
      break;
    }
  }
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:23,代码来源:AppliedModule.java

示例7: onBlockFromTo

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * Checks if lava has reached the leak distance below this core.
 *
 * @param event The event.
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) {
  Match match = Cardinal.getMatch(event.getWorld());
  if (match == null) {
    return;
  }
  Block to = event.getToBlock();
  Material type = event.getBlock().getType();
  if (type.equals(Material.STATIONARY_LAVA) || type.equals(Material.LAVA)) {
    Core core = getClosestCore(match, to.getLocation().clone());
    if (core != null && !core.isComplete()) {
      int distance = getBottom(core) - to.getY();
      if (distance >= core.getLeak()) {
        core.setComplete(true);
        Channels.getGlobalChannel(Cardinal.getMatchThread(match)).sendMessage(new LocalizedComponentBuilder(
            ChatConstant.getConstant("objective.core.completed"),
            new TeamComponent(core.getOwner()),
            Components.setColor(core.getComponent(), ChatColor.RED)).color(ChatColor.RED).build());
        Bukkit.getPluginManager().callEvent(new ObjectiveCompleteEvent(core, null));
      }
    }
  }
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:29,代码来源:CoreModule.java

示例8: PlayerContainerData

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * Creates new container data under a match thread, match, and player container.
 *
 * @param matchThread The match thread.
 * @param match The match.
 * @param playing The player container.
 */
public PlayerContainerData(MatchThread matchThread, Match match, CompetitorContainer playing) {
  if (match != null && playing == null) {
    throw new IllegalArgumentException("Playing cannot be null when match is not null");
  }
  this.matchThread = matchThread;
  this.match = match;
  this.playing = playing;
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:16,代码来源:PlayerContainerData.java

示例9: getTeamObjectives

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * Gets the objectives required for a team to complete.
 *
 * @param team The team.
 * @return The team's objectives.
 */
public static List<Objective> getTeamObjectives(@NonNull Match match, @NonNull Team team) {
  List<Objective> objectives = Lists.newArrayList();
  objectives.addAll(Objective.getObjectives(match).stream().filter(objective ->
      (objective instanceof OwnedObjective && !((OwnedObjective) objective).getOwner().equals(team))
      || (objective instanceof Wool && ((Wool) objective).getTeam().equals(team))).collect(Collectors.toList()));
  return objectives;
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:14,代码来源:Team.java

示例10: getMatch

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * @param world The world.
 * @return The match that uses that world.
 */
@NonNull
public static Match getMatch(@NonNull World world) {
  for (MatchThread matchThread : getInstance().getMatchThreads()) {
    if (matchThread.getCurrentMatch().getWorld().equals(world)) {
      return matchThread.getCurrentMatch();
    }
  }
  return null;
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:14,代码来源:Cardinal.java

示例11: getTeamByName

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * @param name The input name.
 * @return The team that ha the input name.
 */
public Team getTeamByName(@NonNull Match match, @NonNull String name) {
  for (Team team : getTeams(match)) {
    if (Strings.getSimplifiedName(team.getName()).startsWith(Strings.getSimplifiedName(name))) {
      return team;
    }
  }
  return null;
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:13,代码来源:TeamModule.java

示例12: getTeamByPlayer

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * @param player The input player.
 * @return The team which the player is on.
 */
public Team getTeamByPlayer(@NonNull Match match, @NonNull Player player) {
  for (Team team : getTeams(match)) {
    if (team.getPlayers().contains(player)) {
      return team;
    }
  }
  return null;
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:13,代码来源:TeamModule.java

示例13: loadMatch

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
@Override
public boolean loadMatch(Match match) {
  for (Element kits : match.getMap().getDocument().getRootElement().getChildren("kits")) {
    for (Element element : kits.getChildren("kit")) {
      Map.Entry<String, Kit> entry = parseKit(match, element);
      IdModule.get().add(match, entry.getKey(), entry.getValue());
    }
  }
  return true;
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:11,代码来源:KitModule.java

示例14: onBlockPlace

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * Filters BlockPlaceEvent.
 *
 * <p>Applies to: block, block place and block place against.<p/>
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
  Match match = Cardinal.getMatch(event.getPlayer());
  if (match == null || !match.hasPlayer(event.getPlayer())) {
    return;
  }
  for (AppliedRegion reg : get(match, ApplyType.BLOCK, ApplyType.BLOCK_PLACE, ApplyType.BLOCK_PLACE_AGAINST)) {
    Block evaluating = reg.isType(ApplyType.BLOCK_PLACE_AGAINST) ? event.getBlockAgainst() : event.getBlock();

    if (apply(reg, evaluating.getLocation(), event.getPlayer(), event, event, evaluating, event.getPlayer())) {
      break;
    }
  }
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:20,代码来源:AppliedModule.java

示例15: onBlockBreak

import in.twizmwaz.cardinal.match.Match; //导入依赖的package包/类
/**
 * Filters BlockBreakEvent.
 *
 * <p>Applies to: block, block break.<p/>
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
  Match match = Cardinal.getMatch(event.getPlayer());
  if (match == null || !match.hasPlayer(event.getPlayer())) {
    return;
  }
  for (AppliedRegion reg : get(match, ApplyType.BLOCK, ApplyType.BLOCK_BREAK)) {
    Block evaluating = event.getBlock();

    if (apply(reg, evaluating.getLocation(), event.getPlayer(), event, event, evaluating, event.getPlayer())) {
      break;
    }
  }
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:20,代码来源:AppliedModule.java


注:本文中的in.twizmwaz.cardinal.match.Match类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。