Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<Boolean> BLOCK_TEXT_INPUTS = Option.<Boolean>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<String> BLOCKED_TEXT_INPUTS = Option.<String>list()
.comment("A list of text inputs that are blocked and cannot be used by the user.")
.node("blocked-text-inputs").type(new TypeToken<List<String>>() {})
.defaultValue(new ArrayList<>(Arrays.asList("/sellall", "/msg", "/pay")))
.notifyClient().build();

/**
* Block chat message text inputs.
*
* @since 1.1.8
*/
public static final SimpleOption<Boolean> BLOCK_CHAT_MESSAGE_TEXT_INPUTS = Option.<Boolean>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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> 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);
}

}
2 changes: 2 additions & 0 deletions bukkit-example-api/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ api-version: 1.13
commands:
apollodebug:
description: "Apollo Debug!"
autotexthotkey:
description: "Auto Text Hotkey!"
beam:
description: "Beams!"
border:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <inputs>");
player.sendMessage("/autotexthotkey blockChatMessageTextInputs <true/false>");
return true;
}

AutoTextHotkeyExample autoTextHotkeyExample = ApolloExamplePlugin.getInstance().getAutoTextHotkeyExample();

switch (args[0].toLowerCase()) {
case "blockedtextinputs": {
List<String> 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 <inputs>");
player.sendMessage("/autotexthotkey blockChatMessageTextInputs <true/false>");
break;
}
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -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<String> blockedTextInputs);

public abstract void setBlockChatMesssageTextInputs(boolean value);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> blockedTextInputs) {
Map<String, Object> 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<String, Object> properties = new HashMap<>();
properties.put("block-chat-message-text-inputs", value);

JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties);
JsonPacketUtil.broadcastPacket(message);
}

}
2 changes: 2 additions & 0 deletions bukkit-example-json/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ softdepend: [ Apollo-Bukkit ]
api-version: 1.13

commands:
autotexthotkey:
description: "Auto Text Hotkey!"
beam:
description: "Beams!"
border:
Expand Down
Loading