Package com.massivecraft.mcore.xlib.gson

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


  }
 
  // EnchantLevelMap
  public static JsonObject convertEnchantLevelMap(Map<Enchantment, Integer> enchantLevelMap)
  {
    JsonObject ret = new JsonObject();
    for (Entry<Enchantment, Integer> entry : enchantLevelMap.entrySet())
    {
      ret.addProperty(String.valueOf(entry.getKey().getId()), entry.getValue());
    }
    return ret;
  }
View Full Code Here


    return ret;
  }
 
  public static Map<Enchantment, Integer> convertEnchantLevelMap(JsonElement jsonElement)
  {
    JsonObject json = jsonElement.getAsJsonObject();
    Map<Enchantment, Integer> ret = new HashMap<Enchantment, Integer>();
    for (Entry<String, JsonElement> entry : json.entrySet())
    {
      int id = Integer.valueOf(entry.getKey());
      Enchantment ench = Enchantment.getById(id);
      int lvl = entry.getValue().getAsInt();
      ret.put(ench, lvl);
View Full Code Here

 
  public static JsonObject toJson(FireworkEffect fireworkEffect)
  {
    if (fireworkEffect == null) return null;
   
    JsonObject ret = new JsonObject();
   
    ret.addProperty(FLICKER, fireworkEffect.hasFlicker());
    ret.addProperty(TRAIL, fireworkEffect.hasTrail());
    ret.add(COLORS, fromColorCollection(fireworkEffect.getColors()));
    ret.add(FADE_COLORS, fromColorCollection(fireworkEffect.getFadeColors()));
    ret.addProperty(TYPE, fireworkEffect.getType().name());
   
    return ret;
  }
View Full Code Here

  public static FireworkEffect fromJson(JsonElement jsonElement)
  {
    if (jsonElement == null) return null;
    if ( ! jsonElement.isJsonObject()) return null;
   
    JsonObject json = jsonElement.getAsJsonObject();
   
    boolean flicker = FLICKER_DEFAULT;
    boolean trail = TRAIL_DEFAULT;
    List<Color> colors = COLORS_DEFAULT;
    List<Color> fadeColors = FADE_COLORS_DEFAULT;
    Type type = TYPE_DEFAULT;
   
    JsonElement element;
   
    element = json.get(FLICKER);
    if (element != null)
    {
      flicker = element.getAsBoolean();
    }
   
    element = json.get(TRAIL);
    if (element != null)
    {
      trail = element.getAsBoolean();
    }
   
    element = json.get(COLORS);
    if (element != null)
    {
      colors = toColorCollection(element);
    }
   
    element = json.get(FADE_COLORS);
    if (element != null)
    {
      fadeColors = toColorCollection(element);
    }
   
    element = json.get(TYPE);
    if (element != null)
    {
      type = Type.valueOf(element.getAsString());
    }
   
View Full Code Here

TOP

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

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.