clean some open TODO tasks
This commit is contained in:
@@ -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);
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user