aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCow <cow@volloeko.de>2020-08-06 18:01:42 +0200
committerCow <cow@volloeko.de>2020-08-06 18:01:42 +0200
commitba4dc3a0cbb58152c1fbdfe58224cb65685acc55 (patch)
tree7b516e171223640172b9e6b77de67f1bbb52cf9b
parent2346e0ead0722f5fa9ce6e5bfda15ce927e3529a (diff)
downloadCowlection-ba4dc3a0cbb58152c1fbdfe58224cb65685acc55.tar.gz
Cowlection-ba4dc3a0cbb58152c1fbdfe58224cb65685acc55.tar.bz2
Cowlection-ba4dc3a0cbb58152c1fbdfe58224cb65685acc55.zip
Conflicts resolving
- Added keybinding to open chat with `/moo ` pre-typed - New sub-command: `/m cmd` to fix command conflicts with server-side commands with the same name `/m` - Added `/<command with tab-completable username> say` (similar to `/moo say`)
-rw-r--r--CHANGELOG.md8
-rw-r--r--src/main/java/de/cowtipper/cowlection/Cowlection.java11
-rw-r--r--src/main/java/de/cowtipper/cowlection/command/MooCommand.java11
-rw-r--r--src/main/java/de/cowtipper/cowlection/command/TabCompletableCommand.java14
-rw-r--r--src/main/java/de/cowtipper/cowlection/listener/PlayerListener.java16
-rw-r--r--src/main/resources/assets/cowlection/lang/en_US.lang2
6 files changed, 59 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14bf418..b69c260 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
+## [1.8.9-xxx] - unreleased
+### Added
+- Added keybinding (default `M`) to open chat with `/moo ` pre-typed
+- New sub-command: `/m cmd [arguments]` to fix command conflicts with server-side commands with the same name `/m`
+ - e.g. `/m cmd hello world` executes the server command `/m hello world`
+- Added `/<command with tab-completable username> say [optional text]`: You can e.g. say `f` again without triggering the server-side command `/f` by typing `/f say`
+
## [1.8.9-0.10.1] - 06.08.2020
### Added
- Dungeon performance tracker: added Class Milestones
@@ -184,6 +191,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
*Note:* The 'best friends' list is currently available via <kbd>ESC</kbd> > Mod Options > Cowlection > Config > bestFriends.
+[1.8.9-xxx]: https://github.com/cow-mc/Cowlection/compare/v1.8.9-0.10.1...master
[1.8.9-0.10.1]: https://github.com/cow-mc/Cowlection/compare/v1.8.9-0.10.0...v1.8.9-0.10.1
[1.8.9-0.10.0]: https://github.com/cow-mc/Cowlection/compare/v1.8.9-0.9.0...v1.8.9-0.10.0
[1.8.9-0.9.0]: https://github.com/cow-mc/Cowlection/compare/v1.8.9-0.8.1...v1.8.9-0.9.0
diff --git a/src/main/java/de/cowtipper/cowlection/Cowlection.java b/src/main/java/de/cowtipper/cowlection/Cowlection.java
index de92ab9..50df539 100644
--- a/src/main/java/de/cowtipper/cowlection/Cowlection.java
+++ b/src/main/java/de/cowtipper/cowlection/Cowlection.java
@@ -12,15 +12,18 @@ import de.cowtipper.cowlection.listener.ChatListener;
import de.cowtipper.cowlection.listener.PlayerListener;
import de.cowtipper.cowlection.util.ChatHelper;
import de.cowtipper.cowlection.util.VersionChecker;
+import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
+import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;
+import org.lwjgl.input.Keyboard;
import java.io.File;
@@ -33,6 +36,7 @@ public class Cowlection {
public static final String VERSION = "@VERSION@";
public static final String MODNAME = "@MODNAME@";
public static final String GITURL = "@GITURL@";
+ public static KeyBinding[] keyBindings;
private static Cowlection instance;
private File configDir;
private File modsDir;
@@ -71,6 +75,13 @@ public class Cowlection {
for (String tabCompletableNamesCommand : MooConfig.tabCompletableNamesCommands) {
ClientCommandHandler.instance.registerCommand(new TabCompletableCommand(this, tabCompletableNamesCommand));
}
+ // key bindings
+ keyBindings = new KeyBinding[1];
+ keyBindings[0] = new KeyBinding("key.cowlection.moo.desc", Keyboard.KEY_M, "key.cowlection.category");
+
+ for (KeyBinding keyBinding : keyBindings) {
+ ClientRegistry.registerKeyBinding(keyBinding);
+ }
}
@EventHandler
diff --git a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java
index 0c784eb..6be1a6c 100644
--- a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java
+++ b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java
@@ -140,9 +140,18 @@ public class MooCommand extends CommandBase {
else if (args[0].equalsIgnoreCase("help")) {
sendCommandUsage(sender);
}
+ // fix: run server-side command /m with optional arguments
+ else if (args[0].equalsIgnoreCase("cmd") || args[0].equalsIgnoreCase("command")) {
+ String cmdArgs = CommandBase.buildString(args, 1);
+ if (cmdArgs.length() > 0) {
+ cmdArgs = " " + cmdArgs;
+ }
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/m" + cmdArgs);
+ }
// "catch-all" remaining sub-commands
else {
- main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Command " + EnumChatFormatting.DARK_RED + "/" + getCommandName() + " " + args[0] + EnumChatFormatting.RED + " doesn't exist. Use " + EnumChatFormatting.DARK_RED + "/" + getCommandName() + " help " + EnumChatFormatting.RED + "to show command usage.");
+ main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Command " + EnumChatFormatting.DARK_RED + "/" + getCommandName() + " " + args[0] + EnumChatFormatting.RED + " doesn't exist. Use " + EnumChatFormatting.DARK_RED + "/" + getCommandName() + " help " + EnumChatFormatting.RED + "to show command usage.\n"
+ + EnumChatFormatting.RED + "Are you trying to use a server-side command " + EnumChatFormatting.DARK_RED + "/m" + EnumChatFormatting.RED + "? Use " + EnumChatFormatting.DARK_RED + "/m cmd [arguments] " + EnumChatFormatting.RED + "instead.");
}
}
diff --git a/src/main/java/de/cowtipper/cowlection/command/TabCompletableCommand.java b/src/main/java/de/cowtipper/cowlection/command/TabCompletableCommand.java
index 5edabe8..b873714 100644
--- a/src/main/java/de/cowtipper/cowlection/command/TabCompletableCommand.java
+++ b/src/main/java/de/cowtipper/cowlection/command/TabCompletableCommand.java
@@ -33,8 +33,18 @@ public class TabCompletableCommand extends CommandBase {
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
- // send client-command to server
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + getCommandName() + " " + CommandBase.buildString(args, 0));
+ String prefix;
+ String arguments;
+ if (args.length >= 1 && args[0].equalsIgnoreCase("say")) {
+ // work-around so you can still say '[commandName]' in chat without triggering the server-side command
+ prefix = "";
+ arguments = CommandBase.buildString(args, 1);
+ } else {
+ // send client-command to server
+ prefix = "/";
+ arguments = CommandBase.buildString(args, 0);
+ }
+ Minecraft.getMinecraft().thePlayer.sendChatMessage(prefix + getCommandName() + (!arguments.isEmpty() ? " " + arguments : ""));
}
@Override
diff --git a/src/main/java/de/cowtipper/cowlection/listener/PlayerListener.java b/src/main/java/de/cowtipper/cowlection/listener/PlayerListener.java
index 1074a43..a990ad4 100644
--- a/src/main/java/de/cowtipper/cowlection/listener/PlayerListener.java
+++ b/src/main/java/de/cowtipper/cowlection/listener/PlayerListener.java
@@ -8,9 +8,12 @@ import de.cowtipper.cowlection.listener.skyblock.SkyBlockListener;
import de.cowtipper.cowlection.util.GsonUtils;
import de.cowtipper.cowlection.util.TickDelay;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiInventory;
+import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -22,6 +25,7 @@ import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerSetSpawnEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
import org.lwjgl.input.Keyboard;
@@ -36,6 +40,18 @@ public class PlayerListener {
}
@SubscribeEvent
+ public void onKeybindingPressed(InputEvent.KeyInputEvent e) {
+ KeyBinding[] keyBindings = Cowlection.keyBindings;
+
+ if (keyBindings[0].isPressed()) {
+ Minecraft mc = Minecraft.getMinecraft();
+ if (mc.currentScreen == null && mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN) {
+ mc.displayGuiScreen(new GuiChat("/moo "));
+ }
+ }
+ }
+
+ @SubscribeEvent
public void onKeyboardInput(GuiScreenEvent.KeyboardInputEvent.Pre e) {
if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_C && GuiScreen.isCtrlKeyDown()) {
// ctrl + C
diff --git a/src/main/resources/assets/cowlection/lang/en_US.lang b/src/main/resources/assets/cowlection/lang/en_US.lang
index 58e85c1..0bcad5d 100644
--- a/src/main/resources/assets/cowlection/lang/en_US.lang
+++ b/src/main/resources/assets/cowlection/lang/en_US.lang
@@ -27,3 +27,5 @@ cowlection.config.logsDirs.tooltip=List of directories containing Minecraft log
cowlection.config.defaultStartDate=Start date for log file search
cowlection.config.defaultStartDate.tooltip=§eCan be either a §6number§e (e.g. "§63§e" means "§6start searching 3 months ago§e"),\n§eor alternatively a §6fixed date §e(§6yyyy-mm-dd§e)
cowlection.commands.generic.exception=%s
+key.cowlection.category=Cowlection
+key.cowlection.moo.desc=Open Command