crwdns137779:0crwdne137779:0
crwdns137781:0:javadoc:crwdne137781:0
crwdns137783:0:javadoc:crwdne137783:0
crwdns137785:0:javadoc:crwdne137785:0
crwdns137787:0crwdne137787:0
crwdns137789:0:javadoc:crwdne137789:0
crwdns137791:0crwdne137791:0
crwdns137793:0crwdne137793:0
crwdns156851:0:javadoc:crwdne156851:0
crwdns137797:0:javadoc:crwdne137797:0
crwdns137799:0crwdne137799:0
crwdns137801:0crwdne137801:0
Note
crwdns137803:0crwdne137803:0
crwdns137805:0:javadoc:crwdne137805:0
crwdns137807:0:javadoc:crwdne137807:0
@Listener
public void onEvent(ExampleCauseEvent event) {
Cause cause = event.cause(); // [Player, Entity]
Optional<Player> firstPlayer = cause.first(Player.class); // 1
Optional<Entity> firstEntity = cause.first(Entity.class); // 2
}
crwdns137809:0crwdne137809:0
crwdns137811:0:javadoc:crwdne137811:0
crwdns137813:0crwdne137813:0
crwdns137815:0:javadoc:crwdne137815:0
crwdns137817:0:javadoc:crwdne137817:0
crwdns137819:0crwdne137819:0
crwdns137821:0:javadoc:crwdnd137821:0:javadoc:crwdnd137821:0:javadoc:crwdnd137821:0:javadoc:crwdne137821:0
crwdns137823:0:javadoc:crwdne137823:0
crwdns137825:0crwdne137825:0
@Listener
public void onGrow(ChangeBlockEvent.All event) {
Optional<UUID> notifier = event.cause().context().get(EventContextKeys.NOTIFIER);
}
crwdns137827:0:javadoc:crwdnd137827:0:javadoc:crwdne137827:0
Note
crwdns137829:0crwdne137829:0
crwdns137831:0crwdne137831:0
crwdns137833:0crwdne137833:0
Note
crwdns137835:0crwdne137835:0
crwdns137837:0crwdne137837:0
Warning
crwdns137839:0crwdne137839:0
crwdns137841:0:javadoc:crwdnd137841:0:javadoc:crwdnd137841:0:javadoc:crwdnd137841:0:javadoc:crwdnd137841:0:javadoc:crwdne137841:0
crwdns137843:0crwdne137843:0
Tip
crwdns137845:0crwdne137845:0
crwdns137847:0crwdne137847:0
crwdns137849:0crwdne137849:0
crwdns137851:0crwdne137851:0
crwdns137853:0:javadoc:crwdnd137853:0:javadoc:crwdne137853:0
CommandSource sourceRunningSudo = ...;
Player playerToSimulate = ...;
try (CauseStackManager.StackFrame frame = Sponge.server().causeStackManager().pushCauseFrame()) {
frame.pushCause(sourceRunningSudo);
frame.pushCause(playerToSimulate);
frame.addContext(EventContextKeys.PLAYER_SIMULATED, playerToSimulate.getProfile());
Cause cause = frame.currentCause();
}
crwdns137855:0crwdne137855:0
Tip
crwdns137857:0:javadoc:crwdne137857:0
crwdns137859:0crwdne137859:0
crwdns137861:0crwdne137861:0
crwdns137863:0:javadoc:crwdnd137863:0:javadoc:crwdne137863:0
crwdns137865:0:javadoc:crwdne137865:0
crwdns137867:0crwdne137867:0
crwdns137869:0crwdne137869:0
crwdns137871:0crwdne137871:0
CommandSource sourceRunningSudo = ...;
Player playerToSimulate = ...;
PluginContainer plugin = ...;
EventContext context = EventContext.builder()
.add(EventContextKeys.PLAYER_SIMULATED, playerToSimulate.profile())
.add(EventContextKeys.PLUGIN, plugin)
.build();
Cause cause = Cause.builder()
.append(playerToSimulate)
.append(sourceRunningSudo)
.append(plugin)
.build(context);
crwdns137873:0crwdne137873:0