@@ -56,6 +56,8 @@ public class Request implements JsonObject, Respondable {
5656 private String login ;
5757 @ Nullable
5858 private String password ;
59+ @ Nullable
60+ private Target player ;
5961
6062 /**
6163 * Instantiates an empty {@link Request}.
@@ -107,6 +109,9 @@ private Request(Request.@NotNull Builder builder) throws IllegalArgumentExceptio
107109
108110 if (builder .password == null && this .type == Type .LOGIN )
109111 throw new IllegalArgumentException ("password cannot be null for login packets" );
112+
113+ if (builder .player == null && this .type == Type .PLAYER_INFO )
114+ throw new IllegalArgumentException ("player cannot be null for player info packets" );
110115 }
111116
112117 // other arguments
@@ -132,6 +137,7 @@ private Request(Request.@NotNull Builder builder) throws IllegalArgumentExceptio
132137 this .originatingSocket = builder .originatingSocket ;
133138 this .login = builder .login ;
134139 this .password = builder .password ;
140+ this .player = builder .player ;
135141
136142 // validate targets are not null
137143 if (builder .targets != null ) {
@@ -363,6 +369,19 @@ public String getPassword() {
363369 return password ;
364370 }
365371
372+ /**
373+ * If this is a {@link Type#PLAYER_INFO} packet, gets the player's info.
374+ *
375+ * @return player info
376+ * @since 3.6.2
377+ */
378+ @ ApiStatus .AvailableSince ("3.6.2" )
379+ @ Nullable
380+ @ CheckReturnValue
381+ public Target getPlayer () {
382+ return player ;
383+ }
384+
366385 /**
367386 * Gets the {@link Socket} that this {@link Request} originated from.
368387 *
@@ -469,12 +488,15 @@ public boolean equals(@Nullable Object o) {
469488 && Objects .equals (duration , request .duration )
470489// && Objects.equals(originatingSocket, request.originatingSocket)
471490 && Objects .equals (source , request .source )
472- && Objects .equals (value , request .value );
491+ && Objects .equals (value , request .value )
492+ && Objects .equals (login , request .login )
493+ && Objects .equals (password , request .password )
494+ && Objects .equals (player , request .player );
473495 }
474496
475497 @ Override
476498 public int hashCode () {
477- int result = Objects .hash (id , type , effect , message , viewer , cost , duration , source , value );
499+ int result = Objects .hash (id , type , effect , message , viewer , cost , duration , source , value , login , password , player );
478500 result = 31 * result + Arrays .hashCode (getTargets ());
479501 result = 31 * result + Arrays .hashCode (getParameters ());
480502 return result ;
@@ -495,6 +517,9 @@ public String toString() {
495517 ", parameters=" + Arrays .toString (parameters ) +
496518 ", source=" + source +
497519 ", value=" + value +
520+ ", login=" + repr (login ) +
521+ ", password=" + repr (password ) +
522+ ", player=" + player +
498523 '}' ;
499524 }
500525
@@ -632,11 +657,15 @@ public TriState usesIncrementalIds() {
632657 */
633658 @ ApiStatus .AvailableSince ("3.0.0" )
634659 public static final class Target {
660+ @ SerializedName (value = "id" , alternate = {"originID" })
635661 private @ Nullable String id ;
636662 private @ Nullable String name ;
637663 private @ Nullable String login ;
664+ @ SerializedName (value = "avatar" , alternate = {"image" })
638665 private @ Nullable String avatar ;
666+ @ SerializedName (value = "service" , alternate = {"profile" })
639667 private @ Nullable String service ;
668+ private @ Nullable String ccUID ;
640669
641670 /**
642671 * Instantiates an empty {@link Target}.
@@ -653,6 +682,7 @@ private Target(@NotNull Builder builder) {
653682 this .login = builder .login ;
654683 this .avatar = builder .avatar ;
655684 this .service = builder .service ;
685+ this .ccUID = builder .ccUID ;
656686 }
657687
658688 /**
@@ -727,6 +757,19 @@ public String getService() {
727757 return service ;
728758 }
729759
760+ /**
761+ * Gets the Crowd Control user ID of the recipient.
762+ *
763+ * @return Crowd Control user ID
764+ * @since 3.6.2
765+ */
766+ @ ApiStatus .AvailableSince ("3.6.2" )
767+ @ Nullable
768+ @ CheckReturnValue
769+ public String getCCUID () {
770+ return ccUID ;
771+ }
772+
730773 @ Override
731774 @ CheckReturnValue
732775 public boolean equals (@ Nullable Object o ) {
@@ -737,7 +780,8 @@ public boolean equals(@Nullable Object o) {
737780 && Objects .equals (getName (), target .getName ())
738781 && Objects .equals (getLogin (), target .getLogin ())
739782 && Objects .equals (getAvatar (), target .getAvatar ())
740- && Objects .equals (getService (), target .getService ());
783+ && Objects .equals (getService (), target .getService ())
784+ && Objects .equals (getCCUID (), target .getCCUID ());
741785 }
742786
743787 /**
@@ -754,13 +798,15 @@ public boolean equalsRoughly(@Nullable Object o) {
754798 if (this == o ) return true ;
755799 if (o == null || getClass () != o .getClass ()) return false ;
756800 Target target = (Target ) o ;
757- return (getId () != null && getId ().equals (target .getId ())) || equals (o );
801+ return (getId () != null && getId ().equals (target .getId ()))
802+ || (getCCUID () != null && getCCUID ().equals (target .getCCUID ()))
803+ || equals (o );
758804 }
759805
760806 @ Override
761807 @ CheckReturnValue
762808 public int hashCode () {
763- return Objects .hash (getId (), getName (), getLogin (), getAvatar (), getService ());
809+ return Objects .hash (getId (), getName (), getLogin (), getAvatar (), getService (), getCCUID () );
764810 }
765811
766812 @ Override
@@ -771,6 +817,7 @@ public String toString() {
771817 ", login=" + repr (login ) +
772818 ", avatar=" + repr (avatar ) +
773819 ", service=" + repr (service ) +
820+ ", ccUID=" + repr (ccUID ) +
774821 '}' ;
775822 }
776823
@@ -798,6 +845,7 @@ public static final class Builder implements Cloneable {
798845 private @ Nullable String login ;
799846 private @ Nullable String avatar ;
800847 private @ Nullable String service ;
848+ private @ Nullable String ccUID ;
801849
802850 // constructors //
803851
@@ -815,6 +863,7 @@ private Builder(@NotNull Target target) {
815863 this .login = target .login ;
816864 this .avatar = target .avatar ;
817865 this .service = target .service ;
866+ this .ccUID = target .ccUID ;
818867 }
819868
820869 private Builder (@ NotNull Builder builder ) {
@@ -823,6 +872,7 @@ private Builder(@NotNull Builder builder) {
823872 this .login = builder .login ;
824873 this .avatar = builder .avatar ;
825874 this .service = builder .service ;
875+ this .ccUID = builder .ccUID ;
826876 }
827877
828878 // setters //
@@ -902,6 +952,21 @@ public Builder service(@Nullable String service) {
902952 return this ;
903953 }
904954
955+ /**
956+ * Sets the Crowd Control user ID of the recipient.
957+ *
958+ * @param ccUID Crowd Control user ID
959+ * @return this builder
960+ * @since 3.6.2
961+ */
962+ @ ApiStatus .AvailableSince ("3.6.2" )
963+ @ NotNull
964+ @ Contract ("_ -> this" )
965+ public Builder ccUID (@ Nullable String ccUID ) {
966+ this .ccUID = ccUID ;
967+ return this ;
968+ }
969+
905970 // getters //
906971
907972 /**
@@ -969,6 +1034,19 @@ public String service() {
9691034 return service ;
9701035 }
9711036
1037+ /**
1038+ * Gets the Crowd Control user ID of the recipient.
1039+ *
1040+ * @return Crowd Control user ID
1041+ * @since 3.6.2
1042+ */
1043+ @ ApiStatus .AvailableSince ("3.6.2" )
1044+ @ Nullable
1045+ @ CheckReturnValue
1046+ public String ccUID () {
1047+ return ccUID ;
1048+ }
1049+
9721050 // misc
9731051
9741052 /**
@@ -1278,6 +1356,7 @@ public static class Builder implements Cloneable {
12781356 private @ Nullable Integer quantity ;
12791357 private @ Nullable String login ;
12801358 private @ Nullable String password ;
1359+ private @ Nullable Target player ;
12811360
12821361 /**
12831362 * Creates a new builder.
@@ -1312,6 +1391,7 @@ private Builder(@NotNull Request source) {
13121391 this .quantity = source .quantity ;
13131392 this .login = source .login ;
13141393 this .password = source .password ;
1394+ this .player = source .player ;
13151395 }
13161396
13171397 /**
@@ -1338,6 +1418,7 @@ private Builder(@NotNull Builder builder) {
13381418 this .quantity = builder .quantity ;
13391419 this .login = builder .login ;
13401420 this .password = builder .password ;
1421+ this .player = builder .player ;
13411422 }
13421423
13431424 // setters
@@ -1568,6 +1649,21 @@ public Builder password(@Nullable String password) {
15681649 return this ;
15691650 }
15701651
1652+ /**
1653+ * Sets the {@link Type#PLAYER_INFO} data.
1654+ *
1655+ * @param player a player target
1656+ * @return this builder
1657+ * @since 3.6.2
1658+ */
1659+ @ ApiStatus .AvailableSince ("3.6.2" )
1660+ @ NotNull
1661+ @ Contract ("_ -> this" )
1662+ public Builder player (@ Nullable Target player ) {
1663+ this .player = player ;
1664+ return this ;
1665+ }
1666+
15711667 // getters
15721668
15731669 /**
@@ -1763,6 +1859,19 @@ public String password() {
17631859 return password ;
17641860 }
17651861
1862+ /**
1863+ * Gets the {@link Type#PLAYER_INFO} data.
1864+ *
1865+ * @return a player target
1866+ * @since 3.6.2
1867+ */
1868+ @ ApiStatus .AvailableSince ("3.6.2" )
1869+ @ Nullable
1870+ @ CheckReturnValue
1871+ public Target player () {
1872+ return player ;
1873+ }
1874+
17661875 // build
17671876
17681877 /**
0 commit comments