mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-29 03:49:10 +00:00
Fix yggdrasil login protect, and rename bot agent
This commit is contained in:
@@ -18,8 +18,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.LeavesConfig;
|
||||
import org.leavesmc.leaves.LeavesLogger;
|
||||
import org.leavesmc.leaves.bot.agent.Actions;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.BotConfig;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotConfig;
|
||||
import org.leavesmc.leaves.bot.agent.Configs;
|
||||
import org.leavesmc.leaves.bot.agent.actions.CraftCustomBotAction;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
@@ -116,7 +116,7 @@ public class BotCommand extends Command {
|
||||
list.add(String.valueOf(i));
|
||||
}
|
||||
} else {
|
||||
BotAction<?> action = Actions.getForName(args[2]);
|
||||
AbstractBotAction<?> action = Actions.getForName(args[2]);
|
||||
if (action != null) {
|
||||
list.addAll(action.getArgument().tabComplete(args.length - 4));
|
||||
}
|
||||
@@ -326,9 +326,9 @@ public class BotCommand extends Command {
|
||||
|
||||
String index = args[3];
|
||||
if (index.equals("all")) {
|
||||
Set<BotAction<?>> forRemoval = new HashSet<>();
|
||||
Set<AbstractBotAction<?>> forRemoval = new HashSet<>();
|
||||
for (int i = 0; i < bot.getBotActions().size(); i++) {
|
||||
BotAction<?> action = bot.getBotActions().get(i);
|
||||
AbstractBotAction<?> action = bot.getBotActions().get(i);
|
||||
BotActionStopEvent event = new BotActionStopEvent(
|
||||
bot.getBukkitEntity(), action.getName(), action.getUUID(), BotActionStopEvent.Reason.COMMAND, sender
|
||||
);
|
||||
@@ -347,7 +347,7 @@ public class BotCommand extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
BotAction<?> action = bot.getBotActions().get(i);
|
||||
AbstractBotAction<?> action = bot.getBotActions().get(i);
|
||||
BotActionStopEvent event = new BotActionStopEvent(
|
||||
bot.getBukkitEntity(), action.getName(), action.getUUID(), BotActionStopEvent.Reason.COMMAND, sender
|
||||
);
|
||||
@@ -364,7 +364,7 @@ public class BotCommand extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
BotAction<?> action = Actions.getForName(args[2]);
|
||||
AbstractBotAction<?> action = Actions.getForName(args[2]);
|
||||
if (action == null) {
|
||||
sender.sendMessage(text("Invalid action", NamedTextColor.RED));
|
||||
return;
|
||||
@@ -382,7 +382,7 @@ public class BotCommand extends Command {
|
||||
System.arraycopy(args, 3, realArgs, 0, realArgs.length);
|
||||
}
|
||||
|
||||
BotAction<?> newAction;
|
||||
AbstractBotAction<?> newAction;
|
||||
try {
|
||||
if (action instanceof CraftCustomBotAction customBotAction) {
|
||||
newAction = customBotAction.createCraft(player, realArgs);
|
||||
@@ -427,7 +427,7 @@ public class BotCommand extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
BotConfig<?> config = Objects.requireNonNull(Configs.getConfig(args[2])).config;
|
||||
AbstractBotConfig<?> config = Objects.requireNonNull(Configs.getConfig(args[2])).config;
|
||||
if (args.length < 4) {
|
||||
config.getMessage().forEach(sender::sendMessage);
|
||||
} else {
|
||||
|
||||
@@ -50,8 +50,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.LeavesConfig;
|
||||
import org.leavesmc.leaves.LeavesLogger;
|
||||
import org.leavesmc.leaves.bot.agent.Actions;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.BotConfig;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotConfig;
|
||||
import org.leavesmc.leaves.bot.agent.Configs;
|
||||
import org.leavesmc.leaves.entity.CraftBot;
|
||||
import org.leavesmc.leaves.event.bot.BotActionScheduleEvent;
|
||||
@@ -70,11 +70,10 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
// TODO test
|
||||
public class ServerBot extends ServerPlayer {
|
||||
|
||||
private final Map<Configs<?>, BotConfig<?>> configs;
|
||||
private final List<BotAction<?>> actions;
|
||||
private final Map<Configs<?>, AbstractBotConfig<?>> configs;
|
||||
private final List<AbstractBotAction<?>> actions;
|
||||
|
||||
public boolean resume = false;
|
||||
public BotCreateState createState;
|
||||
@@ -97,7 +96,7 @@ public class ServerBot extends ServerPlayer {
|
||||
this.gameMode = new ServerBotGameMode(this);
|
||||
this.actions = new ArrayList<>();
|
||||
|
||||
ImmutableMap.Builder<Configs<?>, BotConfig<?>> configBuilder = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<Configs<?>, AbstractBotConfig<?>> configBuilder = ImmutableMap.builder();
|
||||
for (Configs<?> config : Configs.getConfigs()) {
|
||||
configBuilder.put(config, config.config.create(this));
|
||||
}
|
||||
@@ -399,7 +398,7 @@ public class ServerBot extends ServerPlayer {
|
||||
|
||||
if (!this.actions.isEmpty()) {
|
||||
ListTag actionNbt = new ListTag();
|
||||
for (BotAction<?> action : this.actions) {
|
||||
for (AbstractBotAction<?> action : this.actions) {
|
||||
actionNbt.add(action.save(new CompoundTag()));
|
||||
}
|
||||
nbt.put("actions", actionNbt);
|
||||
@@ -407,7 +406,7 @@ public class ServerBot extends ServerPlayer {
|
||||
|
||||
if (!this.configs.isEmpty()) {
|
||||
ListTag configNbt = new ListTag();
|
||||
for (BotConfig<?> config : this.configs.values()) {
|
||||
for (AbstractBotConfig<?> config : this.configs.values()) {
|
||||
configNbt.add(config.save(new CompoundTag()));
|
||||
}
|
||||
nbt.put("configs", configNbt);
|
||||
@@ -442,9 +441,9 @@ public class ServerBot extends ServerPlayer {
|
||||
ListTag actionNbt = nbt.getList("actions", 10);
|
||||
for (int i = 0; i < actionNbt.size(); i++) {
|
||||
CompoundTag actionTag = actionNbt.getCompound(i);
|
||||
BotAction<?> action = Actions.getForName(actionTag.getString("actionName"));
|
||||
AbstractBotAction<?> action = Actions.getForName(actionTag.getString("actionName"));
|
||||
if (action != null) {
|
||||
BotAction<?> newAction = action.create();
|
||||
AbstractBotAction<?> newAction = action.create();
|
||||
newAction.load(actionTag);
|
||||
this.actions.add(newAction);
|
||||
}
|
||||
@@ -509,11 +508,11 @@ public class ServerBot extends ServerPlayer {
|
||||
private void runAction() {
|
||||
if (LeavesConfig.modify.fakeplayer.canUseAction) {
|
||||
this.actions.forEach(action -> action.tryTick(this));
|
||||
this.actions.removeIf(BotAction::isCancelled);
|
||||
this.actions.removeIf(AbstractBotAction::isCancelled);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addBotAction(BotAction<?> action, CommandSender sender) {
|
||||
public boolean addBotAction(AbstractBotAction<?> action, CommandSender sender) {
|
||||
if (!LeavesConfig.modify.fakeplayer.canUseAction) {
|
||||
return false;
|
||||
}
|
||||
@@ -527,7 +526,7 @@ public class ServerBot extends ServerPlayer {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<BotAction<?>> getBotActions() {
|
||||
public List<AbstractBotAction<?>> getBotActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
@@ -537,8 +536,8 @@ public class ServerBot extends ServerPlayer {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <E> BotConfig<E> getConfig(Configs<E> config) {
|
||||
return (BotConfig<E>) Objects.requireNonNull(this.configs.get(config));
|
||||
public <E> AbstractBotConfig<E> getConfig(Configs<E> config) {
|
||||
return (AbstractBotConfig<E>) Objects.requireNonNull(this.configs.get(config));
|
||||
}
|
||||
|
||||
public <E> E getConfigValue(Configs<E> config) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class BotAction<E extends BotAction<E>> {
|
||||
public abstract class AbstractBotAction<E extends AbstractBotAction<E>> {
|
||||
|
||||
private final String name;
|
||||
private final CommandArgument argument;
|
||||
@@ -28,7 +28,7 @@ public abstract class BotAction<E extends BotAction<E>> {
|
||||
private int needWaitTick;
|
||||
private int canDoNumber;
|
||||
|
||||
public BotAction(String name, CommandArgument argument, Supplier<E> creator) {
|
||||
public AbstractBotAction(String name, CommandArgument argument, Supplier<E> creator) {
|
||||
this.name = name;
|
||||
this.argument = argument;
|
||||
this.uuid = UUID.randomUUID();
|
||||
@@ -9,20 +9,20 @@ import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class BotConfig<E> {
|
||||
public abstract class AbstractBotConfig<E> {
|
||||
|
||||
private final String name;
|
||||
private final CommandArgument argument;
|
||||
private final Supplier<BotConfig<E>> creator;
|
||||
private final Supplier<AbstractBotConfig<E>> creator;
|
||||
protected ServerBot bot;
|
||||
|
||||
public BotConfig(String name, CommandArgument argument, Supplier<BotConfig<E>> creator) {
|
||||
public AbstractBotConfig(String name, CommandArgument argument, Supplier<AbstractBotConfig<E>> creator) {
|
||||
this.name = name;
|
||||
this.argument = argument;
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public BotConfig<E> setBot(ServerBot bot) {
|
||||
public AbstractBotConfig<E> setBot(ServerBot bot) {
|
||||
this.bot = bot;
|
||||
return this;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public abstract class BotConfig<E> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BotConfig<E> create(ServerBot bot) {
|
||||
public AbstractBotConfig<E> create(ServerBot bot) {
|
||||
return this.creator.get().setBot(bot);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.Set;
|
||||
|
||||
public class Actions {
|
||||
|
||||
private static final Map<String, BotAction<?>> actions = new HashMap<>();
|
||||
private static final Map<String, AbstractBotAction<?>> actions = new HashMap<>();
|
||||
|
||||
public static void registerAll() {
|
||||
register(new AttackAction());
|
||||
@@ -33,7 +33,7 @@ public class Actions {
|
||||
register(new RotationAction());
|
||||
}
|
||||
|
||||
public static boolean register(@NotNull BotAction<?> action) {
|
||||
public static boolean register(@NotNull AbstractBotAction<?> action) {
|
||||
if (!actions.containsKey(action.getName())) {
|
||||
actions.put(action.getName(), action);
|
||||
return true;
|
||||
@@ -51,7 +51,7 @@ public class Actions {
|
||||
|
||||
@NotNull
|
||||
@Contract(pure = true)
|
||||
public static Collection<BotAction<?>> getAll() {
|
||||
public static Collection<AbstractBotAction<?>> getAll() {
|
||||
return actions.values();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static BotAction<?> getForName(String name) {
|
||||
public static AbstractBotAction<?> getForName(String name) {
|
||||
return actions.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Configs<E> {
|
||||
|
||||
private static final Map<String, Configs<?>> configs = new HashMap<>();
|
||||
@@ -18,9 +19,9 @@ public class Configs<E> {
|
||||
public static final Configs<Boolean> SPAWN_PHANTOM = register(new SpawnPhantomConfig());
|
||||
public static final Configs<Integer> SIMULATION_DISTANCE = register(new SimulationDistanceConfig());
|
||||
|
||||
public final BotConfig<E> config;
|
||||
public final AbstractBotConfig<E> config;
|
||||
|
||||
private Configs(BotConfig<E> config) {
|
||||
private Configs(AbstractBotConfig<E> config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ public class Configs<E> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static <T> Configs<T> register(BotConfig<T> botConfig) {
|
||||
private static <T> Configs<T> register(AbstractBotConfig<T> botConfig) {
|
||||
Configs<T> config = new Configs<>(botConfig);
|
||||
configs.put(botConfig.getName(), config);
|
||||
return config;
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.leavesmc.leaves.bot.agent.actions;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
@@ -11,7 +11,7 @@ import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class AbstractTimerAction<E extends AbstractTimerAction<E>> extends BotAction<E> {
|
||||
public abstract class AbstractTimerAction<E extends AbstractTimerAction<E>> extends AbstractBotAction<E> {
|
||||
|
||||
public AbstractTimerAction(String name, Supplier<E> creator) {
|
||||
super(name, CommandArgument.of(CommandArgumentType.INTEGER, CommandArgumentType.INTEGER), creator);
|
||||
|
||||
@@ -4,33 +4,33 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.agent.Actions;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.entity.botaction.BotActionType;
|
||||
import org.leavesmc.leaves.entity.botaction.LeavesBotAction;
|
||||
|
||||
public class CraftBotAction extends LeavesBotAction {
|
||||
|
||||
private final BotAction<?> handle;
|
||||
private final AbstractBotAction<?> handle;
|
||||
|
||||
public CraftBotAction(@NotNull BotAction<?> action) {
|
||||
public CraftBotAction(@NotNull AbstractBotAction<?> action) {
|
||||
super(BotActionType.valueOf(action.getName()), action.getTickDelay(), action.getCanDoNumber());
|
||||
this.handle = action;
|
||||
}
|
||||
|
||||
@Contract("_ -> new")
|
||||
@NotNull
|
||||
public static LeavesBotAction asAPICopy(BotAction<?> action) {
|
||||
public static LeavesBotAction asAPICopy(AbstractBotAction<?> action) {
|
||||
return new CraftBotAction(action);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static BotAction<?> asInternalCopy(@NotNull LeavesBotAction action) {
|
||||
BotAction<?> act = Actions.getForName(action.getActionName());
|
||||
public static AbstractBotAction<?> asInternalCopy(@NotNull LeavesBotAction action) {
|
||||
AbstractBotAction<?> act = Actions.getForName(action.getActionName());
|
||||
if (act == null) {
|
||||
throw new IllegalArgumentException("Invalid action name!");
|
||||
}
|
||||
|
||||
BotAction<?> newAction = null;
|
||||
AbstractBotAction<?> newAction = null;
|
||||
String[] args = new String[]{String.valueOf(action.getExecuteInterval()), String.valueOf(action.getRemainingExecuteTime())};
|
||||
try {
|
||||
if (act instanceof CraftCustomBotAction customBotAction) {
|
||||
@@ -48,7 +48,7 @@ public class CraftBotAction extends LeavesBotAction {
|
||||
return newAction;
|
||||
}
|
||||
|
||||
public BotAction<?> getHandle() {
|
||||
public AbstractBotAction<?> getHandle() {
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import org.leavesmc.leaves.entity.botaction.CustomBotAction;
|
||||
|
||||
public class CraftCustomBotAction extends BotAction<CraftCustomBotAction> {
|
||||
public class CraftCustomBotAction extends AbstractBotAction<CraftCustomBotAction> {
|
||||
|
||||
private final CustomBotAction realAction;
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LookAction extends BotAction<LookAction> {
|
||||
public class LookAction extends AbstractBotAction<LookAction> {
|
||||
|
||||
public LookAction() {
|
||||
super("look", CommandArgument.of(CommandArgumentType.DOUBLE, CommandArgumentType.DOUBLE, CommandArgumentType.DOUBLE), LookAction::new);
|
||||
|
||||
@@ -5,11 +5,11 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
|
||||
public class RotateAction extends BotAction<RotateAction> {
|
||||
public class RotateAction extends AbstractBotAction<RotateAction> {
|
||||
|
||||
public RotateAction() {
|
||||
super("rotate", CommandArgument.EMPTY, RotateAction::new);
|
||||
|
||||
@@ -5,14 +5,14 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RotationAction extends BotAction<RotationAction> {
|
||||
public class RotationAction extends AbstractBotAction<RotationAction> {
|
||||
|
||||
public RotationAction() {
|
||||
super("rotation", CommandArgument.of(CommandArgumentType.FLOAT, CommandArgumentType.FLOAT), RotationAction::new);
|
||||
|
||||
@@ -4,11 +4,11 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
|
||||
public class SneakAction extends BotAction<SneakAction> {
|
||||
public class SneakAction extends AbstractBotAction<SneakAction> {
|
||||
|
||||
public SneakAction() {
|
||||
super("sneak", CommandArgument.EMPTY, SneakAction::new);
|
||||
|
||||
@@ -5,11 +5,11 @@ import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
|
||||
public class SwimAction extends BotAction<SwimAction> {
|
||||
public class SwimAction extends AbstractBotAction<SwimAction> {
|
||||
|
||||
public SwimAction() {
|
||||
super("swim", CommandArgument.EMPTY, SwimAction::new);
|
||||
|
||||
@@ -4,14 +4,14 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.LeavesConfig;
|
||||
|
||||
import org.leavesmc.leaves.bot.agent.BotConfig;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotConfig;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AlwaysSendDataConfig extends BotConfig<Boolean> {
|
||||
public class AlwaysSendDataConfig extends AbstractBotConfig<Boolean> {
|
||||
|
||||
private boolean value;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.leavesmc.leaves.bot.agent.configs;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.agent.BotConfig;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotConfig;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
@@ -10,7 +10,7 @@ import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SimulationDistanceConfig extends BotConfig<Integer> {
|
||||
public class SimulationDistanceConfig extends AbstractBotConfig<Integer> {
|
||||
|
||||
public SimulationDistanceConfig() {
|
||||
super("simulation_distance", CommandArgument.of(CommandArgumentType.INTEGER).setTabComplete(0, List.of("2", "10", "<INT 2 - 32>")), SimulationDistanceConfig::new);
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.leavesmc.leaves.bot.agent.configs;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.agent.BotConfig;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotConfig;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
@@ -10,7 +10,7 @@ import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SkipSleepConfig extends BotConfig<Boolean> {
|
||||
public class SkipSleepConfig extends AbstractBotConfig<Boolean> {
|
||||
|
||||
public SkipSleepConfig() {
|
||||
super("skip_sleep", CommandArgument.of(CommandArgumentType.BOOLEAN).setTabComplete(0, List.of("true", "false")), SkipSleepConfig::new);
|
||||
|
||||
@@ -3,14 +3,14 @@ package org.leavesmc.leaves.bot.agent.configs;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.LeavesConfig;
|
||||
import org.leavesmc.leaves.bot.agent.BotConfig;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotConfig;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnPhantomConfig extends BotConfig<Boolean> {
|
||||
public class SpawnPhantomConfig extends AbstractBotConfig<Boolean> {
|
||||
|
||||
private boolean value;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.BotList;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.bot.agent.actions.CraftBotAction;
|
||||
import org.leavesmc.leaves.entity.botaction.LeavesBotAction;
|
||||
import org.leavesmc.leaves.event.bot.BotActionStopEvent;
|
||||
@@ -60,7 +60,7 @@ public class CraftBot extends CraftPlayer implements Bot {
|
||||
|
||||
@Override
|
||||
public void stopAllActions() {
|
||||
for (BotAction<?> action : this.getHandle().getBotActions()) {
|
||||
for (AbstractBotAction<?> action : this.getHandle().getBotActions()) {
|
||||
action.stop(this.getHandle(), BotActionStopEvent.Reason.PLUGIN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.leavesmc.leaves.bot.BotCreateState;
|
||||
import org.leavesmc.leaves.bot.BotList;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.Actions;
|
||||
import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotAction;
|
||||
import org.leavesmc.leaves.bot.agent.actions.CraftCustomBotAction;
|
||||
import org.leavesmc.leaves.entity.botaction.CustomBotAction;
|
||||
import org.leavesmc.leaves.event.bot.BotCreateEvent;
|
||||
@@ -66,7 +66,7 @@ public class CraftBotManager implements BotManager {
|
||||
|
||||
@Override
|
||||
public boolean unregisterCustomBotAction(String name) {
|
||||
BotAction<?> action = Actions.getForName(name);
|
||||
AbstractBotAction<?> action = Actions.getForName(name);
|
||||
if (action instanceof CraftCustomBotAction) {
|
||||
return Actions.unregister(name);
|
||||
}
|
||||
|
||||
@@ -74,13 +74,12 @@ public class LeavesMinecraftSessionService extends PaperMinecraftSessionService
|
||||
final HasJoinedMinecraftServerResponse response = client.get(url, HasJoinedMinecraftServerResponse.class);
|
||||
if (response != null && response.id() != null) {
|
||||
if (LeavesConfig.mics.yggdrasil.loginProtect && cache != null) {
|
||||
if (response.id() != cache.getId()) {
|
||||
if (!response.id().equals(cache.getId())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final GameProfile result1 = new GameProfile(response.id(), profileName);
|
||||
|
||||
if (response.properties() != null) {
|
||||
result1.getProperties().putAll(response.properties());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user