Skip to content

Commit

Permalink
Decrease keepalive interval and autoupdate config (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Axionize authored Oct 26, 2024
1 parent 233a1e0 commit ac5175b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void onPlayerQuit(UUID uuid) {
return;

if (playerData.isInCombat())
playerData.quitCombat(true);
playerData.quitCombat();

PlayerDataManager.removePlayerData(uuid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.List;

public class PingReceiveListener extends PacketListenerAbstract {
// TODO supplement our own ping calculations with over keepalive sent by the server with

@Override
public void onPacketSend(PacketSendEvent event) {
if (!Base.INSTANCE.getConfigManager().isToggled()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void reloadConfig() {
try {
if (!configFile.exists()) {
Base.INSTANCE.saveDefaultConfig();
} else {
updateConfig();
}
yamlConfig.load();
config = yamlConfig.getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,18 +296,16 @@ public void updateCombat() {
CombatManager.addPlayer(uuid);
}

public void quitCombat(boolean cancelTask) {
if (cancelTask)
combatTask.cancel();

public void quitCombat() {
combatTask.cancel(); // should do nothing
combatTask = null;
CombatManager.removePlayer(uuid);
}

@NotNull
private AbstractTaskHandle newCombatTask() {
return Base.INSTANCE.getScheduler().runTaskLaterAsynchronously(
() -> quitCombat(false), Base.INSTANCE.getConfigManager().getCombatTimer());
this::quitCombat, Base.INSTANCE.getConfigManager().getCombatTimer());
}

public ClientVersion getClientVersion() {
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#########################################

# Do not modify!
config_version: 3
config_version: 4

# Plugin enabled state
# Toggleable using /knockbacksync toggle
Expand All @@ -18,7 +18,7 @@ notify_updates: true
# Disabling this may lead to inaccuracies in calculations
runnable:
enabled: true # Runnable enabled state
interval: 20 # The interval in ticks between sending out pings to players
interval: 5 # The interval in ticks between sending out pings to players
combat_timer: 30 # The timer in ticks before being considered out of combat

# The minimum change in ping required for it to be considered a lag spike.
Expand Down

0 comments on commit ac5175b

Please sign in to comment.