mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-29 11:59:17 +00:00
Resolve #599
This commit is contained in:
@@ -297,8 +297,36 @@ index 184d116320f0cd3e9fba47a86e94e0a8424c913f..baeeb4a0863cb37eee487b0e463fea37
|
||||
}
|
||||
|
||||
public boolean canBypassPlayerLimit(GameProfile profile) {
|
||||
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||
index f9e7532f86122a379692561a639a209a126e8bba..2412f46837e967694222730e68e7d25ac32225cf 100644
|
||||
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||
+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||
@@ -22,6 +22,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||
|
||||
@Override
|
||||
public void trackWaypoint(WaypointTransmitter waypoint) {
|
||||
+ // Leaves start - fakeplayer
|
||||
+ if (waypoint instanceof org.leavesmc.leaves.bot.ServerBot bot && !bot.getConfigValue(org.leavesmc.leaves.bot.agent.Configs.ENABLE_LOCATOR_BAR)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaves end - fakeplayer
|
||||
this.waypoints.add(waypoint);
|
||||
|
||||
for (ServerPlayer serverPlayer : this.players) {
|
||||
@@ -53,6 +58,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||
}
|
||||
|
||||
public void addPlayer(ServerPlayer player) {
|
||||
+ // Leaves start - fakeplayer
|
||||
+ if (player instanceof org.leavesmc.leaves.bot.ServerBot) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaves end - fakeplayer
|
||||
this.players.add(player);
|
||||
|
||||
for (WaypointTransmitter waypointTransmitter : this.waypoints) {
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index b257428466f25b90caadc54ce01d948287d46c26..7082b94662c23ccb688a203866df2d2feaf23917 100644
|
||||
index d0b30657d7f1caf49d2b75802c4cad192a16c71d..64445278e4c8f0f050cc1b7c12eae1364c2d5627 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1487,7 +1487,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
@@ -166,6 +166,9 @@ public final class LeavesConfig {
|
||||
}
|
||||
}
|
||||
|
||||
@GlobalConfig("enable-locator-bar")
|
||||
public boolean enableLocatorBar = false;
|
||||
|
||||
@GlobalConfig("always-send-data")
|
||||
public boolean canSendDataAlways = true;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ public class Configs<E> {
|
||||
public static final Configs<Boolean> SPAWN_PHANTOM = register(SpawnPhantomConfig.class, SpawnPhantomConfig::new);
|
||||
public static final Configs<Integer> SIMULATION_DISTANCE = register(SimulationDistanceConfig.class, SimulationDistanceConfig::new);
|
||||
public static final Configs<ServerBot.TickType> TICK_TYPE = register(TickTypeConfig.class, TickTypeConfig::new);
|
||||
public static final Configs<Boolean> ENABLE_LOCATOR_BAR = register(LocatorBarConfig.class, LocatorBarConfig::new);
|
||||
|
||||
private final Class<? extends AbstractBotConfig<E>> configClass;
|
||||
private final Supplier<? extends AbstractBotConfig<E>> configCreator;
|
||||
|
||||
@@ -40,6 +40,6 @@ public class AlwaysSendDataConfig extends AbstractBotConfig<Boolean> {
|
||||
|
||||
@Override
|
||||
public void load(@NotNull CompoundTag nbt) {
|
||||
this.setValue(nbt.getBoolean(NAME).orElseThrow());
|
||||
this.setValue(nbt.getBooleanOr(NAME, LeavesConfig.modify.fakeplayer.canSendDataAlways));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.leavesmc.leaves.bot.agent.configs;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.waypoints.ServerWaypointManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.LeavesConfig;
|
||||
import org.leavesmc.leaves.bot.agent.AbstractBotConfig;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LocatorBarConfig extends AbstractBotConfig<Boolean> {
|
||||
|
||||
public static final String NAME = "enable_locator_bar";
|
||||
|
||||
private boolean value;
|
||||
|
||||
public LocatorBarConfig() {
|
||||
super(NAME, CommandArgument.of(CommandArgumentType.BOOLEAN).setSuggestion(0, List.of("true", "false")));
|
||||
this.value = LeavesConfig.modify.fakeplayer.enableLocatorBar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Boolean value) throws IllegalArgumentException {
|
||||
this.value = value;
|
||||
ServerWaypointManager manager = this.bot.level().getWaypointManager();
|
||||
if (value) {
|
||||
manager.trackWaypoint(this.bot);
|
||||
} else {
|
||||
manager.untrackWaypoint(this.bot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompoundTag save(@NotNull CompoundTag nbt) {
|
||||
super.save(nbt);
|
||||
nbt.putBoolean(NAME, this.getValue());
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(@NotNull CompoundTag nbt) {
|
||||
this.setValue(nbt.getBooleanOr(NAME, LeavesConfig.modify.fakeplayer.enableLocatorBar));
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,6 @@ public class SimulationDistanceConfig extends AbstractBotConfig<Integer> {
|
||||
|
||||
@Override
|
||||
public void load(@NotNull CompoundTag nbt) {
|
||||
this.setValue(nbt.getInt(NAME).orElseThrow());
|
||||
this.setValue(nbt.getIntOr(NAME, this.bot.getBukkitEntity().getSimulationDistance()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,6 @@ public class SkipSleepConfig extends AbstractBotConfig<Boolean> {
|
||||
|
||||
@Override
|
||||
public void load(@NotNull CompoundTag nbt) {
|
||||
this.setValue(nbt.getBoolean(NAME).orElseThrow());
|
||||
this.setValue(nbt.getBooleanOr(NAME, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,6 @@ public class SpawnPhantomConfig extends AbstractBotConfig<Boolean> {
|
||||
|
||||
@Override
|
||||
public void load(@NotNull CompoundTag nbt) {
|
||||
this.setValue(nbt.getBoolean(NAME).orElseThrow());
|
||||
this.setValue(nbt.getBooleanOr(NAME, LeavesConfig.modify.fakeplayer.canSpawnPhantom));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@ public class TickTypeConfig extends AbstractBotConfig<ServerBot.TickType> {
|
||||
|
||||
@Override
|
||||
public void load(@NotNull CompoundTag nbt) {
|
||||
this.setValue(TICK_TYPE_ARGUMENT.parse(nbt.getString(NAME).orElseThrow()));
|
||||
this.setValue(TICK_TYPE_ARGUMENT.parse(nbt.getStringOr(NAME, LeavesConfig.modify.fakeplayer.tickType.name())));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user