forked from SteamWar/SteamWar
Add MissileWars module
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
*
|
||||
* 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.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");
|
||||
}
|
||||
|
||||
@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.");
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendMessage(CommandSender sender, String message, Object[] args) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
private void message(MWTeam mwTeam, String s) {
|
||||
mwTeam.getPlayers().forEach(player -> player.sendMessage(s));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user