Created
July 20, 2014 12:16
-
-
Save Bastian/95953846d59c28e8fc72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package de.oppermann.bastian.lib.miscellaneous; | |
| import java.util.UUID; | |
| import net.minecraft.server.v1_7_R4.Packet; | |
| import org.bukkit.Bukkit; | |
| import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; | |
| import org.bukkit.entity.Player; | |
| public class CraftBukkitUtil { | |
| private CraftBukkitUtil() { } | |
| /** | |
| * Sends a packet to every online player. | |
| * | |
| * @param packet The packet to send. | |
| */ | |
| public static void sendGlobalPacket(Packet packet) { | |
| for (Player player : Bukkit.getOnlinePlayers()) { | |
| sendPacket(packet, player); | |
| } | |
| } | |
| /** | |
| * Sends a packet to every online player. | |
| * | |
| * @param packet The packet to send. | |
| * @param besides If the packet should not be send to the player with this uuid. | |
| */ | |
| public static void sendGlobalPacket(Packet packet, UUID besides) { | |
| for (Player player : Bukkit.getOnlinePlayers()) { | |
| if (player.getUniqueId() == besides) { | |
| continue; | |
| } | |
| sendPacket(packet, player); | |
| } | |
| } | |
| /** | |
| * Sends a packet to a specific player. | |
| * | |
| * @param packet The packet to send. | |
| * @param player The player. | |
| */ | |
| public static void sendPacket(Packet packet, Player player) { | |
| ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment