Feat: ItemContainer больше не дудосит лог ошибками & улучшена реализация команды tps

This commit is contained in:
Reider745
2024-09-02 17:19:28 +03:00
parent decf61d1a1
commit d6f4555763
2 changed files with 11 additions and 9 deletions
@@ -23,25 +23,27 @@ public class TpsCommand extends Command {
long innerCoreSum = 0; long innerCoreSum = 0;
for(long time : innerCoreTimes) for(long time : innerCoreTimes)
if(time != 0) { if(time != 0) {
innerCoreSum += Math.min(20, 1000 / time); innerCoreSum += time;
aboba1++; aboba1++;
} }
long nukkitSum = 0; long nukkitSum = 0;
for(long time : nukkitTimes) for(long time : nukkitTimes)
if(time != 0) { if(time != 0) {
nukkitSum += Math.min(20, 1000 / time); nukkitSum += time;
aboba2++; aboba2++;
} }
if(innerCoreSum != 0) if(innerCoreSum != 0) {
commandSender.sendMessage("Inner core tps: " + (innerCoreSum / aboba1)); final float avgTime = innerCoreSum / aboba1;
else commandSender.sendMessage("Inner core tps: " + Math.min(20, 1000 / avgTime) + ", ms: "+avgTime);
}else
commandSender.sendMessage("Inner core tps: 20.0"); commandSender.sendMessage("Inner core tps: 20.0");
if(nukkitSum != 0) if(nukkitSum != 0) {
commandSender.sendMessage("Nukkit tps: " + (nukkitSum / aboba2)); final float avgTime = nukkitSum / aboba1;
else commandSender.sendMessage("Nukkit tps: " + Math.min(20, 1000 / avgTime) + ", ms: "+avgTime);
}else
commandSender.sendMessage("Nukkit tps: 20.0"); commandSender.sendMessage("Nukkit tps: 20.0");
}catch (Exception e){ }catch (Exception e){
commandSender.sendMessage("Not enough information"); commandSender.sendMessage("Not enough information");
@@ -529,7 +529,7 @@ public class ItemContainer implements WorkbenchField, ObjectSaverRegistry.IHashS
networkEntity.send("bindings", new JSONObject(dirtyBindingsMap)); networkEntity.send("bindings", new JSONObject(dirtyBindingsMap));
dirtyBindingsMap.clear(); dirtyBindingsMap.clear();
}catch (Exception e){ }catch (Exception e){
Logger.error(dirtyBindingsMap.toString(), e); //Logger.error(dirtyBindingsMap.toString(), e);
} }
} }
} }