Hello, i code for 2 weeks, and i have seen the events for players (joins, die, …) doesn’t exist.
i know we can create our event, but i don"t understand how…
i’m french and english is not my maternal language…
how can i do for a class is reconized like an event?
thx
Saladoc
September 27, 2015, 7:14pm
2
Have you checked the SpongeDocs ? The pages you’re looking for might also be already translated in the French translation .
Tzk
September 27, 2015, 7:25pm
3
i have understand how create a class, but now how declarate the event at the player login
import org.spongepowered.api.event.impl.AbstractEvent;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Cancellable;
public class PlayerJoinEvent extends AbstractEvent{
private Player player;
private String joinmessage;
public Player getPlayer() {
return player;
}
public String getJoinMessage() {
return joinmessage;
}
}
how can i do?
JBYoshi
September 27, 2015, 9:00pm
5
Are you wanting to create an instance of the event from your plugin? If so, then use SpongeEventFactory
to create an instance, then pass it to game.getEventManager().post(event)
.
where do i have to put game.getEventManager?
(i think it’s in the Listener)
and how the event know when it has to activate it?
i don’t understand…
JBYoshi
September 27, 2015, 9:59pm
7
I’m not sure exactly what you’re asking. Are you wanting to run some code when the player joins, or are you wanting to cause other plugins’ “player join” code to run?
no, i found, i’m just stupid…
sorry
Saladoc
September 28, 2015, 2:07pm
9
TheSebakl:
i’m just stupid
You misspelled “learning”
1 Like
yes, but the answer is just behind my eyes (french expression) and i didn’t find it