| 1 | package net.minecraft.util;
|
| 2 |
|
| 3 | import com.google.gson.JsonDeserializationContext;
|
| 4 | import com.google.gson.JsonDeserializer;
|
| 5 | import com.google.gson.JsonElement;
|
| 6 | import com.google.gson.JsonObject;
|
| 7 | import com.google.gson.JsonParseException;
|
| 8 | import com.google.gson.JsonPrimitive;
|
| 9 | import com.google.gson.JsonSerializationContext;
|
| 10 | import com.google.gson.JsonSerializer;
|
| 11 | import java.lang.reflect.Type;
|
| 12 | import net.minecraft.event.ClickEvent;
|
| 13 | import net.minecraft.event.HoverEvent;
|
| 14 |
|
| 15 | public class ChatStyle
|
| 16 | {
|
| 17 | /**
|
| 18 | * The parent of this ChatStyle. Used for looking up values that this instance does not override.
|
| 19 | */
|
| 20 | private ChatStyle parentStyle;
|
| 21 | private EnumChatFormatting color;
|
| 22 | private Boolean bold;
|
| 23 | private Boolean italic;
|
| 24 | private Boolean underlined;
|
| 25 | private Boolean strikethrough;
|
| 26 | private Boolean obfuscated;
|
| 27 | private ClickEvent chatClickEvent;
|
| 28 | private HoverEvent chatHoverEvent;
|
| 29 | private String insertion;
|
| 30 |
|
| 31 | /**
|
| 32 | * The base of the ChatStyle hierarchy. All ChatStyle instances are implicitly children of this.
|
| 33 | */
|
| 34 | private static final ChatStyle rootStyle = new ChatStyle()
|
| 35 | {
|
| 36 | public EnumChatFormatting getColor()
|
| 37 | {
|
| 38 | return null;
|
| 39 | }
|
| 40 | public boolean getBold()
|
| 41 | {
|
| 42 | return false;
|
| 43 | }
|
| 44 | public boolean getItalic()
|
| 45 | {
|
| 46 | return false;
|
| 47 | }
|
| 48 | public boolean getStrikethrough()
|
| 49 | {
|
| 50 | return false;
|
| 51 | }
|
| 52 | public boolean getUnderlined()
|
| 53 | {
|
| 54 | return false;
|
| 55 | }
|
| 56 | public boolean getObfuscated()
|
| 57 | {
|
| 58 | return false;
|
| 59 | }
|
| 60 | public ClickEvent getChatClickEvent()
|
| 61 | {
|
| 62 | return null;
|
| 63 | }
|
| 64 | public HoverEvent getChatHoverEvent()
|
| 65 | {
|
| 66 | return null;
|
| 67 | }
|
| 68 | public String getInsertion()
|
| 69 | {
|
| 70 | return null;
|
| 71 | }
|
| 72 | public ChatStyle setColor(EnumChatFormatting color)
|
| 73 | {
|
| 74 | throw new UnsupportedOperationException();
|
| 75 | }
|
| 76 | public ChatStyle setBold(Boolean boldIn)
|
| 77 | {
|
| 78 | throw new UnsupportedOperationException();
|
| 79 | }
|
| 80 | public ChatStyle setItalic(Boolean italic)
|
| 81 | {
|
| 82 | throw new UnsupportedOperationException();
|
| 83 | }
|
| 84 | public ChatStyle setStrikethrough(Boolean strikethrough)
|
| 85 | {
|
| 86 | throw new UnsupportedOperationException();
|
| 87 | }
|
| 88 | public ChatStyle setUnderlined(Boolean underlined)
|
| 89 | {
|
| 90 | throw new UnsupportedOperationException();
|
| 91 | }
|
| 92 | public ChatStyle setObfuscated(Boolean obfuscated)
|
| 93 | {
|
| 94 | throw new UnsupportedOperationException();
|
| 95 | }
|
| 96 | public ChatStyle setChatClickEvent(ClickEvent event)
|
| 97 | {
|
| 98 | throw new UnsupportedOperationException();
|
| 99 | }
|
| 100 | public ChatStyle setChatHoverEvent(HoverEvent event)
|
| 101 | {
|
| 102 | throw new UnsupportedOperationException();
|
| 103 | }
|
| 104 | public ChatStyle setParentStyle(ChatStyle parent)
|
| 105 | {
|
| 106 | throw new UnsupportedOperationException();
|
| 107 | }
|
| 108 | public String toString()
|
| 109 | {
|
| 110 | return "Style.ROOT";
|
| 111 | }
|
| 112 | public ChatStyle createShallowCopy()
|
| 113 | {
|
| 114 | return this;
|
| 115 | }
|
| 116 | public ChatStyle createDeepCopy()
|
| 117 | {
|
| 118 | return this;
|
| 119 | }
|
| 120 | public String getFormattingCode()
|
| 121 | {
|
| 122 | return "";
|
| 123 | }
|
| 124 | };
|
| 125 |
|
| 126 | /**
|
| 127 | * Gets the effective color of this ChatStyle.
|
| 128 | */
|
| 129 | public EnumChatFormatting getColor()
|
| 130 | {
|
| 131 | return this.color == null ? this.getParent().getColor() : this.color;
|
| 132 | }
|
| 133 |
|
| 134 | /**
|
| 135 | * Whether or not text of this ChatStyle should be in bold.
|
| 136 | */
|
| 137 | public boolean getBold()
|
| 138 | {
|
| 139 | return this.bold == null ? this.getParent().getBold() : this.bold.booleanValue();
|
| 140 | }
|
| 141 |
|
| 142 | /**
|
| 143 | * Whether or not text of this ChatStyle should be italicized.
|
| 144 | */
|
| 145 | public boolean getItalic()
|
| 146 | {
|
| 147 | return this.italic == null ? this.getParent().getItalic() : this.italic.booleanValue();
|
| 148 | }
|
| 149 |
|
| 150 | /**
|
| 151 | * Whether or not to format text of this ChatStyle using strikethrough.
|
| 152 | */
|
| 153 | public boolean getStrikethrough()
|
| 154 | {
|
| 155 | return this.strikethrough == null ? this.getParent().getStrikethrough() : this.strikethrough.booleanValue();
|
| 156 | }
|
| 157 |
|
| 158 | /**
|
| 159 | * Whether or not text of this ChatStyle should be underlined.
|
| 160 | */
|
| 161 | public boolean getUnderlined()
|
| 162 | {
|
| 163 | return this.underlined == null ? this.getParent().getUnderlined() : this.underlined.booleanValue();
|
| 164 | }
|
| 165 |
|
| 166 | /**
|
| 167 | * Whether or not text of this ChatStyle should be obfuscated.
|
| 168 | */
|
| 169 | public boolean getObfuscated()
|
| 170 | {
|
| 171 | return this.obfuscated == null ? this.getParent().getObfuscated() : this.obfuscated.booleanValue();
|
| 172 | }
|
| 173 |
|
| 174 | /**
|
| 175 | * Whether or not this style is empty (inherits everything from the parent).
|
| 176 | */
|
| 177 | public boolean isEmpty()
|
| 178 | {
|
| 179 | return this.bold == null && this.italic == null && this.strikethrough == null && this.underlined == null && this.obfuscated == null && this.color == null && this.chatClickEvent == null && this.chatHoverEvent == null;
|
| 180 | }
|
| 181 |
|
| 182 | /**
|
| 183 | * The effective chat click event.
|
| 184 | */
|
| 185 | public ClickEvent getChatClickEvent()
|
| 186 | {
|
| 187 | return this.chatClickEvent == null ? this.getParent().getChatClickEvent() : this.chatClickEvent;
|
| 188 | }
|
| 189 |
|
| 190 | /**
|
| 191 | * The effective chat hover event.
|
| 192 | */
|
| 193 | public HoverEvent getChatHoverEvent()
|
| 194 | {
|
| 195 | return this.chatHoverEvent == null ? this.getParent().getChatHoverEvent() : this.chatHoverEvent;
|
| 196 | }
|
| 197 |
|
| 198 | /**
|
| 199 | * Get the text to be inserted into Chat when the component is shift-clicked
|
| 200 | */
|
| 201 | public String getInsertion()
|
| 202 | {
|
| 203 | return this.insertion == null ? this.getParent().getInsertion() : this.insertion;
|
| 204 | }
|
| 205 |
|
| 206 | /**
|
| 207 | * Sets the color for this ChatStyle to the given value. Only use color values for this; set other values using the
|
| 208 | * specific methods.
|
| 209 | */
|
| 210 | public ChatStyle setColor(EnumChatFormatting color)
|
| 211 | {
|
| 212 | this.color = color;
|
| 213 | return this;
|
| 214 | }
|
| 215 |
|
| 216 | /**
|
| 217 | * Sets whether or not text of this ChatStyle should be in bold. Set to false if, e.g., the parent style is bold
|
| 218 | * and you want text of this style to be unbolded.
|
| 219 | */
|
| 220 | public ChatStyle setBold(Boolean boldIn)
|
| 221 | {
|
| 222 | this.bold = boldIn;
|
| 223 | return this;
|
| 224 | }
|
| 225 |
|
| 226 | /**
|
| 227 | * Sets whether or not text of this ChatStyle should be italicized. Set to false if, e.g., the parent style is
|
| 228 | * italicized and you want to override that for this style.
|
| 229 | */
|
| 230 | public ChatStyle setItalic(Boolean italic)
|
| 231 | {
|
| 232 | this.italic = italic;
|
| 233 | return this;
|
| 234 | }
|
| 235 |
|
| 236 | /**
|
| 237 | * Sets whether or not to format text of this ChatStyle using strikethrough. Set to false if, e.g., the parent
|
| 238 | * style uses strikethrough and you want to override that for this style.
|
| 239 | */
|
| 240 | public ChatStyle setStrikethrough(Boolean strikethrough)
|
| 241 | {
|
| 242 | this.strikethrough = strikethrough;
|
| 243 | return this;
|
| 244 | }
|
| 245 |
|
| 246 | /**
|
| 247 | * Sets whether or not text of this ChatStyle should be underlined. Set to false if, e.g., the parent style is
|
| 248 | * underlined and you want to override that for this style.
|
| 249 | */
|
| 250 | public ChatStyle setUnderlined(Boolean underlined)
|
| 251 | {
|
| 252 | this.underlined = underlined;
|
| 253 | return this;
|
| 254 | }
|
| 255 |
|
| 256 | /**
|
| 257 | * Sets whether or not text of this ChatStyle should be obfuscated. Set to false if, e.g., the parent style is
|
| 258 | * obfuscated and you want to override that for this style.
|
| 259 | */
|
| 260 | public ChatStyle setObfuscated(Boolean obfuscated)
|
| 261 | {
|
| 262 | this.obfuscated = obfuscated;
|
| 263 | return this;
|
| 264 | }
|
| 265 |
|
| 266 | /**
|
| 267 | * Sets the event that should be run when text of this ChatStyle is clicked on.
|
| 268 | */
|
| 269 | public ChatStyle setChatClickEvent(ClickEvent event)
|
| 270 | {
|
| 271 | this.chatClickEvent = event;
|
| 272 | return this;
|
| 273 | }
|
| 274 |
|
| 275 | /**
|
| 276 | * Sets the event that should be run when text of this ChatStyle is hovered over.
|
| 277 | */
|
| 278 | public ChatStyle setChatHoverEvent(HoverEvent event)
|
| 279 | {
|
| 280 | this.chatHoverEvent = event;
|
| 281 | return this;
|
| 282 | }
|
| 283 |
|
| 284 | /**
|
| 285 | * Set a text to be inserted into Chat when the component is shift-clicked
|
| 286 | */
|
| 287 | public ChatStyle setInsertion(String insertion)
|
| 288 | {
|
| 289 | this.insertion = insertion;
|
| 290 | return this;
|
| 291 | }
|
| 292 |
|
| 293 | /**
|
| 294 | * Sets the fallback ChatStyle to use if this ChatStyle does not override some value. Without a parent, obvious
|
| 295 | * defaults are used (bold: false, underlined: false, etc).
|
| 296 | */
|
| 297 | public ChatStyle setParentStyle(ChatStyle parent)
|
| 298 | {
|
| 299 | this.parentStyle = parent;
|
| 300 | return this;
|
| 301 | }
|
| 302 |
|
| 303 | /**
|
| 304 | * Gets the equivalent text formatting code for this style, without the initial section sign (U+00A7) character.
|
| 305 | */
|
| 306 | public String getFormattingCode()
|
| 307 | {
|
| 308 | if (this.isEmpty())
|
| 309 | {
|
| 310 | return this.parentStyle != null ? this.parentStyle.getFormattingCode() : "";
|
| 311 | }
|
| 312 | else
|
| 313 | {
|
| 314 | StringBuilder stringbuilder = new StringBuilder();
|
| 315 |
|
| 316 | if (this.getColor() != null)
|
| 317 | {
|
| 318 | stringbuilder.append((Object)this.getColor());
|
| 319 | }
|
| 320 |
|
| 321 | if (this.getBold())
|
| 322 | {
|
| 323 | stringbuilder.append((Object)EnumChatFormatting.BOLD);
|
| 324 | }
|
| 325 |
|
| 326 | if (this.getItalic())
|
| 327 | {
|
| 328 | stringbuilder.append((Object)EnumChatFormatting.ITALIC);
|
| 329 | }
|
| 330 |
|
| 331 | if (this.getUnderlined())
|
| 332 | {
|
| 333 | stringbuilder.append((Object)EnumChatFormatting.UNDERLINE);
|
| 334 | }
|
| 335 |
|
| 336 | if (this.getObfuscated())
|
| 337 | {
|
| 338 | stringbuilder.append((Object)EnumChatFormatting.OBFUSCATED);
|
| 339 | }
|
| 340 |
|
| 341 | if (this.getStrikethrough())
|
| 342 | {
|
| 343 | stringbuilder.append((Object)EnumChatFormatting.STRIKETHROUGH);
|
| 344 | }
|
| 345 |
|
| 346 | return stringbuilder.toString();
|
| 347 | }
|
| 348 | }
|
| 349 |
|
| 350 | /**
|
| 351 | * Gets the immediate parent of this ChatStyle.
|
| 352 | */
|
| 353 | private ChatStyle getParent()
|
| 354 | {
|
| 355 | return this.parentStyle == null ? rootStyle : this.parentStyle;
|
| 356 | }
|
| 357 |
|
| 358 | public String toString()
|
| 359 | {
|
| 360 | return "Style{hasParent=" + (this.parentStyle != null) + ", color=" + this.color + ", bold=" + this.bold + ", italic=" + this.italic + ", underlined=" + this.underlined + ", obfuscated=" + this.obfuscated + ", clickEvent=" + this.getChatClickEvent() + ", hoverEvent=" + this.getChatHoverEvent() + ", insertion=" + this.getInsertion() + '}';
|
| 361 | }
|
| 362 |
|
| 363 | public boolean equals(Object p_equals_1_)
|
| 364 | {
|
| 365 | if (this == p_equals_1_)
|
| 366 | {
|
| 367 | return true;
|
| 368 | }
|
| 369 | else if (!(p_equals_1_ instanceof ChatStyle))
|
| 370 | {
|
| 371 | return false;
|
| 372 | }
|
| 373 | else
|
| 374 | {
|
| 375 | boolean flag;
|
| 376 | label0:
|
| 377 | {
|
| 378 | ChatStyle chatstyle = (ChatStyle)p_equals_1_;
|
| 379 |
|
| 380 | if (this.getBold() == chatstyle.getBold() && this.getColor() == chatstyle.getColor() && this.getItalic() == chatstyle.getItalic() && this.getObfuscated() == chatstyle.getObfuscated() && this.getStrikethrough() == chatstyle.getStrikethrough() && this.getUnderlined() == chatstyle.getUnderlined())
|
| 381 | {
|
| 382 | label85:
|
| 383 | {
|
| 384 | if (this.getChatClickEvent() != null)
|
| 385 | {
|
| 386 | if (!this.getChatClickEvent().equals(chatstyle.getChatClickEvent()))
|
| 387 | {
|
| 388 | break label85;
|
| 389 | }
|
| 390 | }
|
| 391 | else if (chatstyle.getChatClickEvent() != null)
|
| 392 | {
|
| 393 | break label85;
|
| 394 | }
|
| 395 |
|
| 396 | if (this.getChatHoverEvent() != null)
|
| 397 | {
|
| 398 | if (!this.getChatHoverEvent().equals(chatstyle.getChatHoverEvent()))
|
| 399 | {
|
| 400 | break label85;
|
| 401 | }
|
| 402 | }
|
| 403 | else if (chatstyle.getChatHoverEvent() != null)
|
| 404 | {
|
| 405 | break label85;
|
| 406 | }
|
| 407 |
|
| 408 | if (this.getInsertion() != null)
|
| 409 | {
|
| 410 | if (this.getInsertion().equals(chatstyle.getInsertion()))
|
| 411 | {
|
| 412 | break label0;
|
| 413 | }
|
| 414 | }
|
| 415 | else if (chatstyle.getInsertion() == null)
|
| 416 | {
|
| 417 | break label0;
|
| 418 | }
|
| 419 | }
|
| 420 | }
|
| 421 |
|
| 422 | flag = false;
|
| 423 | return flag;
|
| 424 | }
|
| 425 | flag = true;
|
| 426 | return flag;
|
| 427 | }
|
| 428 | }
|
| 429 |
|
| 430 | public int hashCode()
|
| 431 | {
|
| 432 | int i = this.color.hashCode();
|
| 433 | i = 31 * i + this.bold.hashCode();
|
| 434 | i = 31 * i + this.italic.hashCode();
|
| 435 | i = 31 * i + this.underlined.hashCode();
|
| 436 | i = 31 * i + this.strikethrough.hashCode();
|
| 437 | i = 31 * i + this.obfuscated.hashCode();
|
| 438 | i = 31 * i + this.chatClickEvent.hashCode();
|
| 439 | i = 31 * i + this.chatHoverEvent.hashCode();
|
| 440 | i = 31 * i + this.insertion.hashCode();
|
| 441 | return i;
|
| 442 | }
|
| 443 |
|
| 444 | /**
|
| 445 | * Creates a shallow copy of this style. Changes to this instance's values will not be reflected in the copy, but
|
| 446 | * changes to the parent style's values WILL be reflected in both this instance and the copy, wherever either does
|
| 447 | * not override a value.
|
| 448 | */
|
| 449 | public ChatStyle createShallowCopy()
|
| 450 | {
|
| 451 | ChatStyle chatstyle = new ChatStyle();
|
| 452 | chatstyle.bold = this.bold;
|
| 453 | chatstyle.italic = this.italic;
|
| 454 | chatstyle.strikethrough = this.strikethrough;
|
| 455 | chatstyle.underlined = this.underlined;
|
| 456 | chatstyle.obfuscated = this.obfuscated;
|
| 457 | chatstyle.color = this.color;
|
| 458 | chatstyle.chatClickEvent = this.chatClickEvent;
|
| 459 | chatstyle.chatHoverEvent = this.chatHoverEvent;
|
| 460 | chatstyle.parentStyle = this.parentStyle;
|
| 461 | chatstyle.insertion = this.insertion;
|
| 462 | return chatstyle;
|
| 463 | }
|
| 464 |
|
| 465 | /**
|
| 466 | * Creates a deep copy of this style. No changes to this instance or its parent style will be reflected in the
|
| 467 | * copy.
|
| 468 | */
|
| 469 | public ChatStyle createDeepCopy()
|
| 470 | {
|
| 471 | ChatStyle chatstyle = new ChatStyle();
|
| 472 | chatstyle.setBold(Boolean.valueOf(this.getBold()));
|
| 473 | chatstyle.setItalic(Boolean.valueOf(this.getItalic()));
|
| 474 | chatstyle.setStrikethrough(Boolean.valueOf(this.getStrikethrough()));
|
| 475 | chatstyle.setUnderlined(Boolean.valueOf(this.getUnderlined()));
|
| 476 | chatstyle.setObfuscated(Boolean.valueOf(this.getObfuscated()));
|
| 477 | chatstyle.setColor(this.getColor());
|
| 478 | chatstyle.setChatClickEvent(this.getChatClickEvent());
|
| 479 | chatstyle.setChatHoverEvent(this.getChatHoverEvent());
|
| 480 | chatstyle.setInsertion(this.getInsertion());
|
| 481 | return chatstyle;
|
| 482 | }
|
| 483 |
|
| 484 | public static class Serializer implements JsonDeserializer<ChatStyle>, JsonSerializer<ChatStyle>
|
| 485 | {
|
| 486 | public ChatStyle deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|
| 487 | {
|
| 488 | if (p_deserialize_1_.isJsonObject())
|
| 489 | {
|
| 490 | ChatStyle chatstyle = new ChatStyle();
|
| 491 | JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
|
| 492 |
|
| 493 | if (jsonobject == null)
|
| 494 | {
|
| 495 | return null;
|
| 496 | }
|
| 497 | else
|
| 498 | {
|
| 499 | if (jsonobject.has("bold"))
|
| 500 | {
|
| 501 | chatstyle.bold = Boolean.valueOf(jsonobject.get("bold").getAsBoolean());
|
| 502 | }
|
| 503 |
|
| 504 | if (jsonobject.has("italic"))
|
| 505 | {
|
| 506 | chatstyle.italic = Boolean.valueOf(jsonobject.get("italic").getAsBoolean());
|
| 507 | }
|
| 508 |
|
| 509 | if (jsonobject.has("underlined"))
|
| 510 | {
|
| 511 | chatstyle.underlined = Boolean.valueOf(jsonobject.get("underlined").getAsBoolean());
|
| 512 | }
|
| 513 |
|
| 514 | if (jsonobject.has("strikethrough"))
|
| 515 | {
|
| 516 | chatstyle.strikethrough = Boolean.valueOf(jsonobject.get("strikethrough").getAsBoolean());
|
| 517 | }
|
| 518 |
|
| 519 | if (jsonobject.has("obfuscated"))
|
| 520 | {
|
| 521 | chatstyle.obfuscated = Boolean.valueOf(jsonobject.get("obfuscated").getAsBoolean());
|
| 522 | }
|
| 523 |
|
| 524 | if (jsonobject.has("color"))
|
| 525 | {
|
| 526 | chatstyle.color = (EnumChatFormatting)p_deserialize_3_.deserialize(jsonobject.get("color"), EnumChatFormatting.class);
|
| 527 | }
|
| 528 |
|
| 529 | if (jsonobject.has("insertion"))
|
| 530 | {
|
| 531 | chatstyle.insertion = jsonobject.get("insertion").getAsString();
|
| 532 | }
|
| 533 |
|
| 534 | if (jsonobject.has("clickEvent"))
|
| 535 | {
|
| 536 | JsonObject jsonobject1 = jsonobject.getAsJsonObject("clickEvent");
|
| 537 |
|
| 538 | if (jsonobject1 != null)
|
| 539 | {
|
| 540 | JsonPrimitive jsonprimitive = jsonobject1.getAsJsonPrimitive("action");
|
| 541 | ClickEvent.Action clickevent$action = jsonprimitive == null ? null : ClickEvent.Action.getValueByCanonicalName(jsonprimitive.getAsString());
|
| 542 | JsonPrimitive jsonprimitive1 = jsonobject1.getAsJsonPrimitive("value");
|
| 543 | String s = jsonprimitive1 == null ? null : jsonprimitive1.getAsString();
|
| 544 |
|
| 545 | if (clickevent$action != null && s != null && clickevent$action.shouldAllowInChat())
|
| 546 | {
|
| 547 | chatstyle.chatClickEvent = new ClickEvent(clickevent$action, s);
|
| 548 | }
|
| 549 | }
|
| 550 | }
|
| 551 |
|
| 552 | if (jsonobject.has("hoverEvent"))
|
| 553 | {
|
| 554 | JsonObject jsonobject2 = jsonobject.getAsJsonObject("hoverEvent");
|
| 555 |
|
| 556 | if (jsonobject2 != null)
|
| 557 | {
|
| 558 | JsonPrimitive jsonprimitive2 = jsonobject2.getAsJsonPrimitive("action");
|
| 559 | HoverEvent.Action hoverevent$action = jsonprimitive2 == null ? null : HoverEvent.Action.getValueByCanonicalName(jsonprimitive2.getAsString());
|
| 560 | IChatComponent ichatcomponent = (IChatComponent)p_deserialize_3_.deserialize(jsonobject2.get("value"), IChatComponent.class);
|
| 561 |
|
| 562 | if (hoverevent$action != null && ichatcomponent != null && hoverevent$action.shouldAllowInChat())
|
| 563 | {
|
| 564 | chatstyle.chatHoverEvent = new HoverEvent(hoverevent$action, ichatcomponent);
|
| 565 | }
|
| 566 | }
|
| 567 | }
|
| 568 |
|
| 569 | return chatstyle;
|
| 570 | }
|
| 571 | }
|
| 572 | else
|
| 573 | {
|
| 574 | return null;
|
| 575 | }
|
| 576 | }
|
| 577 |
|
| 578 | public JsonElement serialize(ChatStyle p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
|
| 579 | {
|
| 580 | if (p_serialize_1_.isEmpty())
|
| 581 | {
|
| 582 | return null;
|
| 583 | }
|
| 584 | else
|
| 585 | {
|
| 586 | JsonObject jsonobject = new JsonObject();
|
| 587 |
|
| 588 | if (p_serialize_1_.bold != null)
|
| 589 | {
|
| 590 | jsonobject.addProperty("bold", p_serialize_1_.bold);
|
| 591 | }
|
| 592 |
|
| 593 | if (p_serialize_1_.italic != null)
|
| 594 | {
|
| 595 | jsonobject.addProperty("italic", p_serialize_1_.italic);
|
| 596 | }
|
| 597 |
|
| 598 | if (p_serialize_1_.underlined != null)
|
| 599 | {
|
| 600 | jsonobject.addProperty("underlined", p_serialize_1_.underlined);
|
| 601 | }
|
| 602 |
|
| 603 | if (p_serialize_1_.strikethrough != null)
|
| 604 | {
|
| 605 | jsonobject.addProperty("strikethrough", p_serialize_1_.strikethrough);
|
| 606 | }
|
| 607 |
|
| 608 | if (p_serialize_1_.obfuscated != null)
|
| 609 | {
|
| 610 | jsonobject.addProperty("obfuscated", p_serialize_1_.obfuscated);
|
| 611 | }
|
| 612 |
|
| 613 | if (p_serialize_1_.color != null)
|
| 614 | {
|
| 615 | jsonobject.add("color", p_serialize_3_.serialize(p_serialize_1_.color));
|
| 616 | }
|
| 617 |
|
| 618 | if (p_serialize_1_.insertion != null)
|
| 619 | {
|
| 620 | jsonobject.add("insertion", p_serialize_3_.serialize(p_serialize_1_.insertion));
|
| 621 | }
|
| 622 |
|
| 623 | if (p_serialize_1_.chatClickEvent != null)
|
| 624 | {
|
| 625 | JsonObject jsonobject1 = new JsonObject();
|
| 626 | jsonobject1.addProperty("action", p_serialize_1_.chatClickEvent.getAction().getCanonicalName());
|
| 627 | jsonobject1.addProperty("value", p_serialize_1_.chatClickEvent.getValue());
|
| 628 | jsonobject.add("clickEvent", jsonobject1);
|
| 629 | }
|
| 630 |
|
| 631 | if (p_serialize_1_.chatHoverEvent != null)
|
| 632 | {
|
| 633 | JsonObject jsonobject2 = new JsonObject();
|
| 634 | jsonobject2.addProperty("action", p_serialize_1_.chatHoverEvent.getAction().getCanonicalName());
|
| 635 | jsonobject2.add("value", p_serialize_3_.serialize(p_serialize_1_.chatHoverEvent.getValue()));
|
| 636 | jsonobject.add("hoverEvent", jsonobject2);
|
| 637 | }
|
| 638 |
|
| 639 | return jsonobject;
|
| 640 | }
|
| 641 | }
|
| 642 | }
|
| 643 | }
|
| 644 |
|