Skip to content

Commit

Permalink
clone locations and disable modules before clear on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 21, 2024
1 parent eba4c45 commit 8285c13
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ public void enable() {
for (Player player : plugin.getServer().getOnlinePlayers()) {
player.getScheduler().run(plugin, checkFlight -> {
if (!player.isGliding()) return;
Location currentLocation = player.getLocation();
Location currentLocation = player.getLocation().clone();
Location lastLocation = LAST_GLIDE_POS.getIfPresent(player.getUniqueId());
if (lastLocation == null)
lastLocation = currentLocation;
@@ -112,7 +112,7 @@ private double getFlatDistanceInChunks(Chunk chunk, Location location) {
@EventHandler(priority = EventPriority.LOW)
private void onChunkLoad(ChunkLoadEvent event) {
for (Player player : event.getWorld().getPlayers()) {
if (this.getFlatDistanceInChunks(event.getChunk(), player.getLocation()) < player.getViewDistance()) {
if (this.getFlatDistanceInChunks(event.getChunk(), player.getLocation().clone()) < player.getViewDistance()) {
if (event.isNewChunk()) {
PLAYERS_NEAR_NEW_CHUNKS.add(player.getUniqueId());
} else {
Original file line number Diff line number Diff line change
@@ -63,10 +63,11 @@ public interface AnarchyExploitFixesModule {
HashSet<AnarchyExploitFixesModule> modules = new HashSet<>();

static void reloadModules() {
modules.clear();
AnarchyExploitFixes plugin = AnarchyExploitFixes.getInstance();
boolean protocolLibIsInstalled = unregisterPacketListeners(plugin);
plugin.getServer().getScheduler().cancelTasks(plugin);
HandlerList.unregisterAll(plugin);
modules.clear();

/*
Bedrock
@@ -218,7 +219,6 @@ static void reloadModules() {
/*
ProtocolLib
*/
boolean protocolLibIsInstalled = unregisterPacketListeners(plugin);

modules.add(new NoComModule());
modules.add(new AntiBoatFlyModule());
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ public boolean shouldEnable() {
public void run() {
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (player.isGliding()) {
Location currentLocation = player.getLocation();
Location currentLocation = player.getLocation().clone();
Location lastLocation = LAST_GLIDE_POS.getIfPresent(player.getUniqueId());
if (lastLocation == null) lastLocation = currentLocation;
PLAYER_SPEEDS_INTERVAL.put(player.getUniqueId(), LocationUtil.getFlatDistance(lastLocation, currentLocation) / checkIntervalTicks);
@@ -103,7 +103,7 @@ private double getFlatDistanceInChunks(Chunk chunk, Location location) {
@EventHandler(priority = EventPriority.LOW)
private void onChunkLoad(ChunkLoadEvent event) {
for (Player player : event.getWorld().getPlayers()) {
if (this.getFlatDistanceInChunks(event.getChunk(), player.getLocation()) < player.getViewDistance()) {
if (this.getFlatDistanceInChunks(event.getChunk(), player.getLocation().clone()) < player.getViewDistance()) {
if (event.isNewChunk()) {
PLAYERS_NEAR_NEW_CHUNKS.add(player.getUniqueId());
} else {

0 comments on commit 8285c13

Please sign in to comment.