gpt4 book ai didi

com.sk89q.worldguard.internal.platform.WorldGuardPlatform.getMatcher()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-24 08:19:05 25 4
gpt4 key购买 nike

本文整理了Java中com.sk89q.worldguard.internal.platform.WorldGuardPlatform.getMatcher()方法的一些代码示例,展示了WorldGuardPlatform.getMatcher()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorldGuardPlatform.getMatcher()方法的具体详情如下:
包路径:com.sk89q.worldguard.internal.platform.WorldGuardPlatform
类名称:WorldGuardPlatform
方法名:getMatcher

WorldGuardPlatform.getMatcher介绍

[英]Gets an instance of the matcher, which handles matching worlds, players, colours, etc from strings.
[中]获取matcher的实例,该实例处理字符串中的匹配世界、玩家、颜色等。

代码示例

代码示例来源:origin: EngineHub/WorldGuard

@Nullable
private static World findWorld(String worldName) {
  return WorldGuard.getInstance().getPlatform().getMatcher().getWorldByName(worldName);
}

代码示例来源:origin: EngineHub/WorldGuard

if (!lastMessageStack.contains(message)) {
  String effective = CommandUtils.replaceColorMacros(message);
  effective = WorldGuard.getInstance().getPlatform().getMatcher().replaceMacros(player, effective);
  for (String mess : effective.replaceAll("\\\\n", "\n").split("\\n")) {
    player.printRaw(mess);

代码示例来源:origin: EngineHub/WorldGuard

@Override
public boolean onCrossBoundary(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType) {
  Set<String> messages = getMessages(player, toSet);
  if (!messages.isEmpty()) {
    // Due to flag priorities, we have to collect the lower
    // priority flag values separately
    for (ProtectedRegion region : toSet) {
      String message = region.getFlag(Flags.FAREWELL_MESSAGE);
      if (message != null) {
        messages.add(message);
      }
    }
  }
  for (String message : lastMessageStack) {
    if (!messages.contains(message)) {
      String effective = CommandUtils.replaceColorMacros(message);
      effective = WorldGuard.getInstance().getPlatform().getMatcher().replaceMacros(player, effective);
      for (String mess : effective.replaceAll("\\\\n", "\n").split("\\n")) {
        player.printRaw(mess);
      }
      break;
    }
  }
  lastMessageStack = messages;
  return true;
}

代码示例来源:origin: EngineHub/WorldGuard

/**
 * Gets the world from the given flag, or falling back to the the current player
 * if the sender is a player, otherwise reporting an error.
 *
 * @param args the arguments
 * @param sender the sender
 * @param flag the flag (such as 'w')
 * @return a world
 * @throws CommandException on error
 */
protected static World checkWorld(CommandContext args, Actor sender, char flag) throws CommandException {
  if (args.hasFlag(flag)) {
    return WorldGuard.getInstance().getPlatform().getMatcher().matchWorld(sender, args.getFlag(flag));
  } else {
    if (sender instanceof LocalPlayer) {
      return ((LocalPlayer) sender).getWorld();
    } else {
      throw new CommandException("Please specify " + "the world with -" + flag + " world_name.");
    }
  }
}

代码示例来源:origin: EngineHub/WorldGuard

targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));

代码示例来源:origin: EngineHub/WorldGuard

@Command(aliases = {"testinteract"}, usage = "[player]", desc = "Simulate a block interact", min = 1, max = 1, flags = "ts")
@CommandPermissions("worldguard.debug.event")
public void fireInteractEvent(CommandContext args, final Actor sender) throws CommandException {
  LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
  worldGuard.getPlatform().getDebugHandler().testInteract(sender, target, args.hasFlag('t'), args.hasFlag('s'));
}

代码示例来源:origin: EngineHub/WorldGuard

@Command(aliases = {"testplace"}, usage = "[player]", desc = "Simulate a block place", min = 1, max = 1, flags = "ts")
@CommandPermissions("worldguard.debug.event")
public void firePlaceEvent(CommandContext args, final Actor sender) throws CommandException {
  LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
  worldGuard.getPlatform().getDebugHandler().testPlace(sender, target, args.hasFlag('t'), args.hasFlag('s'));
}

代码示例来源:origin: EngineHub/WorldGuard

@Command(aliases = {"testbreak"}, usage = "[player]", desc = "Simulate a block break", min = 1, max = 1, flags = "ts")
@CommandPermissions("worldguard.debug.event")
public void fireBreakEvent(CommandContext args, final Actor sender) throws CommandException {
  LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
  worldGuard.getPlatform().getDebugHandler().testBreak(sender, target, args.hasFlag('t'), args.hasFlag('s'));
}

代码示例来源:origin: EngineHub/WorldGuard

@Command(aliases = {"testdamage"}, usage = "[player]", desc = "Simulate an entity damage", min = 1, max = 1, flags = "ts")
  @CommandPermissions("worldguard.debug.event")
  public void fireDamageEvent(CommandContext args, final Actor sender) throws CommandException {
    LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
    worldGuard.getPlatform().getDebugHandler().testDamage(sender, target, args.hasFlag('t'), args.hasFlag('s'));
  }
}

代码示例来源:origin: EngineHub/WorldGuard

/**
 * Tell a sender that s/he cannot do something 'here'.
 *
 * @param event the event
 * @param cause the cause
 * @param location the location
 * @param what what was done
 */
private void tellErrorMessage(DelegateEvent event, Cause cause, Location location, String what) {
  if (event.isSilent() || cause.isIndirect()) {
    return;
  }
  Object rootCause = cause.getRootCause();
  if (rootCause instanceof Player) {
    Player player = (Player) rootCause;
    LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
    long now = System.currentTimeMillis();
    Long lastTime = WGMetadata.getIfPresent(player, DENY_MESSAGE_KEY, Long.class);
    if (lastTime == null || now - lastTime >= LAST_MESSAGE_DELAY) {
      RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
      String message = query.queryValue(BukkitAdapter.adapt(location), localPlayer, Flags.DENY_MESSAGE);
      message = WorldGuard.getInstance().getPlatform().getMatcher().replaceMacros(localPlayer, message);
      message = CommandUtils.replaceColorMacros(message);
      if (message != null && !message.isEmpty()) {
        player.sendMessage(message.replace("%what%", what));
      }
      WGMetadata.put(player, DENY_MESSAGE_KEY, now);
    }
  }
}

代码示例来源:origin: EngineHub/WorldGuard

targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));

代码示例来源:origin: EngineHub/WorldGuard

targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));

代码示例来源:origin: EngineHub/WorldGuard

targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));

代码示例来源:origin: EngineHub/WorldGuard

@Command(aliases = {"locate"}, usage = "[player]", desc = "Locate a player", max = 1)
@CommandPermissions({"worldguard.locate"})
public void locate(CommandContext args, Actor sender) throws CommandException {
  LocalPlayer player = worldGuard.checkPlayer(sender);
  
  if (args.argsLength() == 0) {
    player.setCompassTarget(new Location(player.getWorld(), player.getWorld().getSpawnPosition().toVector3()));
    
    sender.print("Compass reset to spawn.");
  } else {
    LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
    player.setCompassTarget(target.getLocation());
    
    sender.print("Compass repointed.");
  }
}

代码示例来源:origin: EngineHub/WorldGuard

@Command(aliases = {"flushstates", "clearstates"},
    usage = "[player]", desc = "Flush the state manager", max = 1)
@CommandPermissions("worldguard.flushstates")
public void flushStates(CommandContext args, Actor sender) throws CommandException {
  if (args.argsLength() == 0) {
    WorldGuard.getInstance().getPlatform().getSessionManager().resetAllStates();
    sender.print("Cleared all states.");
  } else {
    LocalPlayer player = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
    if (player != null) {
      WorldGuard.getInstance().getPlatform().getSessionManager().resetState(player);
      sender.print("Cleared states for player \"" + player.getName() + "\".");
    }
  }
}

代码示例来源:origin: EngineHub/WorldGuard

@Command(aliases = {"allowfire"}, usage = "[<world>]",
    desc = "Allows all fire spread temporarily", max = 1)
@CommandPermissions({"worldguard.fire-toggle.stop"})
public void allowFire(CommandContext args, Actor sender) throws CommandException {
  
  World world;
  
  if (args.argsLength() == 0) {
    world = worldGuard.checkPlayer(sender).getWorld();
  } else {
    world = worldGuard.getPlatform().getMatcher().matchWorld(sender, args.getString(0));
  }
  
  WorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world);
  if (wcfg.fireSpreadDisableToggle) {
    worldGuard.getPlatform().broadcastNotification(Style.YELLOW
        + "Fire spread has been globally for '" + world.getName() + "' re-enabled by "
        + sender.getDisplayName() + ".");
  } else {
    sender.print("Fire spread was already globally enabled.");
  }
  wcfg.fireSpreadDisableToggle = false;
}

代码示例来源:origin: EngineHub/WorldGuard

@Command(aliases = {"stopfire"}, usage = "[<world>]",
    desc = "Disables all fire spread temporarily", max = 1)
@CommandPermissions({"worldguard.fire-toggle.stop"})
public void stopFire(CommandContext args, Actor sender) throws CommandException {
  
  World world;
  
  if (args.argsLength() == 0) {
    world = worldGuard.checkPlayer(sender).getWorld();
  } else {
    world = worldGuard.getPlatform().getMatcher().matchWorld(sender, args.getString(0));
  }
  
  WorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world);
  if (!wcfg.fireSpreadDisableToggle) {
    worldGuard.getPlatform().broadcastNotification(
        Style.YELLOW
        + "Fire spread has been globally disabled for '" + world.getName() + "' by "
        + sender.getDisplayName() + ".");
  } else {
    sender.print("Fire spread was already globally disabled.");
  }
  wcfg.fireSpreadDisableToggle = true;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com