I have this method defined:
public static TreeSet<ItemStack> getItems() {
TreeSet<ItemStack> things = new TreeSet<>();
things.add(new ItemStack(Material.ACACIA_DOOR));
return things;
}
I also tried putting multiple things in the TreeSet, it doesn't work either.
Now I have this code part:
TreeSet<ItemStack> things = getItems();
If I run this, nothing happens. If I surround it with try/catch, there seems to be an exception thrown. But if I print the error like that:
} catch (Exception exc) {
System.out.println("Catched an exception:")
exc.printStackTrace();
System.out.println(exc.getMessage());
System.out.println(exc);
}
There isn't any error / Stacktrace or so coming up. It just says:
[INFO]: Catched an exception:
[WARN]: java.lang.ClassCastException
[INFO]: null
[INFO]: java.lang.ClassCastException
So what is the error, how do I prevent it and why do I get it by casting a TreeSet with ItemSets to a TreeSet with ItemSets?