PlayerJoinEvent == ClientConnectionEvent.Join PlayerQuitEvent == ClientConnectionEvent.Disconnect (I don’t think this makes sense) PlayerBreakBlockEvent == Not sure, there’s BreakBlockEvent but that has no sub-interfaces PlayerPlaceBlockEvent == Again, not sure PlaceBlockEvent
In order to get the source for any event that is CauseTracked, you now must query for the Cause. So for example, lets assume you want to see if a Player caused a BreakBlockEvent, you would do the following :
public void onBreakBlockEvent(BreakBlockEvent event) {
Optional<Player> player = event.getCause().first(Player.class);
if (player.isPresent()) {
// do stuff
}
}
Is their going to be an event that will solely listen for a Player breaking a block being added back to the API or is this the only way of checking from now on? Also, with the code example above, how would you get the block that was broken, I cannot seem to figure it out?
As far as I know this will be the method going forward, as allows you to drill down into much more complex cause chains than the simple example given.
BlockBreakEvent does not assume one block has been broken - it can also be multiple. As such, the even has a getTransactions() function. This is a list of all the blocks that have been changed/broken, and what their default and overridden replacements are.
That’s what I did. I guess it’s not needed to find the cause since it is very clearly caused by a player joining, hence the naming of it. Although now I have to cast Entity to Player (safely ofc)…