/** * @param location the {@link Location} around which players must be to see the effect * @param effectName list of effects: https://gist.github.com/riking/5759002 * @param offsetX the amount to be randomly offset by in the X axis * @param offsetY the amount to be randomly offset by in the Y axis * @param offsetZ the amount to be randomly offset by in the Z axis * @param speed the speed of the particles * @param count the number of particles * @param radius the radius around the location */ public static void playParticleEffect( Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius) { Validate.notNull(location, "Location cannot be null"); Validate.notNull(effectName, "Effect cannot be null"); Validate.notNull(location.getWorld(), "World cannot be null"); PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles( effectName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count); for (Player player : location.getWorld().getPlayers()) { if ((int) player.getLocation().distance(location) <= radius) { ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); } } }
@Override public void run() { ticks++; if (holo.showing && holo.following != null && holo.following.isOnline() && !holo.following.isDead()) { Location l = holo.following.getLocation(); for (int id : holo.entities.keySet()) { PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport( id, (int) (l.getX() * 32), (int) ((l.getY() + holo.entities.get(id)) * 32) + 30, (int) (l.getZ() * 32), (byte) 0, (byte) 0); for (Player p : players) ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } } if (ticks >= (Integer) Configuration.getConfig("hologram.showtime") * 20 || !holo.showing) { holograms.remove(holo); following = null; destroy(); task.cancel(); } }
public void destroy() { if (!showing) return; int[] ints = toInt(entities.keySet()); PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ints); for (Player player : Bukkit.getOnlinePlayers()) ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); showing = false; }
public static void sendPacketNearby(Location location, Packet packet, double radius) { radius *= radius; final World world = location.getWorld(); for (Player p : Bukkit.getServer().getOnlinePlayers()) { if (p == null || world != p.getWorld()) { continue; } if (location.distanceSquared(p.getLocation()) > radius) { continue; } ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } }
public void removeItem(String name2) { if (items.remove(name2) != null) { PacketPlayOutScoreboardScore pack = new PacketPlayOutScoreboardScore(); setReflectionValue(pack.getClass(), "a", name2); setReflectionValue(pack.getClass(), "b", name); setReflectionValue(pack.getClass(), "c", 0); setReflectionValue(pack.getClass(), "d", 1); for (Player p : players) { if (!isUnique(p)) { continue; } ((CraftPlayer) p).getHandle().playerConnection.sendPacket(pack); } } }
public static void sendClickableMessage( Player p, String baseMsg, String hoverMsg, String action, String toDo) { IChatBaseComponent comp = ChatSerializer.a( "{\"text\":\"" + baseMsg + "\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"" + hoverMsg + "\"},\"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + toDo + "\"}}"); PacketPlayOutChat pack = new PacketPlayOutChat(comp, true); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(pack); }
public void sendPacket(Player p, Packet packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); }
public void send(Player player) { ((CraftPlayer) player) .getHandle() .playerConnection .sendPacket(new PacketPlayOutChat(ChatSerializer.a(toJSONString()))); }
public static void sendPacket(Player player, Packet packet) { if (packet == null) return; ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); }