fixed player join when no event is loaded
This commit is contained in:
@@ -127,7 +127,7 @@ public class Deathrun extends Appliance implements Event, Scorable {
|
|||||||
public void stop() {
|
public void stop() {
|
||||||
this.getScoreboardBuilder().stopAutomaticUpdates();
|
this.getScoreboardBuilder().stopAutomaticUpdates();
|
||||||
Title title = Title.title(Component.text("Ende!"), Component.empty());
|
Title title = Title.title(Component.text("Ende!"), Component.empty());
|
||||||
this.pvpTask.cancel();
|
if(this.pvpTask != null) this.pvpTask.cancel();
|
||||||
this.pvpDisabled = true;
|
this.pvpDisabled = true;
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
player.showTitle(title);
|
player.showTitle(title);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.GameRule;
|
import org.bukkit.GameRule;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -86,7 +87,7 @@ public class EventController extends Appliance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void scheduleStart(long durationMinutes) {
|
public void scheduleStart(long durationMinutes) {
|
||||||
if(this.selectedEvent == null) throw new ApplianceCommand.Error("There is no event selected!");
|
if(!this.hasLoadedEvent()) throw new ApplianceCommand.Error("There is no event selected!");
|
||||||
this.durationMinutes = durationMinutes;
|
this.durationMinutes = durationMinutes;
|
||||||
this.countdown.start();
|
this.countdown.start();
|
||||||
}
|
}
|
||||||
@@ -188,6 +189,13 @@ public class EventController extends Appliance {
|
|||||||
return String.format("%02d:%02d:%02d", seconds / 3600, (seconds / 60) % 60, seconds % 60);
|
return String.format("%02d:%02d:%02d", seconds / 3600, (seconds / 60) % 60, seconds % 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected @NotNull List<Listener> listeners() {
|
||||||
|
return List.of(
|
||||||
|
new EventPlayerLoginListener()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @NotNull List<ApplianceCommand<?>> commands() {
|
protected @NotNull List<ApplianceCommand<?>> commands() {
|
||||||
return List.of(
|
return List.of(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
public class EventPlayerLoginListener extends ApplianceListener<EventController> {
|
public class EventPlayerLoginListener extends ApplianceListener<EventController> {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
if(event.getPlayer().hasPermission("admin")) return;
|
if(event.getPlayer().isOp()) return;
|
||||||
if(this.getAppliance().hasLoadedEvent()) return;
|
if(this.getAppliance().hasLoadedEvent()) return;
|
||||||
event.getPlayer().kick(Component.text("Es ist kein Event geladen."));
|
event.getPlayer().kick(Component.text("Es ist kein Event geladen."));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user