Hello,
I tried to give to a random player tree diamond but Intellij Idea sayed that I can’t.
Here’s the code and the error :
`
if(src instanceof Player) {
Player p = (Player) src;
Player choosenPlayer = getRandomPlayer(Sponge.getServer());
**_choosenPlayer.getInventory().set(ItemStack.of(ItemTypes.DIAMOND, 3))_**
spongePrivate.getLogger().info("GIVED 3 DIAMOND TO "+ choosenPlayer.getName());
Text textRandom = Text.of("A player is selected.");
for(int i = 0;i < Sponge.getServer().getOnlinePlayers().size() + 1;i++) {
Player[] playersList = Sponge.getServer().getOnlinePlayers().toArray(new Player[Sponge.getServer().getOnlinePlayers().size()]);
Player allPlayers = playersList[i];
allPlayers.sendMessage(textRandom);
}
return CommandResult.success();
}
`
At choosenPlayer.getInventory().set(ItemStack.of(ItemTypes.DIAMOND, 3)) it says : Static interface method invocations are not supported at this language level.
I also tried ItemStack diamond = ItemStack.builder().itemType(ItemTypes.DIAMOND).quantity(3).build(); and it says the same thing.
Can someone help me please ?
Sorry if there is a wrong spelling I’m french.