Package com.massivecraft.mcore.xlib.gson

Examples of com.massivecraft.mcore.xlib.gson.JsonElement


    Boolean hostFactionAllowed = null;
    Set<String> factionIds = null;
    Set<String> playerIds = null;
   
    // Read variables (test old values first)
    JsonElement element = null;
   
    element = obj.get("ID");
    if (element == null) element = obj.get(HOST_FACTION_ID);
    hostFactionId = element.getAsString();
   
    element = obj.get("open");
    if (element == null) element = obj.get(HOST_FACTION_ALLOWED);
    if (element != null) hostFactionAllowed = element.getAsBoolean();
   
    element = obj.get("factions");
    if (element == null) element = obj.get(FACTION_IDS);
    if (element != null) factionIds = context.deserialize(element, SET_OF_STRING_TYPE);
   
View Full Code Here


    JsonObject ret = new JsonObject();
   
    String type = src.getClass().getCanonicalName();
    ret.addProperty(TYPE, type);
   
    JsonElement value = context.serialize(src);
    ret.add(VALUE, value);
   
    return ret;
  }
View Full Code Here

    JsonObject json = jsonElement.getAsJsonObject();
   
    PotionEffectType pet = PotionEffectType.getById(json.get(POTION_EFFECT_ID).getAsInt());
   
    int duration = POTION_DURATION_DEFAULT;
    JsonElement durationElement = json.get(POTION_DURATION);
    if (durationElement != null)
    {
      duration = durationElement.getAsInt();
    }
   
    int amplifier = POTION_AMPLIFIER_DEFAULT;
    JsonElement amplifierElement = json.get(POTION_AMPLIFIER);
    if (amplifierElement != null)
    {
      amplifier = amplifierElement.getAsInt();
    }
   
    boolean ambient = POTION_AMBIENT_DEFAULT;
    JsonElement ambientElement = json.get(POTION_AMBIENT);
    if (ambientElement != null)
    {
      ambient = ambientElement.getAsBoolean();
    }
   
    return new PotionEffect(pet, duration, amplifier, ambient);
  }
View Full Code Here

      if (id == DEFAULT_ID) return;
      json.addProperty(ID, id);
    }
    else
    {
      JsonElement element = json.get(ID);
      if (element == null) return;
      stack.setTypeId(element.getAsInt());
    }
  }
View Full Code Here

      if (count == DEFAULT_COUNT) return;
      json.addProperty(COUNT, count);
    }
    else
    {
      JsonElement element = json.get(COUNT);
      if (element == null) return;
      stack.setAmount(element.getAsInt());
    }
  }
View Full Code Here

      if (damage == DEFAULT_DAMAGE) return;
      json.addProperty(DAMAGE, damage);
    }
    else
    {
      JsonElement element = json.get(DAMAGE);
      if (element == null) return;
      stack.setDurability(element.getAsShort());
    }
  }
View Full Code Here

      if (!meta.hasDisplayName()) return;
      json.addProperty(NAME, meta.getDisplayName());
    }
    else
    {
      JsonElement element = json.get(NAME);
      if (element == null) return;
      meta.setDisplayName(element.getAsString());
    }
  }
View Full Code Here

      if (!meta.hasLore()) return;
      json.add(LORE, convertStringList(meta.getLore()));
    }
    else
    {
      JsonElement element = json.get(LORE);
      if (element == null) return;
      meta.setLore(convertStringList(element));
    }
  }
View Full Code Here

      if (!meta.hasEnchants()) return;
      json.add(ENCHANTS, convertEnchantLevelMap(meta.getEnchants()));
    }
    else
    {
      JsonElement element = json.get(ENCHANTS);
      if (element == null) return;
      for (Entry<Enchantment, Integer> entry : convertEnchantLevelMap(element).entrySet())
      {
        meta.addEnchant(entry.getKey(), entry.getValue(), true);
      }
View Full Code Here

      if (!repairable.hasRepairCost()) return;
      json.addProperty(REPAIRCOST, repairable.getRepairCost());
    }
    else
    {
      JsonElement element = json.get(REPAIRCOST);
      if (element == null) return;

      repairable.setRepairCost(element.getAsInt());
    }
  }
View Full Code Here

TOP

Related Classes of com.massivecraft.mcore.xlib.gson.JsonElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.