[ci skip] Add some helper methods to the ObfHelper util class (#6374)

This commit is contained in:
Jason Penilla
2021-08-14 03:06:17 -07:00
parent f5dd603274
commit 92222b3c9d
2 changed files with 70 additions and 30 deletions

View File

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