Food Level Change Event?

I know there were plans to add a universal data change event sort of thing. The plugin I am working on needs to check if a player’s food changes. Is this possible yet? I tried a couple things but they didn’t work. I’m currently using the 5.0.0 API but I can use 6.0.0 if need be.

1 Like

Try just a general ChangeDataHolderEvent or ChangeDataHolderEvent.ValueChange, and check if it’s the food being altered.

How do I check if it’s the food? I tried something that didn’t work (but for unrelated reasons), and can’t work on it now.

ChangeDataHolderEvent isn’t implemented yet. I’ve been working on it, but I’m waiting for some other changes to be merged.

I figured as much. Thanks anyways. I am excited for the end result!

Edit:
Here are the results of my work, which, until data change events, will run a loop to change a specific key for all players.

Task.builder().execute(() -> {
	for (Player player : Sponge.getServer().getOnlinePlayers()) {
		player.offer(Keys.FOOD_LEVEL, LockAmount.x);
	}
}).intervalTicks(20).submit(this);
}

I’m still not sure why people use Sponge.getScheduler().createTaskBuilder() when Task.builder() is so much simpler.

1 Like

I did not know that. I simply searched how to do it (I knew how to do it in Spigot but not here). Thanks!

In Sponge, if you need to create something, it’s nearly always done with a static of() or builder().

1 Like