Permalink
Browse files

JoinEvent inject Entity

The function "set_metadata" and similar require an entity to be online. 
The entity (player) is known by the event already, but not the rest of the server. 
Injecting it, to make it accessible.
  • Loading branch information...
Ecconia committed Jun 8, 2018
1 parent ca72bc5 commit 1a703a247b185252efccd48834ade148a8fd60e8
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java
@@ -817,6 +817,24 @@ public BindableEvent convert(CArray manual, Target t) {
return e;
}
@Override
public void preExecution(Environment env, ActiveEvent activeEvent) {
if(activeEvent.getUnderlyingEvent() instanceof MCPlayerJoinEvent) {
//Static lookups of the player as entity don't seem to work here, but
//the player is passed in with the event.
MCPlayer player = ((MCPlayerJoinEvent) activeEvent.getUnderlyingEvent()).getPlayer();
Static.InjectEntity(player);
}
}
@Override
public void postExecution(Environment env, ActiveEvent activeEvent) {
if(activeEvent.getUnderlyingEvent() instanceof MCPlayerJoinEvent) {
MCPlayer player = ((MCPlayerJoinEvent) activeEvent.getUnderlyingEvent()).getPlayer();
Static.UninjectEntity(player);
}
}
}
@api

0 comments on commit 1a703a2

Please sign in to comment.