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


Java Location类代码示例

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


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

示例1: onPistonExtend

import org.bukkit.Location; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onPistonExtend(BlockPistonExtendEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    Location pistonLoc = e.getBlock().getLocation();
    if (Settings.allowPistonPush || !Util.inWorld(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    Island island = plugin.getIslands().getProtectedIslandAt(pistonLoc);
    if (island == null || !island.onIsland(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not on is island protection zone");
        return;
    }
    // We need to check where the blocks are going to go, not where they are
    for (Block b : e.getBlocks()) {
        if (!island.onIsland(b.getRelative(e.getDirection()).getLocation())) {
            //plugin.getLogger().info("DEBUG: Block is outside protected area");
            e.setCancelled(true);
            return;
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:25,代码来源:IslandGuard.java

示例2: isPVPEnabled

import org.bukkit.Location; //导入依赖的package包/类
public static boolean isPVPEnabled(Location location) {
	String global = "__global__";
	if(plugin.getWorldGuard().getRegionManager(location.getWorld()) == null)	
		return true;
	RegionManager regionManager = plugin.getWorldGuard().getRegionManager(location.getWorld());
	ApplicableRegionSet arset = regionManager.getApplicableRegions(location);
	ProtectedRegion region = regionManager.getRegion(global);
	int priority = -10000;
	for(ProtectedRegion r : arset.getRegions()) { 
		if(r.getPriority() > priority) {
			region = r;
			priority = r.getPriority();
		}
	}
	if(region == null) {
		if(regionManager.getRegion(global) == null)
			return false;
		return "ALLOW".equals(regionManager.getRegion(global).getFlag(DefaultFlag.PVP).toString());
	}
	if(region.getFlag(DefaultFlag.PVP) == null)
		return true;
	return "ALLOW".equalsIgnoreCase(region.getFlag(DefaultFlag.PVP).toString());
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:24,代码来源:Utility.java

示例3: handleWinner

import org.bukkit.Location; //导入依赖的package包/类
/**
 * Handles the winner for this event.
 *
 * @param winner
 *            the {@link Player} that won
 */
public void handleWinner(Player winner) {
    if (this.eventFaction == null)
        return;

    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(winner);
    Bukkit.broadcastMessage(ChatColor.GOLD + "[" + "WIN" + "] " + ChatColor.RED + winner.getName() + ChatColor.AQUA
            + ChatColor.YELLOW + " has captured " + ChatColor.RED + this.eventFaction.getName()
            + ChatColor.YELLOW + " after " + ChatColor.RED + DurationFormatUtils.formatDurationWords(getUptime(), true, true) + " of up-time" + ChatColor.YELLOW + '.');

    EventType eventType = this.eventFaction.getEventType();
    World world = winner.getWorld();
    Location location = winner.getLocation();
    EventKey eventKey = plugin.getKeyManager().getEventKey();
    Collection<Inventory> inventories = eventKey.getInventories(eventType);
    ItemStack keyStack = eventKey.getItemStack(new EventKey.EventKeyData(eventType, inventories.isEmpty() ? 1 : plugin.getRandom().nextInt(inventories.size()) + 1));
    Map<Integer, ItemStack> excess = winner.getInventory().addItem(keyStack, EventSignListener.getEventSign(eventFaction.getName(), winner.getName()));
    for (ItemStack entry : excess.values()) {
        world.dropItemNaturally(location, entry);
    }

    this.clearCooldown(); // must always be cooled last as this nulls some variables.
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:29,代码来源:EventTimer.java

示例4: spawn

import org.bukkit.Location; //导入依赖的package包/类
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final net.minecraft.server.v1_8_R1.World mcWorld = ((org.bukkit.craftbukkit.v1_8_R1.CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final net.minecraft.server.v1_8_R1.NBTTagCompound compound = new net.minecraft.server.v1_8_R1.NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.rabbit.getEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:31,代码来源:CustomGroundArmorstand.java

示例5: shoot

import org.bukkit.Location; //导入依赖的package包/类
/**
 * A basic shoot method, it _can_ be overridden but take care.
 * Handles passing the bullet to its BulletType for configuration, sets shooter, velocity, etc.
 * 
 * @param begin The location to shoot from
 * @param bulletType the Bullet type of this bullet
 * @param shooter the entity shooting
 * @param velocity the velocity to use as base for this shooting, if any
 * @param overrideVelocity if true, use the passed velocity and override anything set up by the bullet type.
 * @return the new Projectile that has been unleashed.
 */
public Projectile shoot(Location begin, Bullet bulletType, ProjectileSource shooter, Vector velocity, boolean overrideVelocity) {
	World world = begin.getWorld();
	begin = begin.clone();
	begin.setDirection(velocity);
	Projectile newBullet = world.spawn(begin, bulletType.getProjectileType() );
			
	newBullet.setCustomName(this.bulletTag);
	newBullet.setBounce(false);
	newBullet.setGravity(true);
	newBullet.setShooter(shooter);
	
	bulletType.configureBullet(newBullet, world, shooter, velocity);
	
	if (overrideVelocity) {
		newBullet.setVelocity(velocity);
	}

	return newBullet;
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:31,代码来源:StandardGun.java

示例6: playSmoke

import org.bukkit.Location; //导入依赖的package包/类
public void playSmoke(Location l) {
	Utils.getInstance().playParticle(l, ParticleEffect.LARGE_SMOKE);

	new BukkitRunnable() {
		int count = 0;

		public void run() {
			this.count += 1;
			if (this.count <= 5) {
				Utils.getInstance().playParticle(l, ParticleEffect.LARGE_SMOKE);
			} else {
				cancel();
			}
		}
	}.runTaskTimer(KingdomFactionsPlugin.getInstance(), 1L, 2L);
	Utils.getInstance().playParticle(l, ParticleEffect.LARGE_SMOKE);
	for(int i = 0; i < 5; i++) {
		Utils.getInstance().playParticle(l, ParticleEffect.HAPPY_VILLAGER);
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:21,代码来源:Spark.java

示例7: playDeathSound

import org.bukkit.Location; //导入依赖的package包/类
private void playDeathSound(@Nullable ParticipantState killer) {
    Location death = player.getBukkit().getLocation();

    for(MatchPlayer listener : player.getMatch().getPlayers()) {
        if(listener == player) {
            // Own death is normal pitch, full volume
            listener.playSound(Sound.ENTITY_IRONGOLEM_DEATH);
        } else if(killer != null && killer.isPlayer(listener)) {
            // Kill is higher pitch, quieter
            listener.playSound(Sound.ENTITY_IRONGOLEM_DEATH, 0.75f, 4f / 3f);
        } else if(listener.getParty() == player.getParty()) {
            // Ally death is a shorter sound
            listener.playSound(Sound.ENTITY_IRONGOLEM_HURT, death);
        } else {
            // Enemy death is higher pitch
            listener.playSound(Sound.ENTITY_IRONGOLEM_HURT, death, 1, 4f / 3f);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:Alive.java

示例8: serializeLocation

import org.bukkit.Location; //导入依赖的package包/类
public static String serializeLocation(Location loc) {
    StringBuilder sb = new StringBuilder();
    sb.append(loc.getX());
    sb.append(LOCATION_DIVIDER);
    if (loc.getY() < 1)
        sb.append("1.0");
    else
        sb.append(loc.getY());
    sb.append(LOCATION_DIVIDER);
    sb.append(loc.getZ());
    sb.append(LOCATION_DIVIDER);
    sb.append(loc.getYaw());
    sb.append(LOCATION_DIVIDER);
    sb.append(loc.getPitch());
    sb.append(LOCATION_DIVIDER);
    sb.append(loc.getWorld().getName());
    return sb.toString();
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:19,代码来源:RSerializer.java

示例9: findOrCreate

import org.bukkit.Location; //导入依赖的package包/类
public Location findOrCreate(Location target) {
    net.minecraft.world.WorldServer worldServer = ((CraftWorld) target.getWorld()).getHandle();
    boolean before = worldServer.theChunkProviderServer.loadChunkOnProvideRequest;
    worldServer.theChunkProviderServer.loadChunkOnProvideRequest = true;

    Location found = this.findPortal(target);
    if (found == null) {
        if (this.getCanCreatePortal() && this.createPortal(target)) {
            found = this.findPortal(target);
        } else {
            found = target; // fallback to original if unable to find or create
        }
    }

    worldServer.theChunkProviderServer.loadChunkOnProvideRequest = before;
    return found;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:18,代码来源:CraftTravelAgent.java

示例10: getNPCsInRange

import org.bukkit.Location; //导入依赖的package包/类
public static List<NPC> getNPCsInRange(int radius, Location location) {
    List<NPC> list = new ArrayList<>();

    for (int x = radius; x >= -radius; x--) {
        for (int y = radius; y >= -radius; y--) {
            for (int z = radius; z >= -radius; z--) {
                NPCPoint point = new NPCPoint(location.clone().add(x, y, z));

                if (NPC_LOCATIONS.containsKey(point)) {
                    list.addAll(NPC_LOCATIONS.get(point));
                }
            }
        }
    }

    return list;
}
 
开发者ID:Dragovorn,项目名称:OpenRPG,代码行数:18,代码来源:NPC.java

示例11: getLocationBehondPlayer

import org.bukkit.Location; //导入依赖的package包/类
/***
 * Locations side
 ***/

public Location getLocationBehondPlayer(Location referential, double radius)
{
    float yaw = referential.getYaw();
    float finalYaw = yaw - 90;

    double relativeX = Math.cos(Math.toRadians(finalYaw)) * radius;
    double relativeZ = Math.sin(Math.toRadians(finalYaw)) * radius;
    double relativeY = -0.90;

    return new Location(referential.getWorld(),
            referential.getX() + relativeX,
            referential.getY() + relativeY,
            referential.getZ() + relativeZ
    );
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:20,代码来源:KillAuraTask.java

示例12: onBlockBreak

import org.bukkit.Location; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onBlockBreak(BlockBreakEvent evt) {
    Location at = evt.getBlock().getLocation();
    if (at.getY() > 20 || !at.getWorld().equals(Core.getMainWorld()))
        return;

    // Remember mined blocks.
    BrokenBlock bk = new BrokenBlock(evt.getPlayer(), evt.getBlock());
    blocks.add(bk);
    if ((bk.getType() == Material.DIAMOND_ORE || Utils.randChance(20))
            && (getBlockScore(evt.getPlayer()) >= 20 || getTimeScore(evt.getPlayer()) >= 20))
            blocks.detect(bk);

    // Handle suspicious ascending / descending.
    if (elevation.getDetections(evt.getPlayer()).stream().noneMatch(b -> b.getLocation().getY() == at.getY()))
        elevation.detect(bk);
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:18,代码来源:Xray.java

示例13: onClickEndPortalFrame

import org.bukkit.Location; //导入依赖的package包/类
@EventHandler
public void onClickEndPortalFrame(PlayerInteractEvent event) {
	Player player = event.getPlayer();
	World world = player.getWorld();
	Block clickedBlock = event.getClickedBlock();
	if (event.getAction() != Action.RIGHT_CLICK_BLOCK || world.getEnvironment() != Environment.THE_END 
			|| clickedBlock.getType() != Material.BEDROCK || event.getHand() != EquipmentSlot.HAND
			|| (player.getInventory().getItemInMainHand() != null || player.getInventory().getItemInOffHand() != null)) return;
	
	NMSAbstract nmsAbstract = plugin.getNMSAbstract();
	DragonBattle dragonBattle = nmsAbstract.getEnderDragonBattleFromWorld(world);
	Location portalLocation = dragonBattle.getEndPortalLocation();
	
	if (event.getClickedBlock().getLocation().distanceSquared(portalLocation) > 36) return; // 5 blocks
	
	EndWorldWrapper endWorld = plugin.getDEDManager().getWorldWrapper(world);
	int secondsRemaining = endWorld.getTimeUntilRespawn();
	if (secondsRemaining <= 0) return;
	
	plugin.sendMessage(player, "Dragon will respawn in " + ChatColor.YELLOW + secondsRemaining);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:22,代码来源:PortalClickListener.java

示例14: onMove

import org.bukkit.Location; //导入依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent event) {
	Game game = Chambers.getInstance().getGameManager().getGame();
	if (game.getStatus() != GameStatus.INGAME) {
		return;
	}
	Location to = event.getTo();
	Location from = event.getFrom();
	if (to.getBlockX() != from.getBlockX() || to.getBlockZ() != from.getBlockZ()) {
		Player player = event.getPlayer();
		Team toTeam = Chambers.getInstance().getClaimManager().getTeamAt(to);
		Team fromTeam = Chambers.getInstance().getClaimManager().getTeamAt(from);
		if (toTeam != fromTeam) {
			Bukkit.getPluginManager().callEvent(new PlayerEnterClaimEvent(player, toTeam.getClaim()));
			Bukkit.getPluginManager().callEvent(new PlayerLeaveClaimEvent(player, fromTeam.getClaim()));
			if (toTeam.getType() == TeamType.KOTH_CAP || fromTeam.getType() == TeamType.KOTH_CAP) {
				return;
			}
			player.sendMessage(ChatColor.YELLOW + "Now leaving: " + fromTeam.getFormattedName());
			player.sendMessage(ChatColor.YELLOW + "Now entering: " + toTeam.getFormattedName());
		}
	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:24,代码来源:ClaimMoveListener.java

示例15: onPlayerInteract

import org.bukkit.Location; //导入依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Location location = player.getLocation();
    ItemStack item = event.getItem();
    if (isBull(item) && event.getAction() == Action.RIGHT_CLICK_AIR | event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (!FactionsXL.getInstance().getBoard().isAnnexable(location)) {
            ParsingUtil.sendMessage(player, FMessage.ERROR_LAND_NOT_FOR_SALE.getMessage());
            return;
        }
        FactionCache factions = FactionsXL.getInstance().getFactionCache();
        BookMeta meta = ((BookMeta) item.getItemMeta());
        String title = meta.getTitle().replace(" ", "-");
        if (factions.getByName(title) != null) {
            title += NumberUtil.generateRandomInt(0, 100);
        }
        FireworkUtil.spawnRandom(location);
        FactionsXL.getInstance().getFactionCache().create(player, title);
        player.getInventory().remove(item);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:22,代码来源:FBull.java


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