join anytime #359
@ -137,10 +137,9 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new LeaveCommand();
|
new LeaveCommand();
|
||||||
new KitCommand();
|
new KitCommand();
|
||||||
new RemoveCommand();
|
new RemoveCommand();
|
||||||
new AcceptCommand();
|
new RequestsCommand();
|
||||||
new WGCommand();
|
new WGCommand();
|
||||||
new TBCommand();
|
new TBCommand();
|
||||||
new DeclineCommand();
|
|
||||||
new GamemodeCommand();
|
new GamemodeCommand();
|
||||||
|
|||||||
new ReadyCommand();
|
new ReadyCommand();
|
||||||
new AkCommand();
|
new AkCommand();
|
||||||
|
@ -247,7 +247,18 @@ AMONG_US_IMPOSTER_AMONG_MESSAGE = §4There is an Imposter among us§8! §7Kill h
|
|||||||
|
|
||||||
|
|
||||||
# Invites
|
# Invites
|
||||||
JOIN_REQUEST=§7Request participation
|
JOIN_REQUEST=§7Request join
|
||||||
JOIN_REQUEST_TITLE=Request participation
|
JOIN_REQUEST_TITLE=Request join
|
||||||
JOIN_REQUEST_ALREADY=§cYou have already sent a participation request
|
JOIN_REQUEST_ALREADY=§cYou have already sent a join request
|
||||||
JOIN_REQUEST_TEAM=§eJoin {0}
|
JOIN_REQUEST_TEAM=§eJoin {0}
|
||||||
Chaoscaot
hat
`§7Join §e{0}`?
Lixfel
hat
Colorcode vor dem Parameter macht keinen Sinn, da der gefärbte Teamname eingesetzt wird. Colorcode vor dem Parameter macht keinen Sinn, da der gefärbte Teamname eingesetzt wird.
|
|||||||
|
JOIN_REQUEST_NOTIFICATION=§e{0} §7requests joining team {1}§8. §7Accept or decline using §8/§erequests
|
||||||
|
|
||||||
Chaoscaot
hat
...requests joining your team? ...requests joining your team?
Lixfel
hat
Nein, kann auch das andere Team sein (nach Kampfbeginn) Nein, kann auch das andere Team sein (nach Kampfbeginn)
|
|||||||
|
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!
|
||||||
Lixfel markierte diese Unterhaltung als gelöst
Veraltet
Chaoscaot
hat
Die Keys sollten ziemlich gleich anfangen, um sie namentlich gruppiert zu haben. Die Keys sollten ziemlich gleich anfangen, um sie namentlich gruppiert zu haben.
|
|||||||
|
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_TITLE=Teambeitritt anfragen
|
||||||
JOIN_REQUEST_ALREADY=§cDu hast bereits ein Team um Beitritt angefragt
|
JOIN_REQUEST_ALREADY=§cDu hast bereits ein Team um Beitritt angefragt
|
||||||
JOIN_REQUEST_TEAM={0} §ebeitreten
|
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=§7Offene Beitrittsanfragen
|
||||||
REQUESTS_TITLE=Offene Beitrittsanfragen
|
REQUESTS_TITLE=Offene Beitrittsanfragen
|
||||||
REQUEST_DECLINED=§cBeitritt von {0} abgelehnt
|
REQUEST_DECLINED=§cBeitritt von {0} abgelehnt
|
||||||
YOUR_REQUEST_DECLINED=§cDeine Betrittsanfrage wurde 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_JOIN_REQUEST=§cDer Spieler hat noch keinen Beitritt angefragt
|
||||||
NO_CONFIRMATION=§cKeine Zustimmung nötig
|
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.fight.*;
|
||||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||||
import de.steamwar.inventory.*;
|
import de.steamwar.inventory.*;
|
||||||
import de.steamwar.message.Message;
|
import de.steamwar.message.Message;
|
||||||
import de.steamwar.sql.PersonalKit;
|
import de.steamwar.sql.PersonalKit;
|
||||||
@ -44,9 +45,10 @@ public class GUI {
|
|||||||
|
|
||||||
private static final Message msg = FightSystem.getMessage();
|
private static final Message msg = FightSystem.getMessage();
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) {
|
private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) {
|
||||||
int colorCode = team.getColor().ordinal();
|
byte colorCode = ColorConverter.chat2dye(team.getColor()).getDyeData();
|
||||||
inv.setItem(pos, SWItem.getDye(colorCode), (byte)colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColoredName()), click -> {
|
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColoredName()), click -> {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
new JoinRequest(p, team);
|
new JoinRequest(p, team);
|
||||||
});
|
});
|
||||||
@ -82,10 +84,10 @@ public class GUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void chooseJoinRequests(Player p){
|
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) -> {
|
SWListInv<Player> inv = new SWListInv<>(p, msg.parse("REQUESTS_TITLE", p), players, (ClickType click, Player player) -> {
|
||||||
p.closeInventory();
|
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.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
inv.open();
|
inv.open();
|
||||||
|
@ -26,7 +26,6 @@ import de.steamwar.fightsystem.fight.FightTeam;
|
|||||||
import de.steamwar.fightsystem.fight.JoinRequest;
|
import de.steamwar.fightsystem.fight.JoinRequest;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -34,38 +33,23 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public class AcceptCommand implements CommandExecutor {
|
public class RequestsCommand implements CommandExecutor {
|
||||||
|
|
||||||
public AcceptCommand() {
|
public RequestsCommand() {
|
||||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "accept", this);
|
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "requests", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
onJoinRequest(sender, args, "ACCEPT_USAGE", JoinRequest::accept);
|
if(!(sender instanceof Player))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
public static void onJoinRequest(CommandSender sender, String[] args, String usage, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
|
||||||
if(!(sender instanceof Player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if(Commands.checkGetLeader(player) == null)
|
if(Commands.checkGetLeader(player) == null)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if(args.length == 0) {
|
GUI.chooseJoinRequests(player);
|
||||||
FightSystem.getMessage().send(usage, sender);
|
return false;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
|
||||||
if(target == null) {
|
|
||||||
FightSystem.getMessage().send("UNKNOWN_PLAYER", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
onJoinRequest(player, target, handleJoinRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onJoinRequest(Player player, Player target, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
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.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -33,16 +34,20 @@ public class JoinRequest {
|
|||||||
|
|
||||||
private static final Map<Player, JoinRequest> activeRequests = new HashMap<>();
|
private static final Map<Player, JoinRequest> activeRequests = new HashMap<>();
|
||||||
|
|
||||||
public static List<SWListInv.SWListEntry<Player>> openRequests(FightTeam team) {
|
public static List<SWListInv.SWListEntry<Player>> openRequests(Player p, FightTeam team) {
|
||||||
//TODO set lore
|
return activeRequests.values().stream().filter(
|
||||||
return activeRequests.values().stream().filter(request -> request.waitOnApproval.contains(team)).map(request -> new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(request.player), request.player)).collect(Collectors.toList());
|
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() {
|
public static void clearRequests() {
|
||||||
//TODO notify players
|
|
||||||
activeRequests.forEach((player, joinRequest) -> {
|
|
||||||
|
|
||||||
});
|
|
||||||
activeRequests.clear();
|
activeRequests.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,9 +63,19 @@ public class JoinRequest {
|
|||||||
this.player = player;
|
this.player = player;
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.waitOnApproval = new HashSet<>(FightState.ingame() ? Fight.teams() : Collections.singleton(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) {
|
public boolean required(FightTeam decider) {
|
||||||
|
@ -12,8 +12,7 @@ api-version: "1.13"
|
|||||||
|
|
||||||
commands:
|
commands:
|
||||||
ak:
|
ak:
|
||||||
accept:
|
requests:
|
||||||
Chaoscaot
hat
Die sind doch mit dem CommandFramework garnicht nötig? Die sind doch mit dem CommandFramework garnicht nötig?
Lixfel
hat
Das FightSystem nutzt das CommandFramework aufgrund der komplexeren (De-)Aktivierungs- und Initialisierungsbedingungen nicht. Das FightSystem nutzt das CommandFramework aufgrund der komplexeren (De-)Aktivierungs- und Initialisierungsbedingungen nicht.
|
|||||||
decline:
|
|
||||||
leave:
|
leave:
|
||||||
ready:
|
ready:
|
||||||
kit:
|
kit:
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Warum wird das ganze Invite System entfernt?
Finde, es hat immer noch seinen nutzen und sollte parallel zu den Requests bestehen.
Das Invite-System wurde entfernt, da es nochmal deutlich aufwändiger ist, beide Varianten zu unterstützen.
Die genannten Beispiele halte ich für ungeeignet, da eh meistens die Spieler erstmal mit "inv" um Beitritt betteln müssen (was sie jetzt direkt anfragen können). Auch bei Massenfights ändert sich kaum etwas, außer, dass Zuschauer nicht mehr ständig Beitrittsanfragen ablehnen müssen. Massenannahmen sollten vonseiten des Leaders aus problemlos möglich sein.