clean some open TODO tasks

This commit is contained in:
destro174 2021-08-25 12:41:47 +02:00
parent 728cac3281
commit 2f8a8fc8ff
8 changed files with 7 additions and 144 deletions

View File

@ -31,7 +31,7 @@ public final class Config {
static boolean verbose;
public static File CONFIGPATH;
public static void init() { // todo setup share for the config
public static void init() {
CONFIGPATH = new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "ChatPlugin");
CONFIG_FILE = new File(CONFIGPATH, "config.yml");
configLoader = YAMLConfigurationLoader.builder()
@ -196,8 +196,8 @@ public final class Config {
public static String GCFORMAT = "<white><light_purple><prefix></light_purple> <gray><sender></gray> <hover:show_text:on <server>><yellow>to Global</yellow></hover><gray>: <message>";
public static String GCPERMISSION = "proxy.globalchat";
public static List<String> GCALIAS = new ArrayList<>();
public static String GCNOTENABLED = "You don't have global chat enabled."; // todo mini message formatting
public static String GCONCOOLDOWN = "You have to wait <cooldown> seconds before using this feature again."; // todo mini message formatting
public static String GCNOTENABLED = "You don't have global chat enabled.";
public static String GCONCOOLDOWN = "You have to wait <cooldown> seconds before using this feature again.";
public static int GCCOOLDOWN = 30;
private static void globalChat() {
GCFORMAT = getString("commands.globalchat.format", GCFORMAT);
@ -215,7 +215,6 @@ public final class Config {
PARTY_SPY = getString("party.spy", PARTY_SPY);
}
// TODO prefixes need hovers, this hasn't been setup yet!
public static String CHATFORMAT = "<white><light_purple><prefixall> <gray><hover:show_text:Click to message <sendername>><click:suggest_command:/msg <sendername> ><sender></hover>: <white><message>";
public static String URLFORMAT = "<click:OPEN_URL:<clickurl>><url></click>";
private static void Chat() {

View File

@ -72,7 +72,7 @@ public class ChatHandler {
sendPrivateMessage(player, target, "privatemessage", component);
Component spymessage = miniMessage.parse(Config.MESSAGESPY, templates);
for(Player pl : Bukkit.getOnlinePlayers()) {
if(pl.hasPermission(Config.SPYPERMISSION) && ChatUserManager.getChatUser(pl.getUniqueId()).isSpy() && !pl.equals(player) && !pl.getName().equalsIgnoreCase(target)) { // todo add a toggle for social spy
if(pl.hasPermission(Config.SPYPERMISSION) && ChatUserManager.getChatUser(pl.getUniqueId()).isSpy() && !pl.equals(player) && !pl.getName().equalsIgnoreCase(target)) {
pl.sendMessage(spymessage);
}
}
@ -111,7 +111,7 @@ public class ChatHandler {
}
if(updatedMessage.contains("[i]"))
updatedMessage = updatedMessage.replace("[i]", "<[i]>"); // end of todo
updatedMessage = updatedMessage.replace("[i]", "<[i]>");
updatedMessage = Utility.formatText(updatedMessage);
@ -201,7 +201,7 @@ public class ChatHandler {
Component spyMessage = miniMessage.parse(Config.PARTY_SPY, templates);
for(Player pl : Bukkit.getOnlinePlayers()) {
if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsersUuid().contains(pl.getUniqueId())) { // todo add a toggle for social spy
if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsersUuid().contains(pl.getUniqueId())) {
pl.sendMessage(spyMessage);
}
}

View File

@ -41,11 +41,6 @@ public class ChatListener implements Listener, ChatRenderer {
+ PlainComponentSerializer.plain().serialize(event.message()) + "</red>");
Bukkit.broadcast(blockedNotification, "chat.alert-blocked");
// Bukkit.getOnlinePlayers().forEach(a ->{
// if (a.hasPermission("chat.alert-blocked")) {
// a.sendMessage(blockedNotification);//TODO make configurable (along with all the messages)
// }
// });
return;
}

View File

@ -1,77 +0,0 @@
package com.alttd.chat.commands;
import com.alttd.chat.VelocityChat;
import com.alttd.chat.events.PrivateMessageEvent;
import com.alttd.chat.config.Config;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.CommandMeta;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
public class Message {
/*public Message(ProxyServer proxyServer) {
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
.<CommandSource>literal("message")
.requires(ctx -> ctx.hasPermission("command.proxy.message"))
.then(RequiredArgumentBuilder
.<CommandSource, String>argument("player", StringArgumentType.word())
.suggests((context, builder) -> {
Collection<String> possibleValues = new ArrayList<>();
for (Player player : proxyServer.getAllPlayers()) {
possibleValues.add(player.getGameProfile().getName());
}
if(possibleValues.isEmpty()) return Suggestions.empty();
String remaining = builder.getRemaining().toLowerCase();
for (String str : possibleValues) {
if (str.toLowerCase().startsWith(remaining)) {
builder.suggest(str = StringArgumentType.escapeIfRequired(str));
}
}
return builder.buildFuture();
})
.then(RequiredArgumentBuilder
.<CommandSource, String>argument("message", StringArgumentType.greedyString())
.executes(context -> {
Optional<Player> playerOptional = proxyServer.getPlayer(context.getArgument("player", String.class));
if (playerOptional.isPresent()) {
Player receiver = playerOptional.get();
VelocityChat.getPlugin().getChatHandler().privateMessage(context.getSource(), receiver, context.getArgument("message", String.class));
return 1;
} else {
// TODO wrong player message?
}
return 0;
})
)
.executes(context -> 0)
)
.executes(context -> 0)
.build();
BrigadierCommand brigadierCommand = new BrigadierCommand(command);
CommandMeta.Builder metaBuilder = proxyServer.getCommandManager().metaBuilder(brigadierCommand);
for (String alias : Config.MESSAGECOMMANDALIASES) {
metaBuilder.aliases(alias);
}
CommandMeta meta = metaBuilder.build();
proxyServer.getCommandManager().register(meta, brigadierCommand);
}*/
}

View File

@ -1,44 +0,0 @@
package com.alttd.chat.events;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.proxy.Player;
import java.util.Objects;
public class PrivateMessageEvent implements ResultedEvent<ResultedEvent.GenericResult> {
private final CommandSource sender;
private final Player recipient;
private final String message;
private GenericResult result = GenericResult.allowed(); // Allowed by default
public PrivateMessageEvent(CommandSource sender, Player recipient, String message) {
this.sender = sender;
this.recipient = recipient;
this.message = message;
}
public CommandSource getSender() {
return sender;
}
public Player getRecipient() {
return recipient;
}
public String getMessage() {
return message;
}
@Override
public GenericResult getResult() {
return result;
}
@Override
public void setResult(GenericResult result) {
this.result = Objects.requireNonNull(result);
}
}

View File

@ -2,13 +2,10 @@ package com.alttd.chat.listeners;
import com.alttd.chat.VelocityChat;
import com.alttd.chat.events.GlobalAdminChatEvent;
import com.alttd.chat.events.PrivateMessageEvent;
import com.alttd.chat.config.Config;
import com.alttd.chat.util.Utility;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.PostOrder;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.player.PlayerChatEvent;
import com.velocitypowered.api.proxy.Player;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
@ -24,11 +21,6 @@ public class ChatListener {
plugin = VelocityChat.getPlugin();
}
@Subscribe(order = PostOrder.FIRST)
public void onMessage(PrivateMessageEvent event) {
// TODO check muted, etc
}
@Subscribe(order = PostOrder.FIRST)
public void onGlobalStaffChat(GlobalAdminChatEvent event) {
String senderName = Config.CONSOLENAME;
@ -45,7 +37,6 @@ public class ChatListener {
Map<String, String> map = new HashMap<>();
map.put("sender", senderName);
//map.put("message", event.getMessage());
map.put("message", event.getMessage());
map.put("server", serverName);

View File

@ -48,7 +48,7 @@ public class PluginMessageListener {
case "globaladminchat":
VelocityChat.getPlugin().getChatHandler().globalAdminChat(in.readUTF());
break;
case "privatemessage": // TODO redirect this to the server that player is on
case "privatemessage":
VelocityChat.getPlugin().getChatHandler().privateMessage(in.readUTF(), in.readUTF(), in.readUTF());
break;
case "chatchannel": {

View File

@ -66,7 +66,6 @@ public class ProxyPlayerListener {
Template.of("player", player.getUsername()),
Template.of("from_server", previousServer.getServerInfo().getName()),
Template.of("to_server", event.getServer().getServerInfo().getName())));
// todo Code clean up @Destro
ServerWrapper wrapper = serverHandler.getWrapper(previousServer.getServerInfo().getName());
if(wrapper != null) {
wrapper.sendJoinLeaveMessage(event.getPlayer().getUniqueId(), miniMessage.parse(Config.SERVERSWTICHMESSAGETO, templates));