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));
}
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);
}
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));
}
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;
}
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);
}
}
Aggregations