Bugfixes, Simplify UX to requests-Command
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
0020b2b152
Commit
98a376a62b
@ -137,10 +137,9 @@ public class FightSystem extends JavaPlugin {
|
||||
new LeaveCommand();
|
||||
new KitCommand();
|
||||
new RemoveCommand();
|
||||
new AcceptCommand();
|
||||
new RequestsCommand();
|
||||
new WGCommand();
|
||||
new TBCommand();
|
||||
new DeclineCommand();
|
||||
new GamemodeCommand();
|
||||
new ReadyCommand();
|
||||
new AkCommand();
|
||||
|
@ -247,7 +247,18 @@ AMONG_US_IMPOSTER_AMONG_MESSAGE = §4There is an Imposter among us§8! §7Kill h
|
||||
|
||||
|
||||
# Invites
|
||||
JOIN_REQUEST=§7Request participation
|
||||
JOIN_REQUEST_TITLE=Request participation
|
||||
JOIN_REQUEST_ALREADY=§cYou have already sent a participation request
|
||||
JOIN_REQUEST=§7Request join
|
||||
JOIN_REQUEST_TITLE=Request join
|
||||
JOIN_REQUEST_ALREADY=§cYou have already sent a join request
|
||||
JOIN_REQUEST_TEAM=§eJoin {0}
|
||||
JOIN_REQUEST_NOTIFICATION=§e{0} §7requests joining team {1}§8. §7Accept or decline using §8/§erequests
|
||||
|
||||
REQUESTS=§7Open join requests
|
||||
REQUESTS_TITLE=Open join requests
|
||||
REQUEST_DECLINED=§cJoin of {0} declined
|
||||
YOUR_REQUEST_DECLINED=§cYour join request was declined
|
||||
REQUESTS_LEFT_CLICK=§eLeft click §7to §eaccept§8!
|
||||
REQUESTS_RIGHT_CLICK=§eRight click §7to §edecline§8!
|
||||
|
||||
NO_JOIN_REQUEST=§cThe player did not request joining
|
||||
NO_CONFIRMATION=§cNo confirmation necessary
|
@ -235,14 +235,14 @@ JOIN_REQUEST=§7Teambeitritt anfragen
|
||||
JOIN_REQUEST_TITLE=Teambeitritt anfragen
|
||||
JOIN_REQUEST_ALREADY=§cDu hast bereits ein Team um Beitritt angefragt
|
||||
JOIN_REQUEST_TEAM={0} §ebeitreten
|
||||
JOIN_REQUEST_NOTIFICATION=§e{0} §7möchte Team {1} §7beitreten§8. §7Akzeptiere oder lehne ab mit §8/§erequests
|
||||
|
||||
REQUESTS=§7Offene Beitrittsanfragen
|
||||
REQUESTS_TITLE=Offene Beitrittsanfragen
|
||||
REQUEST_DECLINED=§cBeitritt von {0} abgelehnt
|
||||
YOUR_REQUEST_DECLINED=§cDeine Betrittsanfrage wurde abgelehnt
|
||||
REQUESTS_LEFT_CLICK=§eLinksklick §7um §eanzunehmen§8!
|
||||
REQUESTS_RIGHT_CLICK=§eRechtsklick §7um §eabzulehnen§8!
|
||||
|
||||
UNKNOWN_PLAYER=§cUnbekannter Spieler
|
||||
NO_JOIN_REQUEST=§cDer Spieler hat noch keinen Beitritt angefragt
|
||||
NO_CONFIRMATION=§cKeine Zustimmung nötig
|
||||
ACCEPT_USAGE=§8/§7accept §8[§eSpieler§8]
|
||||
DECLINE_USAGE=§8/§7decline §8[§eSpieler§8]
|
||||
|
@ -1,41 +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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.JoinRequest;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class DeclineCommand implements CommandExecutor {
|
||||
|
||||
public DeclineCommand() {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "decline", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
AcceptCommand.onJoinRequest(sender, args, "DECLINE_USAGE", JoinRequest::decline);
|
||||
return false;
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.*;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.inventory.*;
|
||||
import de.steamwar.message.Message;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
@ -44,9 +45,10 @@ public class GUI {
|
||||
|
||||
private static final Message msg = FightSystem.getMessage();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) {
|
||||
int colorCode = team.getColor().ordinal();
|
||||
inv.setItem(pos, SWItem.getDye(colorCode), (byte)colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColoredName()), click -> {
|
||||
byte colorCode = ColorConverter.chat2dye(team.getColor()).getDyeData();
|
||||
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColoredName()), click -> {
|
||||
p.closeInventory();
|
||||
new JoinRequest(p, team);
|
||||
});
|
||||
@ -82,10 +84,10 @@ public class GUI {
|
||||
}
|
||||
|
||||
public static void chooseJoinRequests(Player p){
|
||||
List<SWListInv.SWListEntry<Player>> players = JoinRequest.openRequests(Fight.getPlayerTeam(p));
|
||||
List<SWListInv.SWListEntry<Player>> players = JoinRequest.openRequests(p, Fight.getPlayerTeam(p));
|
||||
SWListInv<Player> inv = new SWListInv<>(p, msg.parse("REQUESTS_TITLE", p), players, (ClickType click, Player player) -> {
|
||||
p.closeInventory();
|
||||
AcceptCommand.onJoinRequest(p, player, click.isLeftClick() ? JoinRequest::accept : JoinRequest::decline);
|
||||
RequestsCommand.onJoinRequest(p, player, click.isLeftClick() ? JoinRequest::accept : JoinRequest::decline);
|
||||
});
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
|
@ -26,7 +26,6 @@ import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.JoinRequest;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -34,38 +33,23 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class AcceptCommand implements CommandExecutor {
|
||||
public class RequestsCommand implements CommandExecutor {
|
||||
|
||||
public AcceptCommand() {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "accept", this);
|
||||
public RequestsCommand() {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "requests", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
onJoinRequest(sender, args, "ACCEPT_USAGE", JoinRequest::accept);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onJoinRequest(CommandSender sender, String[] args, String usage, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(Commands.checkGetLeader(player) == null)
|
||||
return;
|
||||
return false;
|
||||
|
||||
if(args.length == 0) {
|
||||
FightSystem.getMessage().send(usage, sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
FightSystem.getMessage().send("UNKNOWN_PLAYER", player);
|
||||
return;
|
||||
}
|
||||
|
||||
onJoinRequest(player, target, handleJoinRequest);
|
||||
GUI.chooseJoinRequests(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onJoinRequest(Player player, Player target, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
@ -24,6 +24,7 @@ import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
@ -33,16 +34,20 @@ public class JoinRequest {
|
||||
|
||||
private static final Map<Player, JoinRequest> activeRequests = new HashMap<>();
|
||||
|
||||
public static List<SWListInv.SWListEntry<Player>> openRequests(FightTeam team) {
|
||||
//TODO set lore
|
||||
return activeRequests.values().stream().filter(request -> request.waitOnApproval.contains(team)).map(request -> new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(request.player), request.player)).collect(Collectors.toList());
|
||||
public static List<SWListInv.SWListEntry<Player>> openRequests(Player p, FightTeam team) {
|
||||
return activeRequests.values().stream().filter(
|
||||
request -> request.waitOnApproval.contains(team)
|
||||
).map(request -> {
|
||||
SWItem item = SWItem.getPlayerSkull(request.player);
|
||||
item.setLore(Arrays.asList(
|
||||
FightSystem.getMessage().parse("REQUESTS_LEFT_CLICK", p),
|
||||
FightSystem.getMessage().parse("REQUESTS_RIGHT_CLICK", p)
|
||||
));
|
||||
return new SWListInv.SWListEntry<>(item, request.player);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void clearRequests() {
|
||||
//TODO notify players
|
||||
activeRequests.forEach((player, joinRequest) -> {
|
||||
|
||||
});
|
||||
activeRequests.clear();
|
||||
}
|
||||
|
||||
@ -58,9 +63,19 @@ public class JoinRequest {
|
||||
this.player = player;
|
||||
this.team = team;
|
||||
this.waitOnApproval = new HashSet<>(FightState.ingame() ? Fight.teams() : Collections.singleton(team));
|
||||
//TODO send request out
|
||||
for(FightTeam t : waitOnApproval) {
|
||||
FightPlayer leader = t.getLeader();
|
||||
if(leader == null)
|
||||
continue;
|
||||
|
||||
activeRequests.put(player, new JoinRequest(player, team));
|
||||
Player leaderPlayer = leader.getPlayer();
|
||||
if(leaderPlayer == null)
|
||||
continue;
|
||||
|
||||
FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), player.getName(), team.getColoredName());
|
||||
}
|
||||
|
||||
activeRequests.put(player, this);
|
||||
}
|
||||
|
||||
public boolean required(FightTeam decider) {
|
||||
|
@ -12,8 +12,7 @@ api-version: "1.13"
|
||||
|
||||
commands:
|
||||
ak:
|
||||
accept:
|
||||
decline:
|
||||
requests:
|
||||
leave:
|
||||
ready:
|
||||
kit:
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren