Wurst7
Wurst7 copied to clipboard
Add .tps command
Pre-suggestion checklist
- [X] I have searched existing issues and didn't find any previous issues with the same suggestion. I did find one oither issue with the same suggestion, but it was closed as stale, and didn't have much detail on how the feature would be implemented
- [X] This is only one suggestion. I understand that GitHub issues don't work well with lists.
- [X] This feature doesn't already exist in the latest version of Wurst. I've made sure my installation is up to date.
- [X] I have looked at the code and am reasonably confident that this suggestion is possible to implement.
What type of improvement are you suggesting?
Adding a new chat command.
What type of player would find this improvement useful?
Griefers, PVPers
Description
The improvement would be a chat command that when run would output the estimated server tps. It does this by calculating the delay between PacketTimeUpdates. This is useful because you can get a profile of how laggy the server is, which is useful when testing lag machines.
Here is a sample implementation (not build in wurst codebase):
import java.util.Timer;
import java.util.TimerTask;
import net.minecraft.hacks.HackClient;
import net.minecraft.hacks.module.Category;
import net.minecraft.hacks.module.Module;
import net.minecraft.network.play.server.S03PacketTimeUpdate;
public class TPS extends Module {
private double lastTime;
private double lastAge = -1d;
public double currentTps = 0;
public TPS() {
super("TPS", -1, Category.NONE);
}
@Override
public void onEventCommand(String command, String[] args) {
if (command.equalsIgnoreCase("tps")) {
displayToChat("Current server TPS is ~" + currentTps);
}
}
@Override
public void onTimeUpdatePacket(S03PacketTimeUpdate packet) {
double age = packet.getTotalWorldTime();
double time = System.currentTimeMillis();
if (lastAge == -1L) {
lastTime = time;
lastAge = age;
return;
}
double diffAge = age - lastAge;
double diffTime = time - lastTime;
lastAge = age;
lastTime = time;
double tps = diffAge / (diffTime / 1000.0);
currentTps = Math.round(tps * 100) / 100.0;
}
}
a small window would be also nice (like in the style of radar) it could display the current tps and mspt, also the time since the last packet received Maybe also add carpet-support to get server-side much more accurate data if the server has it installed
This issue has been open for a while with no recent activity. If this issue is still important to you, please add a comment within the next 7 days to keep it open. Otherwise, the issue will be automatically closed to free up time for other tasks.
Issues should be closed if:
- They are duplicates of other issues
- There is not enough demand
- They are no longer relevant
- There are not enough details