Commit reply/continue rework

This commit is contained in:
destro174
2022-04-21 15:45:50 +02:00
parent 0a6dfe799e
commit 29dd5d2d55
6 changed files with 92 additions and 5 deletions
@@ -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);