#[IN DEV] CVN (Cross-Version-NMS)

1 messages ยท Page 3 of 1

rigid saffron
#

What is on decompiled line 58

fallow sky
#

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

rigid saffron
#

What is in the remapped plugin, still the same thing?

rigid saffron
#

e(String) is what?

fallow sky
#

setMotd

rigid saffron
#

ah

#

Weird stuff

fallow sky
#

let me try something

#

I bet this will work

rigid saffron
#

What are you trying

fallow sky
#

very weird if this is the problem

rigid saffron
#

I wonder how it'd look in decompiled remapped form

fallow sky
#

but "We need to make sure everything is ideal"

#

so let's try

#

if it works

#

@rigid saffron you marry me

rigid saffron
#

you want me to marry you?

fallow sky
#

if it works

#

you're lucky

inland spoke
# fallow sky this

I recommend using Krakatau instead of an online decompiler; can catch less noticeable blunders more easily

fallow sky
#

we've got something interesting

inland spoke
#

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)

fallow sky
#

wtf

#

in decompiled

fallow sky
inland spoke
#

it's in the root package -> no import necessary

rigid saffron
#

Lol

fallow sky
#

oh my bad x)

#

BUT STILL

inland spoke
#

that is how official mappings work

fallow sky
#

it's named aas

#

so this should works

#

but no

inland spoke
#

is it called aas at runtime?

fallow sky
rigid saffron
fallow sky
fallow sky
rigid saffron
#

ass

fallow sky
inland spoke
#

lemme fire up recaf then

fallow sky
#

perfect โ˜•

#

with Java's cup please

inland spoke
#

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

fallow sky
#

I'm using paper

#

?whereami

rigid saffron
inland spoke
#

decompilers don't lie

fallow sky
#

sussy baka

rigid saffron
#

Sir where are all classes

fallow sky
#

SO RAYDAN

inland spoke
#

perhaps you looked at the mojang jar by accident?

fallow sky
rigid saffron
#

Well, we are in spigot

#

So, fuck paper for now

fallow sky
#

wanna see spigot one ?

rigid saffron
#

The paper motherfuckers messed something up and we are in the mess

fallow sky
#

WHAT

#

is get bukkit legal ?

inland spoke
#

class names are not obfuscated under spigot either btw

fallow sky
#

looks like I can't say get-bukkit here

rigid saffron
#

That's weird as fuck

inland spoke
fallow sky
#

THIS IS SPIGOT

rigid saffron
fallow sky
#

Spigot. DedicatedServer

inland spoke
#

yeah, they were obfuscated from mojmap to spigot mappings

fallow sky
#

using. Spigot. Mappings

#

Since. The. Beginning.

#

I. Said. That. Since. The. Beginning.

inland spoke
#

Spigot mappings only keeps class names deobfuscated-ish

rigid saffron
#

AHHHH

#

Why did nobody know that

#

I assumed that should not be the case

fallow sky
inland spoke
#

Everybody knows that

rigid saffron
inland spoke
#

with quite a few exceptions (in that some methods and fields are also renamed) probably

fallow sky
#

sigh

rigid saffron
#

I'm gonna go drown myself

#

By everybody

fallow sky
#

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 ๐Ÿ‘

rigid saffron
fallow sky
rigid saffron
#

SpecialSource moment

fallow sky
#

what is this

rigid saffron
fallow sky
#

okay

rigid saffron
#

I already have code for taking mappings and mapping

#

In the plugin

fallow sky
#

can you make it/send it please ? x)

rigid saffron
#

In the gradle plugin

#

It's all live on spigot

#

Okay gtg sleep bye bye everybody

fallow sky
#

remapJarToObfuscated ?

fallow sky
#

uh, I need to shade specialsource @inland spoke ?

inland spoke
#

But I already linked you that file.
It's standard CSRG, mapping-io should be able to handle it

inland spoke
#

using specialsource is overkill and won't save you any issues

#

well it's overkill in the sense that we already have TR

fallow sky
#

idk how to use mappings-io ๐Ÿค”

#

tiny remapper will not works with this ?

inland spoke
#

TR uses mapping-io. You might best ask nebelnidas about it tbh

fallow sky
inland spoke
#

no, fabriccord (or the recaf discord)

fallow sky
inland spoke
#

done.

fallow sky
#

thank you

inland spoke
#

#toolchain-other being the channel to best ask this in

fallow sky
#

oh okay

#

I'm idiot

rigid saffron
#

I'm back for a minute

fallow sky
#

I thought fabriccord was another server, but it's just fabricmc discord..

fallow sky
rigid saffron
#

I'll rewrite the gradle plugin to remap to spigot tomorrow

rigid saffron
#

Or actually, wait

#

The plugin can stay untouched

#

I'll commit to the lib ig

fallow sky
#

okay

#

let me commit my changes

rigid saffron
#

Okay, that's it for today

#

Now I'm going to sleep

#

Bye

fallow sky
#

okay goodbye

inland spoke
#

that being said, you might get away with a more direct approach; this code was written for an older version of tiny-remapper

fallow sky
inland spoke
#

well more like what the necessary APIs are

fallow sky
#

hum

fallow sky
inland spoke
#

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

fallow sky
#

I'll edit my message

inland spoke
#

Providing a terrible workaround that may or may not work is generally a good way to bait a maintainer to respond

inland spoke
#

Anyways, this concludes my tutorial on how to abuse the foundations of open source to your own advantage

inland spoke
#

It's not really manipulation and more a way of knowing how to ensure that the conversation is not being derailed by tangential discussions

fallow sky
#

it happened yesterday, I made a girl angry toward me because of this :/

inland spoke
#

wut

fallow sky
#

when thinking of craftbukkit imports

inland spoke
#

not useful

fallow sky
#

huh

#

how can I edit craftbukkit imports then?

inland spoke
#

imports don't exist?

fallow sky
#

imports aren't on the good version

inland spoke
#

Mercury is for remapping source files

fallow sky
#

oh ok

fallow sky
#

because it's created using 1.17.1, so craftbukkit wants 1.17.1

inland spoke
#

that can easily be done by renaming the references

fallow sky
fallow sky
fallow sky
inland spoke
#

Yeah

#

Although it is even easier if you use something like cafedude as you'd really only need to modify the constant pool

fallow sky
#

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;
}
}```

inland spoke
#

did you ask ChatGPT here?

fallow sky
#

Gemini

inland spoke
#

regardless, that is some very obvious hallucination here

fallow sky
#

I confirm, it is

inland spoke
#

yeah - if anything ConstantPool would be named ConstantPoolVisitor

#

However, ASM never allowed direct manipulation of the constant pool

fallow sky
#

humm

fallow sky
#

CAFED00D ?

inland spoke
#

Anyways, you'd want to use ClassRemapper in conjunction with a custom Remapper instance - I'd say that works the best

inland spoke
fallow sky
inland spoke
#

technically speaking you could use TR and a hand-crafted IMappingProvider implementation

fallow sky
#

yeah, maybe

inland spoke
#

ClassRemapper and Remapper does the heavy lifting already

fallow sky
#

I'm dumb ๐Ÿคฆโ€โ™‚๏ธ

inland spoke
#

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

fallow sky
fallow sky
#

and I never used javap and Recaf

inland spoke
#

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;
    }
inland spoke
inland spoke
fallow sky
#

wow

#

okay that's... really simple

inland spoke
#

You'd also need to use a ClassRemapper as a ClassVisitor but that's quite easy too

fallow sky
inland spoke
#

Then you just connect the ClassReader with the ClassWriter using your ClassRemapper and everything works

fallow sky
#

org\/bukkit\/craftbukkit\/(.*?)\/ ๐Ÿ‘

#

@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();

inland spoke
#

paper method?

fallow sky
#

yeah, a method papermc implemented in 2020 in Bukkit#getServer

#

they make everything so difficult :/

inland spoke
#

Well even getBukkitVersion works here

fallow sky
#

it's true

inland spoke
#

That being said, they cannot be used in your context (well you can use that to disable mojmap remapping, but eh)

fallow sky
#

x)

inland spoke
#

Yeah, it's the example below it

#

getBukkitVersion existed since forever, so it is safe to use

fallow sky
#

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

inland spoke
fallow sky
#

PAPI

#

well

#

too big

#

I prefer mine x)

#

(I never finished this API)

inland spoke
#

won't handle absolutely all maven versions - while mine handles absolutely any version the same way maven does

fallow sky
inland spoke
#

Well getBukkitVersion at it's core is the version string used for maven

#

technically all of them are relevant - perhaps minus VersionRange

fallow sky
#

okay

#

what are member mappings ๐Ÿ˜ฐ

inland spoke
#

just respond with "oh, I wanted to be better safe than sorry"

#

he has a valid point, though. Halfway forgot that

fallow sky
inland spoke
#

Member mappings are field or method mappings (this specific mapping file only contains class mappings as spigot mappings only have class names remapped)

fallow sky
#

but we just want the class name mapping, right?

inland spoke
#

I mean techncially yes. So technically we could forget that step

fallow sky
#

you look unsure ๐Ÿ‘€

inland spoke
#

Technically correct is the best form of correct

fallow sky
#

technically

inland spoke
#

Jokes aside, I look unsure because I am.

fallow sky
#

I need to go eat, see you later or tomorrow

rigid saffron
#

What have ya guys done while I was asleep?

#

Any progress?

rigid saffron
#

@fallow sky we can probably add a spigot namespace onto our already existing mappings to make stuff easiet

fallow sky
fallow sky
#

I could update mappings-downloader to do that

#

But not rn because school goes first ๐Ÿค“โ˜๏ธ

rigid saffron
#

I also figured out how to pull spigot mappings

rigid saffron
rigid saffron
# rigid saffron I also figured out how to pull spigot mappings

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

woven arrow
#

yarn mappings are pretty good ngl

rigid saffron
#

But I am planning to write some tool to remap spigot into other mappings than mojmaps

#

Yarn us pretty cool but I prefer parchment

woven arrow
#

spigot is obf

rigid saffron
#

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

rigid saffron
#

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

rigid saffron
#

But atleast I know a lot about spigot now

fallow sky
#

Me too x)

rigid saffron
#

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

fallow sky
#

I'd dig a bit into how spigot load plugins

rigid saffron
fallow sky
#

I didn't understand how to use it at first time

rigid saffron
#

Isn't it just loading a file

fallow sky
#

So I'd read some bukkit code

rigid saffron
#

And I'm pretty sure it can load from anywhere

fallow sky
#

I misunderstood what I was saying

rigid saffron
#

Ah, it just does the same thing you do with the plugin.yml

rigid saffron
#

It finds it

fallow sky
rigid saffron
fallow sky
#

Same for cvn-plugin.yml

rigid saffron
#

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

fallow sky
#

but well, the "fack plugin" system is perfectly working

rigid saffron
#

fack plugin?

fallow sky
rigid saffron
#

Well, we aren't making fake plugins

fallow sky
#

I was thinking of "fuck" at the same time because you wrote that x)

rigid saffron
#

We are making real plugins

rigid saffron
fallow sky
rigid saffron
#

Also, we will also have to remap the nms package because of v1_12_R01 or whatever

fallow sky
#

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

fallow sky
#

not a problem

#

I'm already working on that

rigid saffron
#

And that includes craftbukkit

fallow sky
#

using โœจ ASM โœจ

rigid saffron
#

Asm is a pain in the ass, isn't it?

fallow sky
rigid saffron
#

That's why I went for using libs instead of plain asm

rigid saffron
fallow sky
#

here is the needed asm code

#

BUT THEN

rigid saffron
#

When below a certain version

fallow sky
#

I'll pass it to some classe, that pass that to some others classes

rigid saffron
#

When did relocation stop

fallow sky
#

I would use @inland spoke's code but there is dependencies everywhere ๐Ÿ’€

rigid saffron
#

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

rigid saffron
#

Or was it moj to spigot? Idk

fallow sky
#

๐Ÿคž may it works

rigid saffron
#

I will prob try giving it DedicatedServer to see whether it'll remap it or no

fallow sky
#

yeah, good idea ๐Ÿ‘

#

It shouldn't

#

it should just remap methods and fields

#

not classes name

rigid saffron
#

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

fallow sky
#

well

#

well, I think it's enough x)

rigid saffron
#

๐Ÿ‘

fallow sky
#

well I'll play a bit, I over-destroyed my brain yesterday

woven arrow
#

serialization

fallow sky
#

lol

fallow sky
#

let's โœจ work โœจ

#

@inland spoke your code is for java 17...

#

we are in โœจ java 8 โœจ

rigid saffron
#

โœจ Backwards Compatibility โœจ

fallow sky
rigid saffron
#

Doubt it

fallow sky
#

not working

#

I'll use my class, it's working

#

(enough)

rigid saffron
#

How much enough

fallow sky
#

not the best, because it's very basic, but still enough

rigid saffron
#

What is it

fallow sky
rigid saffron
#

What are the content of the class

#

Don't you dare to post the bytecode

fallow sky
rigid saffron
#

Looks fine

#

I used to have a pretty much identical class

fallow sky
#

perfect

spiral onyx
# fallow sky

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

fallow sky
#

yeah for sure

spiral onyx
#

Or make it a public static Version of(String version)

fallow sky
#

yeah

spiral onyx
#

Yay I sorta contributed

#

xD

fallow sky
spiral onyx
#

It doesn't matter which you choose in this case

#

A matter of taste & preference

fallow sky
spiral onyx
#

๐Ÿ˜„

fallow sky
#

ั‚ะพะฒะฐั€ะธั‰

spiral onyx
rigid saffron
#

Actually, wouldn't a Version class be a good interface

rigid saffron
#

Interface with getMajor, getMinor and getPatch

#

And then a static of method

fallow sky
#

hummmmm

#

I can do that

rigid saffron
#

No idea why so, but I kinda feel like it would look nicer

fallow sky
#

well

#

I want simplicity for now x)

#

idk how to make it like an interface

rigid saffron
#
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

spiral onyx
#

Version is basically a data class

#

Could be a record even

#

Why make it an interface

rigid saffron
#

No idea why

spiral onyx
#

Ehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

inland spoke
rigid saffron
#

Reasoning 100

spiral onyx
#

I feel like you are pushing it

inland spoke
#

You know what - I'll just port it right now

spiral onyx
#

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

fallow sky
spiral onyx
#

I had no idea you were coding in Java 8, besides this was just an example of why Version should not be an interface

fallow sky
spiral onyx
#

Do not caps your letters at me, I will cry

rigid saffron
fallow sky
#

x) sorry

spiral onyx
rigid saffron
#

We don't got a good emoji for that

fallow sky
#

I've got one

spiral onyx
fallow sky
rigid saffron
#

Damn

spiral onyx
#

That was.. fast

fallow sky
#

I know

spiral onyx
#

Ah yes, why did I think I could connect to 1.20.6 on 1.20.6

#

Rookie mistake

woven arrow
fallow sky
#

I think I'll use this

#

but well, now, time to go โœจ sleep โœจ

rigid saffron
#

This chat on weekends: ๐Ÿ“ˆ
This chat on weekdays: ๐Ÿ“‰

fallow sky
#

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

rigid saffron
#

Lol

#

I got a phone

#

That's it

spiral onyx
#

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);
    }
rigid saffron
#

Lol

spiral onyx
#

Their license is MIT though

spiral onyx
#

getCurrentVersion() returns 1165 for 1.16.5 for example

#

And just save it in some globally accessible variable

rigid saffron
spiral onyx
#

`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

rigid saffron
#

Solyanka is licensiy

spiral onyx
#

Not legal advice

spiral onyx
rigid saffron
#

Lets just use our own stuff

spiral onyx
#

Just illegally bundle copies of Spigot

rigid saffron
#

Lmao

spiral onyx
#

Hy a xyJIu

rigid saffron
#

Replace the spigot jar with your own while nobody is looking

spiral onyx
#

Ha cBou cTpax U PucK

spiral onyx
rigid saffron
spiral onyx
rigid saffron
rigid saffron
#

It work

fallow sky
#

perfect

woven arrow
#

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

rigid saffron
#

can we please rename the org to SpigotCVN or something

fallow sky
#

I'll change that in a few minutes

woven arrow
#

๐Ÿ‘

rigid saffron
#

does the access transformer count to the mappings

fallow sky
#

okay let's โœจ rename โœจ

#

so, like this io.github.spigotcvn.cvn ?

woven arrow
#

looks good

fallow sky
#

okay ๐Ÿ‘

rigid saffron
woven arrow
#

how many times have you changed names now

rigid saffron
woven arrow
#

damn

fallow sky
#

really ? x)

#

GNI -> CVN -> SpigotCVN

#

so 3 names

rigid saffron
#

something something interface

fallow sky
rigid saffron
#

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

rigid saffron
#

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

woven arrow
#

how do i build the test plugin

#

bt errored ๐Ÿ’€

rigid saffron
#

Lol

woven arrow
#

bro please give an answer \๐Ÿ™

rigid saffron
#

If you don't have the current spigot version built using buildtools the gradle plugin will yell at you anyways

rigid saffron
woven arrow
#

do i build it without --remapped

fallow sky
#

okay I pushed everything on github

#

"From CVN to SpigotCVN"

rigid saffron
#

You need remapped

#

Otherwise the gradle plugin will yell at you

woven arrow
#

bro it doesn't work with remapped \๐Ÿ’€

fallow sky
rigid saffron
#

Womp womp

woven arrow
#

1.19.4

fallow sky
#

it should works

woven arrow
#

i literally can't build it

rigid saffron
#

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

rigid saffron
fallow sky
#

yeah ๐Ÿ‘

fallow sky
woven arrow
#

i'll try updating bt

fallow sky
woven arrow
fallow sky
#

and use BT GUI

rigid saffron
woven arrow
#

uh only in dms

woven arrow
#

never send that on the server lmao

fallow sky
rigid saffron
rigid saffron
#

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

fallow sky
#

x)

rigid saffron
#

Since we are LGPL we can do it, lol

fallow sky
#

we are in legality

rigid saffron
#

Yk, rn cvn is just some Frankenstein assembled from pieces of libraries and applications

fallow sky
rigid saffron
#

lol

woven arrow
rigid saffron
#

Ik I spied on you

woven arrow
#

why did I not put the "raydan ik you're watching"

#

always works

rigid saffron
#

When I saw that error my first thought was mvn clean but since it's build tools I thought that was weird

woven arrow
#

bt is weird

rigid saffron
#

Well, yeah

#

The spigot mappings are seperated into 4 files

#

That's even worse

woven arrow
#

i appreciate the fact that paper ships with mojmaps

#

mojmaps are best

rigid saffron
#

Says a yarner

woven arrow
rigid saffron
#

Imagine writing spigot in parchment

#

Shit I haven't tested any of the things I had to today

woven arrow
#

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

rigid saffron
rigid saffron
#

But it might not work because, well, you know, stuff

woven arrow
#

everything set to j17

rigid saffron
#

No idea

#

does j8 work

#

It should work wjth j8 because of old versions, yk

#

But otherwise, @fallow sky coded it, he knows better

woven arrow
#

noop

#

oh ffs

#

intellij chooses a different java version for gradle

#

it's so fucking stupid

rigid saffron
#

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

woven arrow
#

it works now

rigid saffron
#

lol

#

Okay I'll go sleep

#

Gn

fallow sky
#

Perfect

woven arrow
fallow sky
#

Do you have an error upper ?

fallow sky
#

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

inland spoke
#

whatever my system is, but okay

fallow sky
inland spoke
#

ah uh that

woven arrow
#

i'll start on that mass server tester thingy tomorrow

fallow sky
#

I'm adding you to the github organization

woven arrow
#

yea

fallow sky
#

I sent you the invitation

woven arrow
#

am in

#

i'm now in 5 orgs damn

fallow sky
#

x)

fallow sky
#

"ASM is easy"

#

using bytebuddy, to try

#

but I'm really unsure of what I'm doing x)

woven arrow
fallow sky
#

that's bytebuddy, not me ๐Ÿ’€

woven arrow
#

yea

fallow sky
#

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 ?

inland spoke
#

Why do beginners want to use bytebuddy so frequently?

fallow sky
#

But I can't find a ASM tutorial ๐Ÿ˜ญ

#

And I need to go sleep

inland spoke
#

whatever - skill issue ๐ŸงŒ

fallow sky
#

I'll not use it

#

Looks trash

#

only ASM ๐Ÿ—ฟ

inland spoke
#

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?

rigid saffron
rigid saffron
#

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

rigid saffron
#

nvim

#

But, yeah

woven arrow
#

based

inland spoke
rigid saffron
#

3 non imported not nulls and one imported not null

inland spoke
#

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<>();
rigid saffron
#

How tf is this related

#

What the fuck are you talking about

inland spoke
#

Then what are these 3 non-imported non-nulls?

rigid saffron
#

net.bytebuddy.jar.asm.@NotNull
net.bytebuddy.description.type.@NotNull
implementation.@NotNull

inland spoke
#

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

rigid saffron
#

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

inland spoke
#

e.g. this does not compile

#

while this does

rigid saffron
#

Sir I just joked about the long name

woven arrow
#

what in the name of fuck

rigid saffron
#

Can you now relax or something

woven arrow
rigid saffron
#

I don't need this knowledge because I am not so dumb to not import my classes

inland spoke
#

in this case you didn't have any choice since bytebuddy apparently shades it's own ASM

rigid saffron
#

What even is bytebuddy for

inland spoke
#

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

inland spoke
#

And I'll defo correct this thing as it's poorly understood

rigid saffron
#

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

inland spoke
#

So it would be less annoying to say "well, it's defined in JLS19 9.7.4"?

rigid saffron
#

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"

inland spoke
#

oh well

rigid saffron
#

Also, whoever made the annotations go like that for unimported classes shall burn in hell

inland spoke
#

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

rigid saffron
#

Are there even people who use those

rigid saffron
fallow sky
#

Seems good ๐Ÿ‘

rigid saffron
#

Can the org name be changed

woven arrow
fallow sky
woven arrow
#

i, uh, made a config

#

oh there's still a dot there

#

that's not good

#

this was a slight pain tho lmao

fallow sky
#

oh ๐Ÿคฃ

#

huh, you're using... kotlin

#

hope your code will works correctly

#

x)

woven arrow
fallow sky
inland spoke
#

Either a byte-array or an input stream

fallow sky
#

the input can be the entire jar ?

inland spoke
#

with the data being the raw .class file

fallow sky
#

oh

#

so I should do that for every classes??

inland spoke
#

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)

fallow sky
inland spoke
#

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

fallow sky
inland spoke
#

Each ClassNode represents a single .class file, yea

fallow sky
#

but

#

how can I pass my Remapper to ASM then ?

woven arrow
#

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?

fallow sky
#

yeah

woven arrow
#

just as a warning you will need an incredibly specific dev setup for this to work

rigid saffron
fallow sky
#

oh yeah

rigid saffron
woven arrow
#

i cannot be bothered to rn

rigid saffron
#

I will later then

woven arrow
#

i just wanna figure out the java version every version needs

rigid saffron
#

It tells you

woven arrow
#

it does not

fallow sky
rigid saffron
woven arrow
#

wat

#

where

#

it doesn't exist on all

rigid saffron
#

It doesn't show it for older versions

#

There just use j8

woven arrow
#

oh true

rigid saffron
#

That's most likely how bt does it

woven arrow
#

now how tf do i filter the html for versions ๐Ÿ’€

rigid saffron
woven arrow
#

nope

#

content-type and accept both don't work

#

it looks like it's just a simple nginx file server

rigid saffron
#

Then regex ig

woven arrow
#

yeahh

rigid saffron
#

Or something like thaz

#

You could write an html parser

#

Or use one already existing

woven arrow
#

'([0-9]+\.[0-9]+\.[0-9]+|[0-9]+\.[0-9]+)'

#

ez

rigid saffron
#

It's all inside a pre block, you can prob get all the a's and that's just all the files

woven arrow
#

there's still snapshots

#

i'll just regex the html

#

easier

rigid saffron
#

And dashes

inland spoke
# fallow sky how can I pass my Remapper to ASM then ?

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

rigid saffron
#

@fallow sky at what step are you rn?

#

Like, how far

woven arrow
#

hm

#

this worked in grep wth

rigid saffron
#

You did something wrong

#

Or something went wrong

woven arrow
#

i swear it works fine in grep

inland spoke
#

Try triple-backslash

#

No actually - discard that; had a brainfart there

rigid saffron
#

Java regex being java regex ig

inland spoke
#

I'd just joink a few more capture groups in there

woven arrow
#

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

rigid saffron
#

Building that much is gonna take long anyways

#

Not gonna make a big difference

woven arrow
#

eh

#

i'll just do this

#

does this looks correct @fallow sky

fallow sky
fallow sky
#

wait

rigid saffron
#

Looks fine

fallow sky
#

it's good yeah

rigid saffron
woven arrow
#

idk

#

probably ktor?

#

no idea

rigid saffron
#

I had the same with I think it was jgit

#

Might get slf4j log4j impl or something

#

Or see if I can disable that

woven arrow
#

i love how you can do these function names in kotlin

#

same with classes

rigid saffron
#

Java user when class in kotlin lib is called `Very Important Util Class`: ๐Ÿ˜ฑ

woven arrow
#

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`

rigid saffron
#

Lol

#

Should've named it `THE ONE INSTANCE` or some shit like that

woven arrow
#

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โœจ

rigid saffron
#

Aren't fully static classes usually called util classes

woven arrow
#

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

rigid saffron
woven arrow
#

oh no

rigid saffron
#

I will @JvmStatic all my functions in kotlin

woven arrow
#

i'm not letting you contrib to the masstester

#

YAY IT WORKS

#

bt runs

rigid saffron
#

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

woven arrow
#

yea

#

i'll see

#

๐ŸŽ‰

#

[WARNING] The requested profile "remapped" could not be activated because it does not exist.
that's an issue

woven arrow
rigid saffron
#

Do you need to remap when it's to run a server

woven arrow
#

idk

#

i'll keep it in

woven arrow
rigid saffron
#

It should just work

woven arrow
#

hmm

fallow sky
#

there is no moj maps for this versions

woven arrow
#

yeah i figured

rigid saffron
#

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

fallow sky
#

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

rigid saffron
#

Lol

fallow sky
#

yahooo

#

still not working

#

partially*

#

not working

rigid saffron
#

Lol

#

Show code

#

I wanna see

fallow sky
#
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);
        }
    }
}
fallow sky
#

working, almost

#

asm is working

rigid saffron
#

can you please change clasz to clazz

woven arrow
#

oh god

rigid saffron
#

lol

fallow sky
rigid saffron
#

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

fallow sky
#

x)

rigid saffron
#

yeah looks like I would want to if I want correctly remapped stuff

#

shit

#

looks like my spigot mappings did not work

fallow sky
#

huh

rigid saffron
#

and I have no idea why...

#

what the heck could go wrong

fallow sky
#

honestly, idk

rigid saffron
#

wait

#

why is it loading the mappings in reverse

#

gimme a sec

#

amazing

fallow sky
#

it's good ?

rigid saffron
#

it's working

inland spoke
rigid saffron
#

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

fallow sky
rigid saffron
fallow sky
#

huh

rigid saffron
#

v1_17_R1

#

but

#

the 1.16.5 cb is in the root dir

fallow sky
rigid saffron
fallow sky
#

okay

#

now, I need to put this in the correct folder...

rigid saffron
#

@inland spoke do you know anything about this

fallow sky
#

I'M NOT PASSING PARAMETERS

#

I'M DUMB

rigid saffron
#

lol

rigid saffron
fallow sky
inland spoke
fallow sky
#

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

rigid saffron
#

well, it's not the right name

fallow sky
#

huh

rigid saffron
#

because of spigot mappigns yk

#

just depending on spigot-mappings-downloader will be the future solution

fallow sky
#

yeah

#

I know

#

but for now, need CB to works

rigid saffron
#

what do I do if my local branch is different from the remote one

inland spoke
fallow sky
rigid saffron
fallow sky
inland spoke
fallow sky
#

oh okay

#

thanks

#

let's do that

#

and now, map

inland spoke
#

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

fallow sky
inland spoke
#

You should generally never have to convert an absolute path to a string and back

rigid saffron
#

this is what happens when you commit changes without ensuring nobody has local changes

rigid saffron
#

well, I have a thicc ass commit that changes everything

#

lying around for a whole week already

fallow sky
#

humm

rigid saffron
#

and now it's all fucked

#

can I overwrite it or something

fallow sky
#

but just save your code before

rigid saffron
#

yeah, I did

#

lets go do the funny stuffs

fallow sky
#

or use โœจ Github Desktop โœจ

rigid saffron
#

ij is going crazy with my build.gradle being fucked

fallow sky
#

x)

rigid saffron
#

it's all messed up ;-;

fallow sky
#

yeah I see

#

just fix it ๐Ÿค“

rigid saffron
#

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

fallow sky
#

I told you that you must refetch your project before editing...

rigid saffron
fallow sky
#

well

rigid saffron
#

my changes are like 4 days old rn

#

and you did know that i needed to test them

fallow sky
#

you lost everything ?

rigid saffron
#

no

fallow sky
#

perfect

rigid saffron
#

it's just that my whole git is absolutely fucked and I won't be able to push anything in the next three hours

fallow sky
#

send your code, I'll push that for you

rigid saffron
#

nah

#

thanks

fallow sky
#

:/