本文整理汇总了Java中com.massivecraft.massivecore.ps.PS类的典型用法代码示例。如果您正苦于以下问题:Java PS类的具体用法?Java PS怎么用?Java PS使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PS类属于com.massivecraft.massivecore.ps包,在下文中一共展示了PS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chunkChangeDetect
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void chunkChangeDetect(PlayerMoveEvent event)
{
// If the player is moving from one chunk to another ...
if (MUtil.isSameChunk(event)) return;
Player player = event.getPlayer();
if (this.isntPlayer(player)) return;
// ... gather info on the player and the move ...
MPlayer mplayer = MPlayer.get(player);
PS chunkFrom = PS.valueOf(event.getFrom()).getChunk(true);
PS chunkTo = PS.valueOf(event.getTo()).getChunk(true);
Faction factionFrom = BoardColl.get().getFactionAt(chunkFrom);
Faction factionTo = BoardColl.get().getFactionAt(chunkTo);
if ( ! isChunkCoord(player)) return;
// ... and send info onwards.
EngineMain.get().chunkChangeTerritoryInfo(mplayer, player, chunkFrom, chunkTo, factionFrom, factionTo);
EngineMain.get().chunkChangeAutoClaim(mplayer, chunkTo);
}
示例2: getInitialRanges
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
@Override
public List<ProtectionRange> getInitialRanges(Player player) {
ArrayList<ProtectionRange> ranges = new ArrayList<>();
MPlayer mplayer = MPlayer.get(player);
if (mplayer.hasFaction()) {
Faction faction = mplayer.getFaction();
MPerm downloadPerm = plugin.getOrRegisterDownloadPerm();
if (downloadPerm.has(mplayer, faction, false)) {
Set<PS> positions = getFactionPositions(player.getWorld(), faction);
ranges.addAll(convertPSToRanges(player.getWorld(), positions, faction));
}
}
return ranges;
}
示例3: convertPSToRanges
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
/**
* Converts a Set of MassiveCraft {@link PS}s to {@link ProtectionRange}s.
*/
public List<ProtectionRange> convertPSToRanges(World world, Set<PS> positions, Faction owningFaction) {
List<ProtectionRange> ranges = new ArrayList<>();
for (PS position : positions) {
if (!position.getWorld().equals(world.getName())) {
continue;
}
int x = position.getChunkX();
int z = position.getChunkZ();
ranges.add(new ProtectionRange(owningFaction.getName(), x, z, x, z));
}
return ranges;
}
示例4: run
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
/**
* Called each tick; try to empty out {@link #playersNeedingUpdating}.
*/
@Override
public void run() {
for (UUID uuid : playersNeedingUpdating) {
Player player = Bukkit.getPlayer(uuid);
if (player != null && rangeGroup.isWDLPlayer(player)) {
Map<PS, Faction> chunkMap = getNearbyChunks(player,
trackDistance);
List<ProtectionRange> ranges = convertChunkMapToRanges(player,
chunkMap);
rangeGroup.setRanges(player, ranges);
}
}
playersNeedingUpdating.clear();
}
示例5: convertChunkMapToRanges
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
/**
* Converts a Map (of MassiveCraft {@link PS}s to Factions) to a list of
* {@link ProtectionRange}s. Only chunks that the player can download in are
* given.
*/
public List<ProtectionRange> convertChunkMapToRanges(Player player, Map<PS, Faction> chunkMap) {
MPlayer mplayer = convertPlayerToMPlayer(player);
String world = player.getWorld().getName();
List<ProtectionRange> ranges = new ArrayList<>();
MPerm downloadPerm = plugin.getOrRegisterDownloadPerm();
for (Map.Entry<PS, Faction> entry : chunkMap.entrySet()) {
if (!entry.getKey().getWorld().equals(world)) {
continue;
}
if (!downloadPerm.has(mplayer, entry.getValue(), false)) {
continue;
}
int x = entry.getKey().getChunkX();
int z = entry.getKey().getChunkZ();
String tag = entry.getValue().getName();
ranges.add(new ProtectionRange(tag, x, z, x, z));
}
return ranges;
}
示例6: process
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
@Override
public void process(World from, World to) {
System.out.println("Preprocessing: Faction " + f.getName());
Set<PS> chunks = BoardColl.get().getChunks(f);
for (PS ps : chunks) {
if (ps.getWorld().equals(from.getName())) {
Chunk c = ps.asBukkitChunk();
int cx = c.getX() * 16;
int cz = c.getZ() * 16;
System.out.println("Preprocessing: FactionBlock x=" + cx + ",z=" + cz);
for (int x = cx; x < cx + 16; x++) {
for (int z = cz; z < cz + 16; z++) {
for (int y = 0; y < 256; y++) {
WorldRestore.addToProcessQueues(from.getBlockAt(x, y, z));
}
}
}
}
}
}
示例7: getAt
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
@Override
public Faction getAt(Chunk chunk) {
com.massivecraft.factions.entity.Faction mfaction = BoardColls.get().getFactionAt(PS.valueOf(chunk));
if (mfaction == null) return null;
return get(mfaction.getId());
}
示例8: doSetAt
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
private void doSetAt(Set<PS> chunks, MPlayer player, com.massivecraft.factions.entity.Faction newFaction) {
String formatOne = "<h>%s<i> %s <h>%d <i>chunk %s<i>.";
String formatMany = "<h>%s<i> %s <h>%d <i>chunks near %s<i>.";
HashMap<com.massivecraft.factions.entity.Faction, Set<PS>> oldFactionChunks = new HashMap<com.massivecraft.factions.entity.Faction, Set<PS>>();
for (PS chunk : chunks) {
com.massivecraft.factions.entity.Faction factionHere = BoardColl.get().getFactionAt(chunk);
Set<PS> claims = new HashSet<PS>();
if (oldFactionChunks.containsKey(factionHere)) {
claims = oldFactionChunks.get(factionHere);
claims.add(chunk);
}
oldFactionChunks.put(factionHere, claims);
BoardColl.get().setFactionAt(chunk, newFaction);
}
// Inform
for (Entry<com.massivecraft.factions.entity.Faction, Set<PS>> entry : oldFactionChunks.entrySet()) {
final com.massivecraft.factions.entity.Faction oldFaction = entry.getKey();
final Set<PS> oldChunks = entry.getValue();
final PS oldChunk = oldChunks.iterator().next();
final Set<MPlayer> informees = MPlayer.getClaimInformees(player, oldFaction, newFaction);
final EventFactionsChunkChangeType type = EventFactionsChunkChangeType.get(oldFaction, newFaction, player.getFaction());
String chunkString = oldChunk.toString(PSFormatHumanSpace.get());
String typeString = type.past;
for (MPlayer informee : informees) {
informee.msg((oldChunks.size() == 1 ? formatOne : formatMany), player.describeTo(informee, true), typeString, oldChunks.size(), chunkString);
informee.msg(" <h>%s<i> --> <h>%s", oldFaction.describeTo(informee, true), newFaction.describeTo(informee, true));
}
}
}
示例9: tryClaim
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
@Override
public boolean tryClaim(Faction faction, Location location) {
Collection<PS> locationsCol = new ArrayList<PS>();
locationsCol.add(PS.valueOf(location));
return this.mplayer.tryClaim(FactionColl.get().get(faction.getId()), locationsCol);
}
示例10: getAt
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
@Override
public Faction getAt(Chunk chunk) {
com.massivecraft.factions.entity.Faction mfaction = BoardColl.get().getFactionAt(PS.valueOf(chunk));
if (mfaction == null) return null;
return get(mfaction.getId());
}
示例11: factionLandNearby
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
/**
* Is there faction land within the radius from location
* @param l
* @return False if none, True if land found.
*/
public boolean factionLandNearby(Location l) {
if (Bukkit.getServer().getPluginManager().getPlugin("Factions") == null) {
return false;
}
if(!RandomCoords.getPlugin().getConfig().getString("Factions").equalsIgnoreCase("true")) {
return false;
}
int radius = RandomCoords.getPlugin().getConfig().getInt("CheckingRadius");
int chunkRadius = radius < 16 ? 1 : (radius - (radius % 16)) / 16;
int x;
int y;
int z;
for (int chX = 0 - chunkRadius; chX <= chunkRadius; chX++) {
for (int chZ = 0 - chunkRadius; chZ <= chunkRadius; chZ++) {
x = l.getBlockX();
y = l.getBlockY();
z = l.getBlockZ();
Block b = l.getWorld().getBlockAt(x + (chX * 16), y, z + (chZ * 16));
if (!(BoardColl.get().getFactionAt(PS.valueOf(b)).isNone())) {
return true;
}
}
}
return false;
}
示例12: getClaims
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
@Override
public List<ChunkPos> getClaims() {
List<ChunkPos> target = new LinkedList<>();
for (Set<PS> ps : BoardColl.get().getFactionToChunks().values()) {
target.addAll(psToChunkPos(ps));
}
return target;
}
示例13: checkSurroundingFactions
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
private boolean checkSurroundingFactions(Location loc) {
int distance = range / 2;
Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
if (BoardColl.get().getFactionAt(PS.valueOf(new Location(loc.getWorld(), loc.getX() + x, loc.getY(), loc.getZ() + z))).isNone())
return true;
}
}
return false;
}
示例14: isProtected
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
private boolean isProtected(Player player, Block b) {
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(b));
MPlayer mp = MPlayer.get(player);
if (faction != null && !faction.getId().equals("none")) {
if (!faction.getId().equals(mp.getFactionId())) return true;
}
return false;
}
示例15: onMembershipChange
import com.massivecraft.massivecore.ps.PS; //导入依赖的package包/类
/**
* Called when someone's membership in a faction changes.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMembershipChange(EventFactionsMembershipChange e) {
MPlayer mplayer = e.getMPlayer();
Player player = convertMPlayerToPlayer(mplayer);
if (player == null) {
return;
}
Set<PS> newPS = getFactionPositions(player.getWorld(), e.getNewFaction());
List<ProtectionRange> newRanges = convertPSToRanges(player.getWorld(), newPS, e.getNewFaction());
rangeGroup.setRanges(player, newRanges);
}