Java 类org.bukkit.Location 实例源码

项目:HCFCore    文件:EventTimer.java   
/**
 * 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.
}
项目:AddGun    文件:StandardGun.java   
/**
 * 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;
}
项目:AsgardAscension    文件:Utility.java   
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());
}
项目:KingdomFactions    文件:Spark.java   
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);
    }
}
项目:bskyblock    文件:IslandGuard.java   
@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;
        }
    }
}
项目:ProjectAres    文件:Alive.java   
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);
        }
    }
}
项目:ZentrelaCore    文件:RSerializer.java   
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();
}
项目:Uranium    文件:CraftTravelAgent.java   
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;
}
项目:OpenRPG    文件:NPC.java   
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;
}
项目:AntiCheat    文件:KillAuraTask.java   
/***
 * 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
    );
}
项目:Kineticraft    文件:Xray.java   
@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);
}
项目:DragonEggDrop    文件:PortalClickListener.java   
@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);
}
项目:Chambers    文件:ClaimMoveListener.java   
@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());
        }
    }
}
项目:FactionsXL    文件:FBull.java   
@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);
    }
}
项目:PA    文件:IronElevators.java   
@EventHandler(priority = EventPriority.HIGH)
public void upElevator(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Block b = e.getTo().getBlock().getRelative(BlockFace.DOWN);
    if (e.getFrom().getY() < e.getTo().getY() && b.getType() == elevatorMaterial) { b = b.getRelative(BlockFace.UP, minElevation);
        int i = maxElevation;
        while (i > 0 && !(b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent())) {
            i--;
            b = b.getRelative(BlockFace.UP);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() + maxElevation + 3 - i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
        }
    }
}
项目:Arcadia-Spigot    文件:ElectricFloorGame.java   
@Override
public void onPreStart() {
    Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(!this.getAPI().getGameManager().isAlive(player)) continue;
        player.teleport(spawnLocation);
        player.setGameMode(GameMode.ADVENTURE);
    }
    List<MaterialData> floorData = new ArrayList<MaterialData>();
    for(String temp : ((String) this.getGameMap().fetchSetting("blocks")).split(",")) {
        floorData.add(Utils.parseMaterialData(temp));
    }
    this.floorOrder = new FloorOrder(floorData);
}
项目:SurvivalAPI    文件:SecurityListener.java   
/**
 * Patch player teleporting through portals to be INSIDE the world border
 *
 * @param event Event
 */
@EventHandler
public void onPlayerPortal(PlayerPortalEvent event)
{
    if (!this.game.getPlugin().getServer().getAllowNether() || this.game.getSurvivalGameLoop().isNetherClosed())
    {
        event.setCancelled(true);
        return;
    }
    TravelAgent travelAgent = event.getPortalTravelAgent();
    Location destination = travelAgent.findPortal(event.getTo());

    if (destination != null)
    {
        if (!SafePortalsUtils.isInsideBorder(destination))
        {
            event.useTravelAgent(false);
            boolean success = travelAgent.createPortal(event.getTo());

            if (success)
            {
                event.setTo(travelAgent.findPortal(event.getTo()));

                if (!SafePortalsUtils.isSafeSpot(event.getTo()))
                {
                    Location safeTo = SafePortalsUtils.searchSafeSpot(event.getTo());
                    if (safeTo != null)
                    {
                        event.setTo(safeTo);
                    }
                }
            }
        }
    }
    else
    {
        event.useTravelAgent(true);
    }
}
项目:Crescent    文件:Behaviour.java   
/**
 * @return The height of the space that the player is in.
 */
public final int getHeightOfSpace() {
    final int max = getPlayer().getWorld().getMaxHeight();
    for (int y = 0; y <= max; y++) {
        final Location added = getPlayer().getLocation().clone().add(0, y, 0);
        if (added.getBlock().getType().isSolid()) {
            return y;
        }
    }
    return max;
}
项目:PetBlocks    文件:CustomGroundArmorstand.java   
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);
    }
}
项目:ProjectAres    文件:TutorialStage.java   
@Nullable Location getSafeTeleport(MatchPlayer player) {
    if(this.teleportPoint == null) return null;

    Location safe = null;
    for(int i = 0; i < SAFE_ITERATIONS; i++) {
        safe = safeCheck(this.teleportPoint.getPoint(player.getMatch(), player.getBukkit()));
        if(safe != null) break;
    }
    return safe;
}
项目:PetBlocks    文件:CustomRabbit.java   
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_8_R3.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
项目:FlexMC    文件:FlexLivingEntity.java   
@Override
public void teleport( Location l, boolean onGround ) {
    Location previous = this.location;
    if( l.getY() < 0 ) {
        damage( 2D );

        return;
    }
    if( previous.getY() > l.getY() ) {
        double tempFallDistance = Math.abs( l.getY() - previous.getY() );
        BlockState state = getWorld().getBlockAt( new Vector3i( l.getBlockX(), ((int) l.getY()) - 1, l.getBlockZ() ) );
        if( state.getTypeId() != 0 || getWorld().getBlockAt( new Vector3i( l.getBlockX(), l.getBlockY(), l.getBlockZ() ) ).getTypeId() != 0 ) {
            fallDistance.updateAndGet( new DoubleUnaryOperator() {
                @Override
                public double applyAsDouble( double operand ) {
                    double finalFallDistance = operand + tempFallDistance;
                    if( finalFallDistance > 3 ) {
                        damage( finalFallDistance * 0.8 );
                    }
                    return 0;
                }
            } );
        } else {
            fallDistance.addAndGet( tempFallDistance );
        }
    } else {
        fallDistance.set( 0D );
    }
    super.teleport( l, onGround );
}
项目:AstralEdit    文件:SelectionManager.java   
/**
 * Undos an operation
 *
 * @param player player
 */
boolean undoOperation(Player player) {
    if (!this.hasSelection(player))
        return false;
    if (!this.operations.containsKey(player))
        this.operations.put(player, new Operation[this.maxUndoAmount]);
    final Operation operation = this.operations.get(player)[0];
    if (operation != null) {
        if (operation.getType() == OperationType.MIRROR) {
            this.getSelection(player).mirror();
        } else if (operation.getType() == OperationType.FLIP) {
            this.getSelection(player).flip();
        } else if (operation.getType() == OperationType.UPSIDEDOWN) {
            this.getSelection(player).upSideDown();
        } else if (operation.getType() == OperationType.UNCOMBINE) {
            this.getSelection(player).join();
        } else if (operation.getType() == OperationType.COMBINE) {
            this.getSelection(player).tearApart();
        } else if (operation.getType() == OperationType.ROTATE) {
            this.selections.get(player).unSecureRotate((Double) operation.getOperationData());
        } else if (operation.getType() == OperationType.ANGLES) {
            this.getSelection(player).setBlockAngle((EulerAngle) operation.getOperationData());
        } else if (operation.getType() == OperationType.PLACE || operation.getType() == OperationType.CONVERTOBLOCKS) {
            final List<Container> containers = (List<Container>) operation.getOperationData();
            Bukkit.getServer().getScheduler().runTask(JavaPlugin.getPlugin(AstralEditPlugin.class), () -> this.placeUndoCalc(0, containers.get(0), containers, 0));
        } else if (operation.getType() == OperationType.MOVE) {
            this.selections.get(player).teleport((Location) operation.getOperationData());
        }
        this.removeOperation(player);
        return true;
    }
    return false;
}
项目:HCFCore    文件:ElevatorListener.java   
public Location teleportSpotUp(Location loc, int min, int max) {
    int k = min;
    while (k < max) {
        Material m = new Location(loc.getWorld(), loc.getBlockX(), k - 1, loc.getBlockZ()).getBlock().getType();
        Material m1 = new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ()).getBlock().getType();
        Material m2 = new Location(loc.getWorld(), loc.getBlockX(), (k + 1), loc.getBlockZ()).getBlock().getType();
        if (m1.equals(Material.AIR) && m2.equals(Material.AIR) && m.isSolid() && !m.equals(Material.SIGN_POST) && !m.equals(Material.WALL_SIGN)) {
            return new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ());
        }
        ++k;
    }
    return new Location(loc.getWorld(), loc.getBlockX(), loc.getWorld().getHighestBlockYAt(loc.getBlockX(), loc.getBlockZ()), loc.getBlockZ());
}
项目:BlockBall    文件:LightHologram.java   
@Override
public void teleport(Location location) {
    this.position = new SLocation(location);
    this.entityArmorStand.locX = this.position.getX();
    this.entityArmorStand.locY = this.position.getY();
    this.entityArmorStand.locZ = this.position.getZ();
    this.entityArmorStand.yaw = (float) this.position.getYaw();
    this.entityArmorStand.pitch = (float) this.position.getPitch();
    final net.minecraft.server.v1_8_R3.Packet packet = new net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport(this.entityArmorStand);
    for (final Player player : location.getWorld().getPlayers()) {
        this.sendPacket(player, packet);
    }
}
项目:CloudNet    文件:SignSelector.java   
public void sendUpdateSynchronized(Location location, String[] layout)
{
    org.bukkit.block.Sign sign = (org.bukkit.block.Sign) location.getBlock().getState();
    sign.setLine(0, layout[0]);
    sign.setLine(1, layout[1]);
    sign.setLine(2, layout[2]);
    sign.setLine(3, layout[3]);
    sign.update();
}
项目:CloudNet    文件:SignSelector.java   
public boolean containsPosition(Location location)
{
    Position position = toPosition(location);
    for (Sign sign : signs.values())
    {
        if (sign.getPosition().equals(position))
        {
            return true;
        }
    }
    return false;
}
项目:CropControl    文件:CropControlEventHandler.java   
/**
 * Propagates cocoa breaks
 * 
 * @param block
 * @param type
 * @param player
 */
private void trySideBreak(Block block, BreakType type, UUID player) {
    for (BlockFace face : directions) {
        Block faceBlock = block.getRelative(face);
        Location loc = faceBlock.getLocation();
        if (Material.COCOA.equals(faceBlock.getType()) && !pendingChecks.contains(loc)) {
            pendingChecks.add(loc);
            handleBreak(faceBlock, type, player, null);
        }
    }
}
项目:EscapeLag    文件:AntiRedstone.java   
@EventHandler
public void CheckRedstone(BlockRedstoneEvent event){
    if(ConfigOptimize.AntiRedstoneenable){
        if(event.getOldCurrent() > event.getNewCurrent()){
            return;
        }
        final Block block = event.getBlock();
        Location loc = block.getLocation();
        if(CheckedTimes.get(loc) == null){
            CheckedTimes.put(loc, 0);
        }
        CheckedTimes.put(loc, CheckedTimes.get(loc) + 1);

        if(CheckedTimes.get(loc) > ConfigOptimize.AntiRedstoneTimes){
            if(ConfigOptimize.AntiRedstoneRemoveBlockList.contains(block.getType().name())){
    Bukkit.getScheduler().runTaskLater(EscapeLag.MainThis,new Runnable(){
        public void run(){
            block.setType(Material.AIR);
        }
    },1);
                String message = ConfigOptimize.AntiRedstoneMessage;
                message = StringUtils.replace(message, "%location%", loc.toString());
                AzureAPI.bc(message);
            }
        }
    }
}
项目:Debuggery    文件:PlatformUtil.java   
/**
 * Gets the first entity at the location that's within the specified tolerance
 *
 * @param location  location to search at
 * @param range     Max distance to search against
 * @param tolerance How close we want the search to be
 * @return entity closest to the location, or null if we couldn't find one
 */
@Nullable
public static Entity getEntityNearestTo(Location location, int range, double tolerance) {
    Collection<Entity> entities = location.getWorld().getNearbyEntities(location, range, range, range);

    return entities.stream()
            .filter(e -> Math.abs(e.getLocation().getX() - location.getX()) < tolerance)
            .filter(e -> Math.abs(e.getLocation().getY() - location.getY()) < tolerance)
            .filter(entity -> Math.abs(entity.getLocation().getX() - location.getX()) < tolerance)
            .findFirst().orElse(null);

}
项目:PetBlocks    文件:CustomZombie.java   
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_8_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
项目:AsgardAscension    文件:Utility.java   
public static boolean canBreak(Player player, Location location) {
    Plot plot = plugin.getPlotsAPI().getPlot(location);
    if(plot == null) {
        return true;
    }
    return plot.isAdded(player.getUniqueId());
}
项目:AlphaLibary    文件:FakeEntity.java   
public FakeEntity(Location startLocation, String name, Object nmsEntity) {
    this.startLocation = startLocation;
    this.currentlocation = startLocation;
    this.name = name;
    this.nmsEntity = nmsEntity;
    this.uuid = UUID.randomUUID();
}
项目:HCFCore    文件:PlayerClaimEnterEvent.java   
public PlayerClaimEnterEvent(Player player, Location from, Location to, Faction fromFaction, Faction toFaction, EnterCause enterCause) {
    this.player = player;
    this.from = from;
    this.to = to;
    this.fromFaction = fromFaction;
    this.toFaction = toFaction;
    this.enterCause = enterCause;
}
项目:MockBukkit    文件:WorldMockTest.java   
@Test
public void setSpawnLocation_SomeNewLocation_LocationChanged()
{
    WorldMock world = new WorldMock();
    Location spawn = world.getSpawnLocation().clone();
    world.setSpawnLocation(spawn.getBlockX() + 10, spawn.getBlockY() + 10, spawn.getBlockZ() + 10);
    assertEquals(spawn.getBlockX() + 10, world.getSpawnLocation().getBlockX());
    assertEquals(spawn.getBlockY() + 10, world.getSpawnLocation().getBlockY());
    assertEquals(spawn.getBlockZ() + 10, world.getSpawnLocation().getBlockZ());

    world.setSpawnLocation(spawn);
    assertEquals(spawn.getBlockX(), world.getSpawnLocation().getBlockX());
    assertEquals(spawn.getBlockY(), world.getSpawnLocation().getBlockY());
    assertEquals(spawn.getBlockZ(), world.getSpawnLocation().getBlockZ());
}
项目:Uranium    文件:CraftBlock.java   
public Location getLocation(Location loc) {
    if (loc != null) {
        loc.setWorld(getWorld());
        loc.setX(x);
        loc.setY(y);
        loc.setZ(z);
        loc.setYaw(0);
        loc.setPitch(0);
    }

    return loc;
}
项目:PetBlocks    文件:PetBlockHelper.java   
public static void playParticleEffectForPipeline(Location location, ParticleEffectMeta particleEffectMeta, PetBlock petBlock) {
    if (ConfigPet.getInstance().areParticlesForOtherPlayersVisible()) {
        for (final Player player : location.getWorld().getPlayers()) {
            Bukkit.getServer().getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PetBlocksPlugin.class), () -> ((ParticleEffectData) particleEffectMeta).applyTo(location, player));
        }
    } else {
        Bukkit.getServer().getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PetBlocksPlugin.class), () -> ((ParticleEffectData) particleEffectMeta).applyTo(location, (Player) petBlock.getPlayer()));
    }
}
项目:AgarMC    文件:Cell.java   
public Cell(int mass, double x, double y) {
    this.mass = mass;

    /** Armor Stand **/
    armorStand = AgarMC.get().getWorld().spawn(new Location(AgarMC.get().getWorld(), x, AgarMC.get().getGame().getOrigin().getY(), y), ArmorStand.class);
    armorStand.setVisible(false);
    armorStand.setSmall(true);
}
项目:mczone    文件:ConfigAPI.java   
public Location getLocation(String s) {
    String base = s + ".";
       String worldName = getString(base + "world");
       if (worldName == null)
        return null;

       return getLocation(s, worldName);
}
项目:ProjectAres    文件:NMSHacks.java   
@Override
public void teleport(Player viewer, Location location) {
    if(!Objects.equals(this.location, location)) {
        this.location = location.clone();
        teleportPacket = teleportEntityPacket(entityId(), location);
    }
    sendPacket(viewer, teleportPacket);
}