Appears to have been removed in recent changes. Whats the equivalent? I’m not finding anything.
You could use the MessageSinkEvent
and check if the command source is a player:
@Listener
public void onChat(MessageSinkEvent event) {
if(event.getSource() instanceof Player) {
Player player = (Player) event.getSource();
}
}
Perfect. Thanks!
One second, @Zidane just wrecked that plan. I’ll post updated code shortly.
Update your Maven dependencies to see the change.
EDIT - This should work:
@Listener
public void onChat(MessageSinkEvent event) {
Optional<Player> playerOptional = event.getCause().first(Player.class);
if(!playerOptional.isPresent()) return;
Player player = playerOptional.get();
}
Credit to @blood
Excellent. Will test tomorrow.
Please note that Sponge doesn’t have a runnable version using this new event API. The new event API should be implemented in the next Sponge version greater than: 1.8-1499-2.1DEV-591
Well I guess testing won’t do me any good then. Either way thanks. All looks good on paper.
Seems Sponge 592 and 602 is available. I’d try with these and the newest API.