Ejemplo n.º 1
0
 /**
  * Deserializes a JSON-represented message from a mapping of key-value pairs. This is called by
  * the Bukkit serialization API. It is not intended for direct public API consumption.
  *
  * @param serialized The key-value mapping which represents a fancy message.
  */
 @SuppressWarnings("unchecked")
 public static FancyMessage deserialize(Map<String, Object> serialized) {
   FancyMessage msg = new FancyMessage();
   msg.messageParts = (List<MessagePart>) serialized.get("messageParts");
   msg.jsonString = serialized.containsKey("JSON") ? serialized.get("JSON").toString() : null;
   msg.dirty = !serialized.containsKey("JSON");
   return msg;
 }
Ejemplo n.º 2
0
 @Override
 public FancyMessage clone() throws CloneNotSupportedException {
   FancyMessage instance = (FancyMessage) super.clone();
   instance.messageParts = new ArrayList<MessagePart>(messageParts.size());
   for (int i = 0; i < messageParts.size(); i++) {
     instance.messageParts.add(i, messageParts.get(i).clone());
   }
   instance.dirty = false;
   instance.jsonString = null;
   return instance;
 }