Added sendMacro to MacroManager to send macros

This commit is contained in:
Bella 2020-05-04 22:18:02 -04:00
parent 5b30a3d586
commit 1915abbc27
No known key found for this signature in database
GPG Key ID: DBD4A6030080C8B3
1 changed files with 21 additions and 2 deletions

View File

@ -6,8 +6,10 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static me.zeroeightsix.kami.util.Macro.readFileToMemory;
import static me.zeroeightsix.kami.util.Macro.writeMemoryToFile;
import static me.zeroeightsix.kami.command.Command.getCommandPrefix;
import static me.zeroeightsix.kami.util.Macro.*;
import static me.zeroeightsix.kami.util.MessageSendHelper.sendKamiCommand;
import static me.zeroeightsix.kami.util.MessageSendHelper.sendServerMessage;
/**
* @author dominikaaaa
@ -37,4 +39,21 @@ public class MacroManager {
writeMemoryToFile();
KamiMod.log.info("Macros saved");
}
/**
* Sends the message or command, depending on which one it is
* @param keyCode int keycode of the key the was pressed
*/
public static void sendMacro(int keyCode) {
List<String> macrosForThisKey = getMacrosForKey(keyCode);
if (macrosForThisKey == null) return;
for (String currentMacro : macrosForThisKey) {
if (currentMacro.startsWith(getCommandPrefix())) {
sendKamiCommand(currentMacro, false);
} else {
sendServerMessage(currentMacro);
}
}
}
}