#you can't just cast a map to an
1 messages · Page 1 of 1 (latest)
which line
Map<Player, ItemStack> playerItemStackMap = itemInSlot;
playerItemInSlotMap.put(player, (ItemStack) itemInSlot);
second one, you're casting it there
itemInSlot is an ItemStack
then you can't assign it to a map var
when i dont cast it i get
'put(org.bukkit.entity.Player, org.bukkit.inventory.ItemStack)' in 'java.util.Map' cannot be applied to '(org.bukkit.entity.Player, java.util.Map<org.bukkit.entity.Player,org.bukkit.inventory.ItemStack>)'
yes, because that code doesn't make sense
when i cast it it fixes the error
it will throw on runtime
so is Map<Player, ItemStack> playerItemStackMap = itemInSlot; correct?
what type of map you talking here
java.util.Map
because afaik. a map is just hashmap so i can set player's variables seperately
a map is an abstraction of a key-value store, HashMap is an implementation of it, ItemStack is neither, hence you can't assign it to that variable
so how do i set the player variable to the itemstack
you want to put the itemstack into the player's inventory?
no
its a shop plugin. but i had the issue of multiple people using it would casue mixing variables
hense im making them per player
I don't know the rest of your code, so I don't know what you're trying to do
I can share the code however it's extensive
~750 lines
Or i can share just the method im using i guess
no idea what you're doing with the maps, but Map<Player, ItemStack> playerItemStackMap = itemInSlot; is invalid if itemInSlot is an ItemStack