gpt4 book ai didi

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

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

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

WorldGuardPlatform.getRegionContainer介绍

[英]Gets a RegionContainer.
[中]得到一个RegionContainer。

代码示例

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

/**
 * Tick the session.
 *
 * @param player The player
 */
public void tick(LocalPlayer player) {
  RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
  Location location = player.getLocation();
  ApplicableRegionSet set = query.getApplicableRegions(location);
  for (Handler handler : handlers.values()) {
    handler.tick(player, set);
  }
}

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

/**
 * Initialize the session.
 *
 * @param player The player
 */
public void initialize(LocalPlayer player) {
  RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
  Location location = player.getLocation();
  ApplicableRegionSet set = query.getApplicableRegions(location);
  lastValid = location;
  lastRegionSet = set.getRegions();
  for (Handler handler : handlers.values()) {
    handler.initialize(player, location, set);
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Gets a TARDIS WorldGuard region.
 *
 * @param world the world the region is in
 * @param p     the Time Lord whose region it is
 * @return the protected region
 */
public ProtectedRegion getRegion(String world, String p) {
  World w = plugin.getServer().getWorld(world);
  if (w == null) {
    return null;
  }
  RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(w));
  return rm.getRegion("tardis_" + p);
}

代码示例来源:origin: ChestShop-authors/ChestShop-3

private ApplicableRegionSet getApplicableRegions(Location location) {
    RegionManager regionManager = worldGuardPlatform.getRegionContainer().get(BukkitAdapter.adapt(location.getWorld()));
    if (regionManager == null) {
      return null;
    }
    return regionManager.getApplicableRegions(BukkitAdapter.adapt(location).toVector().toBlockPoint());
  }
}

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

private static Event.Result canPvP(Player player) {
  if (!hasSupport || !useWorldGuard)
    return Event.Result.ALLOW;
  LocalPlayer localPlayer = wgPlugin.wrapPlayer(player);
  State stat = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(localPlayer.getLocation(), localPlayer, Flags.PVP);
  return (stat == null || stat.equals(State.ALLOW)) ? Event.Result.ALLOW : Event.Result.DENY;
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Adds a player to a region's membership.
 *
 * @param w     the world the region is located in
 * @param owner the player whose region it is
 * @param a     the player to add
 */
public void addMemberToRegion(World w, String owner, String a) {
  RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(w));
  if (rm.hasRegion("tardis_" + owner)) {
    plugin.getServer().dispatchCommand(plugin.getConsole(), "rg addmember tardis_" + owner + " " + a + " -w " + w.getName());
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Removes a player from a region's membership.
 *
 * @param w     the world the region is located in
 * @param owner the player whose region it is
 * @param a     the player to add
 */
public void removeMemberFromRegion(World w, String owner, String a) {
  RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(w));
  if (rm.hasRegion("tardis_" + owner)) {
    plugin.getServer().dispatchCommand(plugin.getConsole(), "rg removemember tardis_" + owner + " " + a + " -w " + w.getName());
  }
}

代码示例来源:origin: mcMMO-Dev/mcMMO

public boolean hasMainFlag(Player player)
{
  if(player == null)
    return false;
  BukkitPlayer localPlayer = BukkitAdapter.adapt(player);
  com.sk89q.worldedit.util.Location loc = localPlayer.getLocation();
  //WorldGuardPlugin worldGuard = getWorldGuard();
  RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
  RegionQuery query = container.createQuery();
  //ApplicableRegionSet set = query.getApplicableRegions(loc);
  return query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), WorldGuardFlags.MCMMO_ENABLE_WG_FLAG);
}

代码示例来源:origin: mcMMO-Dev/mcMMO

public boolean hasXPFlag(Player player)
{
  if(player == null)
    return false;
  BukkitPlayer localPlayer = BukkitAdapter.adapt(player);
  com.sk89q.worldedit.util.Location loc = localPlayer.getLocation();
  //WorldGuardPlugin worldGuard = getWorldGuard();
  RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
  RegionQuery query = container.createQuery();
  //ApplicableRegionSet set = query.getApplicableRegions(loc);
  return query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), WorldGuardFlags.MCMMO_XP_WG_FLAG);
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Removes the WorldGuard region when the TARDIS is deleted.
 *
 * @param w the world the region is located in
 * @param p the player's name
 */
public void removeRegion(World w, String p) {
  RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(w));
  rm.removeRegion("tardis_" + p);
  try {
    rm.save();
  } catch (StorageException e) {
    plugin.getConsole().sendMessage(plugin.getPluginName() + "Could not remove WorldGuard Protection for TARDIS! " + e.getMessage());
  }
}

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

static void refreshPlayerWG(Player p) {
  LocalPlayer localPlayer = WGSupport.wgPlugin.wrapPlayer(p);
  RegionContainer container = worldGuardInstance.getPlatform().getRegionContainer();
  RegionManager regions = container.get(localPlayer.getWorld());
  if (regions == null) return;
  ApplicableRegionSet set = regions.getApplicableRegions(localPlayer.getLocation().toVector().toBlockPoint());
  refresh(set, localPlayer);
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
   * Checks whether there is a protected region at a location and if so whether mobs can spawn.
   *
   * @param l the location to check
   * @return true if mobs can spawn, otherwise false
   */
  public boolean mobsCanSpawnAtLocation(Location l) {
    RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(l.getWorld()));
    BlockVector3 vector = BlockVector3.at(l.getX(), l.getY(), l.getZ());
    ApplicableRegionSet ars = rm.getApplicableRegions(vector);
    return ars.testState(null, Flags.MOB_SPAWNING);
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Checks if a player can build (a Police Box) at this location.
 *
 * @param p the player to check
 * @param l the location to check
 * @return true of false depending on whether the player has permission to build at this location
 */
public boolean canBuild(Player p, Location l) {
  BlockVector3 vector = BlockVector3.at(l.getX(), l.getY(), l.getZ());
  RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(l.getWorld()));
  ApplicableRegionSet rs = rm.getApplicableRegions(vector);
  return rs.testState(wgp.wrapPlayer(p), Flags.BUILD);
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Checks whether a block can be broken
 *
 * @param p the player trying to break the block
 * @param b the block
 * @return whether the block can be broken
 */
public boolean canBreakBlock(Player p, Block b) {
  BlockVector3 vector = BlockVector3.at(b.getX(), b.getY(), b.getZ());
  RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(b.getWorld()));
  ApplicableRegionSet rs = rm.getApplicableRegions(vector);
  return rs.testState(wgp.wrapPlayer(p), Flags.BUILD);
}

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

private RegionAssociable createRegionAssociable(Cause cause) {
  Object rootCause = cause.getRootCause();
  if (!cause.isKnown()) {
    return Associables.constant(Association.NON_MEMBER);
  } else if (rootCause instanceof Player) {
    return getPlugin().wrapPlayer((Player) rootCause);
  } else if (rootCause instanceof OfflinePlayer) {
    return getPlugin().wrapOfflinePlayer((OfflinePlayer) rootCause);
  } else if (rootCause instanceof Entity) {
    RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
    return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(((Entity) rootCause).getLocation()));
  } else if (rootCause instanceof Block) {
    RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
    return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(((Block) rootCause).getLocation()));
  } else {
    return Associables.constant(Association.NON_MEMBER);
  }
}

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

@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlaceBlock(final PlaceBlockEvent event) {
  com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(event.getWorld());
  if (!isRegionSupportEnabled(weWorld)) return; // Region support disabled
  RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
  Block block;
  if ((block = event.getCause().getFirstBlock()) != null) {
    if (Materials.isPistonBlock(block.getType())) {
      event.filter(testState(query, Flags.PISTONS), false);
    }
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Removes the WorldGuard region when the recharger is removed.
 *
 * @param name the name of the recharger to remove
 */
public void removeRechargerRegion(String name) {
  World w = plugin.getServer().getWorld(plugin.getConfig().getString("rechargers." + name + ".world"));
  RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(w));
  rm.removeRegion("tardis_recharger_" + name);
  try {
    rm.save();
  } catch (StorageException e) {
    plugin.getConsole().sendMessage(plugin.getPluginName() + "Could not remove recharger WorldGuard Protection for recharger! " + e.getMessage());
  }
}

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

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onLightningStrike(LightningStrikeEvent event) {
    ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
    WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getWorld()));

    if (wcfg.disallowedLightningBlocks.size() > 0) {
      Material targetId = event.getLightning().getLocation().getBlock().getType();
      if (wcfg.disallowedLightningBlocks.contains(BukkitAdapter.asBlockType(targetId).getId())) {
        event.setCancelled(true);
      }
    }

    Location loc = event.getLightning().getLocation();
    if (wcfg.useRegions) {
      if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(loc), (RegionAssociable) null, Flags.LIGHTNING))) {
        event.setCancelled(true);
      }
    }
  }
}

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

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) {
  Player player = event.getPlayer();
  LocalPlayer localPlayer = plugin.wrapPlayer(player);
  ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
  WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
  if (wcfg.useRegions) {
    ApplicableRegionSet set =
        WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());
    com.sk89q.worldedit.util.Location spawn = set.queryValue(localPlayer, Flags.SPAWN_LOC);
    if (spawn != null) {
      event.setRespawnLocation(BukkitAdapter.adapt(spawn));
    }
  }
}

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