Skip to content

Commit

Permalink
Fix ping for 1.70+
Browse files Browse the repository at this point in the history
  • Loading branch information
Elikill58 committed Apr 27, 2024
1 parent 360dcb4 commit 29a6553
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public List<Player> getOnlinePlayers() {

public int getPlayerPing(Player player) {
try {
if (version.isNewerOrEquals(Version.V1_20_2)) {
return pingField.getInt(getPlayerConnection(player));
if (version.isNewerOrEquals(Version.V1_17)) {
return (int) player.getClass().getDeclaredMethod("getPing").invoke(player);
} else {
return pingField.getInt(getPlayerHandle.invoke(player));
}
Expand Down Expand Up @@ -321,6 +321,8 @@ public static SpigotVersionAdapter getVersionAdapter() {
return instance = new Spigot_1_20_R2();
case "v1_20_R3":
return instance = new Spigot_1_20_R3();
case "v1_20_R4":
return instance = new Spigot_1_20_R4();
default:
return instance = new Spigot_UnknowVersion(VERSION);
}
Expand Down
15 changes: 15 additions & 0 deletions spigot/src/com/elikill58/negativity/spigot/nms/Spigot_1_20_R4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.elikill58.negativity.spigot.nms;

import com.elikill58.negativity.spigot.utils.PacketUtils;

public class Spigot_1_20_R4 extends SpigotVersionAdapter {

public Spigot_1_20_R4() {
super(PacketUtils.getProtocolVersion());
}

@Override
public String getTpsFieldName() {
return "ab";
}
}

0 comments on commit 29a6553

Please sign in to comment.