@@ -64,7 +64,7 @@ public P4JServer(CodecManager cm, EncryptionManager em, CompressionManager com)
6464 this .compression = com ;
6565 this .clientManager = new ClientManager (this );
6666
67- MAX_PACKET_SIZE = PCUtils .toInteger (System .getProperty ("P4J_maxPacketSize" ), MAX_PACKET_SIZE );
67+ MAX_PACKET_SIZE = PCUtils .parseInteger (System .getProperty ("P4J_maxPacketSize" ), MAX_PACKET_SIZE );
6868 }
6969
7070 /*
@@ -154,8 +154,6 @@ private void handleException(P4JServerException e) {
154154
155155 /**
156156 * Sends the packet to all the connected clients.
157- *
158- * @param S2CPacket the packet to send
159157 */
160158 public void broadcast (S2CPacket <?> packet ) {
161159 Objects .requireNonNull (packet );
@@ -165,10 +163,25 @@ public void broadcast(S2CPacket<?> packet) {
165163 }
166164 }
167165
166+ /**
167+ * Sends the packet to all the connected clients.
168+ */
169+ public void broadcast (List <S2CPacket <?>> packets ) {
170+ Objects .requireNonNull (packets );
171+
172+ if (packets .isEmpty ()) {
173+ return ;
174+ }
175+
176+ for (ServerClient sc : clientManager .getAllClients ()) {
177+ for (S2CPacket <?> packet : packets ) {
178+ sc .write (packet );
179+ }
180+ }
181+ }
182+
168183 /**
169184 * Sends the packet provided by the supplier to all the connected clients.
170- *
171- * @param S2CPacket the packet to send
172185 */
173186 public void broadcast (Function <ServerClient , S2CPacket <?>> packetSupplier ) {
174187 for (ServerClient sc : clientManager .getAllClients ()) {
@@ -178,8 +191,6 @@ public void broadcast(Function<ServerClient, S2CPacket<?>> packetSupplier) {
178191
179192 /**
180193 * Iterates over all the connected clients and sends the specified packet if the predicate's condition is met.
181- *
182- * @param S2CPacket the packet to send
183194 */
184195 public void broadcastIf (S2CPacket <?> packet , Predicate <ServerClient > condition ) {
185196 Objects .requireNonNull (packet );
@@ -191,6 +202,9 @@ public void broadcastIf(S2CPacket<?> packet, Predicate<ServerClient> condition)
191202 }
192203 }
193204
205+ /**
206+ * Iterates over all the connected clients and sends the specified packet(s) if the predicate's condition is met.
207+ */
194208 public void broadcastIf (List <S2CPacket <?>> packets , Predicate <ServerClient > condition ) {
195209 Objects .requireNonNull (packets );
196210
@@ -209,8 +223,6 @@ public void broadcastIf(List<S2CPacket<?>> packets, Predicate<ServerClient> cond
209223
210224 /**
211225 * Iterates over all the connected clients and sends the packet provided by the supplier, if the predicate's condition is met.
212- *
213- * @param S2CPacket the packet to send
214226 */
215227 public void broadcastIf (Function <ServerClient , S2CPacket <?>> packetSupplier , Predicate <ServerClient > condition ) {
216228 for (ServerClient sc : clientManager .getAllClients ()) {
0 commit comments