content: package myau.command;
  
  import myau.Myau;
  import myau.event.EventTarget;
  import myau.event.types.EventType;
  import myau.event.types.Priority;
  import myau.events.PacketEvent;
  import myau.util.ChatUtil;
  import net.minecraft.network.play.client.C01PacketChatMessage;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  
  public class CommandManager {
      public ArrayList<Command> commands;
  
      public CommandManager() {
          this.commands = new ArrayList<>();
      }
  
      public void handleCommand(String string) {
          List<String> params = Arrays.asList(string.substring(1).trim().split("\\s+"));
          ArrayList<String> arrayList = new ArrayList<>(params);
          if (params.get(0).isEmpty()) {
              ChatUtil.sendFormatted(String.format("%sUnknown command&r", Myau.clientName).replace("&", "§"));
          } else {
              for (Command command : Myau.commandManager.commands) {
                  for (String name : command.names) {
                      if (params.get(0).equalsIgnoreCase(name)) {
                          command.runCommand(arrayList);
                          return;
                      }
                  }
              }
              ChatUtil.sendFormatted(String.format("%sUnknown command (&o%s&r)&r", Myau.clientName, params.get(0)).replace("&", "§"));
          }
      }
  
      public boolean isTypingCommand(String string) {
          if (string == null || string.length() < 2) {
              return false;
          } else {
              return string.charAt(0) == '.' && Character.isLetterOrDigit(string.charAt(1));
          }
      }
  
      @EventTarget(Priority.HIGHEST)
      public void onPacket(PacketEvent event) {
          if (event.getType() == EventType.SEND && event.getPacket() instanceof C01PacketChatMessage) {
              String msg = ((C01PacketChatMessage) event.getPacket()).getMessage();
              if (this.isTypingCommand(msg)) {
                  event.setCancelled(true);
                  this.handleCommand(msg);
              }
          }
      }
  }
  