Skip to content

Commit

Permalink
Added option to change the hotkey for auto compressor.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbRandy committed Feb 11, 2024
1 parent b7f16cf commit bed6d81
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "tmb.randy"
version = "1.2"
version = "1.2.1"

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/tmb/randy/tmbgriefergames/core/Addon.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public GameInfoWidget getGameInfoWidget() {
}

public static boolean isChatGuiOpen() {
if(!Laby.labyAPI().minecraft().isMouseLocked())
return true;

for (IngameOverlayActivity activity : Laby.labyAPI().ingameOverlay().getActivities()) {
if(activity.isAcceptingInput()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tmb.randy.tmbgriefergames.core.config;

import net.labymod.api.client.gui.screen.key.Key;
import net.labymod.api.client.gui.screen.widget.widgets.input.MultiKeybindWidget.MultiKeyBindSetting;
import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting;
import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget.DropdownSetting;
import net.labymod.api.configuration.loader.Config;
Expand All @@ -23,6 +25,9 @@ public class AutoCrafterSubConfig extends Config {
@DropdownSetting
private final ConfigProperty<AutoCrafterNewFinalAction> finalAction = new ConfigProperty<>(AutoCrafterNewFinalAction.COMP);

@MultiKeyBindSetting
private final ConfigProperty<Key[]> autoCompHotkey = new ConfigProperty<>(new Key[]{Key.ARROW_LEFT, Key.ARROW_UP, Key.ARROW_RIGHT});

public ConfigProperty<QueueType> getAutoCraftSpeed() { return this.autoCraftSpeed; }
public ConfigProperty<Boolean> getAutoDrop() {
return this.autoDrop;
Expand All @@ -35,4 +40,6 @@ public ConfigProperty<Boolean> getEndlessMode() {
public ConfigProperty<Boolean> getOnlyFullStacks() { return this.onlyFullStacks; }

public ConfigProperty<AutoCrafterNewFinalAction> getFinalAction() { return finalAction; }

public ConfigProperty<Key[]> getAutoCompHotkey() {return autoCompHotkey;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"name": "Lobby überspringen"
},
"autoCrafterConfig": {
"name": "Autocrafter",
"name": "Autocrafter & Autokomprimierer",
"description": "Es gibt 2 verschiedene Autocrafter:\\n\\nV1 nutzt das Vanilla Crafting Menü (Werkbank). Lege dein Rezept in die Werkbank und speichere mit SHIFT + ENTER. Drücke anschließend ENTER, um das Rezept zu craften.\\n\\nV2 nutzt das /rezepte Menü. Lege das Item, welches du craften willst in deinen ersten Hotbar Slot. Gib anschließend /autocraft in den Chat ein. Das /rezepte Menü öffnet sich automatisch und craftet deine Items.",
"autoCraftSpeed": {
"name": "[V1] Geschwindigkeit"
Expand All @@ -137,6 +137,9 @@
"finalAction": {
"name": "[V2] Schlussaktion",
"description": "Legt fest, ob bei Nutzung des Autocrafters V2 (/autocraft) die gecrafteten Items aus dem Inventar geworfen oder komprimiert werden sollen."
},
"autoCompHotkey": {
"name": "Hotkey für Autokomprimierer"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"description": "Go to the previous plot (/p h <player> -1)"
},
"autoCrafterConfig": {
"name": "Autocrafter",
"name": "Auto-crafter & auto-compressor",
"description": "There are 2 different Autocrafters:\n\nV1 uses the Vanilla Crafting menu (Workbench). Place your recipe in the Workbench and save with SHIFT + ENTER. Then press ENTER to craft the recipe.\n\nV2 uses the /recipes menu. Place the item you want to craft in your first hotbar slot. Then type /autocraft in the chat. The /recipes menu will open automatically and craft your items.",
"autoCraftSpeed": {
"name": "[V1] Speed"
Expand All @@ -137,6 +137,9 @@
"finalAction": {
"name": "[V2] Final action",
"description": "Specifies whether, when using Autocrafter V2 (/autocraft), the crafted items should be dropped or compressed in the inventory."
},
"autoCompHotkey": {
"name": "Hotkey for auto-compressor"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void onKeyEvent(KeyEvent event) {
}
}
} else {
if ((event.key() == Key.ARROW_UP || event.key() == Key.ARROW_LEFT || event.key() == Key.ARROW_RIGHT) && Key.ARROW_UP.isPressed() && Key.ARROW_LEFT.isPressed() && Key.ARROW_RIGHT.isPressed() && !isGUIOpen()) {
if (Addon.areKeysPressed(Addon.getSharedInstance().configuration().getAutoCrafterConfig().getAutoCompHotkey().get())) {
startComp();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void onKeyEvent(KeyEvent event) {
}
}
} else {
if ((event.key() == Key.ARROW_UP || event.key() == Key.ARROW_LEFT || event.key() == Key.ARROW_RIGHT) && Key.ARROW_UP.isPressed() && Key.ARROW_LEFT.isPressed() && Key.ARROW_RIGHT.isPressed() && !isGUIOpen()) {
if (Addon.areKeysPressed(Addon.getSharedInstance().configuration().getAutoCrafterConfig().getAutoCompHotkey().get())) {
startComp();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,4 @@ public boolean isCompActive() {
return autoComp.isCompActive();
}


}

0 comments on commit bed6d81

Please sign in to comment.