mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 02:04:51 +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"))
|
if (!(args.length > 1 && args[0].equalsIgnoreCase("debug") && args[1].equalsIgnoreCase("dump"))
|
||||||
&& !sender.hasPermission(ROOT_PERMISSION)) {
|
&& !sender.hasPermission(ROOT_PERMISSION)) {
|
||||||
String tag = Iris.instance == null ? "" : Iris.instance.getTag();
|
sendTaggedError(sender, IrisLanguage.text(
|
||||||
ComponentMessenger.sendSection(sender, tag + ChatReport.Tone.ERROR.paint(IrisLanguage.text(
|
|
||||||
IrisMessages.COMMAND_PERMISSION_DENIED,
|
IrisMessages.COMMAND_PERMISSION_DENIED,
|
||||||
MessageArgument.trusted("permission", ROOT_PERMISSION)
|
MessageArgument.trusted("permission", ROOT_PERMISSION)
|
||||||
)));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
J.aBukkit(() -> executeCommand(sender, label, args));
|
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) {
|
public List<String> tabCompleteRoot(CommandSender sender, String alias, String[] args) {
|
||||||
List<String> suggestions = args.length > 0 && args[0].equalsIgnoreCase("language")
|
List<String> suggestions = args.length > 0 && args[0].equalsIgnoreCase("language")
|
||||||
? Iris.instance.completeLanguage(sender, Arrays.copyOfRange(args, 1, args.length))
|
? 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;
|
return sender instanceof Player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The director only reports parse and execution failures here, so they get the error style. */
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
if (message != null && !message.trim().isEmpty()) {
|
if (message != null && !message.trim().isEmpty()) {
|
||||||
ComponentMessenger.sendLiteral(sender, message);
|
sendTaggedError(sender, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ final class EngineMetricsReport {
|
|||||||
totalWeight += j;
|
totalWeight += j;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String j : timings.k()) {
|
for (String metric : timings.k()) {
|
||||||
weights.put(engine.getName() + "." + j, (wallClock / totalWeight) * timings.get(j));
|
weights.put(metric, (wallClock / totalWeight) * timings.get(metric));
|
||||||
}
|
}
|
||||||
|
|
||||||
totals.put(engine.getName(), wallClock);
|
totals.put(engine.getName(), wallClock);
|
||||||
@@ -84,15 +84,19 @@ final class EngineMetricsReport {
|
|||||||
|
|
||||||
output.accept(IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_DETAILS));
|
output.accept(IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_DETAILS));
|
||||||
|
|
||||||
for (String i : weights.sortKNumber().reverse()) {
|
for (String metric : weights.sortKNumber().reverse()) {
|
||||||
String befb = C.UNDERLINE + "" + C.GREEN + "" + i.split("\\Q[\\E")[0] + C.RESET + C.GRAY + "[";
|
output.accept(timingLine(metric, weights.get(metric)));
|
||||||
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)))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
double getGeneratedPerSecond() {
|
||||||
if (engine.getPerSecondLatch().flip()) {
|
if (engine.getPerSecondLatch().flip()) {
|
||||||
double g = engine.getGenerated() - engine.getGeneratedLast().get();
|
double g = engine.getGenerated() - engine.getGeneratedLast().get();
|
||||||
|
|||||||
Reference in new issue
Block a user