Skip to content

Commit 02245fb

Browse files
committed
Add Auto Text Hotkey Module
1 parent 6dbf255 commit 02245fb

File tree

18 files changed

+396
-0
lines changed

18 files changed

+396
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* This file is part of Apollo, licensed under the MIT License.
3+
*
4+
* Copyright (c) 2023 Moonsworth
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.lunarclient.apollo.module.autotexthotkey;
25+
26+
import com.lunarclient.apollo.module.ApolloModule;
27+
import com.lunarclient.apollo.module.ModuleDefinition;
28+
import com.lunarclient.apollo.option.ListOption;
29+
import com.lunarclient.apollo.option.Option;
30+
import io.leangen.geantyref.TypeToken;
31+
import java.util.ArrayList;
32+
import java.util.Arrays;
33+
import java.util.List;
34+
35+
/**
36+
* Represents the auto text hotkey module.
37+
*
38+
* @since 1.1.8
39+
*/
40+
@ModuleDefinition(id = "auto_text_hotkey", name = "Auto Text Hotkey")
41+
public final class AutoTextHotkeyModule extends ApolloModule {
42+
43+
/**
44+
* A list of text inputs that are blocked and cannot be used by the user.
45+
*
46+
* @since 1.1.8
47+
*/
48+
public static final ListOption<String> BLOCKED_TEXT_INPUTS = Option.<String>list()
49+
.comment("A list of text inputs that are blocked and cannot be used by the user.")
50+
.node("blocked-text-inputs").type(new TypeToken<List<String>>() {})
51+
.defaultValue(new ArrayList<>(Arrays.asList("/sellall", "/msg", "/pay")))
52+
.notifyClient().build();
53+
54+
AutoTextHotkeyModule() {
55+
this.registerOptions(
56+
AutoTextHotkeyModule.BLOCKED_TEXT_INPUTS
57+
);
58+
}
59+
60+
@Override
61+
public boolean isClientNotify() {
62+
return true;
63+
}
64+
65+
}

bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.lunarclient.apollo.example.api.commands.debug.ApolloDebugCommand;
2929
import com.lunarclient.apollo.example.api.debug.SpamPacketDebug;
3030
import com.lunarclient.apollo.example.api.listener.ApolloPlayerApiListener;
31+
import com.lunarclient.apollo.example.api.module.AutoTextHotkeyApiExample;
3132
import com.lunarclient.apollo.example.api.module.BeamApiExample;
3233
import com.lunarclient.apollo.example.api.module.BorderApiExample;
3334
import com.lunarclient.apollo.example.api.module.ChatApiExample;
@@ -75,6 +76,7 @@ public void registerCommands() {
7576

7677
@Override
7778
public void registerModuleExamples() {
79+
this.setAutoTextHotkeyExample(new AutoTextHotkeyApiExample());
7880
this.setBeamExample(new BeamApiExample());
7981
this.setBorderExample(new BorderApiExample());
8082
this.setChatExample(new ChatApiExample());
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* This file is part of Apollo, licensed under the MIT License.
3+
*
4+
* Copyright (c) 2023 Moonsworth
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.lunarclient.apollo.example.api.module;
25+
26+
import com.lunarclient.apollo.Apollo;
27+
import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample;
28+
import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule;
29+
import java.util.List;
30+
31+
public class AutoTextHotkeyApiExample extends AutoTextHotkeyExample {
32+
33+
private final AutoTextHotkeyModule autoTextHotkeyModule = Apollo.getModuleManager().getModule(AutoTextHotkeyModule.class);
34+
35+
@Override
36+
public void setBlockedTextInputs(List<String> blockedTextInputs) {
37+
this.autoTextHotkeyModule.getOptions().set(AutoTextHotkeyModule.BLOCKED_TEXT_INPUTS, blockedTextInputs);
38+
}
39+
40+
}

bukkit-example-api/src/main/resources/plugin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ api-version: 1.13
88
commands:
99
apollodebug:
1010
description: "Apollo Debug!"
11+
autotexthotkey:
12+
description: "Auto Text Hotkey!"
1113
beam:
1214
description: "Beams!"
1315
border:

bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package com.lunarclient.apollo.example;
2525

26+
import com.lunarclient.apollo.example.command.AutoTextHotkeyCommand;
2627
import com.lunarclient.apollo.example.command.BeamCommand;
2728
import com.lunarclient.apollo.example.command.BorderCommand;
2829
import com.lunarclient.apollo.example.command.ChatCommand;
@@ -51,6 +52,7 @@
5152
import com.lunarclient.apollo.example.command.TransferCommand;
5253
import com.lunarclient.apollo.example.command.VignetteCommand;
5354
import com.lunarclient.apollo.example.command.WaypointCommand;
55+
import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample;
5456
import com.lunarclient.apollo.example.module.impl.BeamExample;
5557
import com.lunarclient.apollo.example.module.impl.BorderExample;
5658
import com.lunarclient.apollo.example.module.impl.ChatExample;
@@ -89,6 +91,7 @@ public abstract class ApolloExamplePlugin extends JavaPlugin {
8991
@Getter
9092
private static ApolloExamplePlugin instance;
9193

94+
private AutoTextHotkeyExample autoTextHotkeyExample;
9295
private BeamExample beamExample;
9396
private BorderExample borderExample;
9497
private ChatExample chatExample;
@@ -137,6 +140,7 @@ public void onDisable() {
137140
}
138141

139142
private void registerCommonCommands() {
143+
this.getCommand("autotexthotkey").setExecutor(new AutoTextHotkeyCommand());
140144
this.getCommand("beam").setExecutor(new BeamCommand());
141145
this.getCommand("border").setExecutor(new BorderCommand());
142146
this.getCommand("chat").setExecutor(new ChatCommand());
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* This file is part of Apollo, licensed under the MIT License.
3+
*
4+
* Copyright (c) 2023 Moonsworth
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.lunarclient.apollo.example.command;
25+
26+
import com.lunarclient.apollo.example.ApolloExamplePlugin;
27+
import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample;
28+
import java.util.Arrays;
29+
import java.util.List;
30+
import org.bukkit.command.Command;
31+
import org.bukkit.command.CommandExecutor;
32+
import org.bukkit.command.CommandSender;
33+
import org.bukkit.entity.Player;
34+
import org.jetbrains.annotations.NotNull;
35+
36+
public class AutoTextHotkeyCommand implements CommandExecutor {
37+
38+
@Override
39+
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
40+
if (!(sender instanceof Player)) {
41+
sender.sendMessage("Player only!");
42+
return true;
43+
}
44+
45+
Player player = (Player) sender;
46+
47+
if (args.length < 2) {
48+
player.sendMessage("Usage: /autotexthotkey blockedTextInputs <inputs>");
49+
return true;
50+
}
51+
52+
AutoTextHotkeyExample autoTextHotkeyExample = ApolloExamplePlugin.getInstance().getAutoTextHotkeyExample();
53+
54+
if (args[0].equalsIgnoreCase("blockedTextInputs")) {
55+
List<String> blockedInputs = Arrays.asList(Arrays.copyOfRange(args, 1, args.length));
56+
autoTextHotkeyExample.setBlockedTextInputs(blockedInputs);
57+
58+
player.sendMessage("Blocked text inputs have been set to: " + String.join(", ", blockedInputs));
59+
return true;
60+
}
61+
62+
player.sendMessage("Usage: /autotexthotkey blockedTextInputs <inputs>");
63+
return true;
64+
}
65+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of Apollo, licensed under the MIT License.
3+
*
4+
* Copyright (c) 2023 Moonsworth
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.lunarclient.apollo.example.module.impl;
25+
26+
import com.lunarclient.apollo.example.module.ApolloModuleExample;
27+
import java.util.List;
28+
29+
public abstract class AutoTextHotkeyExample extends ApolloModuleExample {
30+
31+
public abstract void setBlockedTextInputs(List<String> blockedTextInputs);
32+
33+
}

bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.lunarclient.apollo.example.ApolloExamplePlugin;
2727
import com.lunarclient.apollo.example.ApolloExampleType;
2828
import com.lunarclient.apollo.example.json.listener.ApolloPlayerJsonListener;
29+
import com.lunarclient.apollo.example.json.module.AutoTextHotkeyJsonExample;
2930
import com.lunarclient.apollo.example.json.module.BeamJsonExample;
3031
import com.lunarclient.apollo.example.json.module.BorderJsonExample;
3132
import com.lunarclient.apollo.example.json.module.ChatJsonExample;
@@ -66,6 +67,7 @@ public void enable() {
6667

6768
@Override
6869
public void registerModuleExamples() {
70+
this.setAutoTextHotkeyExample(new AutoTextHotkeyJsonExample());
6971
this.setBeamExample(new BeamJsonExample());
7072
this.setBorderExample(new BorderJsonExample());
7173
this.setChatExample(new ChatJsonExample());
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* This file is part of Apollo, licensed under the MIT License.
3+
*
4+
* Copyright (c) 2023 Moonsworth
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.lunarclient.apollo.example.json.module;
25+
26+
import com.google.gson.JsonObject;
27+
import com.lunarclient.apollo.example.json.util.JsonPacketUtil;
28+
import com.lunarclient.apollo.example.json.util.JsonUtil;
29+
import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample;
30+
import java.util.HashMap;
31+
import java.util.List;
32+
import java.util.Map;
33+
34+
public class AutoTextHotkeyJsonExample extends AutoTextHotkeyExample {
35+
36+
@Override
37+
public void setBlockedTextInputs(List<String> blockedTextInputs) {
38+
Map<String, Object> properties = new HashMap<>();
39+
properties.put("blocked-text-inputs", blockedTextInputs);
40+
41+
JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties);
42+
JsonPacketUtil.broadcastPacket(message);
43+
}
44+
45+
}

bukkit-example-json/src/main/resources/plugin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ softdepend: [ Apollo-Bukkit ]
66
api-version: 1.13
77

88
commands:
9+
autotexthotkey:
10+
description: "Auto Text Hotkey!"
911
beam:
1012
description: "Beams!"
1113
border:

0 commit comments

Comments
 (0)