Fixed: Исправлена ошибка в кэлбеках
- Исправлено деление на 0 в команде tps
This commit is contained in:
@@ -17,11 +17,21 @@ public class TpsCommand extends Command {
|
||||
|
||||
long innerCoreSum = 0;
|
||||
for(long time : innerCoreTimes)
|
||||
innerCoreSum += Math.min(20, 1000 / time);
|
||||
if(time != 0)
|
||||
innerCoreSum += Math.min(20, 1000 / time);
|
||||
else{
|
||||
commandSender.sendMessage("Not enough information");
|
||||
return true;
|
||||
}
|
||||
|
||||
long nukkitSum = 0;
|
||||
for(long time : nukkitTimes)
|
||||
nukkitSum += Math.min(20, 1000 / time);
|
||||
if(time != 0)
|
||||
nukkitSum += Math.min(20, 1000 / time);
|
||||
else{
|
||||
commandSender.sendMessage("Not enough information");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(innerCoreSum != 0 && nukkitSum != 0) {
|
||||
commandSender.sendMessage("Inner core tps: " + (innerCoreSum / 20.0f));
|
||||
|
||||
@@ -66,9 +66,11 @@ public class Callback {
|
||||
Scriptable parent;
|
||||
if (funcs != null) {
|
||||
long profilingNanos = !profilingEnabled || isTick ? 0 : System.nanoTime();
|
||||
for (CallbackFunction callback : funcs) {
|
||||
parent = callback.function.getParentScope();
|
||||
callback.function.call(ctx, parent, parent, params);
|
||||
synchronized (funcs) {
|
||||
for (CallbackFunction callback : funcs) {
|
||||
parent = callback.function.getParentScope();
|
||||
callback.function.call(ctx, parent, parent, params);
|
||||
}
|
||||
}
|
||||
if (profilingNanos != 0) {
|
||||
profilingNanos = System.nanoTime() - profilingNanos;
|
||||
@@ -96,13 +98,15 @@ public class Callback {
|
||||
if (profilingEnabled && !isTick) {
|
||||
result.add(() -> profilingNanos.set(System.nanoTime()));
|
||||
}
|
||||
for (CallbackFunction func0 : funcs) {
|
||||
result.add(new Runnable() {
|
||||
public void run() {
|
||||
Scriptable parent = func0.function.getParentScope();
|
||||
func0.function.call(Compiler.assureContextForCurrentThread(), parent, parent, params);
|
||||
}
|
||||
});
|
||||
synchronized (funcs) {
|
||||
for (CallbackFunction func0 : funcs) {
|
||||
result.add(new Runnable() {
|
||||
public void run() {
|
||||
Scriptable parent = func0.function.getParentScope();
|
||||
func0.function.call(Compiler.assureContextForCurrentThread(), parent, parent, params);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (profilingNanos.get() != 0) {
|
||||
result.add(() -> Logger.debug("Profiling/" + name, funcs.size() + " functions in "
|
||||
|
||||
Reference in New Issue
Block a user