#[IN DEV] CVN (Cross-Version-NMS)
1 messages ยท Page 3 of 1
a catch
I know this line too much
try {
line 58 -> loader.loadPlugin();
} catch (InvalidPluginException | InvalidDescriptionException e) {
throw new RuntimeException(e);
}```
public void loadPlugin() throws InvalidPluginException, InvalidDescriptionException {
if(remappedPlugin == null) throw new InvalidPluginException("You can't load the plugin if it wasn't remapped!");
System.out.println(remappedPlugin);
Plugin loadedPlugin = cvn.getServer().getPluginManager().loadPlugin(remappedPlugin);
if(loadedPlugin == null) throw new InvalidPluginException("The remapped plugin can't be loaded!");
cvn.getServer().getPluginManager().enablePlugin(loadedPlugin);
}```
I already looked six times at those lines :/
but the problem is in the remapped plugin, basically
What is in the remapped plugin, still the same thing?
this
e(String) is what?
setMotd
What are you trying
I wonder how it'd look in decompiled remapped form
but "We need to make sure everything is ideal"
so let's try
if it works
@rigid saffron you marry me
I recommend using Krakatau instead of an online decompiler; can catch less noticeable blunders more easily
we've got something interesting
I'll switch to that then
Alternatively if Kraktau is a bit overkill for you (since you'd more or less need to have Rust installed for that), javap also does a fair job (which is provided by the JDK)
okay
where is the nms import??
it's in the root package -> no import necessary
Lol
that is how official mappings work
is it called aas at runtime?
yeah
What else
see the logs
nespresso
ass
yeah ?
lemme fire up recaf then
idk - the class is very obviously named net/minecraft/server/dedicated/DedicatedServer at runtime. There is no aas at runtime - at least not under paper
In 1.17.1 paper wasn't mojmapped yet afaik
decompilers don't lie
Sir where are all classes
SO RAYDAN
perhaps you looked at the mojang jar by accident?
I looked at the mojang jar
wanna see spigot one ?
The paper motherfuckers messed something up and we are in the mess
class names are not obfuscated under spigot either btw
the fuck
looks like I can't say get-bukkit here
That's weird as fuck
You didn't know that?
THIS IS SPIGOT
I was pretty sure plugins were obfuscated from mojmaps after compilation so I assumed the server should be obfuscated too
Spigot. DedicatedServer
yeah, they were obfuscated from mojmap to spigot mappings
using. Spigot. Mappings
Since. The. Beginning.
I. Said. That. Since. The. Beginning.
Spigot mappings only keeps class names deobfuscated-ish
I tried to tell you this ๐ญ
Everybody knows that
It made no sense
with quite a few exceptions (in that some methods and fields are also renamed) probably
looks like you were wrong x)
well
so another problem (another brick in the wall ? Pt.2 especially)
how do we remap to spigot mappings ?
google please ๐
We gotta download them
SpecialSource moment
what is this
Just use specialsource
okay
can you make it/send it please ? x)
well, gn
uh, I need to shade specialsource @inland spoke ?
hum ?
But I already linked you that file.
It's standard CSRG, mapping-io should be able to handle it
wait
using specialsource is overkill and won't save you any issues
well it's overkill in the sense that we already have TR
TR uses mapping-io. You might best ask nebelnidas about it tbh
he's on paper server ?
no, fabriccord (or the recaf discord)
can you send me the links please ?
done.
thank you
#toolchain-other being the channel to best ask this in
I'm back for a minute
I thought fabriccord was another server, but it's just fabricmc discord..
we'll gonna ask our friends
I'll rewrite the gradle plugin to remap to spigot tomorrow
perfect
okay goodbye
Okay just as an FYI in how questions should ideally be formed: You should ask the how, not whether.
But anyways, the remapping process shouldn't differ too much from https://github.com/stianloader/GslStarplane/blob/v0.1.0/src/main/java/de/geolykt/starplane/ObfuscationHandler.java#L670-L683
that being said, you might get away with a more direct approach; this code was written for an older version of tiny-remapper
so, not "how can I remap?" but "how to remap?" ?
oh okay, I'm checking that
well more like what the necessary APIs are
hum
is that how I should ask ?
I generally also discard my usecase and in this case would just have asked "I have a CSRG file - I wish to use that as an input mappings file in tiny-remapper. Given that I know that I can use mapping-IO to read the CSRG file and that TR uses MIO under the hood, I should be able to combine the two systems; however, as CSRG is missing the descriptor I am unsure how to best approach it. What do you reckon would work best here? I'd like to avoid having to list all library classes using an early ClassVisitor pass"
The other problem is that you might need to use two passes with tiny-remapper since layered mappings are a bit difficult (but not impossible) to pull off under TR
oh okay I see, I need to tell much more informations
I'll edit my message
Providing a terrible workaround that may or may not work is generally a good way to bait a maintainer to respond
oh okay
all an art
Anyways, this concludes my tutorial on how to abuse the foundations of open source to your own advantage
x)
brain manipulation
It's not really manipulation and more a way of knowing how to ensure that the conversation is not being derailed by tangential discussions
yeah I see
it happened yesterday, I made a girl angry toward me because of this :/
wut
I found something that might be useful
https://github.com/CadixDev/Mercury
when thinking of craftbukkit imports
not useful
imports don't exist?
imports aren't on the good version
Mercury is for remapping source files
oh ok
running the plugin on a 1.16.5 server
because it's created using 1.17.1, so craftbukkit wants 1.17.1
that can easily be done by renaming the references
I don't know how to do that ๐ถ
And looks like Google doesn't really know too
is this message good?
Hello, I have a system to do some modifications in a jar file at runtime for compatibility purposes, I want to rename every imports from
org.bukkit.craftbukkit.1_17\_R01.xxxtoorg.bukkit.craftbukkit.1_16\_R01.xxx, how can I do that?
using ASM ?
Yeah
Although it is even easier if you use something like cafedude as you'd really only need to modify the constant pool
something like this?```java
import org.objectweb.asm.*;
public class ImportRenamer extends ClassVisitor {
private final String oldVersion;
private final String newVersion;
public ImportRenamer(ClassVisitor cv, String oldVersion, String newVersion) {
super(Opcodes.ASM6, cv);
this.oldVersion = oldVersion;
this.newVersion = newVersion;
}
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
}
@Override
public void visitConstantPool(ConstantPool cp) {
super.visitConstantPool(new ConstantPoolRenamer(cp, oldVersion, newVersion));
}
}
class ConstantPoolRenamer extends ConstantPool {
private final String oldVersion;
private final String newVersion;
public ConstantPoolRenamer(ConstantPool cp, String oldVersion, String newVersion) {
super(cp);
this.oldVersion = oldVersion;
this.newVersion = newVersion;
}
@Override
public Item getItem(int index) {
Item item = super.getItem(index);
if (item == null) {
return null;
}
if (item.getType() == Const.CONSTANT_Class) {
String className = ((ClassItem) item).name.replace('/', '.');
if (className.startsWith("org.bukkit.craftbukkit." + oldVersion + ".")) {
String newClassName = className.replace(oldVersion, newVersion);
return new ClassItem(newClassName);
}
}
return item;
}
}```
did you ask ChatGPT here?
regardless, that is some very obvious hallucination here
really ? x)
I confirm, it is
yeah - if anything ConstantPool would be named ConstantPoolVisitor
However, ASM never allowed direct manipulation of the constant pool
humm
let's see about that
CAFED00D ?
Anyways, you'd want to use ClassRemapper in conjunction with a custom Remapper instance - I'd say that works the best
ye
I don't know how to use ASM actually x)
technically speaking you could use TR and a hand-crafted IMappingProvider implementation
yeah, maybe
Don't worry it's easy.
ClassRemapper and Remapper does the heavy lifting already
this would be the easiest ?
I'm dumb ๐คฆโโ๏ธ
You'd only need to extend Remapper and overwrite the map method to do your own mapping logic
there isn't anything to learn about OW2 ASM really. If you can read javap output and use Recaf you are good to go. Now ideally you'd want to also be able to read and write jasmin files (e.g. via krakatau), but that is an optional step for experts
humm```java
public class CustomRemapper extends Remapper {
@Override
public String map(String internalName) {
return super.map(internalName);
}
}
I'm not really an expert :/
and I never used javap and Recaf
yeah though obviously here you do
@Override
public String map(String internalName) {
if (internalName.startsWith("org/bukkit/craftbukkit/" + oldVersion + "/")) {
return internalName.replace(oldVersion, newVersion);
}
return internalName;
}
this is just that ???
shame really, they are useful tools
ye
You'd also need to use a ClassRemapper as a ClassVisitor but that's quite easy too
I'll use regex instead to avoid the oldVersion ๐
Then you just connect the ClassReader with the ClassWriter using your ClassRemapper and everything works
I'll see that, and I'll (for sure) ask you for help x)
org\/bukkit\/craftbukkit\/(.*?)\/ ๐
Future removal of CB package relocation + moving away from obfuscation at runtime
If you are not a developer but a server owner, this might still be important for you. Check the bottom section on what action you might have to take.
Update: This change has been put into effect in 1.20.5, make...
@inland spoke should I call a paper method using reflection? (I'm doing this to be sure to have the good string in final)
I want to do Bukkit.getServer().getMinecraftVersion();
paper method?
yeah, a method papermc implemented in 2020 in Bukkit#getServer
they make everything so difficult :/
Well even getBukkitVersion works here
it's true
That being said, they cannot be used in your context (well you can use that to disable mojmap remapping, but eh)
x)
getBukkitVersion?
Yeah, it's the example below it
getBukkitVersion existed since forever, so it is safe to use
yeah
huh, I need to see if the server is equal to or after 1.20.5 from a string ๐
I had created a class for that
If you wish to compare the output you are free to use https://github.com/stianloader/PicoResolve/tree/c1333f8514742f2e54cca6a151430672b77dec65/src/main/java/org/stianloader/picoresolve/version for that \s
PAPI
well
too big
I prefer mine x)
https://github.com/Paulem79/PAPI/blob/master/src/main/java/fr/paulem/papi/compatibility/Version.java
(I never finished this API)
won't handle absolutely all maven versions - while mine handles absolutely any version the same way maven does
but I don't want to handle maven ? ๐ค
oh it's yours x)
which file should I use ?
Well getBukkitVersion at it's core is the version string used for maven
technically all of them are relevant - perhaps minus VersionRange
okay
@inland spoke he responded !! #566418023372816394 message
what are member mappings ๐ฐ
just respond with "oh, I wanted to be better safe than sorry"
he has a valid point, though. Halfway forgot that
I understood approximately nothing
Member mappings are field or method mappings (this specific mapping file only contains class mappings as spigot mappings only have class names remapped)
yeah I see
but we just want the class name mapping, right?
I mean techncially yes. So technically we could forget that step
"technically" "could" ?
you look unsure ๐
Technically correct is the best form of correct
oh okay x)
technically
Jokes aside, I look unsure because I am.
I need to go eat, see you later or tomorrow
@fallow sky we can probably add a spigot namespace onto our already existing mappings to make stuff easiet
We are basically sleeping at the same time
Yeah, in a separated folder, but that's a great idea
I could update mappings-downloader to do that
But not rn because school goes first ๐คโ๏ธ
I also figured out how to pull spigot mappings
Why in a seperated folder? Tiny mappings would probably let us just add it into already exisiting mappings, making the job easier for everybody
Here is how it works:
You get a version json from https://hub.spigotmc.org/versions
In that version json you will have a few commit hashes, including the BuildData one, the one we need (it'll look like 8df2731012bb6887630ce7ebd4c7220eabe49a07)
Then, we fetch the BuildData repo and run merge with the previously mentioned commit hash
git fetch https://huh.spigotmc.org/stash/scm/spigot/builddata.git master
git merge 8df2731012bb6887630ce7ebd4c7220eabe49a07
``` That will pull the repo with spigot mappings and an info.json
The info.json has data to where exactly the mappings are located (under what name they are)
We could do spigot mapping downloading on runtime, but that's quite a pain in the ass, so that's why I talked about adding spigot mappings to our intermediary mappings
wait so which final mappings did you wanna go for? yarn?
yarn mappings are pretty good ngl
Final mappings? We are going from mojmaps to intermediary to spigot
But I am planning to write some tool to remap spigot into other mappings than mojmaps
Yarn us pretty cool but I prefer parchment
why spigot
spigot is obf
Apparently that's what the server jar is in
I will have to rewrite the gradle plugin to also create a spigot jar and I will most likely write a script to download spigot mappings for all the intermediary mappings we have and combine them or something
okay I think the gradle plugin is now successfully remapping to spigot
but I'm a bit unsure because spigot is very similar to just simply being obfuscated (especially the MinecraftServer class)
But I will not upload to github yet, I don't have much time on weekdays, it still needs testing and my git is absolutely messed up
The issue with not having my laptop most of the time is that I end up reading so much source code to figure out a thing as simple as a string
Yeah that's working too
That's a problem x)
But atleast I know a lot about spigot now
Me too x)
And I also know that we'll either find a good way to git without a git client or we will end up downloading a portable git client into the server
Or we just make proper mappings
I'd dig a bit into how spigot load plugins
Why tho
For the jarfile handler
I didn't understand how to use it at first time
Isn't it just loading a file
So I'd read some bukkit code
And I'm pretty sure it can load from anywhere
Nah, about knowing if there is a plugin.yml*
I misunderstood what I was saying
Ah, it just does the same thing you do with the plugin.yml
It finds it
It finds it
Or it doesn't
Cvn when there is no cvn-plugin.yml:
Ah, it's fine, I'll just skip
Spigot when there is no plugin.yml:
ALARM! ALARM! FUCK, FUCK, EVERYTHINGS BAD, CODE RED, WE ARE SINKING, SOS, WE ARE DYING, NOO, HELP
exactly x)
but well, the "fack plugin" system is perfectly working
fack plugin?
fake**
Well, we aren't making fake plugins
I was thinking of "fuck" at the same time because you wrote that x)
We are making real plugins
But better
yeah, but we are faking the server ๐ค
Also, we will also have to remap the nms package because of v1_12_R01 or whatever
to prevent the HEY YOU DON'T HAVE A PLUGIN.YML RIGHT ??? IT WAS JUST TO SAY THAT, EVEN IF YOU ALREADY KNOW THIS I'LL SAY IT EVERYTIME YOU LAUNCH ME
yeah ๐
not a problem
I'm already working on that
And that includes craftbukkit
using โจ ASM โจ
Asm is a pain in the ass, isn't it?
wanna see ?
That's why I went for using libs instead of plain asm
Sure
Do the same to nms btw
When below a certain version
I'll pass it to some classe, that pass that to some others classes
When did relocation stop
I'm working on a version system
I would use @inland spoke's code but there is dependencies everywhere ๐
Lol
Well, I did write the obf to spigot remapper, turned out to be a pain in the ass and I also have no idea what exactly it does because I definitely did not ever copy some code from buildtools
huh
Or was it moj to spigot? Idk
๐ค may it works
I will prob try giving it DedicatedServer to see whether it'll remap it or no
yeah, good idea ๐
It shouldn't
it should just remap methods and fields
not classes name
Well, some class names differ from moj to spigot I think
Actually, if you have time, can you find some? I'll test them tomorrow then
I already know some
well
version: 1.20.4, hash: 6183be7a09
this one, much simpler to test because it's implemented in DedicatedServer
https://mappings.cephx.dev/1.20.4/net/minecraft/server/ServerInterface.html
version: 1.20.4, hash: 93838b9544
version: 1.20.4, hash: 41984ba841
well, I think it's enough x)
๐
well I'll play a bit, I over-destroyed my brain yesterday
i'm destroying my brain rn
serialization
lol
let's โจ work โจ
@inland spoke your code is for java 17...
we are in โจ java 8 โจ
โจ Backwards Compatibility โจ
so it should works ?
Doubt it
How much enough
enough for comparing versions
not the best, because it's very basic, but still enough
What is it
a class
perfect
Maybe also have a
public Version(String version) {
String[] split = version.split("."); // or "\\." if it takes regex i don't remember
if (split.length < 3) {
throw new IllegalArgumentException("Invalid version string " + version);
}
try {
this.major = Integer.parseInt(split[0]);
this.minor = Integer.parseInt(split[1]);
this.revision = Integer.parseInt(split[2]);
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("Invalid version string " + version);
}
}
For convenience
yeah for sure
Or make it a public static Version of(String version)
yeah
why not instancing ?
programmation is so relative ๐ฎโ๐จ
๐
yay!
Actually, wouldn't a Version class be a good interface
huh ?
No idea why so, but I kinda feel like it would look nicer
public interface Version {
int getMajor();
int getMinor();
int getPatch();
static Version of(int major, int minor, int patch) {
return new Version() {
@Override
public int getMajor() {
return major;
}
@Override
public int getMinor() {
return minor;
}
@Override
public int getPatch() {
return patch;
}
}
}
}``` or something
Wrote this on my phone rq
I have no idea why you would want to do that?
Version is basically a data class
Could be a record even
Why make it an interface
I used to do that, thought it looked fancy
No idea why
Ehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
I donno, shouldn't be all too difficult to port. The most painful aspect of porting J17 code to J8 are records, but beyond that it's fre real estate
Reasoning 100
I feel like you are pushing it
You know what - I'll just port it right now
I don't like records tbh
The fact that record Clazz(int a) the method is not getA() but just a()
Is just
Meh
Lombok's @Data and Kotlin's data class are better at this
RECORD DOESN'T EXIST ON JAVA 8 ๐ฃ๏ธ๐ฃ๏ธ๐ฃ๏ธ๐ฃ๏ธ๐ฃ๏ธ
I had no idea you were coding in Java 8, besides this was just an example of why Version should not be an interface
don't worry, I'll just use my class ๐
Do not caps your letters at me, I will cry
Don't be sad ะัะฑะปะธะบ
x) sorry
Please hold me and pet my head
We don't got a good emoji for that
I've got one
Theoretically
Damn
That was.. fast
๐
perfect thanks ๐
I think I'll use this
but well, now, time to go โจ sleep โจ
This chat on weekends: ๐
This chat on weekdays: ๐
real x)
I'm on a college pc, basically programming
but well, I don't have intellij idea or github desktop on my usb key, so I don't think I can work on the project now x)
If I can put Intellij on my usb key, I think I'll just migrate the version system to geol's system
:3
Yall were talking about versions yesterday
Maybe you would like to steal this from TriumphGui?
private static int getCurrentVersion() {
// No need to cache since will only run once
final Matcher matcher = Pattern.compile("(?<version>\\d+\\.\\d+)(?<patch>\\.\\d+)?").matcher(Bukkit.getBukkitVersion());
final StringBuilder stringBuilder = new StringBuilder();
if (matcher.find()) {
stringBuilder.append(matcher.group("version").replace(".", ""));
final String patch = matcher.group("patch");
if (patch == null) stringBuilder.append("0");
else stringBuilder.append(patch.replace(".", ""));
}
//noinspection UnstableApiUsage
final Integer version = Ints.tryParse(stringBuilder.toString());
// Should never fail
if (version == null) throw new GuiException("Could not retrieve server version!");
return version;
}
private static String getNmsVersion() {
final String version = Bukkit.getServer().getClass().getPackage().getName();
return version.substring(version.lastIndexOf('.') + 1);
}
Lol
Their license is MIT though
This is good fr though
getCurrentVersion() returns 1165 for 1.16.5 for example
And just save it in some globally accessible variable
We are LGPL
`including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.`
Just ship the license in a comment header for the file that you want to use this method in
I think
Solyanka is licensiy
Not legal advice
Realno
Lets just use our own stuff
Just illegally bundle copies of Spigot
Lmao
Hy a xyJIu
Replace the spigot jar with your own while nobody is looking
Ha cBou cTpax U PucK
imagine somebody who does not understand cyrillic reading this
CTpaLLIHo u pucKoro
noxyu
It's already been a topic, with fasqler I think
It work
perfect
okay i probably can't help with the mapping stuff but i can set up the server thingies ig
what was that again
mass server tester?
it downloads all mc versions, runs bt
uh builds a test plugin for that version as well as the main plugin?
i couldn't really get the test plugin to compile for some reason
@fallow sky quick reminder that you're using io.github.cvn, and cvn is used by somebody else, see #general message
can we please rename the org to SpigotCVN or something
Oh
Yeah for sure
I'll change that in a few minutes
๐
does the access transformer count to the mappings
Idk ๐
okay let's โจ rename โจ
so, like this io.github.spigotcvn.cvn ?
looks good
okay ๐
yeah
how many times have you changed names now
4
damn
you forgot one in between
something something interface
bruh
https://github.com/Cross-Version-NMS/spigot-mappings-downloader wrote this, it's a bit of a temporary thing, gonna rewrite it a bit, but it works
I also need a better package name
should I maybe do io.github.spigotcvn.smdownloader or something like that
instead of the whole io.github.spigotcvn.spigotmappingsdownloader
I was also thinking we could put it into the already existing mappings downloader and use it as a library
yea
Oh, btw, that lib has been mostly written on my phone
Oh wait, did I forget to push the updated gni remapper
cvn remapper*
The gradle plugin basically
Lol
bro please give an answer \๐
If you don't have the current spigot version built using buildtools the gradle plugin will yell at you anyways
yeah
bt errors ๐ ๐
Lmao
No
You need remapped
Otherwise the gradle plugin will yell at you
bro it doesn't work with remapped \๐
which version ?
Womp womp
1.19.4
it should works
We need a public readme which will have two explanations, one for normal people and one for devs. The one for devs will be short because it's simple to explain to somebody who knows, the one for normal users will make it more abstract so users can more or less understand
Then change the spigot version to 1.18.2 and try building 1.18.2, idk
yeah ๐
I can send you the remapped jars
i'll try updating bt
yeah, do that
i'm not manually going into my .m2
and use BT GUI
You will need to send a whole ton of stuff for the gradle plugin to work
uh only in dms
yeah that's true
never send that on the server lmao
x)
It needs mappings and stuff, it gets that from the minecraft-server repo in your maven local
yeah
Those only exist when bt is ran with remapped
As you can notice, I have wasted a lot of time looking at my .m2/repository/org/spigotmc
And also at the BuildTools source code
x)
I also stole a class from there
Since we are LGPL we can do it, lol
we are in legality
Yk, rn cvn is just some Frankenstein assembled from pieces of libraries and applications
and some prayers of "please, works"
lol
i had to rerun in a clean folder ajhkjhasjkdhas
Ik I spied on you
When I saw that error my first thought was mvn clean but since it's build tools I thought that was weird
bt is weird
Says a yarner
yarn is also good
Imagine writing spigot in parchment
Shit I haven't tested any of the things I had to today
lmao
@rigid saffron what java version do i use
and how does this work now
do i put the cvn plugin and test plugin inside of a server
17, 1.19.4 is not 1.12.2
Yee
But it might not work because, well, you know, stuff
No idea
does j8 work
It should work wjth j8 because of old versions, yk
But otherwise, @fallow sky coded it, he knows better
noop
oh ffs
intellij chooses a different java version for gradle
it's so fucking stupid
Lmao
IJ being IJ
When I started modding I had the issue I needed to change fifty things for gradle to use jdk11 instead of my jre8
it works now
Perfect
the motd still isn't "eee" :(
let's implement geol's system x)
@rigid saffron I'm doing some little changes on spigot-mappings-downloader for consistency, you'll need to refetch the code from github
whatever my system is, but okay
for versioning
ah uh that
i'll start on that mass server tester thingy tomorrow
okay perfect thanks
I'm adding you to the github organization
yea
I sent you the invitation
x)
love the fact that you're using three different @NotNull annotations
yeah...
that's bytebuddy, not me ๐
yea
4 MB WHAT THE HELL
let's launch the server to see
hey
It's โจ not working โจ
let's stop that
this is not working
so
how can I use my CustomRemapper ?
mon dieu - non! What are you doing???????????
Why do beginners want to use bytebuddy so frequently?
Idk, google
But I can't find a ASM tutorial ๐ญ
And I need to go sleep
whatever - skill issue ๐ง
Huh
I'll not use it
Looks trash
only ASM ๐ฟ
well bytebuddy is a needless wrapper around ASM for all that I can care for.
And really ASM is so simple that it's basically just
ClassNode node = new ClassNode();
ClassReader reader = new ClassReader(rawData);
reader.accept(node, 0);
// Modify `node`
ClassWriter writer = new ClassWriter(0); // Or use ClassWriter.COMPUTE_FRAMES to compute frames - but beware that this would load classes by default! That is not what we want. For simple remapping operations, you don't need to compute frames though.
node.accept(writer);
byte[] outputData = writer.toByteArray();
so yeah - what's the point in an ASM tutorial?
Seems simple, thanks
has 4 different not null annotations
"Why does it looked so complicated and big?"
Idk why, byte buddy is strange
I personally never annotate my parameters, I will tell about them in javadocs
Ooo I see you changed the package name on the smdownloader, very good
On my phone that would be a pain in the ass
Funnily enough, I don't need to gitignore .idea because it doesn't even exist on my phone
do you just vim it or sth
based
what are you talking about? It's the same not null annotation
3 non imported not nulls and one imported not null
No?
I think you are forgetting that type annotations (@NotNull being one) is applied on the simple name of a type.
So following usages are valid:
@NotNull Object o = new Object();
java.lang.@NotNull Object o2 = new Object();
List<@NotNull Object> o3 = new ArrayList<>();
List<java.lang.@NotNull Object> o4 = new ArrayList<>();
@NotNull List<@NotNull Object> o3 = new ArrayList<>();
@NotNull List<java.lang.@NotNull Object> o4 = new ArrayList<>();
while following usage is invalid:
List<@NotNull java.lang.Object> o5 = new ArrayList<>();
Then what are these 3 non-imported non-nulls?
net.bytebuddy.jar.asm.@NotNull
net.bytebuddy.description.type.@NotNull
implementation.@NotNull
Yeah then that is very much related.
FYI - that would be about the same as doing Implementation.@org.jetbrains.annotations.NotNull Context. Doing @org.jetbrains.annotations.NotNull Implementation.Context would annotate the Implementation type - which makes no sense under most circumstances since your argument is of type Context, so it is irrelevant whether it's nest host is a not-null or not
notice how if I wanted to use a non-imported annotation, the FQN is behind that @ - not in front
I have no idea what the hell you are taking about
I literally just made a joke that because of a long annotation name it looks more confusing and you came with all of this whatever the fuck it means drama
Sir I just joked about the long name
what in the name of fuck
Can you now relax or something
who tf thought of this
I don't need this knowledge because I am not so dumb to not import my classes
in this case you didn't have any choice since bytebuddy apparently shades it's own ASM
What even is bytebuddy for
Higher level wrapper around ASM. The most attractive usecase is runtime class transformation apparently - but really one ought to be using proper classloading utensils instead
well the thing is you can't be wrong on the internet without anyone correcting you
And I'll defo correct this thing as it's poorly understood
I can be wrong when joking because that's a part of joking
I find it extremely annoying that instead of explaining it properly you came up with some snippets of code that do not give me anything
So it would be less annoying to say "well, it's defined in JLS19 9.7.4"?
I would still have no idea what you are talking about
Instead of incoming with some weird shit start with "it's not the not nulls that are unimported, they are all the same" or something
"Its the same not null annotation" confused me and then you came with pieces of code and that confused me even more
Explain it slowly and "gently"
oh well
Also, whoever made the annotations go like that for unimported classes shall burn in hell
The intuition behind the second clause is that if Outer.this is legal in a nested class
enclosed by Outer, then Outer may be annotated because it represents the type of some
object at run time. On the other hand, if Outer.this is not legal - because the class where it
appears has no enclosing instance of Outer at run time - then Outer may not be annotated
because it is logically just a name, akin to components of a package name in a fully qualified
type name.
Blame non-static nested classes I guess
Are there even people who use those
Neat
Seems good ๐
Can the org name be changed
to spigotcvn?
we already changed
i, uh, made a config
oh there's still a dot there
that's not good
this was a slight pain tho lmao
raydan told me i could lol
you can ๐
what is rawData ?
Either a byte-array or an input stream
oh okay thanks
the input can be the entire jar ?
with the data being the raw .class file
It operates on a per-class basis; so you'd need to unzip the jar first (or transform the entries individually - it alls boils down to how you wish to modify the classes)
so I can just do that on one .class and it will updates on every one?
uh not really
it will only modify the classes you update
However as there are a bazillion ways of using ASM I can't quite elaborate further
so I need to iterates through .class of the jar and then d asm on them
Each ClassNode represents a single .class file, yea
i'm really not sure how I would manage this
i could have a config param for each java version ig
8, 17 and 21
rn i'm manually initialising the main class, that's not gonna work for multi-java version support
so i guess i'll just make it spawn a command process?
yeah
just as a warning you will need an incredibly specific dev setup for this to work
oh yeah
not a problem
You should automate the getting of versions
i cannot be bothered to rn
I will later then
i just wanna figure out the java version every version needs
1.0 - 1.16.5 Java 8
1.17 Java 16
1.17.1-1.20.4 Java 17
1.20.5-1.20.6 Java 21
oh true
That's most likely how bt does it
now how tf do i filter the html for versions ๐
Try requesting it as json
nope
content-type and accept both don't work
it looks like it's just a simple nginx file server
Then regex ig
yeahh
Or something like thaz
You could write an html parser
Or use one already existing
It's all inside a pre block, you can prob get all the a's and that's just all the files
You can filter them out by the amount of dots
And dashes
Well for that you'd want to use ClassVisitor API instead. It would look about like follows:
ClassReader reader = new ClassReader(โฆ);
ClassWriter writer = new ClassWriter(โฆ);
reader.accept(new ClassRemapper(writer, โฆ), โฆ);
byte[] outputData = writer.toByteArray();
in theory you could also in-memory remap ClassNodes (stianloader-remapper being one of these tools), but doing it with the ClassVisitor API is the simplest way
Java regex being java regex ig
I'd just joink a few more capture groups in there
oh i fixed it
idk what i changed
@rigid saffron the thing about that mirror is that i can't just make all of these requests at once lol
You don't need to, you can slowly do them
Building that much is gonna take long anyways
Not gonna make a big difference
remapping craftbukkit
it's good yeah
I'll try that, thanks
Btw, where does the slf4j error come from?
I had the same with I think it was jgit
Might get slf4j log4j impl or something
Or see if I can disable that
Java user when class in kotlin lib is called `Very Important Util Class`: ๐ฑ
java users when they have to `Very Important Util Class`.INSTANCE.`get extremely important string i'm ngl i love the string it is so necessary`
no you can't
in kotlin it would be ```kt
object Very Important Util Class {
val extremely important string i'm ngl i love the string it is so necessary = "foo"
}
which is kotlin's equivalent to static
โจsingletonsโจ
Aren't fully static classes usually called util classes
yes
but in kotlin there's no static
there's just objects, which are singletons
which act "static" to kotlin tho
meaning you can use it similar to java's static in your kotlin code
okay fuck toml
@JvmStatic wants to talk to you
oh no
I will @JvmStatic all my functions in kotlin
Nice
Bt should exit with code 0 when it finished (saw that in the bt code)
Idk if it throws another code when it exits for another reason
yea
i'll see
๐
[WARNING] The requested profile "remapped" could not be activated because it does not exist.
that's an issue
what
i did "--rev", ver.toString(), "--remapped" as args
Do you need to remap when it's to run a server
wouldn't i need to make the test plugin that version too?
It should just work
hmm
below 1.14.4 isn't remapped
there is no moj maps for this versions
yeah i figured
And you don't even need it remapped
You'll still use the final spigot mapped jar
Hmm, I wonder if we could check what env the cvn plugin is running in (mojmapped, spigot, obfuscated or somehow intermediary) and then remap to that, so cvn plugins easily run on any server jar no matter what it's mapped to
yeah, that's a good idea
even
checking that for the plugin created by the user
so he can use any mapping
we should do a lib for that
but first, I'm finishing my ASM x)
heeeeey
this is โจ not working โจ
lol
I didn't used the function I created
Lol
public class CustomRemapper extends Remapper {
@Override
public String map(String internalName) {
if (internalName.matches("org\\/bukkit\\/craftbukkit\\/(.*?)\\/")) {
String cbLocation = CompatiblityUtils.getCBOldNotation();
if(cbLocation == null) return internalName;
return internalName.replaceFirst("org\\/bukkit\\/craftbukkit\\/(.*?)\\/", cbLocation);
}
return internalName;
}
}
public class AsmWriter {
public AsmWriter(File clasz, Remapper remapper) throws IOException {
ClassReader reader = new ClassReader(Files.newInputStream(clasz.toPath()));
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
reader.accept(new ClassRemapper(writer, remapper), ClassReader.SKIP_FRAMES);
byte[] outputData = writer.toByteArray();
try (FileOutputStream outputStream = new FileOutputStream(clasz)) {
outputStream.write(outputData);
}
}
}
can you please change clasz to clazz
oh god i just noticed that
oh god
lol
oh yeah
rn I'm sitting here, looking at how spigot mappings work
if this requires me to also download mojang mappings I'm gonna jump out the window
x)
yeah looks like I would want to if I want correctly remapped stuff
shit
looks like my spigot mappings did not work
huh
honestly, idk
it's good ?
it's working
Don't compute frames while writing. Use 0 instead. (or COMPUTE_MAXS, but that is a teeny tiny bit overkill)
Likewise you shouldn't be skipping frames while reading. Use 0 instead. (or SKIP_DEBUG, but meh)
Computing frames requires ASM to know the class hierarchy - see ClassWriter#getCommonSuperClass(String, String)
okay okay thanks
spigot requires me to create field mappings and then create combined mappings on runtime because the builddata only provides me member and class mappings
apparently
I'm not dumb, this is on 1.16.5 craftbukkit ?
huh
so my decompiler is dumb
https://www.decompiler.com/jar/c16b56de9bf6404da1bcfa597729434c/TestProject-1.0-remapped.jar/io/github/cvn/testplugin/TestProject.java
Online decompiler for Java, Android, Python and C#.
yeah
@inland spoke do you know anything about this
lol
wait, the fuck is zg
the remapped obfuscated name
ye, as you already found the problem is that it isn't in the right directory
bruh guys I'm a bit stuckjava parameters.setDefaultFolderPath(Paths.get(file.getAbsolutePath()).toString().replace("\\" + Paths.get(cvn.getTempFolder() + "/asm-remap"), ""));
manipulating paths in java is hell
huh
because of spigot mappigns yk
just depending on spigot-mappings-downloader will be the future solution
what do I do if my local branch is different from the remote one
what on earth is that supposed to be doing?
get the relative path of the asm-mapped file
because I wrote code way before this https://github.com/Cross-Version-NMS/CVN-remapper-plugin/commit/93d9a4ca8b11205ed79dd2aac938d1d28e6f27c3 but didn't push it
so, its original path in the jar file
FYI you can do ClassReader.getClassName() to get the fully qualified internal name of the class (e.g. x/y/z)
Otherwise you also have Path#relativize(Path) and Path#resolve(String) you might want to use, but I can't quite figure out what your code is supposed to be doing
I'll check that, thank you ๐
You should generally never have to convert an absolute path to a string and back
this is what happens when you commit changes without ensuring nobody has local changes
I told you that ๐
well, I have a thicc ass commit that changes everything
lying around for a whole week already
humm
logically, you can
but just save your code before
or use โจ Github Desktop โจ
ij is going crazy with my build.gradle being fucked
x)
it's all messed up ;-;
aahhh
fuck this shit
why did you have to fucking push it
you broke everything
everything here is fucking broken
AAAAAAAAAAAAAH
and you didn't even rename the org anyways
I told you that you must refetch your project before editing...
it was before that
well
you lost everything ?
no
perfect
it's just that my whole git is absolutely fucked and I won't be able to push anything in the next three hours
send your code, I'll push that for you
:/