Jump to content

Recommended Posts

Posted
{
  "holz": [
    {
      "itemname": "Eichenholz",
      "item": {
        "material": "OAK_LOG",
        "anzahl": "1"
      },
      "lore": [
        {
          "preis": "10"
        }
      ]
    },
    {
      "itemname": "Brauner Pilzblock",
      "item": {
        "material": "BROWN_MUSHROOM_BLOCK",
        "anzahl": "1"
      },
      "lore": [
        {
          "preis": "15"
        }
      ]
    },
    {
      "itemname": "Tropenbaumlaub",
      "item": {
        "material": "JUNGLE_LEAVES",
        "anzahl": "1"
      },
      "lore": [
        {
          "preis": "2"
        }
      ]
    },
    {
      "itemname": "Eichenholz",
      "item": {
        "material": "OAK_LOG",
        "anzahl": "64"
      },
      "lore": [
        {
          "preis": "64"
        }
      ]
    },
    {
      "itemname": "Eichenholz",
      "item": {
        "material": "OAK_LOG",
        "anzahl": "64"
      },
      "lore": [
        {
          "preis": "10"
        }
      ]
    },
    {
      "itemname": "Brauner Pilzblock",
      "item": {
        "material": "BROWN_MUSHROOM_BLOCK",
        "anzahl": "64"
      },
      "lore": [
        {
          "preis": "960"
        }
      ]
    },
    {
      "itemname": "Tropenbaumlaub",
      "item": {
        "material": "JUNGLE_LEAVES",
        "anzahl": "64"
      },
      "lore": [
        {
          "preis": "128"
        }
      ]
    }
  ]
}

ich würde gerne diese json datei in mein Plugin laden , nur die umsetzung ist etwas naja

ich arbeite noch nicht solange mit Json

Gson gson = new Gson();
ShopItems[] shopItems= gson.fromJson(json, ShopItems[].class);
for(ShopItems shopItem: shopItems)
    System.out.println(shopItem.toString());

ich habe das so probiert aber ohne erfolg

es kommt immer eine java.lang.NullPointerException

Posted

Soll sich die Datei direkt im Plugin befinden oder soll sie aus dem Plugins-Ordner geladen werden?

Was genau soll erst mal ausgegeben werden? Die ganze Datei als String oder bestimmte Objekte der Datei?

Posted

hi , die datei liegt im Plugin ordner , und soll so ausgegbene werden das das als Obejct aus geben kann , damit ich das dann ins Inventar vom Shop packen kann

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...
B
B