gpt4 book ai didi

com.sk89q.worldguard.internal.platform.WorldGuardPlatform类的使用及代码示例

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

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

WorldGuardPlatform介绍

[英]A platform for implementing.
[中]一个实施的平台。

代码示例

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

/**
 * Warn the region saving is failing.
 *
 * @param sender the sender to send the message to
 */
protected static void warnAboutSaveFailures(Actor sender) {
  RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
  Set<RegionManager> failures = container.getSaveFailures();
  if (failures.size() > 0) {
    String failingList = Joiner.on(", ").join(failures.stream().map(regionManager -> "'" + regionManager.getName() + "'").collect(Collectors.toList()));
    sender.printRaw(Style.YELLOW_DARK +
        "(Warning: The background saving of region data is failing for these worlds: " + failingList + ". " +
        "Your changes are getting lost. See the server log for more information.)");
  }
}

代码示例来源:origin: NyaaCat/RPGItems-reloaded

static void unregisterHandler() {
  SessionManager sessionManager = worldGuardInstance.getPlatform().getSessionManager();
  sessionManager.unregisterHandler(FACTORY);
}

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

/**
 * Check that the given region manager is not null.
 *
 * @param world the world
 * @throws CommandException thrown if the manager is null
 */
protected static RegionManager checkRegionManager(com.sk89q.worldedit.world.World world) throws CommandException {
  if (!WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).useRegions) {
    throw new CommandException("Region support is disabled in the target world. " +
        "It can be enabled per-world in WorldGuard's configuration files. " +
        "However, you may need to restart your server afterwards.");
  }
  RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(world);
  if (manager == null) {
    throw new CommandException("Region data failed to load for this world. " +
        "Please ask a server administrator to read the logs to identify the reason.");
  }
  return manager;
}

代码示例来源: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 = {"report"}, desc = "Writes a report on WorldGuard", flags = "p", max = 0)
@CommandPermissions({"worldguard.report"})
public void report(CommandContext args, final Actor sender) throws CommandException, AuthorizationException {
  ReportList report = new ReportList("Report");
  worldGuard.getPlatform().addPlatformReports(report);
  report.add(new SystemInfoReport());
  report.add(new ConfigReport());
  String result = report.toString();
  try {
    File dest = new File(worldGuard.getPlatform().getConfigDir().toFile(), "report.txt");
    Files.write(result, dest, Charset.forName("UTF-8"));
    sender.print("WorldGuard report written to " + dest.getAbsolutePath());
  } catch (IOException e) {
    throw new CommandException("Failed to write report: " + e.getMessage());
  }
  
  if (args.hasFlag('p')) {
    sender.checkPermission("worldguard.report.pastebin");
    ActorCallbackPaste.pastebin(worldGuard.getSupervisor(), sender, result, "WorldGuard report: %s.report", worldGuard.getExceptionConverter());
  }
}

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

Player player = event.getPlayer();
LocalPlayer localPlayer = plugin.wrapPlayer(player);
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
if (wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())) {
  ApplicableRegionSet set =
      WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());

代码示例来源: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

/**
 * Create a new instance.
 *
 * @param cache the query cache
 */
public RegionQuery(QueryCache cache) {
  checkNotNull(cache);
  this.config = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
  this.cache = cache;
  //noinspection deprecation
}

代码示例来源: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

@EventHandler
  public void onVehicleMove(VehicleMoveEvent event) {
    Vehicle vehicle = event.getVehicle();
    if (vehicle.getPassengers().isEmpty()) return;
    List<LocalPlayer> playerPassengers =
        vehicle.getPassengers().stream().filter(ent -> ent instanceof Player).map(ent -> plugin.wrapPlayer((Player) ent)).collect(Collectors.toList());
    if (playerPassengers.isEmpty()) {
      return;
    }
    World world = vehicle.getWorld();
    ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
    WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));

    if (wcfg.useRegions) {
      // Did we move a block?
      if (Locations.isDifferentBlock(BukkitAdapter.adapt(event.getFrom()), BukkitAdapter.adapt(event.getTo()))) {
        for (LocalPlayer player : playerPassengers) {
          if (null != WorldGuard.getInstance().getPlatform().getSessionManager().get(player)
              .testMoveTo(player, BukkitAdapter.adapt(event.getTo()), MoveType.RIDE)) {
            vehicle.setVelocity(new Vector(0, 0, 0));
            vehicle.teleport(event.getFrom());
            return;
          }
        }
      }
    }
  }
}

代码示例来源: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

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

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

Player player = event.getPlayer();
LocalPlayer localPlayer = plugin.wrapPlayer(player);
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
      WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(event.getTo()));
  ApplicableRegionSet setFrom =
      WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(event.getFrom()));
    if (null != WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer).testMoveTo(localPlayer,
        BukkitAdapter.adapt(event.getTo()),
        MoveType.TELEPORT)) {
    if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())
        && !(set.testState(localPlayer, Flags.ENDERPEARL)
            && setFrom.testState(localPlayer, Flags.ENDERPEARL))) {
      if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())) {
        boolean allowFrom = setFrom.testState(localPlayer, Flags.CHORUS_TELEPORT);
        boolean allowTo = set.testState(localPlayer, Flags.CHORUS_TELEPORT);

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

/**
 * Get the global configuration.
 *
 * @return the configuration
 */
protected ConfigurationManager getConfig() {
  return WorldGuard.getInstance().getPlatform().getGlobalStateManager();
}

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

targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);

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

@EventHandler
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
  Player player = event.getPlayer();
  LocalPlayer localPlayer = plugin.wrapPlayer(player);
  WorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
  Session session = WorldGuard.getInstance().getPlatform().getSessionManager().getIfPresent(localPlayer);
  if (session != null) {
    GameModeFlag handler = session.getHandler(GameModeFlag.class);
    if (handler != null && wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer,
        localPlayer.getWorld())) {
      GameMode expected = handler.getSetGameMode();
      if (handler.getOriginalGameMode() != null && expected != null && expected != BukkitAdapter.adapt(event.getNewGameMode())) {
        log.info("Game mode change on " + player.getName() + " has been blocked due to the region GAMEMODE flag");
        event.setCancelled(true);
      }
    }
  }
}

代码示例来源: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;
}

代码示例来源: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

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: eccentricdevotion/TARDIS

/**
 * Gets a List of all TARDIS regions in a world.
 *
 * @param w the world to get the regions for
 * @return a list of TARDIS region names for this world
 */
public List<String> getTARDISRegions(World w) {
  List<String> regions = new ArrayList<>();
  RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(w));
  rm.getRegions().forEach((key, value) -> {
    if (key.contains("tardis")) {
      regions.add(key);
    }
  });
  return regions;
}

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