Add Start Command
Dieser Commit ist enthalten in:
Ursprung
625f39fba4
Commit
8e7437efcb
@ -25,3 +25,5 @@ GAME_WIN=
|
|||||||
GAME_STARTING=§7Starting: §e{0}s§8!
|
GAME_STARTING=§7Starting: §e{0}s§8!
|
||||||
GAME_WAITING=§7Waiting for players§8!
|
GAME_WAITING=§7Waiting for players§8!
|
||||||
SERVER_STOPPING=§cThe server stops in §e{0}s§8!
|
SERVER_STOPPING=§cThe server stops in §e{0}s§8!
|
||||||
|
|
||||||
|
COMMAND_START=§aThe game will start soon§8!
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.towerrun;
|
package de.steamwar.towerrun;
|
||||||
|
|
||||||
import de.steamwar.message.Message;
|
import de.steamwar.message.Message;
|
||||||
|
import de.steamwar.towerrun.commands.StartCommand;
|
||||||
import de.steamwar.towerrun.countdowns.EndCountdown;
|
import de.steamwar.towerrun.countdowns.EndCountdown;
|
||||||
import de.steamwar.towerrun.countdowns.LobbyCountdown;
|
import de.steamwar.towerrun.countdowns.LobbyCountdown;
|
||||||
import de.steamwar.towerrun.listener.GlobalListener;
|
import de.steamwar.towerrun.listener.GlobalListener;
|
||||||
@ -56,7 +57,8 @@ public class TowerRun extends JavaPlugin {
|
|||||||
new GlobalListener();
|
new GlobalListener();
|
||||||
new LobbyListener();
|
new LobbyListener();
|
||||||
new NotLobbyListener();
|
new NotLobbyListener();
|
||||||
new LobbyCountdown();
|
final LobbyCountdown lobbyCountdown = new LobbyCountdown();
|
||||||
new EndCountdown();
|
new EndCountdown();
|
||||||
|
new StartCommand(lobbyCountdown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
49
src/de/steamwar/towerrun/commands/StartCommand.java
Normale Datei
49
src/de/steamwar/towerrun/commands/StartCommand.java
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.towerrun.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import de.steamwar.sql.UserGroup;
|
||||||
|
import de.steamwar.towerrun.TowerRun;
|
||||||
|
import de.steamwar.towerrun.countdowns.LobbyCountdown;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class StartCommand extends SWCommand {
|
||||||
|
private final LobbyCountdown countdown;
|
||||||
|
|
||||||
|
public StartCommand(LobbyCountdown countdown) {
|
||||||
|
super("start", "skip");
|
||||||
|
this.countdown = countdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void command(@Validator Player player) {
|
||||||
|
countdown.setOverride(true);
|
||||||
|
countdown.setTime(10);
|
||||||
|
TowerRun.getMessage().send("COMMAND_START", player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassValidator(value = Player.class, local = true)
|
||||||
|
public TypeValidator<Player> playerValidator() {
|
||||||
|
return (commandSender, player, messageSender) -> SteamwarUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Member;
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ package de.steamwar.towerrun.countdowns;
|
|||||||
import de.steamwar.towerrun.TowerRun;
|
import de.steamwar.towerrun.TowerRun;
|
||||||
import de.steamwar.towerrun.state.GameStateToggleListener;
|
import de.steamwar.towerrun.state.GameStateToggleListener;
|
||||||
import de.steamwar.towerrun.state.GameStates;
|
import de.steamwar.towerrun.state.GameStates;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ import java.util.EnumSet;
|
|||||||
|
|
||||||
public abstract class Countdown extends GameStateToggleListener {
|
public abstract class Countdown extends GameStateToggleListener {
|
||||||
|
|
||||||
|
@Setter
|
||||||
protected int time = defaultTime();
|
protected int time = defaultTime();
|
||||||
protected BukkitTask task;
|
protected BukkitTask task;
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ import de.steamwar.towerrun.config.Config;
|
|||||||
import de.steamwar.towerrun.game.TowerRunGame;
|
import de.steamwar.towerrun.game.TowerRunGame;
|
||||||
import de.steamwar.towerrun.state.GameStateToggleListener;
|
import de.steamwar.towerrun.state.GameStateToggleListener;
|
||||||
import de.steamwar.towerrun.state.GameStates;
|
import de.steamwar.towerrun.state.GameStates;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -32,8 +34,12 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class LobbyCountdown extends Countdown {
|
public class LobbyCountdown extends Countdown {
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private boolean override = false;
|
||||||
|
|
||||||
public LobbyCountdown() {
|
public LobbyCountdown() {
|
||||||
super(EnumSet.of(GameStates.LOBBY));
|
super(EnumSet.of(GameStates.LOBBY));
|
||||||
}
|
}
|
||||||
@ -50,7 +56,7 @@ public class LobbyCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean timerShouldCancel() {
|
boolean timerShouldCancel() {
|
||||||
return super.timerShouldCancel();
|
return !override && Bukkit.getOnlinePlayers().size() < Config.MIN_PLAYERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren