Commit reply/continue rework
This commit is contained in:
parent
0a6dfe799e
commit
29dd5d2d55
|
|
@ -21,6 +21,7 @@ public class ChatUser {
|
|||
// private Component prefixAll; // doesn't need saving, we get this from luckperms
|
||||
//private boolean toggleGc; // should be saved, this toggles if the player can see and use global chat
|
||||
private String replyTarget; // reply target for use in /msg i don't mind setting this to null on login, feedback?
|
||||
private String replyContinueTarget; // reply target for use in /c
|
||||
private long gcCooldown; // the time when they last used gc, is used for the cooldown, i wouldn't save this, but setting this to the login time means they can't use gc for 30 seconds after logging in
|
||||
private boolean spy;
|
||||
private List<Mail> mails; // mails aren't finalized yet, so for now a table sender, reciever, sendtime, readtime(if emtpy mail isn't read yet?, could also do a byte to control this), the actual message
|
||||
|
|
@ -45,6 +46,7 @@ public class ChatUser {
|
|||
// prefixAll = Utility.getPrefix(uuid, false);
|
||||
|
||||
replyTarget = null;
|
||||
replyContinueTarget = null;
|
||||
gcCooldown = System.currentTimeMillis(); // players can't use gc for 30 seconds after logging in if we use this?
|
||||
mails = Queries.getMails(uuid);
|
||||
ignoredPlayers = Queries.getIgnoredUsers(uuid);
|
||||
|
|
@ -101,10 +103,18 @@ public class ChatUser {
|
|||
return replyTarget;
|
||||
}
|
||||
|
||||
public String getReplyContinueTarget() {
|
||||
return replyTarget;
|
||||
}
|
||||
|
||||
public void setReplyTarget(String replyTarget) {
|
||||
this.replyTarget = replyTarget;
|
||||
}
|
||||
|
||||
public void setReplyContinueTarget(String replyTarget) {
|
||||
this.replyContinueTarget = replyTarget;
|
||||
}
|
||||
|
||||
public List<Mail> getMails() {
|
||||
return mails;
|
||||
}
|
||||
|
|
|
|||
27
galaxy/src/main/java/com/alttd/chat/commands/Continue.java
Normal file
27
galaxy/src/main/java/com/alttd/chat/commands/Continue.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package com.alttd.chat.commands;
|
||||
|
||||
import com.alttd.chat.ChatPlugin;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Continue implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player player)) {
|
||||
return true;
|
||||
}
|
||||
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
if (user.getReplyContinueTarget() == null) return false;
|
||||
if(args.length == 0) return false; // todo error message or command info
|
||||
|
||||
String message = StringUtils.join(args, " ", 0, args.length);
|
||||
ChatPlugin.getInstance().getChatHandler().continuePrivateMessage(player, user.getReplyContinueTarget(), message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.alttd.chat.commands;
|
||||
|
||||
import com.alttd.chat.ChatPlugin;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
|
@ -11,10 +13,11 @@ public class Message implements CommandExecutor {
|
|||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
if(!(sender instanceof Player player)) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
user.setReplyContinueTarget(args[0]);
|
||||
if(args.length < 2) return false; // todo error message or command info
|
||||
|
||||
String message = StringUtils.join(args, " ", 1, args.length);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,49 @@ public class ChatHandler {
|
|||
GCNOTENABLED = Utility.parseMiniMessage(Config.GCNOTENABLED);
|
||||
}
|
||||
|
||||
public void continuePrivateMessage(Player player, String target, String message) {
|
||||
// ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
// user.setReplyTarget(target);
|
||||
ModifiableString modifiableString = new ModifiableString(message);
|
||||
// todo a better way for this
|
||||
if(!RegexManager.filterText(player.getName(), player.getUniqueId(), modifiableString, "privatemessage")) {
|
||||
GalaxyUtility.sendBlockedNotification("DM Language",
|
||||
player,
|
||||
Utility.parseMiniMessage(Utility.parseColors(modifiableString.string())),
|
||||
target);
|
||||
return; // the message was blocked
|
||||
}
|
||||
String updatedMessage = modifiableString.string();
|
||||
|
||||
if(!player.hasPermission("chat.format")) {
|
||||
updatedMessage = Utility.stripTokens(updatedMessage);
|
||||
} else {
|
||||
updatedMessage = Utility.parseColors(updatedMessage);
|
||||
}
|
||||
|
||||
if(updatedMessage.contains("[i]"))
|
||||
updatedMessage = updatedMessage.replace("[i]", "<[i]>");
|
||||
|
||||
updatedMessage = Utility.formatText(updatedMessage);
|
||||
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.parsed("message", updatedMessage),
|
||||
Placeholder.component("sendername", player.name()),
|
||||
Placeholder.parsed("receivername", target),
|
||||
Placeholder.component("[i]", itemComponent(player.getInventory().getItemInMainHand()))
|
||||
);
|
||||
|
||||
Component component = Utility.parseMiniMessage("<message>", placeholders);
|
||||
|
||||
sendPrivateMessage(player, target, "privatemessage", component);
|
||||
Component spymessage = Utility.parseMiniMessage(Config.MESSAGESPY, placeholders);
|
||||
for(Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if(pl.hasPermission(Config.SPYPERMISSION) && ChatUserManager.getChatUser(pl.getUniqueId()).isSpy() && !pl.equals(player) && !pl.getName().equalsIgnoreCase(target)) {
|
||||
pl.sendMessage(spymessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void privateMessage(Player player, String target, String message) {
|
||||
// ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
// user.setReplyTarget(target);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ public class PluginMessage implements PluginMessageListener {
|
|||
p.sendMessage(GsonComponentSerializer.gson().deserialize(message));
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1); // todo load this from config
|
||||
ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||
user.setReplyTarget(target);
|
||||
if (!user.getReplyContinueTarget().equalsIgnoreCase(target))
|
||||
user.setReplyTarget(target);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -62,8 +63,8 @@ public class PluginMessage implements PluginMessageListener {
|
|||
ChatUser chatUser = ChatUserManager.getChatUser(uuid);
|
||||
if (!chatUser.getIgnoredPlayers().contains(targetuuid)) {
|
||||
p.sendMessage(GsonComponentSerializer.gson().deserialize(message));
|
||||
ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||
user.setReplyTarget(target);
|
||||
// ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||
// user.setReplyTarget(target);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ commands:
|
|||
reply:
|
||||
permission: command.chat.message
|
||||
aliases: r
|
||||
continue:
|
||||
permission: command.chat.message
|
||||
aliases: c
|
||||
ignore:
|
||||
permission: command.chat.ignore
|
||||
unignore:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user