diff --git a/README.md b/README.md
index e8af461..f566247 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ I am always looking for ways to improve the mod. If you have any feature request
| Auto Advert | Automatically sends messages from a specified file. | **Skyblock Advert File** - The txt file containing your /skyblock advertisements.
**Economy Advert File** - The txt file containing your /economy advertisements.
**Classic Advert File** - The txt file containing your /classic advertisements.
**Advert Delay** - The delay between messages. (Seconds)
**Advert Initial Delay** - The delay between joining and sending an advert. (Seconds)
**Use Advert Whitelist** - Only sends adverts from the accounts specified in the whitelist.
**Advert Whitelist** - A list of accounts that may send adverts if 'Use Advert Whitelist' is enabled. |
| Join Commands | Automatically sends commands when you join the server.
If you would like to set a join command for all accounts, add it to global.txt in .minecraft/sbutils/joincommands.
If you would like to set a join command for one account, create a txt file with either the name or UUID of the account, and add the command. | **Initial Delay** - The delay between joining the server and sending the commands. (Seconds)
**Delay** - The delay between each command. (Seconds)
**Servers** - A list of servers to send join commands on. |
| Mentions | Notifies you with a sound when something is mentioned in chat. | **Exclude Server Messages** - Doesn't notify you about server messages.
**Exclude Self Messages** - Doesn't notify you about your own messages.
**Mention Sound** - The sound played when something is mentioned in chat.
**Mention Highlighting** - Whether to change the color of mentions in chat.
**Highlight Color** - The color to highlight mentions with.
**Current Account Mentions** - Notifies you when your username is mentioned in chat.
**Aliases** - A list of strings you would like to be notified for. |
-| Enchant All | Enchants either your held item, or all items in your inventory. Can also be used to unenchant. | **Enchant Delay** - The delay between sending enchant commands. (Seconds)
**Cooldown Frequency** - The number of commands to be executed before a cooldown is initiated. (To avoid spam kick)
**Cooldown Time** - The length of the cooldown. (Seconds)
**Exclude Frost** - Excludes Frost Walker from /enchantall. |
+| Enchant All | Enchants either your held item, or all items in your inventory. Can also be used to unenchant. | **Enchant Mode** - Whether to use the built in /enchantall command, or send enchants individually.
**Enchant Delay** - The delay between sending enchant commands. (Seconds)
**Cooldown Frequency** - The number of commands to be executed before a cooldown is initiated. (To avoid spam kick)
**Cooldown Time** - The length of the cooldown. (Seconds)
**Exclude Frost** - Excludes Frost Walker from /enchantall. |
| Chat Append | Adds a prefix and/or suffix to the messages you send. | **Add Prefix** - Adds the specified prefix to all the messages you send.
**Chat Prefix** - The prefix to add to your messages.
**Add Suffix** - Adds the specified suffix to all the messages you send.
**Chat Suffix** - The suffix to add to your messages. |
| Chat Filters | Filters certain messages from chat. | **Filter Tips** - Whether tip messages should be filtered from chat.
**Filter Advancements** - Whether advancement messages should be filtered from chat.
**Filter Welcome Messages** - Whether player welcome messages should be filtered from chat.
**Filter Friend Joins** - Whether friend join messages should be filtered from chat.
**Filter Island MOTDs** - Whether island MOTD messages should be filtered from chat.
**Filter Votes** - Whether player vote messages should be filtered from chat.
**Filter Vote Rewards** - Whether player vote reward messages should be filtered from chat.
**Filter Raffle Messages** - Whether raffle messages should be filtered from chat.
**Filter Crate Messages** - Whether crate opening messages should be filtered from chat.
**Filter ClearLag Messages** - Whether ClearLag messages should be filtered from chat.
**Filter Perished In Void Messages** - Whether 'perished in void' messages should be filtered from chat.
**Filter SkyChats** - Whether SkyChat messages should be filtered from chat." |
| Chat Logger | Logs transactions, private messages, and visits to .minecraft/sbutils/chatlogger. | **Log Incoming Transactions** - Whether to log transaction messages from your shops.
**Log Outgoing Transactions** - Whether to log transaction messages from other players' shops.
**Log Incoming Messages** - Whether to log incoming private messages.
**Log Outgoing Messages** - Whether to log outgoing private messages.
**Log Visits** - Whether to log players visiting your island.
**Log Drop Party Messages** - Whether to log messages from drop party events. |
@@ -46,7 +46,7 @@ I am always looking for ways to improve the mod. If you have any feature request
| `/autoadvert` | `/advert` | `/advert` - Toggles Auto Advert.
`/advert info` - If Auto Advert is enabled, tells you how long until the next ad is sent, and the ad index.
`/advert ` - Tells you the current advert file for the specified server.
`/advert ` - Sets the advert file for the specified server.
`/advert list` - Lists the ads in the current advert file, with their indexes.
`/advert add ` - Adds the specified advert to the current advert file.
`/advert del ` - Removes the advert at the specified index from the current advert file.
`/advert insert ` - Inserts the advert at the specified index in the advert file.
`/advert delay` - Tells you what the current advert delay is.
`/advert delay ` - Sets the advert delay.
`/advert initialDelay` - Tells you what the current initial delay is.
`/advert initialDelay ` - Sets the initial delay.
`/advert whitelist` - Lists the current advert whitelist.
`/advert whitelist ` - Enables or disables advert whitelist.
`/advert whitelist ` - Adds or removes an account from the advert whitelist.
`/advert reset` - Resets remaining delay to 0 and returns to the first ad index. |
| `/joincmds` | `/jc` | `/jc` - Toggles Join Commands.
`/jc ` - Lists your global or account join commands.
`/jc add ` - Adds the specified command to global commands or the current account's commands.
`/jc del ` - Removes the command at the specified index from global commands or the current account's commands.
`/jc insert ` - Inserts the command at the specified index in global commands or the current accounts commands.
`/jc delay` - Tells you the current command delay.
`/jc delay ` - Sets join command delay.
`/jc initialDelay` - Tells you the current initial delay.
`/jc initialDelay ` - Sets initial delay. |
| `/mentions` | `/ment` | `/ment` - Toggles Mentions.
`/ment excludeServer` - Tells you if server messages are being ignored by Mentions.
`/ment excludeServer ` - Enables or disables server message exclusion.
`/ment excludeSelf` - Tells you if your own messages are being ignored by Mentions.
`/ment excludeSelf ` - Enables or disables self message exclusion.
`/ment currentAccount` - Tells you if current account mentions are enabled.
`/ment currentAccount ` - Enables or disables current account mentions.
`/ment aliases` - Lists the current mention aliases.
`/ment aliases ` - Adds or removes a mention alias.
`/ment sound` - Tells you what the current notification sound is.
`/ment sound ` - Sets the notification sound.
`/ment highlight` - Tells you if mention highlighting is enabled.
`/ment highlight ` - Enables or disables mention highlighting.
`/ment highlight color` - Tells you the current highlight color.
`/ment highlight color ` - Sets the highlight color. |
-| `/enchantall` | `/eall` | `/eall` - Enchants your held item with all possible enchants.
`/eall inv` - Enchants all items in your inventory with all possible enchants.
`/eall delay` - Tells you the current delay between enchantments.
`/eall delay ` - Sets the delay between enchantments.
`/eall cooldownFrequency` - Tells you the current cooldown frequency.
`/eall cooldownFrequency ` - Sets the cooldown frequency.
`/eall cooldownTime` - Tells you the current cooldown time.
`/eall cooldownTime ` - Sets the cooldown time.
`/eall excludeFrost` - Tells you whether exlude frost walker is enabled.
`/eall excludeFrost ` - Enables or disables exclude frost walker. |
+| `/enchantall` | `/eall` | `/eall` - Enchants your held item with all possible enchants.
`/eall inv` - Enchants all items in your inventory with all possible enchants.
`/eall mode` - Tells you the current enchant mode.
`/eall mode ` - Sets the enchant mode.
`/eall delay` - Tells you the current delay between enchantments.
`/eall delay ` - Sets the delay between enchantments.
`/eall cooldownFrequency` - Tells you the current cooldown frequency.
`/eall cooldownFrequency ` - Sets the cooldown frequency.
`/eall cooldownTime` - Tells you the current cooldown time.
`/eall cooldownTime ` - Sets the cooldown time.
`/eall excludeFrost` - Tells you whether exlude frost walker is enabled.
`/eall excludeFrost ` - Enables or disables exclude frost walker. |
| `/unenchantall` | `/ueall` | `/ueall` - Unenchants your held item.
`/ueall inv` - Unenchants all items in your inventory.
`/ueall delay` - Tells you the current delay between enchantments.
`/ueall delay ` - Sets the delay between enchantments.
`/ueall cooldownFrequency` - Tells you the current cooldown frequency.
`/ueall cooldownFrequency ` - Sets the cooldown frequency.
`/ueall cooldownTime` - Tells you the current cooldown time.
`/ueall cooldownTime ` - Sets the cooldown time.
`/ueall excludeFrost` - Tells you whether exlude frost walker is enabled.
`/ueall excludeFrost ` - Enables or disables exclude frost walker. |
| `/chatappend` | `/append` | `/append prefix` - Tells you whether add prefix is enabled.
`/append prefix ` - Enables or disables add prefix.
`/append prefix set ` - Sets your chat prefix.
`/append suffix` - Tells you whether add suffix is enabled.
`/append suffix ` - Enables or disables add suffix.
`/append suffix set ` - Sets your chat suffix. |
| `/chatfilter` | `/filter` | `/filter` - Lists all enabled and disabled filters.
`/filter ` - Tells you if the specified filter is enabled.
`/filter ` - Enables or disables a filter. |
@@ -59,6 +59,6 @@ I am always looking for ways to improve the mod. If you have any feature request
| `/autoreply` | `/areply` | `/areply` - Toggles Auto Reply.
`/areply response` - Tells you the current auto response.
`/areply response ` - Sets your auto reponse.
`/areply delay` - Tells you the current reply delay.
`/areply delay ` - Sets the reply delay. |
| `/autoraffle` | `/autoraf` | `/autoraf` - Toggles Auto Raffle.
`/autoraf sbTickets` - Tells you the current skyblock tickets setting.
`/autoraf sbTickets ` - Sets the skyblock tickets setting.
`/autoraf ecoTickets` - Tells you the current economy tickets setting.
`/autoraf ecoTickets ` - Sets the economy tickets setting.
`/autoraf checkDelay` - Tells you the current grass check delay.
`/autoraf checkDelay ` - Sets the grass check delay. |
| `/autoprivate` | `/ap` | `/ap` - Toggles Auto Private.
`/ap names` - Lists the current Auto Private names.
`/ap names ` - Adds or removes an Auto Private name. |
-| `/autosilk` | `/silk` | `/silk` - Toggles Auto Silk.
`/silk delay` - Tells you the current enchanting delay.
`/silk delay ` - Sets the enchanting delay. |
+| `/autosilk` | `/silk` | `/silk` - Toggles Auto Silk.
`/silk target` - Tells you the current target tool setting.
`/silk target ` - Sets the target tool setting.
`/silk delay` - Tells you the current enchanting delay.
`/silk delay ` - Sets the enchanting delay. |
| `/staffdetect` | `/sd` | `/sd detectJoin` - Tells you whether detect join is enabled.
`/sd detectJoin ` - Enables or disables detect join.
`/sd detectLeave` - Tells you whether detect leave is enabled.
`/sd detectLeave ` - Enables or disables detect leave.
`/sd sound` - Tells you what the current notification sound is.
`/sd sound ` - Sets the notification sound. |
| `/convert` | `/cv` | `/cv ` - Converts a quantity into double chests, stacks, and remainder.
Example usage:
`/cv 1.7dc` or `/cv 54s` or `/cv 1728` or `/cv 1.7dc + (54s - 1728)` or `/cv 5 * (256 / 2)` or `/cv sqrt(256)`
For a full list of supported functions, see [here](https://www.objecthunter.net/exp4j/apidocs/index.html). |
diff --git a/gradle.properties b/gradle.properties
index ca7d165..60140e8 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,12 +6,12 @@ mc_version=1.19.4
yarn_mappings=1.19.4+build.2
loader_version=0.14.19
# Mod Properties
-mod_version=1.1.1
+mod_version=1.1.2
maven_group=net.xolt
archives_base_name=sbutils
# Dependencies
# check this on https://modmuss50.me/fabric.html
-fabric_version=0.79.0+1.19.4
+fabric_version=0.80.0+1.19.4
modmenu_version=6.2.0
yacl_version=2.4.1
exp4j_version = 0.4.8
diff --git a/src/main/java/net/xolt/sbutils/config/ConfigGui.java b/src/main/java/net/xolt/sbutils/config/ConfigGui.java
index ddef455..e441f71 100644
--- a/src/main/java/net/xolt/sbutils/config/ConfigGui.java
+++ b/src/main/java/net/xolt/sbutils/config/ConfigGui.java
@@ -332,6 +332,16 @@ private static ConfigCategory buildEnchantAllCategory(ModConfig defaults, ModCon
.name(Text.translatable("text.sbutils.config.category.enchantall"))
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.sbutils.config.group.enchantAll"))
+ .option(Option.createBuilder(ModConfig.EnchantMode.class)
+ .name(Text.translatable("text.sbutils.config.option.enchantMode"))
+ .tooltip(Text.translatable("text.sbutils.config.option.enchantMode.tooltip"))
+ .binding(
+ defaults.enchantMode,
+ () -> config.enchantMode,
+ (value) -> config.enchantMode = value
+ )
+ .controller(EnumController::new)
+ .build())
.option(Option.createBuilder(double.class)
.name(Text.translatable("text.sbutils.config.option.enchantDelay"))
.tooltip(Text.translatable("text.sbutils.config.option.enchantDelay.tooltip"))
diff --git a/src/main/java/net/xolt/sbutils/config/ModConfig.java b/src/main/java/net/xolt/sbutils/config/ModConfig.java
index da2f3c2..db3742b 100644
--- a/src/main/java/net/xolt/sbutils/config/ModConfig.java
+++ b/src/main/java/net/xolt/sbutils/config/ModConfig.java
@@ -1,10 +1,13 @@
package net.xolt.sbutils.config;
+import com.mojang.brigadier.context.CommandContext;
import dev.isxander.yacl.api.NameableEnum;
import dev.isxander.yacl.config.ConfigEntry;
import dev.isxander.yacl.config.ConfigInstance;
+import net.minecraft.command.argument.EnumArgumentType;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
+import net.minecraft.registry.Registries;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
@@ -62,6 +65,7 @@ public class ModConfig {
// Enchant All Settings
+ @ConfigEntry public EnchantMode enchantMode = EnchantMode.ALL;
@ConfigEntry public double enchantDelay = 0.55;
@ConfigEntry public int cooldownFrequency = 12;
@ConfigEntry public double cooldownTime = 6.0;
@@ -210,9 +214,23 @@ public Text getDisplayName() {
public Formatting getFormatting() {
return formatting;
}
+
+ public static class ColorArgumentType extends EnumArgumentType {
+ private ColorArgumentType() {
+ super(StringIdentifiable.createCodec(Color::values), Color::values);
+ }
+
+ public static ColorArgumentType color() {
+ return new ColorArgumentType();
+ }
+
+ public static Color getColor(CommandContext> context, String id) {
+ return context.getArgument(id, Color.class);
+ }
+ }
}
- public enum FixMode implements NameableEnum {
+ public enum FixMode implements NameableEnum, StringIdentifiable {
HAND("text.sbutils.config.option.autoFixMode.hand"),
ALL("text.sbutils.config.option.autoFixMode.all");
@@ -225,9 +243,60 @@ public enum FixMode implements NameableEnum {
public Text getDisplayName() {
return Text.translatable(name);
}
+
+ public String asString() {
+ return getDisplayName().getString();
+ }
+
+ public static class FixModeArgumentType extends EnumArgumentType {
+ private FixModeArgumentType() {
+ super(StringIdentifiable.createCodec(FixMode::values), FixMode::values);
+ }
+
+ public static FixModeArgumentType fixMode() {
+ return new FixModeArgumentType();
+ }
+
+ public static FixMode getFixMode(CommandContext> context, String id) {
+ return context.getArgument(id, FixMode.class);
+ }
+ }
+ }
+
+ public enum EnchantMode implements NameableEnum, StringIdentifiable {
+ INDIVIDUAL("text.sbutils.config.option.enchantMode.individual"),
+ ALL("text.sbutils.config.option.enchantMode.all");
+
+ private final String name;
+
+ EnchantMode(String name) {
+ this.name = name;
+ }
+
+ public Text getDisplayName() {
+ return Text.translatable(name);
+ }
+
+ public String asString() {
+ return getDisplayName().getString();
+ }
+
+ public static class EnchantModeArgumentType extends EnumArgumentType {
+ private EnchantModeArgumentType() {
+ super(StringIdentifiable.createCodec(EnchantMode::values), EnchantMode::values);
+ }
+
+ public static EnchantModeArgumentType enchantMode() {
+ return new EnchantModeArgumentType();
+ }
+
+ public static EnchantMode getEnchantMode(CommandContext> context, String id) {
+ return context.getArgument(id, EnchantMode.class);
+ }
+ }
}
- public enum SilkTarget implements NameableEnum {
+ public enum SilkTarget implements NameableEnum, StringIdentifiable {
DIAMOND_PICKAXE(Items.DIAMOND_PICKAXE),
DIAMOND_AXE(Items.DIAMOND_AXE),
DIAMOND_SHOVEL(Items.DIAMOND_SHOVEL),
@@ -247,6 +316,25 @@ public Item getTool() {
public Text getDisplayName() {
return Text.translatable(tool.getTranslationKey());
}
+
+ @Override
+ public String asString() {
+ return Registries.ITEM.getId(tool).getPath();
+ }
+
+ public static class SilkTargetArgumentType extends EnumArgumentType {
+ private SilkTargetArgumentType() {
+ super(StringIdentifiable.createCodec(ModConfig.SilkTarget::values), ModConfig.SilkTarget::values);
+ }
+
+ public static SilkTargetArgumentType silkTarget() {
+ return new SilkTargetArgumentType();
+ }
+
+ public static SilkTarget getSilkTarget(CommandContext> context, String id) {
+ return context.getArgument(id, SilkTarget.class);
+ }
+ }
}
public enum NotifSound implements NameableEnum, StringIdentifiable {
@@ -291,5 +379,19 @@ public Text getDisplayName() {
public SoundEvent getSound() {
return sound;
}
+
+ public static class NotifSoundArgumentType extends EnumArgumentType {
+ private NotifSoundArgumentType() {
+ super(StringIdentifiable.createCodec(NotifSound::values), NotifSound::values);
+ }
+
+ public static NotifSoundArgumentType notifSound() {
+ return new NotifSoundArgumentType();
+ }
+
+ public static NotifSound getNotifSound(CommandContext> context, String id) {
+ return context.getArgument(id, NotifSound.class);
+ }
+ }
}
}
diff --git a/src/main/java/net/xolt/sbutils/features/AutoFix.java b/src/main/java/net/xolt/sbutils/features/AutoFix.java
index 945de9a..a0de2b4 100644
--- a/src/main/java/net/xolt/sbutils/features/AutoFix.java
+++ b/src/main/java/net/xolt/sbutils/features/AutoFix.java
@@ -61,18 +61,11 @@ public static void registerCommand(CommandDispatcher
Messenger.printSetting("text.sbutils.config.option.autoFixMode", ModConfig.INSTANCE.getConfig().autoFixMode);
return Command.SINGLE_SUCCESS;
})
- .then(ClientCommandManager.literal("hand")
+ .then(ClientCommandManager.argument("mode", ModConfig.FixMode.FixModeArgumentType.fixMode())
.executes(context -> {
- ModConfig.INSTANCE.getConfig().autoFixMode = ModConfig.FixMode.HAND;
+ ModConfig.INSTANCE.getConfig().autoFixMode = ModConfig.FixMode.FixModeArgumentType.getFixMode(context, "mode");
ModConfig.INSTANCE.save();
- Messenger.printChangedSetting("text.sbutils.config.option.autoFixMode", ModConfig.FixMode.HAND);
- return Command.SINGLE_SUCCESS;
- }))
- .then(ClientCommandManager.literal("all")
- .executes(context -> {
- ModConfig.INSTANCE.getConfig().autoFixMode = ModConfig.FixMode.ALL;
- ModConfig.INSTANCE.save();
- Messenger.printChangedSetting("text.sbutils.config.option.autoFixMode", ModConfig.FixMode.ALL);
+ Messenger.printChangedSetting("text.sbutils.config.option.autoFixMode", ModConfig.INSTANCE.getConfig().autoFixMode);
return Command.SINGLE_SUCCESS;
})))
.then(ClientCommandManager.literal("percent")
@@ -219,6 +212,10 @@ public static void tick() {
}
}
+ public static void onDisconnect() {
+ reset();
+ }
+
public static void onUpdateInventory() {
if (!ModConfig.INSTANCE.getConfig().autoFix || fixing) {
return;
@@ -326,7 +323,7 @@ public static boolean fixing() {
return fixing;
}
- public static void reset() {
+ private static void reset() {
fixing = false;
waitingForResponse = false;
findMostDamaged = true;
diff --git a/src/main/java/net/xolt/sbutils/features/AutoSilk.java b/src/main/java/net/xolt/sbutils/features/AutoSilk.java
index 941b69a..5784b6f 100644
--- a/src/main/java/net/xolt/sbutils/features/AutoSilk.java
+++ b/src/main/java/net/xolt/sbutils/features/AutoSilk.java
@@ -46,6 +46,18 @@ public static void registerCommand(CommandDispatcher
Messenger.printChangedSetting("text.sbutils.config.category.autosilk", ModConfig.INSTANCE.getConfig().autoSilk);
return Command.SINGLE_SUCCESS;
})
+ .then(ClientCommandManager.literal("target")
+ .executes(context -> {
+ Messenger.printSetting("text.sbutils.config.option.targetTool", ModConfig.INSTANCE.getConfig().targetTool);
+ return Command.SINGLE_SUCCESS;
+ })
+ .then(ClientCommandManager.argument("tool", ModConfig.SilkTarget.SilkTargetArgumentType.silkTarget())
+ .executes(context -> {
+ ModConfig.INSTANCE.getConfig().targetTool = ModConfig.SilkTarget.SilkTargetArgumentType.getSilkTarget(context, "tool");
+ ModConfig.INSTANCE.save();
+ Messenger.printChangedSetting("text.sbutils.config.option.targetTool", ModConfig.INSTANCE.getConfig().targetTool);
+ return Command.SINGLE_SUCCESS;
+ })))
.then(ClientCommandManager.literal("delay")
.executes(context -> {
Messenger.printSetting("text.sbutils.config.option.autoSilkDelay", ModConfig.INSTANCE.getConfig().autoSilkDelay);
@@ -66,6 +78,10 @@ public static void registerCommand(CommandDispatcher
.redirect(autoSilkNode));
}
+ public static void onDisconnect() {
+ reset();
+ }
+
public static void onPlayerCloseScreen() {
if (!ModConfig.INSTANCE.getConfig().autoSilk || !(MC.currentScreen instanceof EnchantmentScreen)) {
return;
@@ -391,7 +407,7 @@ private enum State {
RETURN_ITEM_AND_RESET;
}
- public static void reset() {
+ private static void reset() {
state = State.INSERT_LAPIS;
lastActionPerformedAt = 0;
screenHandler = null;
diff --git a/src/main/java/net/xolt/sbutils/features/EnchantAll.java b/src/main/java/net/xolt/sbutils/features/EnchantAll.java
index 93fc0df..803adc3 100644
--- a/src/main/java/net/xolt/sbutils/features/EnchantAll.java
+++ b/src/main/java/net/xolt/sbutils/features/EnchantAll.java
@@ -12,32 +12,36 @@
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.network.encryption.NetworkEncryptionUtils;
+import net.minecraft.network.message.ArgumentSignatureDataMap;
+import net.minecraft.network.message.LastSeenMessagesCollector;
+import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket;
import net.minecraft.registry.Registries;
-import net.minecraft.screen.slot.SlotActionType;
+import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.xolt.sbutils.config.ModConfig;
import net.xolt.sbutils.util.InvUtils;
import net.xolt.sbutils.util.Messenger;
+import net.xolt.sbutils.util.RegexFilters;
-import java.util.*;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import static net.xolt.sbutils.SbUtils.MC;
public class EnchantAll {
- private static Map itemsToEnchant;
- private static ItemStack currentItem;
+
private static boolean enchanting;
private static boolean unenchanting;
- private static boolean sentLastEnchantForItem;
+ private static boolean inventory;
+ private static boolean awaitingResponse;
private static boolean pause;
private static boolean cooldown;
- private static boolean sendCooldownMessage;
+ private static int prevSelectedSlot;
+ private static int commandCount;
private static long lastActionPerformedAt;
- private static int selectedSlot;
- private static int enchantIndex;
- private static int commandCounter;
-
- private static List enchantments;
public static void init() {
reset();
@@ -45,13 +49,25 @@ public static void init() {
public static void registerCommand(CommandDispatcher dispatcher) {
final LiteralCommandNode enchantAllNode = dispatcher.register(ClientCommandManager.literal("enchantall")
- .executes(enchantAll ->
- onEnchantAllCommand(false)
+ .executes(context ->
+ onEnchantAllCommand(false, false)
)
.then(ClientCommandManager.literal("inv")
- .executes(enchantAll ->
- onEnchantAllInvCommand(false)
+ .executes(context ->
+ onEnchantAllCommand(false, true)
))
+ .then(ClientCommandManager.literal("mode")
+ .executes(context -> {
+ Messenger.printSetting("text.sbutils.config.option.enchantMode", ModConfig.INSTANCE.getConfig().enchantMode);
+ return Command.SINGLE_SUCCESS;
+ })
+ .then(ClientCommandManager.argument("mode", ModConfig.EnchantMode.EnchantModeArgumentType.enchantMode())
+ .executes(context -> {
+ ModConfig.INSTANCE.getConfig().enchantMode = ModConfig.EnchantMode.EnchantModeArgumentType.getEnchantMode(context, "mode");
+ ModConfig.INSTANCE.save();
+ Messenger.printSetting("text.sbutils.config.option.enchantMode", ModConfig.INSTANCE.getConfig().enchantMode);
+ return Command.SINGLE_SUCCESS;
+ })))
.then(ClientCommandManager.literal("delay")
.executes(context -> {
Messenger.printSetting("text.sbutils.config.option.enchantDelay", ModConfig.INSTANCE.getConfig().enchantDelay);
@@ -110,12 +126,12 @@ public static void registerCommand(CommandDispatcher
final LiteralCommandNode unenchantAllNode = dispatcher.register(ClientCommandManager.literal("unenchantall")
- .executes(enchantAll ->
- onEnchantAllCommand(true)
+ .executes(context ->
+ onEnchantAllCommand(true, false)
)
.then(ClientCommandManager.literal("inv")
- .executes(enchantAll ->
- onEnchantAllInvCommand(true)
+ .executes(context ->
+ onEnchantAllCommand(true, true)
))
.then(ClientCommandManager.literal("delay")
.executes(context -> {
@@ -186,182 +202,196 @@ public static void registerCommand(CommandDispatcher
.redirect(unenchantAllNode));
}
+ private static int onEnchantAllCommand(boolean unenchant, boolean inv) {
+ if (MC.player == null) {
+ return Command.SINGLE_SUCCESS;
+ }
+
+ if (enchanting || unenchanting) {
+ Messenger.printMessage("message.sbutils.enchantAll.pleaseWait", Formatting.RED);
+ return Command.SINGLE_SUCCESS;
+ }
+
+ enchanting = !unenchant;
+ unenchanting = unenchant;
+ prevSelectedSlot = MC.player.getInventory().selectedSlot;
+ inventory = inv;
+
+ return Command.SINGLE_SUCCESS;
+ }
+
public static void tick() {
- if (!enchanting && !unenchanting) {
+ if ((!enchanting && !unenchanting) || awaitingResponse || MC.player == null) {
return;
}
- if (commandCounter >= ModConfig.INSTANCE.getConfig().cooldownFrequency) {
- if (!(sentLastEnchantForItem && itemsToEnchant.size() < 2)) {
- cooldown = true;
- sendCooldownMessage = true;
- lastActionPerformedAt = System.currentTimeMillis();
- }
- commandCounter = 0;
+ if (MC.player.getInventory().selectedSlot != prevSelectedSlot) {
+ Messenger.printMessage("message.sbutils.enchantAll.cancelSlotSwitch", Formatting.RED);
+ reset();
+ return;
+ }
+
+ if (done()) {
+ Messenger.printMessage("message.sbutils.enchantAll.complete");
+ reset();
+ return;
}
- if (sendCooldownMessage && System.currentTimeMillis() - lastActionPerformedAt >= 250) {
+ if (commandCount >= ModConfig.INSTANCE.getConfig().cooldownFrequency) {
+ cooldown = true;
Messenger.printEnchantCooldown(ModConfig.INSTANCE.getConfig().cooldownTime);
- sendCooldownMessage = false;
+ commandCount = 0;
}
if (delayLeft() > 0) {
return;
}
- pause = false;
- cooldown = false;
-
- if (!sentLastEnchantForItem) {
- if (checkForSlotSwitch()) {
- return;
- }
-
- sendNextEnchant();
-
- lastActionPerformedAt = System.currentTimeMillis();
- commandCounter++;
- enchantIndex++;
+ if (pause || cooldown) {
+ pause = false;
+ cooldown = false;
+ return;
+ }
- if (enchantIndex >= enchantments.size()) {
- sentLastEnchantForItem = true;
- pause = true;
- }
+ if (inventory) {
+ doEnchantInv(unenchanting);
} else {
- if (itemsToEnchant.size() > 1 && checkForSlotSwitch()) {
- return;
- }
+ doEnchant(unenchanting);
+ }
+ }
- if (currentItem != null) {
- int originalSlot = itemsToEnchant.get(currentItem);
+ public static void onDisconnect() {
+ reset();
+ }
- if (!InvUtils.canSwapSlot(originalSlot)) {
- return;
- }
+ public static void processMessage(Text message) {
+ if (!enchanting && !unenchanting) {
+ return;
+ }
- // Move item back to original slot
- InvUtils.swapToHotbar(originalSlot, selectedSlot);
- itemsToEnchant.remove(currentItem);
- currentItem = null;
- }
+ String messageString = message.getString();
+ if (RegexFilters.enchantSingleSuccess.matcher(messageString).matches() ||
+ RegexFilters.enchantAllSuccess.matcher(messageString).matches() ||
+ RegexFilters.unenchantSuccess.matcher(messageString).matches() ||
+ RegexFilters.enchantError.matcher(messageString).matches()) {
+ awaitingResponse = false;
+ }
+ }
- if (itemsToEnchant.size() == 0) {
- Messenger.printMessage("message.sbutils.enchantAll.complete");
- reset();
- } else {
- ItemStack newItem = getNextItem();
- int newItemSlot = itemsToEnchant.get(newItem);
+ private static void doEnchant(boolean unenchant) {
+ if (MC.player == null) {
+ return;
+ }
- if (!InvUtils.canSwapSlot(newItemSlot)) {
- return;
- }
+ ItemStack hand = MC.player.getMainHandStack();
- currentItem = newItem;
- sentLastEnchantForItem = false;
- enchantments = getEnchantsForItem(currentItem, unenchanting);
- enchantIndex = 0;
- InvUtils.swapToHotbar(itemsToEnchant.get(newItem), selectedSlot);
- lastActionPerformedAt = System.currentTimeMillis();
- }
+ if (!hand.getItem().isEnchantable(hand)) {
+ Messenger.printMessage("message.sbutils.enchantAll.cantEnchantItem");
+ reset();
+ return;
}
- }
- public static int onEnchantAllInvCommand(boolean unenchant) {
- if (enchanting || unenchanting) {
- Messenger.printMessage("message.sbutils.enchantAll.pleaseWait", Formatting.RED);
- return Command.SINGLE_SUCCESS;
- }
+ List enchants = getEnchantsForItem(MC.player.getMainHandStack(), unenchant);
- for (int i = 0; i < MC.player.getInventory().size(); i++) {
- if (i >= 36 && i <= 39) {
- // Skip armor slots
- continue;
- }
- ItemStack itemStack = MC.player.getInventory().getStack(i);
- if (getEnchantsForItem(itemStack, unenchant).size() > 0) {
- itemsToEnchant.put(itemStack.copy(), i);
+ if (enchants.size() < 1) {
+ if (shouldRemoveFrost()) {
+ sendEnchantCommand(Enchantments.FROST_WALKER, true);
}
+ return;
}
- selectedSlot = MC.player.getInventory().selectedSlot;
+ sendNextEnchant(enchants, unenchant);
+ }
- if (itemsToEnchant.size() == 0) {
- Messenger.printMessage("message.sbutils.enchantAll.nothingEnchantable");
- reset();
- return Command.SINGLE_SUCCESS;
+ private static void doEnchantInv(boolean unenchant) {
+ if (MC.player == null) {
+ return;
}
- if (!itemsToEnchant.containsValue(MC.player.getInventory().selectedSlot) && !MC.player.getMainHandStack().isEmpty()) {
- int emptySlot = InvUtils.findEmptyHotbarSlot();
- if (emptySlot != -1) {
- MC.player.getInventory().selectedSlot = emptySlot;
+ ItemStack hand = MC.player.getMainHandStack();
+ List enchants = getEnchantsForItem(hand, unenchant);
+
+ if (enchants.size() < 1) {
+ if (shouldRemoveFrost()) {
+ sendEnchantCommand(Enchantments.FROST_WALKER, true);
+ return;
+ }
+ int enchantableSlot = findEnchantableSlot(unenchant);
+ if (enchantableSlot != -1) {
+ if (!InvUtils.canSwapSlot(enchantableSlot)) {
+ return;
+ }
+ InvUtils.swapToHotbar(enchantableSlot, MC.player.getInventory().selectedSlot);
+ pause = true;
}
+ return;
}
- currentItem = getNextItem();
- enchantments = getEnchantsForItem(currentItem, unenchant);
- enchanting = !unenchant;
- unenchanting = unenchant;
- selectedSlot = MC.player.getInventory().selectedSlot;
- InvUtils.swapToHotbar(itemsToEnchant.get(currentItem), selectedSlot);
- lastActionPerformedAt = System.currentTimeMillis();
- pause = true;
-
- return Command.SINGLE_SUCCESS;
+ sendNextEnchant(enchants, unenchant);
}
- public static int onEnchantAllCommand(boolean unenchant) {
- if (enchanting || unenchanting) {
- Messenger.printMessage("message.sbutils.enchantAll.pleaseWait", Formatting.RED);
- return Command.SINGLE_SUCCESS;
+ private static void sendNextEnchant(List enchants, boolean unenchant) {
+ if (!unenchant && ModConfig.INSTANCE.getConfig().enchantMode == ModConfig.EnchantMode.ALL) {
+ sendEnchantAllCommand();
+ return;
}
- reset();
- itemsToEnchant.put(MC.player.getMainHandStack().copy(), MC.player.getInventory().selectedSlot);
- currentItem = getNextItem();
- enchantments = getEnchantsForItem(currentItem, unenchant);
- selectedSlot = MC.player.getInventory().selectedSlot;
+ sendEnchantCommand(enchants.iterator().next(), unenchant);
+ }
- if (enchantments.size() == 0) {
- Messenger.printMessage("message.sbutils.enchantAll.cantEnchantItem");
- reset();
- return Command.SINGLE_SUCCESS;
+ private static void sendEnchantCommand(Enchantment enchantment, boolean unenchant) {
+ if (MC.getNetworkHandler() == null) {
+ return;
}
- enchanting = !unenchant;
- unenchanting = unenchant;
-
- return Command.SINGLE_SUCCESS;
+ String enchantName = Registries.ENCHANTMENT.getId(enchantment).getPath().replaceAll("_", "");
+ MC.getNetworkHandler().sendChatCommand("enchant " + enchantName + " " + (unenchant ? 0 : enchantment.getMaxLevel()));
+ afterSendCommand();
}
- public static void onClickSlot(int slotIndex, SlotActionType actionType, int button) {
- if (!enchanting && !unenchanting) {
+ private static void sendEnchantAllCommand() {
+ if (MC.getNetworkHandler() == null) {
return;
}
- boolean conflicts = doesClickConflict(slotIndex);
- if (!conflicts && actionType.equals(SlotActionType.SWAP)) {
- conflicts = doesClickConflict(button);
- }
+ MC.getNetworkHandler().sendPacket(new CommandExecutionC2SPacket("enchantall", Instant.now(), NetworkEncryptionUtils.SecureRandomUtil.nextLong(),
+ ArgumentSignatureDataMap.EMPTY, new LastSeenMessagesCollector(20).collect().update()));
+ afterSendCommand();
+ }
- if (conflicts) {
- reset();
- Messenger.printMessage("message.sbutils.enchantAll.cancelInventoryInteract", Formatting.RED);
- }
+ private static void afterSendCommand() {
+ commandCount++;
+ lastActionPerformedAt = System.currentTimeMillis();
+ awaitingResponse = true;
}
- private static boolean doesClickConflict(int slotIndex) {
+ private static int findEnchantableSlot(boolean unenchant) {
if (MC.player == null) {
- return false;
+ return -1;
+ }
+
+ for (int i = 0; i < MC.player.getInventory().size(); i++) {
+ if (i >= 36 && i <= 39) {
+ // Skip armor slots
+ continue;
+ }
+ ItemStack itemStack = MC.player.getInventory().getStack(i);
+ if (getEnchantsForItem(itemStack, unenchant).size() > 0) {
+ return i;
+ }
}
- return getEnchantsForItem(MC.player.getInventory().getStack(slotIndex), unenchanting).size() > 0 && (slotIndex == MC.player.getInventory().selectedSlot || itemsToEnchant.size() > 1);
+
+ return -1;
}
private static List getEnchantsForItem(ItemStack itemStack, boolean unenchant) {
Item item = itemStack.getItem();
- Map itemsEnchants = EnchantmentHelper.fromNbt(itemStack.getEnchantments());
+ if (!itemStack.getItem().isEnchantable(itemStack)) {
+ return new ArrayList<>();
+ }
+ Map itemsEnchants = EnchantmentHelper.fromNbt(itemStack.getEnchantments());
List enchantments = new ArrayList<>();
if (!unenchant) {
for (Enchantment enchantment : Registries.ENCHANTMENT) {
@@ -391,36 +421,6 @@ private static List getEnchantsForItem(ItemStack itemStack, boolean
return enchantments;
}
- private static void sendNextEnchant() {
- sendEnchantCommand(enchantments.get(enchantIndex), unenchanting);
- }
-
- private static void sendEnchantCommand(Enchantment enchantment, boolean unenchant) {
- if (MC.getNetworkHandler() == null) {
- return;
- }
-
- String enchantName = Registries.ENCHANTMENT.getId(enchantment).getPath().replaceAll("_", "");
- MC.getNetworkHandler().sendChatCommand("enchant " + enchantName + " " + (unenchant ? 0 : enchantment.getMaxLevel()));
- }
-
- private static ItemStack getNextItem() {
- try {
- return itemsToEnchant.keySet().iterator().next();
- } catch (NoSuchElementException e) {
- return null;
- }
- }
-
- private static boolean checkForSlotSwitch() {
- if (MC.player.getInventory().selectedSlot != selectedSlot) {
- Messenger.printMessage("message.sbutils.enchantAll.cancelSlotSwitch", Formatting.RED);
- reset();
- return true;
- }
- return false;
- }
-
private static int delayLeft() {
long delay = (long)(ModConfig.INSTANCE.getConfig().enchantDelay * 1000.0);
if (cooldown) {
@@ -432,22 +432,39 @@ private static int delayLeft() {
return (int)Math.max(delay - (System.currentTimeMillis() - lastActionPerformedAt), 0L);
}
- public static boolean active() {
- return enchanting || unenchanting;
+ private static boolean done() {
+ if (MC.player == null) {
+ return true;
+ }
+
+ ItemStack hand = MC.player.getMainHandStack();
+
+ return ((inventory && findEnchantableSlot(unenchanting) == -1) ||
+ (!inventory && getEnchantsForItem(hand, unenchanting).size() < 1)) &&
+ !shouldRemoveFrost();
}
- public static void reset() {
+ private static boolean shouldRemoveFrost() {
+ if (MC.player == null) {
+ return false;
+ }
+
+ return ModConfig.INSTANCE.getConfig().excludeFrost &&
+ EnchantmentHelper.fromNbt(MC.player.getMainHandStack().getEnchantments()).containsKey(Enchantments.FROST_WALKER);
+ }
+
+ private static void reset() {
enchanting = false;
unenchanting = false;
- sentLastEnchantForItem = false;
+ inventory = false;
+ awaitingResponse = false;
pause = false;
cooldown = false;
- sendCooldownMessage = false;
- selectedSlot = 0;
- enchantIndex = 0;
- commandCounter = 0;
- enchantments = List.of();
- itemsToEnchant = new LinkedHashMap<>();
- currentItem = null;
+ prevSelectedSlot = -1;
+ commandCount = 0;
+ }
+
+ public static boolean active() {
+ return enchanting || unenchanting;
}
}
diff --git a/src/main/java/net/xolt/sbutils/features/JoinCommands.java b/src/main/java/net/xolt/sbutils/features/JoinCommands.java
index c74781e..dc8a549 100644
--- a/src/main/java/net/xolt/sbutils/features/JoinCommands.java
+++ b/src/main/java/net/xolt/sbutils/features/JoinCommands.java
@@ -174,6 +174,10 @@ private static int onInsertCommand(int index, String command, boolean global) {
return Command.SINGLE_SUCCESS;
}
+ public static void onDisconnect() {
+ reset();
+ }
+
public static void onJoinGame() {
if (!ModConfig.INSTANCE.getConfig().joinCmdsEnabled) {
return;
@@ -256,7 +260,7 @@ private static void sendJoinCommand() {
}
}
- public static void reset() {
+ private static void reset() {
waitingToSend = false;
joinedAt = 0;
lastCommandSentAt = 0;
diff --git a/src/main/java/net/xolt/sbutils/features/Mentions.java b/src/main/java/net/xolt/sbutils/features/Mentions.java
index d398622..6f7b767 100644
--- a/src/main/java/net/xolt/sbutils/features/Mentions.java
+++ b/src/main/java/net/xolt/sbutils/features/Mentions.java
@@ -8,9 +8,7 @@
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.text.*;
import net.xolt.sbutils.config.ModConfig;
-import net.xolt.sbutils.util.command.ColorArgumentType;
import net.xolt.sbutils.util.Messenger;
-import net.xolt.sbutils.util.command.NotifSoundArgumentType;
import net.xolt.sbutils.util.RegexFilters;
import java.util.ArrayList;
@@ -107,9 +105,9 @@ public static void registerCommand(CommandDispatcher
Messenger.printSetting("text.sbutils.config.option.mentionSound", ModConfig.INSTANCE.getConfig().mentionSound);
return Command.SINGLE_SUCCESS;
})
- .then(ClientCommandManager.argument("sound", NotifSoundArgumentType.notifSound())
+ .then(ClientCommandManager.argument("sound", ModConfig.NotifSound.NotifSoundArgumentType.notifSound())
.executes(context -> {
- ModConfig.INSTANCE.getConfig().mentionSound = NotifSoundArgumentType.getNotifSound(context, "sound");
+ ModConfig.INSTANCE.getConfig().mentionSound = ModConfig.NotifSound.NotifSoundArgumentType.getNotifSound(context, "sound");
ModConfig.INSTANCE.save();
Messenger.printChangedSetting("text.sbutils.config.option.mentionSound", ModConfig.INSTANCE.getConfig().mentionSound);
return Command.SINGLE_SUCCESS;
@@ -138,9 +136,9 @@ public static void registerCommand(CommandDispatcher
Messenger.printSetting("text.sbutils.config.option.highlightColor", ModConfig.INSTANCE.getConfig().highlightColor);
return Command.SINGLE_SUCCESS;
})
- .then(ClientCommandManager.argument("color", ColorArgumentType.color())
+ .then(ClientCommandManager.argument("color", ModConfig.Color.ColorArgumentType.color())
.executes(context -> {
- ModConfig.INSTANCE.getConfig().highlightColor = ColorArgumentType.getColor(context, "color");
+ ModConfig.INSTANCE.getConfig().highlightColor = ModConfig.Color.ColorArgumentType.getColor(context, "color");
ModConfig.INSTANCE.save();
Messenger.printChangedSetting("text.sbutils.config.option.highlightColor", ModConfig.INSTANCE.getConfig().highlightColor);
return Command.SINGLE_SUCCESS;
diff --git a/src/main/java/net/xolt/sbutils/features/StaffDetector.java b/src/main/java/net/xolt/sbutils/features/StaffDetector.java
index 8e53a56..a26e3fd 100644
--- a/src/main/java/net/xolt/sbutils/features/StaffDetector.java
+++ b/src/main/java/net/xolt/sbutils/features/StaffDetector.java
@@ -8,7 +8,6 @@
import net.minecraft.client.network.PlayerListEntry;
import net.xolt.sbutils.config.ModConfig;
import net.xolt.sbutils.util.Messenger;
-import net.xolt.sbutils.util.command.NotifSoundArgumentType;
import net.xolt.sbutils.util.RegexFilters;
import java.util.UUID;
@@ -64,9 +63,9 @@ public static void registerCommand(CommandDispatcher
Messenger.printSetting("text.sbutils.config.option.staffDetectSound", ModConfig.INSTANCE.getConfig().staffDetectSound);
return Command.SINGLE_SUCCESS;
})
- .then(ClientCommandManager.argument("sound", NotifSoundArgumentType.notifSound())
+ .then(ClientCommandManager.argument("sound", ModConfig.NotifSound.NotifSoundArgumentType.notifSound())
.executes(context ->{
- ModConfig.INSTANCE.getConfig().staffDetectSound = NotifSoundArgumentType.getNotifSound(context, "sound");
+ ModConfig.INSTANCE.getConfig().staffDetectSound = ModConfig.NotifSound.NotifSoundArgumentType.getNotifSound(context, "sound");
ModConfig.INSTANCE.save();
Messenger.printChangedSetting("text.sbutils.config.option.staffDetectSound", ModConfig.INSTANCE.getConfig().staffDetectSound);
return Command.SINGLE_SUCCESS;
diff --git a/src/main/java/net/xolt/sbutils/mixins/ClientConnectionMixin.java b/src/main/java/net/xolt/sbutils/mixins/ClientConnectionMixin.java
index feb5220..7459965 100644
--- a/src/main/java/net/xolt/sbutils/mixins/ClientConnectionMixin.java
+++ b/src/main/java/net/xolt/sbutils/mixins/ClientConnectionMixin.java
@@ -15,10 +15,10 @@ public class ClientConnectionMixin {
@Inject(method = "handleDisconnection", at = @At("HEAD"))
private void onHandleDisconnection(CallbackInfo ci) {
ServerDetector.onDisconnect();
- EnchantAll.reset();
- JoinCommands.reset();
- AutoSilk.reset();
- AutoFix.reset();
+ EnchantAll.onDisconnect();
+ JoinCommands.onDisconnect();
+ AutoSilk.onDisconnect();
+ AutoFix.onDisconnect();
if (ModConfig.INSTANCE.getConfig().autoSilk || ModConfig.INSTANCE.getConfig().autoMine) {
ModConfig.INSTANCE.getConfig().autoSilk = false;
diff --git a/src/main/java/net/xolt/sbutils/mixins/CreativeInventoryScreenMixin.java b/src/main/java/net/xolt/sbutils/mixins/CreativeInventoryScreenMixin.java
deleted file mode 100644
index 8c682f7..0000000
--- a/src/main/java/net/xolt/sbutils/mixins/CreativeInventoryScreenMixin.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package net.xolt.sbutils.mixins;
-
-import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
-import net.minecraft.screen.slot.Slot;
-import net.minecraft.screen.slot.SlotActionType;
-import net.xolt.sbutils.features.EnchantAll;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
-@Mixin(CreativeInventoryScreen.class)
-public class CreativeInventoryScreenMixin {
-
- @Inject(method = "onMouseClick", at = @At("HEAD"))
- private void onMouseClick(Slot slot, int slotId, int button, SlotActionType actionType, CallbackInfo ci) {
- if (slot == null) {
- return;
- }
- EnchantAll.onClickSlot(slot.getIndex(), actionType, button);
- }
-}
diff --git a/src/main/java/net/xolt/sbutils/mixins/HandledScreenMixin.java b/src/main/java/net/xolt/sbutils/mixins/HandledScreenMixin.java
deleted file mode 100644
index c0a8399..0000000
--- a/src/main/java/net/xolt/sbutils/mixins/HandledScreenMixin.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package net.xolt.sbutils.mixins;
-
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
-import net.minecraft.screen.slot.Slot;
-import net.minecraft.screen.slot.SlotActionType;
-import net.xolt.sbutils.features.EnchantAll;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
-@Mixin(HandledScreen.class)
-public class HandledScreenMixin {
-
- @Inject(method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V", at = @At("HEAD"))
- private void onClickSlot(Slot slot, int slotId, int button, SlotActionType actionType, CallbackInfo ci) {
- if (slot == null) {
- return;
- }
- EnchantAll.onClickSlot(slot.getIndex(), actionType, button);
- }
-}
diff --git a/src/main/java/net/xolt/sbutils/mixins/MessageHandlerMixin.java b/src/main/java/net/xolt/sbutils/mixins/MessageHandlerMixin.java
index 37adf1f..05b36ea 100644
--- a/src/main/java/net/xolt/sbutils/mixins/MessageHandlerMixin.java
+++ b/src/main/java/net/xolt/sbutils/mixins/MessageHandlerMixin.java
@@ -57,6 +57,7 @@ private static void preFilterMessage(Text message) {
AutoFix.processMessage(message);
AutoRaffle.processMessage(message);
AutoReply.processMessage(message);
+ EnchantAll.processMessage(message);
}
private static void postFilterMessage(Text message) {
diff --git a/src/main/java/net/xolt/sbutils/util/RegexFilters.java b/src/main/java/net/xolt/sbutils/util/RegexFilters.java
index 45363dc..9976dcc 100644
--- a/src/main/java/net/xolt/sbutils/util/RegexFilters.java
+++ b/src/main/java/net/xolt/sbutils/util/RegexFilters.java
@@ -13,6 +13,14 @@ public class RegexFilters {
public static final Pattern playerMsgFilter = Pattern.compile("((\u00a7[0-9a-fk-or])*\\[.*\\](\u00a7[0-9a-fk-or])* )*[\u00a7_a-zA-Z0-9]+: .*");
+
+ // Enchant All
+
+ public static final Pattern enchantSingleSuccess = Pattern.compile("The enchantment .* has been applied to your item in hand\\.");
+ public static final Pattern enchantAllSuccess = Pattern.compile("All possible enchantments have been applied to the item in your hand\\.");
+ public static final Pattern unenchantSuccess = Pattern.compile("The enchantment .* has been removed from your item in hand\\.");
+ public static final Pattern enchantError = Pattern.compile("Error: .*");
+
// Chat Filters
@@ -21,7 +29,7 @@ public class RegexFilters {
public static final Pattern welcomeFilter = Pattern.compile("Welcome [\u00a7_a-zA-Z0-9]+ to Skyblock!");
public static final Pattern friendJoinFilter = Pattern.compile("\\[Friends\\] [\u00a7_a-zA-Z0-9]+ has joined [a-zA-Z0-9]+");
public static final Pattern motdFilter = Pattern.compile("============ Welcome to [\u00a7_a-zA-Z0-9]+'s Island ============|\\+ .*");
- public static final Pattern voteFilter = Pattern.compile("\\[Broadcast\\] [\u00a7_a-zA-Z0-9]+ voted at vote.skyblock.net for 1x Grass Block and 1x Voter Key! /vote");
+ public static final Pattern voteFilter = Pattern.compile("\\[Broadcast\\] [\u00a7_a-zA-Z0-9]+ voted at vote.skyblock.net for .* and 1x Voter Key! /vote");
public static final Pattern voteRewardFilter = Pattern.compile("[\u00a7_a-zA-Z0-9]+ was (super |super duper )?lucky and received [a-zA-Z0-9/! ]+! ?");
public static final Pattern raffleFilter = Pattern.compile("\\[SBRaffle\\].*");
public static final Pattern cratesFilter = Pattern.compile("[\u00a7_a-zA-Z0-9]+ has just opened a (Rare|Epic|Legendary) Crate!");
@@ -54,14 +62,6 @@ public class RegexFilters {
public static final Pattern raffleEndFilter = Pattern.compile("\\[SBRaffle\\] Congratulations go to [\u00a7_a-zA-Z0-9]+ for winning [0-9]+ Grass block with [0-9]+ (ticket|tickets)");
- // Auto Crate
-
- public static final Pattern voterKeyFilter = Pattern.compile("Click the (Voting|Voter) Crate to use this key");
- public static final Pattern commonKeyFilter = Pattern.compile("Click the Common Crate to use this key");
- public static final Pattern voterCrateFilter = Pattern.compile("Voter");
- public static final Pattern commonCrateFilter = Pattern.compile("Common");
-
-
// Staff Detector
public static final Pattern staffFilter = Pattern.compile("\\[Helper\\].*|\\[Mod\\].*|\\[Dev\\].*|\\[Manager\\].*");
diff --git a/src/main/java/net/xolt/sbutils/util/command/ColorArgumentType.java b/src/main/java/net/xolt/sbutils/util/command/ColorArgumentType.java
deleted file mode 100644
index 98a30d1..0000000
--- a/src/main/java/net/xolt/sbutils/util/command/ColorArgumentType.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package net.xolt.sbutils.util.command;
-
-import com.mojang.brigadier.context.CommandContext;
-import net.minecraft.command.argument.EnumArgumentType;
-import net.minecraft.util.StringIdentifiable;
-import net.xolt.sbutils.config.ModConfig;
-
-public class ColorArgumentType extends EnumArgumentType {
- private ColorArgumentType() {
- super(StringIdentifiable.createCodec(ModConfig.Color::values), ModConfig.Color::values);
- }
-
- public static ColorArgumentType color() {
- return new ColorArgumentType();
- }
-
- public static ModConfig.Color getColor(CommandContext> context, String id) {
- return context.getArgument(id, ModConfig.Color.class);
- }
-}
diff --git a/src/main/java/net/xolt/sbutils/util/command/NotifSoundArgumentType.java b/src/main/java/net/xolt/sbutils/util/command/NotifSoundArgumentType.java
deleted file mode 100644
index 0dbdcb6..0000000
--- a/src/main/java/net/xolt/sbutils/util/command/NotifSoundArgumentType.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package net.xolt.sbutils.util.command;
-
-import com.mojang.brigadier.context.CommandContext;
-import net.minecraft.command.argument.EnumArgumentType;
-import net.minecraft.util.StringIdentifiable;
-import net.xolt.sbutils.config.ModConfig;
-
-public class NotifSoundArgumentType extends EnumArgumentType {
- private NotifSoundArgumentType() {
- super(StringIdentifiable.createCodec(ModConfig.NotifSound::values), ModConfig.NotifSound::values);
- }
-
- public static NotifSoundArgumentType notifSound() {
- return new NotifSoundArgumentType();
- }
-
- public static ModConfig.NotifSound getNotifSound(CommandContext> context, String id) {
- return context.getArgument(id, ModConfig.NotifSound.class);
- }
-}
diff --git a/src/main/resources/assets/sbutils/lang/en_us.json b/src/main/resources/assets/sbutils/lang/en_us.json
index 8ab6c5a..56bcc2f 100644
--- a/src/main/resources/assets/sbutils/lang/en_us.json
+++ b/src/main/resources/assets/sbutils/lang/en_us.json
@@ -210,6 +210,10 @@
"text.sbutils.config.category.enchantall": "Enchant All",
"text.sbutils.config.group.enchantAll": "Enchant All Settings",
+ "text.sbutils.config.option.enchantMode": "Enchant Mode",
+ "text.sbutils.config.option.enchantMode.tooltip": "Whether to use the built in /enchantall command, or send enchants individually.",
+ "text.sbutils.config.option.enchantMode.all": "All",
+ "text.sbutils.config.option.enchantMode.individual": "Individual",
"text.sbutils.config.option.enchantDelay": "Enchant Delay",
"text.sbutils.config.option.enchantDelay.tooltip": "The delay between sending enchant commands. (Seconds)",
"text.sbutils.config.option.cooldownFrequency": "Cooldown Frequency",
diff --git a/src/main/resources/sbutils.mixins.json b/src/main/resources/sbutils.mixins.json
index 5aee1dd..fb7ea69 100644
--- a/src/main/resources/sbutils.mixins.json
+++ b/src/main/resources/sbutils.mixins.json
@@ -8,9 +8,7 @@
"ClientPlayerEntityMixin",
"ClientPlayerInteractionManagerMixin",
"ClientPlayNetworkHandlerMixin",
- "CreativeInventoryScreenMixin",
"GameRendererMixin",
- "HandledScreenMixin",
"MessageHandlerMixin",
"MinecraftClientMixin"
],