Better Chat Color Utility Handling for Commands

This commit is contained in:
Kam committed 2025-02-18 16:11:58 -05:00
1 parent 3cac4e764f
commit eb899061bf
24 files changed
+202 -26

No files matched your search

@@ -9,6 +9,9 @@ import noppes.npcs.controllers.data.PlayerData;
import java.util.List;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class AnimationCommand extends CommandKamkeelBase {
@Override
@@ -17,6 +17,8 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
import static kamkeel.npcs.util.ColorUtil.*;
public class CloneCommand extends CommandKamkeelBase {
@Override
@@ -10,6 +10,9 @@ import noppes.npcs.api.IWorld;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.CustomNPCsEvent;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendMessage;
public class CommandCommand extends CommandKamkeelBase {
@Override
@@ -55,18 +55,6 @@ public abstract class CommandKamkeelBase extends CommandBase{
return !subcommands.isEmpty();
}
protected static void sendMessage(ICommandSender sender, String message, Object... obs) {
sender.addChatMessage(new ChatComponentTranslation(message, obs));
}
protected static void sendResult(ICommandSender sender, String message, Object... obs) {
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A77 " + message, obs));
}
protected static void sendError(ICommandSender sender, String message, Object... obs) {
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A74 Error:\u00A7c " + message, obs));
}
@Retention(value = RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface SubCommand {
@@ -20,6 +20,9 @@ import noppes.npcs.controllers.PlayerDataController;
import java.util.Arrays;
import java.util.Set;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class ConfigCommand extends CommandKamkeelBase {
@@ -11,6 +11,9 @@ import noppes.npcs.controllers.data.PlayerData;
import java.util.Collection;
import java.util.List;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class DialogCategoryCommand extends CommandKamkeelBase {
@Override
@@ -20,6 +20,9 @@ import noppes.npcs.entity.EntityDialogNpc;
import java.util.Collection;
import java.util.List;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class DialogCommand extends CommandKamkeelBase {
@Override
@@ -13,6 +13,9 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class EffectCommand extends CommandKamkeelBase {
@Override
@@ -26,7 +29,7 @@ public class EffectCommand extends CommandKamkeelBase {
}
@SubCommand(desc = "Lists all Effects")
public void infoAll(ICommandSender sender, String[] args) throws CommandException {
public void list(ICommandSender sender, String[] args) throws CommandException {
CustomEffectController controller = CustomEffectController.getInstance();
if (controller.indexMapper.isEmpty()) {
sendError(sender, "No effects found.");
@@ -11,6 +11,9 @@ import noppes.npcs.controllers.data.PlayerFactionData;
import java.util.Arrays;
import java.util.List;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class FactionCommand extends CommandKamkeelBase {
public Faction selectedFaction;
@@ -7,6 +7,9 @@ import net.minecraft.util.ChatComponentTranslation;
import java.lang.reflect.Method;
import java.util.Map.Entry;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendMessage;
public class HelpCommand extends CommandKamkeelBase{
private CommandKamkeel parent;
@@ -22,6 +22,9 @@ import org.apache.commons.lang3.ArrayUtils;
import java.util.Arrays;
import java.util.List;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class NpcCommand extends CommandKamkeelBase {
public EntityNPCInterface selectedNpc;
@@ -9,6 +9,9 @@ import noppes.npcs.controllers.data.SkinOverlay;
import java.util.List;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class OverlayCommand extends CommandKamkeelBase {
@Override
@@ -16,6 +16,9 @@ import noppes.npcs.controllers.data.QuestData;
import java.util.Collection;
import java.util.List;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class QuestCategoryCommand extends CommandKamkeelBase {
@Override
@@ -21,6 +21,9 @@ import noppes.npcs.util.ValueUtil;
import java.util.Collection;
import java.util.List;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class QuestCommand extends CommandKamkeelBase {
@Override
@@ -3,6 +3,9 @@ package kamkeel.npcs.command;
import net.minecraft.command.ICommandSender;
import noppes.npcs.controllers.ScriptController;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class ScriptCommand extends CommandKamkeelBase {
@@ -20,6 +20,8 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.*;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class SlayCommand extends CommandKamkeelBase {
public Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
@@ -7,6 +7,9 @@ import net.minecraft.util.ChatComponentTranslation;
import java.lang.reflect.Method;
import java.util.Map.Entry;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendMessage;
public class CommandHelpProfile extends CommandProfileBase {
private CommandProfile parent;
@@ -12,6 +12,8 @@ import net.minecraft.nbt.NBTTagCompound;
import java.util.Map;
import java.util.UUID;
import static kamkeel.npcs.util.ColorUtil.*;
public class CommandProfileAdmin extends CommandProfileBase {
@Override
@@ -4,7 +4,10 @@ import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import noppes.npcs.CustomNpcsPermissions;
import java.lang.annotation.ElementType;
@@ -16,6 +19,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public abstract class CommandProfileBase extends CommandBase{
public Map<String, Method> subcommands = new HashMap<String, Method>();
@@ -55,19 +60,7 @@ public abstract class CommandProfileBase extends CommandBase{
return !subcommands.isEmpty();
}
protected static void sendMessage(ICommandSender sender, String message, Object... obs) {
sender.addChatMessage(new ChatComponentTranslation(message, obs));
}
protected static void sendResult(ICommandSender sender, String message, Object... obs) {
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A77 " + message, obs));
}
protected static void sendError(ICommandSender sender, String message, Object... obs) {
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A74 Error:\u00A7c " + message, obs));
}
@Retention(value = RetentionPolicy.RUNTIME)
@Retention(value = RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface SubCommand {
@@ -6,6 +6,9 @@ import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class CommandProfileChange extends CommandProfileBase {
@Override
@@ -9,6 +9,9 @@ import net.minecraft.entity.player.EntityPlayer;
import java.util.Map;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendMessage;
public class CommandProfileList extends CommandProfileBase {
@Override
@@ -6,6 +6,9 @@ import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class CommandProfileRemove extends CommandProfileBase {
@Override
@@ -7,6 +7,9 @@ import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import static kamkeel.npcs.util.ColorUtil.sendError;
import static kamkeel.npcs.util.ColorUtil.sendResult;
public class CommandProfileRename extends CommandProfileBase {
@Override