mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 08:14:45 +00:00
Fix metrics details and theme command errors
- Stop iris metrics crashing once a world has generation timings - Tag and color director parse and execution errors
This commit is contained in:
1 parent
1144032d62
commit
8531fcf103
2 files changed
+21
-12
No files matched your search
@@ -191,17 +191,21 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
|
||||
}
|
||||
if (!(args.length > 1 && args[0].equalsIgnoreCase("debug") && args[1].equalsIgnoreCase("dump"))
|
||||
&& !sender.hasPermission(ROOT_PERMISSION)) {
|
||||
String tag = Iris.instance == null ? "" : Iris.instance.getTag();
|
||||
ComponentMessenger.sendSection(sender, tag + ChatReport.Tone.ERROR.paint(IrisLanguage.text(
|
||||
sendTaggedError(sender, IrisLanguage.text(
|
||||
IrisMessages.COMMAND_PERMISSION_DENIED,
|
||||
MessageArgument.trusted("permission", ROOT_PERMISSION)
|
||||
)));
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
J.aBukkit(() -> executeCommand(sender, label, args));
|
||||
}
|
||||
|
||||
private static void sendTaggedError(CommandSender sender, String message) {
|
||||
String tag = Iris.instance == null ? "" : Iris.instance.getTag();
|
||||
ComponentMessenger.sendSection(sender, tag + ChatReport.Tone.ERROR.paint(message));
|
||||
}
|
||||
|
||||
public List<String> tabCompleteRoot(CommandSender sender, String alias, String[] args) {
|
||||
List<String> suggestions = args.length > 0 && args[0].equalsIgnoreCase("language")
|
||||
? Iris.instance.completeLanguage(sender, Arrays.copyOfRange(args, 1, args.length))
|
||||
@@ -351,10 +355,11 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
|
||||
return sender instanceof Player;
|
||||
}
|
||||
|
||||
/** The director only reports parse and execution failures here, so they get the error style. */
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (message != null && !message.trim().isEmpty()) {
|
||||
ComponentMessenger.sendLiteral(sender, message);
|
||||
sendTaggedError(sender, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ final class EngineMetricsReport {
|
||||
totalWeight += j;
|
||||
}
|
||||
|
||||
for (String j : timings.k()) {
|
||||
weights.put(engine.getName() + "." + j, (wallClock / totalWeight) * timings.get(j));
|
||||
for (String metric : timings.k()) {
|
||||
weights.put(metric, (wallClock / totalWeight) * timings.get(metric));
|
||||
}
|
||||
|
||||
totals.put(engine.getName(), wallClock);
|
||||
@@ -84,15 +84,19 @@ final class EngineMetricsReport {
|
||||
|
||||
output.accept(IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_DETAILS));
|
||||
|
||||
for (String i : weights.sortKNumber().reverse()) {
|
||||
String befb = C.UNDERLINE + "" + C.GREEN + "" + i.split("\\Q[\\E")[0] + C.RESET + C.GRAY + "[";
|
||||
String num = C.GOLD + i.split("\\Q[\\E")[1].split("]")[0] + C.RESET + C.GRAY + "].";
|
||||
String afb = C.ITALIC + "" + C.AQUA + i.split("\\Q]\\E")[1].substring(1) + C.RESET + C.GRAY;
|
||||
|
||||
output.accept(IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_MESSAGE, MessageArgument.untrusted("befb", String.valueOf(befb)), MessageArgument.untrusted("num", String.valueOf(num)), MessageArgument.untrusted("afb", String.valueOf(afb)), MessageArgument.untrusted("value", String.valueOf(Form.pc(weights.get(i), 0)))));
|
||||
for (String metric : weights.sortKNumber().reverse()) {
|
||||
output.accept(timingLine(metric, weights.get(metric)));
|
||||
}
|
||||
}
|
||||
|
||||
private static String timingLine(String metric, double share) {
|
||||
return IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_MESSAGE,
|
||||
MessageArgument.untrusted("befb", C.AQUA + metric + C.GRAY),
|
||||
MessageArgument.untrusted("num", ""),
|
||||
MessageArgument.untrusted("afb", ""),
|
||||
MessageArgument.untrusted("value", Form.pc(share, 0)));
|
||||
}
|
||||
|
||||
double getGeneratedPerSecond() {
|
||||
if (engine.getPerSecondLatch().flip()) {
|
||||
double g = engine.getGenerated() - engine.getGeneratedLast().get();
|
||||
|
||||
Reference in new issue
Block a user