strom: fix RegisterUntilLow to panic on reverse range, use dual-range registrations

- RegisterUntilLow now panics if startIndex > endIndex (programmer
  must address version incompatibility explicitly, not silently skip)
- Replace per-version RegisterCritical handlers with dual-range
  RegisterUntil: modern range (v1_21_8->latest) + legacy range (v1_8->1.12.2)
- Remove v1_12_2 handler duplicates (covered by upward range from v1_8)
- Move legacy chat handling into chat.Module.SendMessage (protocol<764
  uses v1_8.PlayToServerPacketChat instead of v1_21_11)
- Skip chat signing init for pre-1.19 versions
This commit is contained in:
Admin Else
2026-08-04 22:16:34 +02:00
parent 1e6ce06fb0
commit 1001c809e5
4 changed files with 19 additions and 63 deletions
+4 -1
View File
@@ -116,6 +116,9 @@ func (c *Conn) RegisterUntilLow(eventType reflect.Type, hv reflect.Value, until
}
startIndex := slices.Index(proto_generated.SupportedVersions, versionInfo.MinecraftVersion)
endIndex := slices.Index(proto_generated.SupportedVersions, until)
if startIndex > endIndex {
panic(fmt.Sprintf("handler version %s is above until version %s", versionInfo.MinecraftVersion, until))
}
for i := startIndex + 1; i <= endIndex; i++ {
versionName := proto_generated.SupportedVersions[i]
versionInfo, err = data.LookUpVersionByName(versionName)
@@ -125,7 +128,7 @@ func (c *Conn) RegisterUntilLow(eventType reflect.Type, hv reflect.Value, until
var newPacketInfo proto_base.PacketInfo
newPacketInfo, found = LookupPacketInfoByNameProtocolVersionStateAndDirection(packetInfo.Name, versionInfo.Version, packetInfo.State, packetInfo.Direction)
if !found {
panic("packet not found in future version")
panic("packet not found in version " + versionName)
}
newT := reflect.TypeOf(newPacketInfo.Type)
if !SmartConvertibleTo(newT, reflect.TypeOf(packetInfo.Type)) {