Skip to content

Commit

Permalink
修复一点点错误
Browse files Browse the repository at this point in the history
  • Loading branch information
CaaMoe committed Apr 29, 2023
1 parent 2bcf3e1 commit d6529ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ import moe.caa.multilogin.bukkit.injector.protocol.PacketLoginDisconnectHandler
import moe.caa.multilogin.bukkit.injector.proxy.SignatureValidatorInvocationHandler
import moe.caa.multilogin.bukkit.injector.proxy.YggdrasilMinecraftSessionServiceInvocationHandler
import moe.caa.multilogin.bukkit.main.MultiLoginBukkit
import java.lang.reflect.Field
import java.lang.reflect.Modifier
import java.lang.reflect.Proxy
import java.lang.reflect.Type
import java.lang.reflect.*
import java.util.concurrent.ConcurrentHashMap
import java.util.stream.Collectors


class BukkitInjector : Injector {
Expand Down Expand Up @@ -83,17 +79,18 @@ class BukkitInjector : Injector {
SignatureValidatorInvocationHandler(anyPair.second)
)
}
if (!modified) throw RuntimeException("Unsupported server.")
}

val newServices = services.javaClass.getDeclaredConstructor(
*constructorArg.stream().map { it.first.type }.collect(Collectors.toList()).toTypedArray()
).newInstance(constructorArg.stream().map { it.second }.toArray())
if (!modified) throw RuntimeException("Unsupported server.")

pairMinecraftServerAndGetServiceField.second[minecraftServer] = newServices
return
}
} catch (_: java.lang.Exception) {
val declaredConstructor: Constructor<*> = servicesRecordClass.getDeclaredConstructor(
*constructorArg.map { it.first.type }.toTypedArray()
)

val newServices = declaredConstructor.newInstance(*constructorArg.map { it.second }.toTypedArray())
pairMinecraftServerAndGetServiceField.second[minecraftServer] = newServices
return
} catch (_: java.lang.Exception) {
}
val pair = forceGetNMS((api.plugin as MultiLoginBukkit).server, MinecraftSessionService::class.java, HashSet())
pair.second.isAccessible = true
Expand Down
2 changes: 1 addition & 1 deletion bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ main: moe.caa.multilogin.bukkit.main.MultiLoginBukkit
author: @contributors@
softdepend:
- ProtocolLib
- PlaceholderAPI
api-version: 1.13
commands:
multilogin: { }

0 comments on commit d6529ca

Please sign in to comment.