Umbau der MissileWars Commands auf das neue Command Framework #53
@ -19,9 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
import de.steamwar.misslewars.commands.CommandAcceptDecline;
|
import de.steamwar.misslewars.commands.AcceptCommand;
|
||||||
import de.steamwar.misslewars.commands.CommandInvite;
|
import de.steamwar.misslewars.commands.DeclineCommand;
|
||||||
import de.steamwar.misslewars.commands.CommandSpectate;
|
import de.steamwar.misslewars.commands.InviteCommand;
|
||||||
|
import de.steamwar.misslewars.commands.SpectateCommand;
|
||||||
import de.steamwar.misslewars.countdowns.EndCountdown;
|
import de.steamwar.misslewars.countdowns.EndCountdown;
|
||||||
import de.steamwar.misslewars.countdowns.ItemCountdown;
|
import de.steamwar.misslewars.countdowns.ItemCountdown;
|
||||||
import de.steamwar.misslewars.countdowns.WaitingCountdown;
|
import de.steamwar.misslewars.countdowns.WaitingCountdown;
|
||||||
@ -73,15 +74,12 @@ public class MissileWars extends JavaPlugin {
|
|||||||
new WaitingListener();
|
new WaitingListener();
|
||||||
new FightListener();
|
new FightListener();
|
||||||
new ChatListener();
|
new ChatListener();
|
||||||
getCommand("spectate").setExecutor(new CommandSpectate());
|
new SpectateCommand();
|
||||||
|
|
||||||
// Invitation Commands
|
// Invitation Commands
|
||||||
CommandInvite commandInvite = new CommandInvite();
|
new InviteCommand();
|
||||||
getCommand("invite").setExecutor(commandInvite);
|
new AcceptCommand();
|
||||||
getCommand("invite").setTabCompleter(commandInvite);
|
new DeclineCommand();
|
||||||
|
|
||||||
getCommand("accept").setExecutor(new CommandAcceptDecline());
|
|
||||||
getCommand("decline").setExecutor(new CommandAcceptDecline());
|
|
||||||
|
|
||||||
new WaitingCountdown();
|
new WaitingCountdown();
|
||||||
new ItemCountdown();
|
new ItemCountdown();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -17,48 +17,49 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
PsiRobot markierte diese Unterhaltung als gelöst
|
|||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.misslewars.commands;
|
package de.steamwar.misslewars.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.misslewars.Config;
|
import de.steamwar.misslewars.Config;
|
||||||
import de.steamwar.misslewars.MWTeam;
|
import de.steamwar.misslewars.MWTeam;
|
||||||
import de.steamwar.misslewars.MissileWars;
|
import de.steamwar.misslewars.MissileWars;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandAcceptDecline implements CommandExecutor {
|
public class AcceptCommand extends SWCommand {
|
||||||
|
|
||||||
@Override
|
public AcceptCommand() {
|
||||||
PsiRobot markierte diese Unterhaltung als gelöst
YoyoNow
hat
Leerzeile bitte davor Leerzeile bitte davor
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
super("accept");
|
||||||
if (!(sender instanceof Player)) return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (!Config.isChallenge()) {
|
|
||||||
player.sendMessage("§cDieser Command ist deaktiviert.");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void onCommand(@Validator Player player, String... varargs) {
|
||||||
MWTeam teamInvitation = MissileWars.getInvitation(player);
|
MWTeam teamInvitation = MissileWars.getInvitation(player);
|
||||||
if (teamInvitation == null) {
|
if (teamInvitation == null) {
|
||||||
player.sendMessage("§cDu wurdest nicht eingeladen.");
|
player.sendMessage("§cDu wurdest nicht eingeladen.");
|
||||||
return false;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
if (command.getName().equalsIgnoreCase("accept")) {
|
|
||||||
teamInvitation.acceptInvite(player);
|
teamInvitation.acceptInvite(player);
|
||||||
message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 ist dem Team §abeigetreten§7.");
|
message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 ist dem Team §abeigetreten§7.");
|
||||||
} else {
|
|
||||||
MWTeam.removeInvitations(player);
|
|
||||||
message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 hat die Einladung §cabgelehnt§7.");
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassValidator(value = Player.class, local = true)
|
||||||
|
public TypeValidator<Player> validator() {
|
||||||
|
return new TypeValidator<Player>() {
|
||||||
|
@Override
|
||||||
|
public boolean validate(CommandSender commandSender, Player player, MessageSender messageSender) {
|
||||||
|
if (Config.isChallenge()) {
|
||||||
|
messageSender.send("§cDieser Command ist deaktiviert.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void message(MWTeam mwTeam, String s) {
|
private void message(MWTeam mwTeam, String s) {
|
||||||
mwTeam.getPlayers().forEach(player -> player.sendMessage(s));
|
mwTeam.getPlayers().forEach(player -> player.sendMessage(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 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.misslewars.commands;
|
|
||||||
|
|
||||||
import de.steamwar.misslewars.Config;
|
|
||||||
import de.steamwar.misslewars.MWTeam;
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class CommandInvite implements CommandExecutor, TabCompleter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (!(sender instanceof Player)) return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (!Config.isChallenge()) {
|
|
||||||
player.sendMessage("§cDieser Command ist deaktiviert.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
MWTeam team = MissileWars.getTeam(player);
|
|
||||||
if (!Config.RedLeader.equals(player.getUniqueId()) && !Config.BlueLeader.equals(player.getUniqueId()) || team == null) {
|
|
||||||
player.sendMessage("§cDu kannst keine Spieler einladen.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length != 1) {
|
|
||||||
player.sendMessage("§c/invite <PLAYER>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player invitedPlayer = Bukkit.getPlayer(args[0]);
|
|
||||||
if (invitedPlayer == null) {
|
|
||||||
player.sendMessage("§cDieser Spieler ist nicht online.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (MissileWars.getTeam(invitedPlayer) != null) {
|
|
||||||
player.sendMessage("§cDieser Spieler ist bereits in einem Team.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (MissileWars.getInvitation(invitedPlayer) != null) {
|
|
||||||
player.sendMessage("§cDieser Spieler wurde bereits eingeladen.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
team.invitePlayer(invitedPlayer);
|
|
||||||
player.sendMessage("§7Du hast §e" + invitedPlayer.getName() + " §7eingeladen.");
|
|
||||||
invitedPlayer.sendMessage("§7Du wurdest von §e" + player.getName() + "§7 in das Team §e" + MissileWars.getTeam(player).getColoredName() + "§7 eingeladen.");
|
|
||||||
invitedPlayer.sendMessage("§8/§eaccept §8- §7Zum akzeptieren.");
|
|
||||||
invitedPlayer.sendMessage("§8/§edecline §8- §7Zum ablehnen.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return Bukkit.getOnlinePlayers()
|
|
||||||
.stream()
|
|
||||||
.filter(p -> MissileWars.getTeam(p) != null)
|
|
||||||
.filter(p -> MissileWars.getInvitation(p) != null)
|
|
||||||
.map(Player::getName)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 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.misslewars.commands;
|
|
||||||
|
|
||||||
import de.steamwar.misslewars.Config;
|
|
||||||
import de.steamwar.misslewars.MWTeam;
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class CommandSpectate implements CommandExecutor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (!(sender instanceof Player)) return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (Config.isChallenge()) {
|
|
||||||
player.sendMessage("§cDieser Command ist deaktiviert.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
MWTeam mwTeam = MissileWars.getTeam(player);
|
|
||||||
if (mwTeam == null) return false;
|
|
||||||
if (mwTeam.size() == 1) {
|
|
||||||
player.sendMessage("§cDu bist alleine im Team, zuschauen ist daher nicht möglich.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
MissileWars.leave(player);
|
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
|
||||||
player.getInventory().clear();
|
|
||||||
player.updateInventory();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
65
src/de/steamwar/misslewars/commands/DeclineCommand.java
Normale Datei
65
src/de/steamwar/misslewars/commands/DeclineCommand.java
Normale Datei
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
PsiRobot markierte diese Unterhaltung als gelöst
YoyoNow
hat
s.o. s.o.
|
|||||||
|
|
||||||
|
package de.steamwar.misslewars.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.misslewars.Config;
|
||||||
|
import de.steamwar.misslewars.MWTeam;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DeclineCommand extends SWCommand {
|
||||||
|
|
||||||
|
public DeclineCommand() {
|
||||||
|
super("decline");
|
||||||
PsiRobot markierte diese Unterhaltung als gelöst
YoyoNow
hat
s.o. s.o.
|
|||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void onCommand(@Validator Player player, String... varargs) {
|
||||||
|
MWTeam teamInvitation = MissileWars.getInvitation(player);
|
||||||
|
if (teamInvitation == null) {
|
||||||
|
player.sendMessage("§cDu wurdest nicht eingeladen.");
|
||||||
|
} else {
|
||||||
|
MWTeam.removeInvitations(player);
|
||||||
|
message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 hat die Einladung §cabgelehnt§7.");
|
||||||
PsiRobot markierte diese Unterhaltung als gelöst
YoyoNow
hat
else gehört in die gleiche Zeile mit } else gehört in die gleiche Zeile mit }
|
|||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassValidator(value = Player.class, local = true)
|
||||||
|
public TypeValidator<Player> validator() {
|
||||||
|
return new TypeValidator<Player>() {
|
||||||
|
@Override
|
||||||
|
public boolean validate(CommandSender commandSender, Player player, MessageSender messageSender) {
|
||||||
|
if (!Config.isChallenge()) {
|
||||||
|
messageSender.send("§cDieser Command ist deaktiviert.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void message(MWTeam mwTeam, String s) {
|
||||||
|
mwTeam.getPlayers().forEach(player -> player.sendMessage(s));
|
||||||
|
}
|
||||||
|
}
|
101
src/de/steamwar/misslewars/commands/InviteCommand.java
Normale Datei
101
src/de/steamwar/misslewars/commands/InviteCommand.java
Normale Datei
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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.misslewars.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.PreviousArguments;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.misslewars.Config;
|
||||||
|
import de.steamwar.misslewars.MWTeam;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class InviteCommand extends SWCommand {
|
||||||
|
|
||||||
|
public InviteCommand() {
|
||||||
|
super("invite", "inv");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void onCommand(@Validator Player player, @AllowNull @OptionalValue("") Player invitedPlayer) {
|
||||||
|
MWTeam team = MissileWars.getTeam(player);
|
||||||
|
|
||||||
|
if (!Config.RedLeader.equals(player.getUniqueId()) && !Config.BlueLeader.equals(player.getUniqueId()) || team == null) {
|
||||||
|
player.sendMessage("§cDu kannst keine Spieler einladen.");
|
||||||
|
} else if (invitedPlayer == null) {
|
||||||
|
player.sendMessage("§cDieser Spieler ist nicht online.");
|
||||||
PsiRobot markierte diese Unterhaltung als gelöst
YoyoNow
hat
So nicht. So nicht.
YoyoNow
hat
Ich komme gleich kurz vorbei und erkläre wie du das machst. Ich komme gleich kurz vorbei und erkläre wie du das machst.
|
|||||||
|
} else if (MissileWars.getTeam(invitedPlayer) != null) {
|
||||||
|
player.sendMessage("§cDieser Spieler ist bereits in einem Team.");
|
||||||
|
} else if (MissileWars.getInvitation(invitedPlayer) != null) {
|
||||||
|
player.sendMessage("§cDieser Spieler wurde bereits eingeladen.");
|
||||||
|
} else {
|
||||||
|
team.invitePlayer(invitedPlayer);
|
||||||
|
player.sendMessage("§7Du hast §e" + invitedPlayer.getName() + " §7eingeladen.");
|
||||||
|
invitedPlayer.sendMessage("§7Du wurdest von §e" + player.getName() + "§7 in das Team §e" + MissileWars.getTeam(player).getColoredName() + "§7 eingeladen.");
|
||||||
|
invitedPlayer.sendMessage("§8/§eaccept §8- §7Zum akzeptieren.");
|
||||||
|
invitedPlayer.sendMessage("§8/§edecline §8- §7Zum ablehnen.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassMapper(value = Player.class, local = true)
|
||||||
|
public TypeMapper<Player> typeMapper() {
|
||||||
|
return new TypeMapper<Player>() {
|
||||||
|
@Override
|
||||||
|
public Player map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
|
return Bukkit.getPlayer(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
|
return Bukkit.getOnlinePlayers()
|
||||||
|
.stream()
|
||||||
|
.filter(p -> MissileWars.getTeam(p) != null)
|
||||||
|
.filter(p -> MissileWars.getInvitation(p) != null)
|
||||||
|
.map(Player::getName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassValidator(value = Player.class, local = true)
|
||||||
|
public TypeValidator<Player> validator() {
|
||||||
|
return new TypeValidator<Player>() {
|
||||||
|
@Override
|
||||||
|
public boolean validate(CommandSender commandSender, Player player, MessageSender messageSender) {
|
||||||
|
if (Config.isChallenge()) {
|
||||||
|
messageSender.send("§cDieser Command ist deaktiviert.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void message(MWTeam mwTeam, String s) {
|
||||||
|
mwTeam.getPlayers().forEach(player -> player.sendMessage(s));
|
||||||
|
}
|
||||||
|
}
|
64
src/de/steamwar/misslewars/commands/SpectateCommand.java
Normale Datei
64
src/de/steamwar/misslewars/commands/SpectateCommand.java
Normale Datei
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
PsiRobot markierte diese Unterhaltung als gelöst
YoyoNow
hat
s.o. s.o.
|
|||||||
|
|
||||||
|
package de.steamwar.misslewars.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.misslewars.Config;
|
||||||
|
import de.steamwar.misslewars.MWTeam;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SpectateCommand extends SWCommand {
|
||||||
|
|
||||||
|
public SpectateCommand() {
|
||||||
|
super("spectate", "spec");
|
||||||
PsiRobot markierte diese Unterhaltung als gelöst
YoyoNow
hat
s.o. s.o.
|
|||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void onCommand(@Validator Player player) {
|
||||||
|
MWTeam mwTeam = MissileWars.getTeam(player);
|
||||||
PsiRobot markierte diese Unterhaltung als gelöst
YoyoNow
hat
Auch hier würde ich String... varargs weglassen Auch hier würde ich String... varargs weglassen
|
|||||||
|
if (mwTeam == null) return;
|
||||||
|
if (mwTeam.size() == 1) {
|
||||||
|
player.sendMessage("§cDu bist alleine im Team, zuschauen ist daher nicht möglich.");
|
||||||
|
}
|
||||||
|
MissileWars.leave(player);
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
player.getInventory().clear();
|
||||||
|
player.updateInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassValidator(value = Player.class, local = true)
|
||||||
|
public TypeValidator<Player> validator() {
|
||||||
|
return new TypeValidator<Player>() {
|
||||||
|
@Override
|
||||||
|
public boolean validate(CommandSender commandSender, Player player, MessageSender messageSender) {
|
||||||
|
if (Config.isChallenge()) {
|
||||||
|
messageSender.send("§cDieser Command ist deaktiviert.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren
Why?