Because i just wanted a simple and quick way to store a players true or false on this bit of code. It may be ugly but for my needs it fits.
I have tried multiple ways of the boolean, still get the issue, this was just the latest way i tried.
The playerpresent just gets whether the player is online.
Here's the full part of that, its using some Sponge methods as its part Sponge and part Forge
public void onBlockPlace(ChangeBlockEvent.Place event) {
if (AdminUtilsSponge.getInstance().getWorldWarningBoolean()) {
String world = event.getTargetWorld().getName();
String worldslist = String.join(", ", AdminUtilsSponge.getInstance().getWorldList());
Optional<Player> player = event.getCause().first(Player.class);
Boolean playerpresent = player.isPresent();
String name = player.get().getName();
UUID uuid = player.get().getUniqueId();
EntityPlayer forgeplayer = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(uuid);
String block = event.getTransactions().get(0).getFinal().getState().getType().getName();
NBTTagCompound data = forgeplayer.getEntityData();
data.setTag("AdminUtils", new NBTTagCompound());
NBTTagCompound adminnbt = data.getCompoundTag("AdminUtils");
adminnbt.setTag("WorldWarnings", new NBTTagCompound());
NBTTagCompound worldwarnings = adminnbt.getCompoundTag("WorldWarnings");
Boolean warning = worldwarnings.getBoolean(world);
if (playerpresent) {
if (!(worldslist.contains(world))) {
if (warning) {
System.out.print(String.valueOf(worldwarnings.getBoolean(world)));
}
}
}
}
}