[ci skip] Put mappings util in a separate class to the stacktrace deobfuscator (#6230)

This commit is contained in:
Jason Penilla
2021-07-19 19:22:18 -07:00
parent d3ba412286
commit 4ca56ff079
2 changed files with 119 additions and 95 deletions

View File

@@ -130,16 +130,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.maxDuration = maxRunTime;
this.entryCondition = requiredMemoryState;
+ // Paper start - configurable behavior tick rate and timings
+ Map<String, io.papermc.paper.util.StacktraceDeobfuscator.ClassMapping> mappings = io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.mappings();
+ String key;
+ String key = this.getClass().getSimpleName();
+ final var mappings = io.papermc.paper.util.ObfHelper.INSTANCE.mappings();
+ if (mappings != null) {
+ key = mappings.get(getClass().getName()).mojangName();
+ int lastSeparator = key.lastIndexOf('.');
+ if (lastSeparator != -1) {
+ key = key.substring(lastSeparator + 1);
+ final var classMapping = mappings.get(this.getClass().getName());
+ if (classMapping != null) {
+ key = classMapping.mojangName();
+ int lastSeparator = key.lastIndexOf('.');
+ if (lastSeparator != -1) {
+ key = key.substring(lastSeparator + 1);
+ }
+ }
+ } else {
+ key = getClass().getSimpleName();
+ }
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
+ this.timing = co.aikar.timings.MinecraftTimings.getBehaviorTimings(configKey);
@@ -196,16 +197,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public Sensor(int senseInterval) {
+ // Paper start - configurable sensor tick rate and timings
+ java.util.Map<String, io.papermc.paper.util.StacktraceDeobfuscator.ClassMapping> mappings = io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.mappings();
+ String key;
+ String key = this.getClass().getSimpleName();
+ final var mappings = io.papermc.paper.util.ObfHelper.INSTANCE.mappings();
+ if (mappings != null) {
+ key = mappings.get(getClass().getName()).mojangName();
+ int lastSeparator = key.lastIndexOf('.');
+ if (lastSeparator != -1) {
+ key = key.substring(lastSeparator + 1);
+ final var classMapping = mappings.get(this.getClass().getName());
+ if (classMapping != null) {
+ key = classMapping.mojangName();
+ int lastSeparator = key.lastIndexOf('.');
+ if (lastSeparator != -1) {
+ key = key.substring(lastSeparator + 1);
+ }
+ }
+ } else {
+ key = getClass().getSimpleName();
+ }
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
+ this.timing = co.aikar.timings.MinecraftTimings.getSensorTimings(configKey);