aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-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
5 files changed, 51 insertions, 3 deletions
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