progress
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package us.ajg0702.queue.commands.commands;
|
||||
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
|
||||
public class PlayerSender implements ICommandSender {
|
||||
|
||||
final AdaptedPlayer handle;
|
||||
|
||||
public VelocitySender(CommandSource handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getHandle() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package us.ajg0702.queue.commands.commands.manage;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.commands.SubCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ISP extends SubCommand {
|
||||
|
||||
final QueueMain main;
|
||||
public ISP(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "isp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "ajqueue.isp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
sender.sendMessage(Component.text(main.getLogic().isPremium()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,9 @@ public class ManageCommand extends BaseCommand {
|
||||
addSubCommand(new Tasks(main));
|
||||
addSubCommand(new Version(main));
|
||||
addSubCommand(new Pause(main));
|
||||
addSubCommand(new ISP(main));
|
||||
addSubCommand(new QueueList(main));
|
||||
addSubCommand(new Send(main));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package us.ajg0702.queue.commands.commands.manage;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.PatternReplacementResult;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.commands.SubCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class QueueList extends SubCommand {
|
||||
|
||||
final QueueMain main;
|
||||
public QueueList(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "ajqueue.list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
int total = 0;
|
||||
for(QueueServer server : main.getQueueManager().getServers()) {
|
||||
|
||||
Component msg = getMessages().getComponent("list.format",
|
||||
"SERVER:"+server.getName()
|
||||
);
|
||||
Component playerList = Component.empty();
|
||||
List<QueuePlayer> players = server.getQueue();
|
||||
boolean none = true;
|
||||
for(QueuePlayer p : players) {
|
||||
playerList = playerList.append(getMessages().getComponent("list.playerlist",
|
||||
"NAME:" + p.getName()
|
||||
));
|
||||
none = false;
|
||||
}
|
||||
if(none) {
|
||||
playerList = playerList.append(getMessages().getComponent("list.none"));
|
||||
playerList = playerList.append(Component.text(", "));
|
||||
}
|
||||
Component finalPlayerList = playerList;
|
||||
msg = msg.replaceText(b -> b.match(Pattern.compile("\\{LIST}")).replacement(finalPlayerList));
|
||||
char[] commaCountString = PlainTextComponentSerializer.plainText().serialize(msg).toCharArray();
|
||||
int commas = 0;
|
||||
for(Character fChar : commaCountString) {
|
||||
if(fChar == ',') commas++;
|
||||
}
|
||||
|
||||
int finalCommas = commas;
|
||||
msg = msg.replaceText(b -> b.match(",(?!.*,)").replacement("").condition((r, c, re) -> {
|
||||
if(c == finalCommas) {
|
||||
return PatternReplacementResult.REPLACE;
|
||||
}
|
||||
return PatternReplacementResult.CONTINUE;
|
||||
}));
|
||||
total += players.size();
|
||||
msg = msg.replaceText(b -> b.match(Pattern.compile("\\{COUNT}")).replacement(players.size()+""));
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
sender.sendMessage(getMessages().getComponent("list.total", "TOTAL:"+total));
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package us.ajg0702.queue.commands.commands.manage;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
import us.ajg0702.queue.commands.SubCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Send extends SubCommand {
|
||||
|
||||
final QueueMain main;
|
||||
public Send(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "send";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "ajqueue.send";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
|
||||
if(main.getQueueManager().findServer(args[1]) == null) {
|
||||
sender.sendMessage(getMessages().getComponent("errors.server-not-exist", "SERVER:"+args[2]));
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> playerNames = main.getPlatformMethods().getPlayerNames(true);
|
||||
if(playerNames.contains(args[0].toLowerCase())) {
|
||||
|
||||
AdaptedPlayer ply = main.getPlatformMethods().getPlayer(args[0]);
|
||||
if(ply == null) {
|
||||
sender.sendMessage(Component.text("player not found"));
|
||||
return;
|
||||
}
|
||||
if(ply.getName() == null) {
|
||||
sender.sendMessage(Component.text("name null"));
|
||||
}
|
||||
main.getQueueManager().addToQueue(ply, args[1]);
|
||||
sender.sendMessage(getMessages().getComponent("send",
|
||||
"PLAYER:"+ply.getName(),
|
||||
"SERVER:"+args[1])
|
||||
);
|
||||
} else if(main.getQueueManager().getServerNames().contains(args[0])) {
|
||||
|
||||
AdaptedServer from = main.getServerBuilder().getServer(args[0]);
|
||||
if(from == null) {
|
||||
sender.sendMessage(getMessages().getComponent("errors.server-not-exist", "SERVER:"+args[0]));
|
||||
return;
|
||||
}
|
||||
List<AdaptedPlayer> players = new ArrayList<>(from.getPlayers());
|
||||
for(AdaptedPlayer ply : players) {
|
||||
main.getQueueManager().addToQueue(ply, args[1]);
|
||||
}
|
||||
|
||||
sender.sendMessage(getMessages().getComponent("send", "PLAYER:"+args[0], "SERVER:"+args[1]));
|
||||
|
||||
} else {
|
||||
sender.sendMessage(getMessages().getComponent("commands.send.player-not-found"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
if(args.length == 1) {
|
||||
List<String> options = new ArrayList<>(main.getPlatformMethods().getServerNames());
|
||||
options.addAll(main.getPlatformMethods().getPlayerNames(false));
|
||||
return options;
|
||||
}
|
||||
if(args.length == 2) {
|
||||
return main.getQueueManager().getServerNames();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user