feat,refactor: add useCorePlaceBlock in config and refactor default config

This commit is contained in:
Chayapak 2024-11-17 17:01:09 +07:00
parent a942cfd557
commit 71d9caa0db
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA
3 changed files with 25 additions and 12 deletions

View file

@ -169,6 +169,7 @@ public class Configuration {
public boolean creayun = false; public boolean creayun = false;
public String serverName; public String serverName;
public boolean useCore = true; public boolean useCore = true;
public boolean useCorePlaceBlock = false;
public boolean useChat = false; public boolean useChat = false;
public boolean coreCommandSpy = false; public boolean coreCommandSpy = false;
public boolean resolveSRV = true; public boolean resolveSRV = true;

View file

@ -171,6 +171,11 @@ public class CorePlugin extends PositionPlugin.Listener {
if (!ready || command.length() > 32767) return; if (!ready || command.length() > 32767) return;
if (bot.options.useCore) { if (bot.options.useCore) {
if (bot.options.useCorePlaceBlock) {
runPlaceBlock(command);
return;
}
if (isRateLimited() && hasRateLimit()) return; if (isRateLimited() && hasRateLimit()) return;
forceRun(command); forceRun(command);
@ -185,6 +190,11 @@ public class CorePlugin extends PositionPlugin.Listener {
public CompletableFuture<Component> runTracked (String command) { public CompletableFuture<Component> runTracked (String command) {
if (!bot.options.useCore) return null; if (!bot.options.useCore) return null;
if (bot.options.useCorePlaceBlock) {
runPlaceBlock(command);
return null;
}
final Vector3i coreBlock = block; final Vector3i coreBlock = block;
run(command); run(command);

View file

@ -131,7 +131,8 @@ bots:
# username - optional, if not specified it will just use a random username # username - optional, if not specified it will just use a random username
# creayun - defaults to false # creayun - defaults to false
# serverName - name it whatever you like, it will be used as server name in trusted broadcast and in console # serverName - name it whatever you like, it will be used as server name in trusted broadcast and in console
# useCore - if enabled it just sends the command using chat instead of using core. recommended to enable useChat too when this is enabled # useCore - if enabled it just sends the command using chat instead of using core. recommended to enable useChat too when this is disabled
# useCorePlaceBlock - uses the place block core instead of the main core. only used if useCore is enabled
# useChat - when the bot tellraws it will chat instead of using the core to run tellraw # useChat - when the bot tellraws it will chat instead of using the core to run tellraw
# coreCommandSpy - set to true if server supports enabling player's commandspy though command block # coreCommandSpy - set to true if server supports enabling player's commandspy though command block
# resolveSRV - whether to resolve SRV records on the server. the notchian minecraft doesn't resolve them # resolveSRV - whether to resolve SRV records on the server. the notchian minecraft doesn't resolve them
@ -140,22 +141,23 @@ bots:
- host: 'localhost' - host: 'localhost'
port: 25565 port: 25565
username: 'ChomeNS_Bot'
creayun: false
serverName: 'Localhost' serverName: 'Localhost'
useCore: true
useChat: false
coreCommandSpy: false
resolveSRV: true
reconnectDelay: 2000 reconnectDelay: 2000
removeNamespaces: false
chatQueueDelay: 125 chatQueueDelay: 125
coreRateLimit: # or with the optional ones
limit: 10
reset: 1000 # in milliseconds
# or without the optional ones:
# - host: 'localhost' # - host: 'localhost'
# port: 25565 # port: 25565
# username: 'ChomeNS_Bot'
# creayun: false
# serverName: 'Localhost' # serverName: 'Localhost'
# useCore: true
# useCorePlaceBlock: false
# useChat: false
# coreCommandSpy: false
# resolveSRV: true
# reconnectDelay: 2000 # reconnectDelay: 2000
# removeNamespaces: false
# chatQueueDelay: 125 # chatQueueDelay: 125
# coreRateLimit:
# limit: 10
# reset: 1000 # in milliseconds