refactor some bits

This commit is contained in:
len
2021-05-12 10:43:30 +02:00
parent 21a15c3817
commit b8ff6a1fb4
9 changed files with 94 additions and 256 deletions
@@ -1,6 +1,6 @@
package com.alttd.chat.commands;
import com.alttd.chat.api.GlobalStaffChatEvent;
import com.alttd.chat.api.GlobalAdminChatEvent;
import com.alttd.chat.config.Config;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@@ -20,7 +20,7 @@ public class GlobalAdminChat {
.then(RequiredArgumentBuilder
.<CommandSource, String>argument("message", StringArgumentType.greedyString())
.executes(context -> {
proxyServer.getEventManager().fire(new GlobalStaffChatEvent(context.getSource(), context.getArgument("message", String.class)));
proxyServer.getEventManager().fire(new GlobalAdminChatEvent(context.getSource(), context.getArgument("message", String.class)));
return 1;
}) // TODO call in the same way as gc?
)
@@ -13,6 +13,7 @@ import com.velocitypowered.api.proxy.ProxyServer;
public class GlobalChat {
// todo move to server implementation and send plugin event to allowed servers, this means we can implement [i] in here
public GlobalChat(ProxyServer proxyServer) {
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
.<CommandSource>literal("globalchat")
@@ -1,6 +1,7 @@
package com.alttd.chat.commands;
import com.alttd.chat.api.MessageEvent;
import com.alttd.chat.ChatPlugin;
import com.alttd.chat.api.PrivateMessageEvent;
import com.alttd.chat.config.Config;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@@ -9,6 +10,7 @@ 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;
@@ -35,8 +37,13 @@ public class Message {
if (playerOptional.isPresent()) {
Player receiver = playerOptional.get();
proxyServer.getEventManager().fire(new MessageEvent(context.getSource(), receiver, context.getArgument("message", String.class)));
proxyServer.getEventManager().fire(new PrivateMessageEvent(context.getSource(), receiver, context.getArgument("message", String.class))).thenAccept((event) -> {
if(event.getResult() == ResultedEvent.GenericResult.allowed()) {
ChatPlugin.getPlugin().getChatHandler().privateMessage(event);
}
// event has finished firing
// do some logic dependent on the result
});
return 1;
} else {
// TODO NOBODY TO REPLY TO