Add success/failure handlers
This commit is contained in:
parent
1e922c93a8
commit
09f59f4975
3 changed files with 23 additions and 3 deletions
|
@ -5,11 +5,14 @@ import java.util.List;
|
|||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import gent.zeus.mc13dtl.MC13DTL;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public abstract class Event {
|
||||
public abstract class Event implements Listener {
|
||||
protected Team team;
|
||||
|
||||
public Event(Team team) {
|
||||
|
@ -17,6 +20,25 @@ public abstract class Event {
|
|||
for (Player player : getPlayers()) {
|
||||
player.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + getMessage());
|
||||
}
|
||||
MC13DTL.instance.getServer().getPluginManager().registerEvents(this, MC13DTL.instance);
|
||||
}
|
||||
|
||||
private void eventFinished() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
protected void eventSuccess() {
|
||||
for (Player player : getPlayers()) {
|
||||
player.sendMessage(ChatColor.GREEN + "Congratulations! You survived this event");
|
||||
}
|
||||
eventFinished();
|
||||
}
|
||||
|
||||
protected void eventFailed() {
|
||||
for (Player player : getPlayers()) {
|
||||
player.sendMessage(ChatColor.RED + "Try harder next time...");
|
||||
}
|
||||
eventFinished();
|
||||
}
|
||||
|
||||
protected List<Player> getPlayers() {
|
||||
|
|
|
@ -7,7 +7,6 @@ import gent.zeus.mc13dtl.events.Event;
|
|||
public class TestEvent extends Event {
|
||||
public TestEvent(Team team) {
|
||||
super(team);
|
||||
System.err.println("test");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,6 @@ import gent.zeus.mc13dtl.MC13DTL;
|
|||
import io.papermc.paper.command.brigadier.BasicCommand;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
Loading…
Reference in a new issue