Skip to content

Commit

Permalink
Simplify mappings generation a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
UserNugget committed Jun 23, 2024
1 parent ca691d8 commit 2278580
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -154,26 +154,12 @@ enum MinecraftVersion {
public static final MinecraftVersion MINIMUM_VERSION = MINECRAFT_1_7_2
public static final MinecraftVersion MAXIMUM_VERSION = values()[values().length - 1]

private static final Map<Integer, MinecraftVersion> PVN_MAP = new HashMap<>()

static {
int pvn = MINIMUM_VERSION.getProtocolVersion()

for (MinecraftVersion version : values()) {
for (; pvn <= version.getProtocolVersion(); pvn++) {
PVN_MAP.put(pvn, version)
}
}
}

static MinecraftVersion fromPVN(int pvn) {
return PVN_MAP.getOrDefault(pvn)
}

static MinecraftVersion fromVersionName(String name) {
return valueOf("MINECRAFT_" + name.replace('.', '_'))
}

// Cache version name to reduce memory usage in general
final String versionName = this.toString().substring(10).replace('_', '.')
final int protocolVersion

MinecraftVersion(int protocolVersion) {
Expand All @@ -185,7 +171,7 @@ enum MinecraftVersion {
}

String getVersionName() {
return this.toString().substring(10).replace('_', '.')
return this.versionName
}
}

Expand Down

0 comments on commit 2278580

Please sign in to comment.