Search in sources :

Example 6 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Glowstone by GlowstoneMC.

the class SoundUtil method playSoundAtLocationExcept.

public static void playSoundAtLocationExcept(Location location, Sound sound, float volume, float pitch, GlowPlayer... exclude) {
    if (location == null || sound == null)
        return;
    GlowWorld world = (GlowWorld) location.getWorld();
    double radiusSquared = volume * volume * 256;
    world.getRawPlayers().parallelStream().filter(player -> player.getLocation().distanceSquared(location) <= radiusSquared).filter(player -> !Arrays.asList(exclude).contains(player)).forEach(player -> player.playSound(location, sound, volume, pitch));
}
Also used : Arrays(java.util.Arrays) Location(org.bukkit.Location) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) GlowPlayer(net.glowstone.entity.GlowPlayer) Sound(org.bukkit.Sound) GlowWorld(net.glowstone.GlowWorld) GlowWorld(net.glowstone.GlowWorld)

Example 7 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Glowstone by GlowstoneMC.

the class GlowBossBar method sendUpdate.

private void sendUpdate(Player player, BossBarMessage message) {
    if (player == null || !player.isOnline()) {
        return;
    }
    GlowPlayer impl = (GlowPlayer) player;
    impl.getSession().send(message);
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer)

Example 8 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Glowstone by GlowstoneMC.

the class GlowJukebox method setPlaying.

@Override
public void setPlaying(Material record) {
    int id = 0;
    if (record == null || record == Material.AIR) {
        playing = null;
    } else {
        playing = new ItemStack(record);
        id = record.getId();
    }
    Collection<GlowPlayer> players = getWorld().getRawPlayers();
    for (GlowPlayer player : players) {
        player.playEffect(getLocation(), Effect.RECORD_PLAY, id);
    }
    setRawData((byte) (id > 0 ? 1 : 0));
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) ItemStack(org.bukkit.inventory.ItemStack)

Example 9 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Glowstone by GlowstoneMC.

the class TellrawCommand method execute.

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!testPermission(sender))
        return true;
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
        return false;
    }
    Player player = Bukkit.getPlayerExact(args[0]);
    if (player == null || sender instanceof Player && !((Player) sender).canSee(player)) {
        sender.sendMessage("There's no player by that name online.");
    } else {
        StringBuilder message = new StringBuilder();
        for (int i = 1; i < args.length; i++) {
            if (i > 1)
                message.append(" ");
            message.append(args[i]);
        }
        GlowPlayer glowPlayer = (GlowPlayer) player;
        Object obj = JSONValue.parse(message.toString());
        if (!(obj instanceof JSONObject)) {
            sender.sendMessage(ChatColor.RED + "Failed to parse JSON");
        } else {
            glowPlayer.getSession().send(new ChatMessage((JSONObject) obj));
        }
    }
    return true;
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) Player(org.bukkit.entity.Player) JSONObject(org.json.simple.JSONObject) ChatMessage(net.glowstone.net.message.play.game.ChatMessage) GlowPlayer(net.glowstone.entity.GlowPlayer) JSONObject(org.json.simple.JSONObject)

Example 10 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Glowstone by GlowstoneMC.

the class GlowBlock method setData.

@Override
public void setData(byte data, boolean applyPhysics) {
    byte oldData = getData();
    ((GlowChunk) world.getChunkAt(this)).setMetaData(x & 0xf, z & 0xf, y, data);
    if (applyPhysics) {
        applyPhysics(getType(), getTypeId(), oldData, data);
    }
    BlockChangeMessage bcmsg = new BlockChangeMessage(x, y, z, getTypeId(), data);
    for (GlowPlayer p : getWorld().getRawPlayers()) {
        p.sendBlockChange(bcmsg);
    }
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) BlockChangeMessage(net.glowstone.net.message.play.game.BlockChangeMessage) GlowChunk(net.glowstone.chunk.GlowChunk)

Aggregations

GlowPlayer (net.glowstone.entity.GlowPlayer)39 ItemStack (org.bukkit.inventory.ItemStack)10 GlowBlock (net.glowstone.block.GlowBlock)5 Player (org.bukkit.entity.Player)5 Message (com.flowpowered.network.Message)4 Location (org.bukkit.Location)4 GlowWorld (net.glowstone.GlowWorld)3 ItemType (net.glowstone.block.itemtype.ItemType)3 UserListItemMessage (net.glowstone.net.message.play.game.UserListItemMessage)3 BlockPlacementMessage (net.glowstone.net.message.play.player.BlockPlacementMessage)3 Material (org.bukkit.Material)3 Block (org.bukkit.block.Block)3 BlockFace (org.bukkit.block.BlockFace)3 Vector (org.bukkit.util.Vector)3 ChunkLocation (org.dragonet.ChunkLocation)3 PEPacket (org.dragonet.net.packet.minecraft.PEPacket)3 AsyncableMessage (com.flowpowered.network.AsyncableMessage)2 Message (com.flowpowered.networking.Message)2 ArrayList (java.util.ArrayList)2 BlockType (net.glowstone.block.blocktype.BlockType)2