diff --git a/api/src/main/java/com/lunarclient/apollo/module/autotexthotkey/AutoTextHotkeyModule.java b/api/src/main/java/com/lunarclient/apollo/module/autotexthotkey/AutoTextHotkeyModule.java new file mode 100644 index 00000000..00db4ea6 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/autotexthotkey/AutoTextHotkeyModule.java @@ -0,0 +1,88 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.module.autotexthotkey; + +import com.lunarclient.apollo.module.ApolloModule; +import com.lunarclient.apollo.module.ModuleDefinition; +import com.lunarclient.apollo.option.ListOption; +import com.lunarclient.apollo.option.Option; +import com.lunarclient.apollo.option.SimpleOption; +import io.leangen.geantyref.TypeToken; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Represents the auto text hotkey module. + * + * @since 1.1.8 + */ +@ModuleDefinition(id = "auto_text_hotkey", name = "Auto Text Hotkey") +public final class AutoTextHotkeyModule extends ApolloModule { + + /** + * Block text inputs. + * + * @since 1.1.8 + */ + public static final SimpleOption BLOCK_TEXT_INPUTS = Option.builder() + .comment("Set to 'true' to block certain text inputs, otherwise 'false'.") + .node("block-text-inputs").type(TypeToken.get(Boolean.class)) + .defaultValue(false).notifyClient().build(); + + /** + * A list of text inputs that are blocked and cannot be used by the user. + * + * @since 1.1.8 + */ + public static final ListOption BLOCKED_TEXT_INPUTS = Option.list() + .comment("A list of text inputs that are blocked and cannot be used by the user.") + .node("blocked-text-inputs").type(new TypeToken>() {}) + .defaultValue(new ArrayList<>(Arrays.asList("/sellall", "/msg", "/pay"))) + .notifyClient().build(); + + /** + * Block chat message text inputs. + * + * @since 1.1.8 + */ + public static final SimpleOption BLOCK_CHAT_MESSAGE_TEXT_INPUTS = Option.builder() + .comment("Set to 'true' to block chat message text inputs, otherwise 'false'.") + .node("block-chat-message-text-inputs").type(TypeToken.get(Boolean.class)) + .defaultValue(false).notifyClient().build(); + + AutoTextHotkeyModule() { + this.registerOptions( + AutoTextHotkeyModule.BLOCK_TEXT_INPUTS, + AutoTextHotkeyModule.BLOCKED_TEXT_INPUTS, + AutoTextHotkeyModule.BLOCK_CHAT_MESSAGE_TEXT_INPUTS + ); + } + + @Override + public boolean isClientNotify() { + return true; + } + +} diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java index 50362c2a..5b3347e1 100644 --- a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java @@ -28,6 +28,7 @@ import com.lunarclient.apollo.example.api.commands.debug.ApolloDebugCommand; import com.lunarclient.apollo.example.api.debug.SpamPacketDebug; import com.lunarclient.apollo.example.api.listener.ApolloPlayerApiListener; +import com.lunarclient.apollo.example.api.module.AutoTextHotkeyApiExample; import com.lunarclient.apollo.example.api.module.BeamApiExample; import com.lunarclient.apollo.example.api.module.BorderApiExample; import com.lunarclient.apollo.example.api.module.ChatApiExample; @@ -75,6 +76,7 @@ public void registerCommands() { @Override public void registerModuleExamples() { + this.setAutoTextHotkeyExample(new AutoTextHotkeyApiExample()); this.setBeamExample(new BeamApiExample()); this.setBorderExample(new BorderApiExample()); this.setChatExample(new ChatApiExample()); diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/AutoTextHotkeyApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/AutoTextHotkeyApiExample.java new file mode 100644 index 00000000..c907e572 --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/AutoTextHotkeyApiExample.java @@ -0,0 +1,48 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.api.module; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; +import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule; +import com.lunarclient.apollo.option.Options; +import java.util.List; + +public class AutoTextHotkeyApiExample extends AutoTextHotkeyExample { + + private final AutoTextHotkeyModule autoTextHotkeyModule = Apollo.getModuleManager().getModule(AutoTextHotkeyModule.class); + + @Override + public void setBlockedTextInputs(List blockedTextInputs) { + Options options = this.autoTextHotkeyModule.getOptions(); + options.set(AutoTextHotkeyModule.BLOCK_TEXT_INPUTS, true); + options.set(AutoTextHotkeyModule.BLOCKED_TEXT_INPUTS, blockedTextInputs); + } + + @Override + public void setBlockChatMesssageTextInputs(boolean value) { + this.autoTextHotkeyModule.getOptions().set(AutoTextHotkeyModule.BLOCK_CHAT_MESSAGE_TEXT_INPUTS, value); + } + +} diff --git a/bukkit-example-api/src/main/resources/plugin.yml b/bukkit-example-api/src/main/resources/plugin.yml index f733a25c..c261990b 100644 --- a/bukkit-example-api/src/main/resources/plugin.yml +++ b/bukkit-example-api/src/main/resources/plugin.yml @@ -8,6 +8,8 @@ api-version: 1.13 commands: apollodebug: description: "Apollo Debug!" + autotexthotkey: + description: "Auto Text Hotkey!" beam: description: "Beams!" border: diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java index ef2413b8..996c9472 100644 --- a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java @@ -23,6 +23,7 @@ */ package com.lunarclient.apollo.example; +import com.lunarclient.apollo.example.command.AutoTextHotkeyCommand; import com.lunarclient.apollo.example.command.BeamCommand; import com.lunarclient.apollo.example.command.BorderCommand; import com.lunarclient.apollo.example.command.ChatCommand; @@ -51,6 +52,7 @@ import com.lunarclient.apollo.example.command.TransferCommand; import com.lunarclient.apollo.example.command.VignetteCommand; import com.lunarclient.apollo.example.command.WaypointCommand; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; import com.lunarclient.apollo.example.module.impl.BeamExample; import com.lunarclient.apollo.example.module.impl.BorderExample; import com.lunarclient.apollo.example.module.impl.ChatExample; @@ -89,6 +91,7 @@ public abstract class ApolloExamplePlugin extends JavaPlugin { @Getter private static ApolloExamplePlugin instance; + private AutoTextHotkeyExample autoTextHotkeyExample; private BeamExample beamExample; private BorderExample borderExample; private ChatExample chatExample; @@ -137,6 +140,7 @@ public void onDisable() { } private void registerCommonCommands() { + this.getCommand("autotexthotkey").setExecutor(new AutoTextHotkeyCommand()); this.getCommand("beam").setExecutor(new BeamCommand()); this.getCommand("border").setExecutor(new BorderCommand()); this.getCommand("chat").setExecutor(new ChatCommand()); diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/AutoTextHotkeyCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/AutoTextHotkeyCommand.java new file mode 100644 index 00000000..e99fc825 --- /dev/null +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/AutoTextHotkeyCommand.java @@ -0,0 +1,81 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.command; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; +import java.util.Arrays; +import java.util.List; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class AutoTextHotkeyCommand implements CommandExecutor { + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage("Player only!"); + return true; + } + + Player player = (Player) sender; + + if (args.length < 2) { + player.sendMessage("/autotexthotkey blockedTextInputs "); + player.sendMessage("/autotexthotkey blockChatMessageTextInputs "); + return true; + } + + AutoTextHotkeyExample autoTextHotkeyExample = ApolloExamplePlugin.getInstance().getAutoTextHotkeyExample(); + + switch (args[0].toLowerCase()) { + case "blockedtextinputs": { + List blockedInputs = Arrays.asList(Arrays.copyOfRange(args, 1, args.length)); + autoTextHotkeyExample.setBlockedTextInputs(blockedInputs); + + player.sendMessage("Blocked text inputs have been set to: " + String.join(", ", blockedInputs)); + break; + } + + case "blockchatmessagetextinputs": { + boolean value = Boolean.parseBoolean(args[1]); + autoTextHotkeyExample.setBlockChatMesssageTextInputs(value); + + player.sendMessage("Block chat message text inputs has been set to " + value); + break; + } + + default: { + player.sendMessage("/autotexthotkey blockedTextInputs "); + player.sendMessage("/autotexthotkey blockChatMessageTextInputs "); + break; + } + } + + return true; + } +} diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/AutoTextHotkeyExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/AutoTextHotkeyExample.java new file mode 100644 index 00000000..31b3cbbc --- /dev/null +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/AutoTextHotkeyExample.java @@ -0,0 +1,35 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.module.impl; + +import com.lunarclient.apollo.example.module.ApolloModuleExample; +import java.util.List; + +public abstract class AutoTextHotkeyExample extends ApolloModuleExample { + + public abstract void setBlockedTextInputs(List blockedTextInputs); + + public abstract void setBlockChatMesssageTextInputs(boolean value); + +} diff --git a/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java index 460b610b..e5c90754 100644 --- a/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java @@ -26,6 +26,7 @@ import com.lunarclient.apollo.example.ApolloExamplePlugin; import com.lunarclient.apollo.example.ApolloExampleType; import com.lunarclient.apollo.example.json.listener.ApolloPlayerJsonListener; +import com.lunarclient.apollo.example.json.module.AutoTextHotkeyJsonExample; import com.lunarclient.apollo.example.json.module.BeamJsonExample; import com.lunarclient.apollo.example.json.module.BorderJsonExample; import com.lunarclient.apollo.example.json.module.ChatJsonExample; @@ -66,6 +67,7 @@ public void enable() { @Override public void registerModuleExamples() { + this.setAutoTextHotkeyExample(new AutoTextHotkeyJsonExample()); this.setBeamExample(new BeamJsonExample()); this.setBorderExample(new BorderJsonExample()); this.setChatExample(new ChatJsonExample()); diff --git a/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/AutoTextHotkeyJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/AutoTextHotkeyJsonExample.java new file mode 100644 index 00000000..e1bd38f9 --- /dev/null +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/AutoTextHotkeyJsonExample.java @@ -0,0 +1,55 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.json.module; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class AutoTextHotkeyJsonExample extends AutoTextHotkeyExample { + + @Override + public void setBlockedTextInputs(List blockedTextInputs) { + Map properties = new HashMap<>(); + properties.put("block-text-inputs", true); + properties.put("blocked-text-inputs", blockedTextInputs); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties); + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void setBlockChatMesssageTextInputs(boolean value) { + Map properties = new HashMap<>(); + properties.put("block-chat-message-text-inputs", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties); + JsonPacketUtil.broadcastPacket(message); + } + +} diff --git a/bukkit-example-json/src/main/resources/plugin.yml b/bukkit-example-json/src/main/resources/plugin.yml index 5e1e6ad2..719711d2 100644 --- a/bukkit-example-json/src/main/resources/plugin.yml +++ b/bukkit-example-json/src/main/resources/plugin.yml @@ -6,6 +6,8 @@ softdepend: [ Apollo-Bukkit ] api-version: 1.13 commands: + autotexthotkey: + description: "Auto Text Hotkey!" beam: description: "Beams!" border: diff --git a/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java index 0b99292c..97074a1b 100644 --- a/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java @@ -26,6 +26,7 @@ import com.lunarclient.apollo.example.ApolloExamplePlugin; import com.lunarclient.apollo.example.ApolloExampleType; import com.lunarclient.apollo.example.proto.listener.ApolloPlayerProtoListener; +import com.lunarclient.apollo.example.proto.module.AutoTextHotkeyProtoExample; import com.lunarclient.apollo.example.proto.module.BeamProtoExample; import com.lunarclient.apollo.example.proto.module.BorderProtoExample; import com.lunarclient.apollo.example.proto.module.ChatProtoExample; @@ -66,6 +67,7 @@ public void enable() { @Override public void registerModuleExamples() { + this.setAutoTextHotkeyExample(new AutoTextHotkeyProtoExample()); this.setBeamExample(new BeamProtoExample()); this.setBorderExample(new BorderProtoExample()); this.setChatExample(new ChatProtoExample()); diff --git a/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/AutoTextHotkeyProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/AutoTextHotkeyProtoExample.java new file mode 100644 index 00000000..56776538 --- /dev/null +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/AutoTextHotkeyProtoExample.java @@ -0,0 +1,63 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.proto.module; + +import com.google.protobuf.ListValue; +import com.google.protobuf.Value; +import com.lunarclient.apollo.configurable.v1.ConfigurableSettings; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class AutoTextHotkeyProtoExample extends AutoTextHotkeyExample { + + @Override + public void setBlockedTextInputs(List blockedTextInputs) { + ListValue listValue = ListValue.newBuilder().addAllValues( + blockedTextInputs.stream() + .map(input -> Value.newBuilder().setStringValue(input).build()) + .collect(Collectors.toList()) + ).build(); + + Map properties = new HashMap<>(); + properties.put("block-text-inputs", Value.newBuilder().setBoolValue(true).build()); + properties.put("blocked-text-inputs", Value.newBuilder().setListValue(listValue).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("auto_text_hotkey", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + + @Override + public void setBlockChatMesssageTextInputs(boolean value) { + Map properties = new HashMap<>(); + properties.put("block-chat-message-text-inputs", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("auto_text_hotkey", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + +} diff --git a/bukkit-example-proto/src/main/resources/plugin.yml b/bukkit-example-proto/src/main/resources/plugin.yml index d4142aea..53737488 100644 --- a/bukkit-example-proto/src/main/resources/plugin.yml +++ b/bukkit-example-proto/src/main/resources/plugin.yml @@ -6,6 +6,8 @@ softdepend: [ Apollo-Bukkit ] api-version: 1.13 commands: + autotexthotkey: + description: "Auto Text Hotkey!" beam: description: "Beams!" border: diff --git a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java index f2be6e51..117e952d 100644 --- a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java +++ b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java @@ -29,6 +29,7 @@ import com.lunarclient.apollo.listener.ApolloWorldListener; import com.lunarclient.apollo.loader.PlatformPlugin; import com.lunarclient.apollo.module.ApolloModuleManagerImpl; +import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule; import com.lunarclient.apollo.module.beam.BeamModule; import com.lunarclient.apollo.module.beam.BeamModuleImpl; import com.lunarclient.apollo.module.border.BorderModule; @@ -123,6 +124,7 @@ public void onEnable() { new ApolloWorldListener(this.plugin); ((ApolloModuleManagerImpl) Apollo.getModuleManager()) + .addModule(AutoTextHotkeyModule.class) .addModule(BeamModule.class, new BeamModuleImpl()) .addModule(BorderModule.class, new BorderModuleImpl()) .addModule(ChatModule.class, new ChatModuleImpl()) diff --git a/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java b/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java index d5c8fb66..44fe00b0 100644 --- a/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java +++ b/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java @@ -28,6 +28,7 @@ import com.lunarclient.apollo.listener.ApolloPlayerListener; import com.lunarclient.apollo.loader.PlatformPlugin; import com.lunarclient.apollo.module.ApolloModuleManagerImpl; +import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule; import com.lunarclient.apollo.module.beam.BeamModule; import com.lunarclient.apollo.module.beam.BeamModuleImpl; import com.lunarclient.apollo.module.border.BorderModule; @@ -108,6 +109,7 @@ public void onEnable() { ApolloManager.bootstrap(this); ((ApolloModuleManagerImpl) Apollo.getModuleManager()) + .addModule(AutoTextHotkeyModule.class) .addModule(BeamModule.class, new BeamModuleImpl()) .addModule(BorderModule.class, new BorderModuleImpl()) .addModule(ChatModule.class, new ChatModuleImpl()) diff --git a/docs/developers/modules/_meta.json b/docs/developers/modules/_meta.json index 8d24bb7e..1ee0d74d 100644 --- a/docs/developers/modules/_meta.json +++ b/docs/developers/modules/_meta.json @@ -1,4 +1,5 @@ { + "autotexthotkey": "Auto Text Hotkey", "beam": "Beam", "border": "Border", "chat": "Chat", diff --git a/docs/developers/modules/autotexthotkey.mdx b/docs/developers/modules/autotexthotkey.mdx new file mode 100644 index 00000000..c154f013 --- /dev/null +++ b/docs/developers/modules/autotexthotkey.mdx @@ -0,0 +1,123 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + +# Auto Text Hotkey Module + +## Overview + +The auto text hotkey module allows you to control the auto text hotkey mod inside Lunar Client. + +- Ability to prevent specific commands & chat messages from being used as hotkeys. +- Ability to prevent all chat messages from being used as hotkeys. + +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Set Blocked Text Inputs + +```java +public void setBlockedTextInputs(List blockedTextInputs) { + Options options = this.autoTextHotkeyModule.getOptions(); + options.set(AutoTextHotkeyModule.BLOCK_TEXT_INPUTS, true); + options.set(AutoTextHotkeyModule.BLOCKED_TEXT_INPUTS, blockedTextInputs); +} +``` + +### Block Chat Message Text Inputs + +```java +public void setBlockChatMesssageTextInputs(boolean value) { + this.autoTextHotkeyModule.getOptions().set(AutoTextHotkeyModule.BLOCK_CHAT_MESSAGE_TEXT_INPUTS, value); +} +``` + + + + + +### Set Blocked Text Inputs + +```java +public void setBlockedTextInputs(List blockedTextInputs) { + ListValue listValue = ListValue.newBuilder().addAllValues( + blockedTextInputs.stream() + .map(input -> Value.newBuilder().setStringValue(input).build()) + .collect(Collectors.toList()) + ).build(); + + Map properties = new HashMap<>(); + properties.put("block-text-inputs", Value.newBuilder().setBoolValue(true).build()); + properties.put("blocked-text-inputs", Value.newBuilder().setListValue(listValue).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("auto_text_hotkey", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + +### Block Chat Message Text Inputs + +```java +public void setBlockChatMesssageTextInputs(boolean value) { + Map properties = new HashMap<>(); + properties.put("block-chat-message-text-inputs", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("auto_text_hotkey", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + + + + + +### Set Blocked Text Inputs + +```java +public void setBlockedTextInputs(List blockedTextInputs) { + Map properties = new HashMap<>(); + properties.put("block-text-inputs", true); + properties.put("blocked-text-inputs", blockedTextInputs); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Block Chat Message Text Inputs + +```java +public void setBlockChatMesssageTextInputs(boolean value) { + Map properties = new HashMap<>(); + properties.put("block-chat-message-text-inputs", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + + + + + +## Available options + +- __`BLOCK_TEXT_INPUTS`__ + - Whether to use blocked text inputs in the `BLOCKED_TEXT_INPUTS` option. + - Values + - Type: `Boolean` + - Default: `false` + +- __`BLOCKED_TEXT_INPUTS`__ + - A list of text inputs that are blocked and cannot be used by the user. + - Values + - Type: `List` + - Default: `["/sellall", "/msg", "/pay"]` + +- __`BLOCK_CHAT_MESSAGE_TEXT_INPUTS`__ + - Whether to block all chat messages from being used as hotkeys. + - Values + - Type: `Boolean` + - Default: `false` diff --git a/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java b/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java index 59c409da..33ede13d 100644 --- a/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java +++ b/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java @@ -28,6 +28,7 @@ import com.lunarclient.apollo.command.impl.LunarClientCommand; import com.lunarclient.apollo.listener.ApolloPlayerListener; import com.lunarclient.apollo.module.ApolloModuleManagerImpl; +import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule; import com.lunarclient.apollo.module.beam.BeamModule; import com.lunarclient.apollo.module.beam.BeamModuleImpl; import com.lunarclient.apollo.module.border.BorderModule; @@ -165,6 +166,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) { ApolloManager.bootstrap(this); ((ApolloModuleManagerImpl) Apollo.getModuleManager()) + .addModule(AutoTextHotkeyModule.class) .addModule(BeamModule.class, new BeamModuleImpl()) .addModule(BorderModule.class, new BorderModuleImpl()) .addModule(ChatModule.class, new ChatModuleImpl())