Chroma-Discord/src
Norbi Peti 6b60135867
NorbiPeti has completed the challenge [Bullseye]
Using the custom event to detect player /stop as now restarts can come from there too (btw it defaults to stop unless a command is ran)
Added support for advancements in 1.16:
- Now each player gets effectively a reference to the player list for advancements, and since I simply call the method on the original object, it will pass that on, instead of my mock
- I tried calling the method that sends the reference on the mock in that case, but that just results in Mockito's version being called which means infinite recursion or something like that (I didn't get a StackOverflowError actually but the server didn't respond)
- I tried implementing the method myself but actually I never tested it because at that point I was convinced I can call the original the right way
- I had an educated guess that the mock is a subclass of the original class, so I just need to call super.method() right?
- But how do you call that reflectively? Apparently Method.invoke() will always respect overriden methods; but thanks to StackOverflow I found out about MethodHandles, and it has the perfect thing I need, findSpecial / unreflectSpecial
- Only problem is, kind of like how you can only use super.method() inside the class, you can only use the 'special' methods inside the class... So how could I make it run inside the mocked class? I have no idea since I can only supply an Answer object which has no connection to it, but apparently all the lookup() method actually does is call a constructor with the caller's class - so let's call the constructor! Which is, of course private
- So now I have a reflection call creating a Lookup object which can get a handle to the method without checking any overrides and then using that handle to call the original method with the 'this' parameter being the mock
#128
2020-07-30 01:54:58 +02:00
..
main NorbiPeti has completed the challenge [Bullseye] 2020-07-30 01:54:58 +02:00
test/java/buttondevteam/DiscordPlugin Fixed the MassiveCore error but there's more 2019-10-27 23:27:54 +01:00