Problème serveur skin + cape



  • Tout d'abord salut tout le monde 😄

    Aujourd'hui j'essais faire un serveur skin + cape via mon mods mais j'y arrive pas ! j'ai gossé la dessus de plus de 2h pour trouver mon problème mais bref, j'ai pas trouver. A l'instant je vais vous montrer tout se que j'ai fait pour serveur skin + cape

    ma class PlayerCustom

    
    package fr.fruitkit.robotykh.warfury.common;
    
    import java.net.HttpURLConnection;
    import java.net.URL;
    
    import net.minecraft.util.StringUtils;
    
    public class PlayerCustom {
    
    private static String connexion (String adress, String par0Str, String part){
    int code=404;
    try {
    URL u = new URL (adress);
    HttpURLConnection huc = ( HttpURLConnection ) u.openConnection ();
    huc.setRequestMethod ("GET");
    huc.connect () ;
    code = huc.getResponseCode() ;
    System.out.println("SKINURL:code "+code);
    if (code == HttpURLConnection.HTTP_OK)
    return adress;else if (code == HttpURLConnection.HTTP_MOVED_TEMP
    || code == HttpURLConnection.HTTP_MOVED_PERM
    || code == HttpURLConnection.HTTP_SEE_OTHER) {
    String newUrl = huc.getHeaderField("Location");
    huc = (HttpURLConnection) new URL(newUrl).openConnection();
    huc.setRequestMethod ("GET");
    huc.connect ();
    code = huc.getResponseCode();
    System.out.println("SKINURL:code "+code);
    if (code == HttpURLConnection.HTTP_OK)
    return newUrl;
    }
    }
    catch(Exception e){
    System.out.println("SKINURL:Bad Url.");
    }
    return String.format("http://skins.minecraft.net/Minecraft"+ part + "/%s.png", new Object[] {StringUtils.stripControlCodes(par0Str)});
    }
    
    public static String getURLSkinCustom(String par0Str)
    {
    String adress=String.format("http://www.warfurypvp.com/skins/skins/%s.png", new Object[] {StringUtils.stripControlCodes(par0Str)});
    return connexion(adress, par0Str, "Skins");
    }
    
    public static String getURLCapeCustom(String par0Str)
    {
    String adress=String.format("http://www.warfurypvp.com/skins//capes/%s.png", new Object[] {StringUtils.stripControlCodes(par0Str)});
    return connexion(adress, par0Str, "Cloaks");
    }
    
    }
    
    

    ma class SkinClassTransformer

    
    package fr.fruitkit.robotykh.warfury.common;
    
    import static org.objectweb.asm.Opcodes.ARETURN;
    import static org.objectweb.asm.Opcodes.ALOAD;
    import static org.objectweb.asm.Opcodes.INVOKESTATIC;
    import java.util.Iterator;
    import org.objectweb.asm.ClassReader;
    import org.objectweb.asm.ClassWriter;
    import org.objectweb.asm.tree.ClassNode;
    import org.objectweb.asm.tree.InsnList;
    import org.objectweb.asm.tree.InsnNode;
    import org.objectweb.asm.tree.MethodInsnNode;
    import org.objectweb.asm.tree.MethodNode;
    import org.objectweb.asm.tree.VarInsnNode;
    
    public class SkinClassTransformer implements net.minecraft.launchwrapper.IClassTransformer {
    
    @Override
    public byte[] transform(String arg0, String arg1, byte[] arg2) {
    if (arg0.equals("beu")) {
    System.out.println("********* INSIDE OBFUSCATED AbstractClientPlayer TRANSFORMER ABOUT TO PATCH: " + arg0);
    return patchClassASM(arg0, arg2, true);
    }
    
    if (arg0.equals("net.minecraft.client.entity.AbstractClientPlayer")) {
    System.out.println("********* INSIDE AbstractClientPlayer TRANSFORMER ABOUT TO PATCH: " + arg0);
    return patchClassASM(arg0, arg2, false);
    }
    return arg2;
    }
    
    public byte[] patchClassASM(String name, byte[] bytes, boolean obfuscated) {
    
    String targetMethod1Name = "", targetMethod2Name = "";
    boolean ok1 = false, ok2 = false;
    
    if(obfuscated == true) {
    targetMethod1Name ="d";
    targetMethod2Name = "e";
    }
    else {
    targetMethod1Name ="getSkinUrl";
    targetMethod2Name = "getCapeUrl";
    }
    
    ClassNode classNode = new ClassNode();
    ClassReader classReader = new ClassReader(bytes);
    classReader.accept(classNode, 0);
    
    Iterator <methodnode>methods = classNode.methods.iterator();
    while(methods.hasNext())
    {
    MethodNode m = methods.next();
    System.out.println("********* Method Name: "+m.name + " Desc:" + m.desc);
    
    if ((m.name.equals(targetMethod1Name) && m.desc.equals("(Ljava/lang/String;)Ljava/lang/String;")))
    {
    System.out.println("********* Inside target method1!");
    
    InsnList toInject = new InsnList();
    toInject.add(new VarInsnNode(ALOAD, 0));
    toInject.add(new MethodInsnNode(INVOKESTATIC, "fr/fruitkit/robotykh/warfury/common/PlayerCustom", "getURLSkinCustom", "(Ljava/lang/String;)Ljava/lang/String;"));
    toInject.add(new InsnNode(ARETURN));
    
    m.instructions = toInject;
    ok1 = true;
    System.out.println("Patching Method1 Complete!");
    }
    else if ((m.name.equals(targetMethod2Name) && m.desc.equals("(Ljava/lang/String;)Ljava/lang/String;")))
    {
    System.out.println("********* Inside target2 method!");
    InsnList toInject = new InsnList();
    
    toInject.add(new VarInsnNode(ALOAD, 0));
    toInject.add(new MethodInsnNode(INVOKESTATIC, "fr/fruitkit/robotykh/warfury/common/PlayerCustom", "getURLCapeCustom", "(Ljava/lang/String;)Ljava/lang/String;"));
    toInject.add(new InsnNode(ARETURN));
    m.instructions = toInject;
    ok2 = true;
    System.out.println("Patching Method2 Complete!");
    }
    
    if(ok1 && ok2)
    break;
    }
    
    ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    classNode.accept(writer);
    return writer.toByteArray();
    }
    }
    
    

    ma class SkinDummyContainer

    
    package fr.fruitkit.robotykh.warfury.common;
    
    import java.util.Arrays;
    
    import com.google.common.eventbus.EventBus;
    
    import cpw.mods.fml.common.DummyModContainer;
    import cpw.mods.fml.common.LoadController;
    import cpw.mods.fml.common.Mod.EventHandler;
    import cpw.mods.fml.common.ModMetadata;
    import cpw.mods.fml.common.event.FMLConstructionEvent;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    
    public class SkinDummyContainer extends DummyModContainer {
    
    public SkinDummyContainer() {
    super(new ModMetadata());
    ModMetadata meta = getMetadata();
    meta.modId = "warfuryskins";
    meta.name = "WarFury Skins";
    meta.version = "1.0"; //String.format("%d.%d.%d.%d", majorVersion, minorVersion, revisionVersion, buildVersion);
    meta.credits = "RobotykH & Mathmatboy";
    meta.authorList = Arrays.asList("RobotykH");
    meta.description = "Faite votre skin et uploader le ici: http://www.warfurypvp.com/skins/";
    meta.url = "http://www.warfurypvp.com/skins/";
    meta.updateUrl = "";
    meta.screenshots = new String[0];
    meta.logoFile = "";
    
    }
    
    @EventHandler
    public boolean registerBus(EventBus bus, LoadController controller) {
    bus.register(this);
    return true;
    }
    
    @EventHandler
    public void modConstruction(FMLConstructionEvent event){
    
    }
    
    @EventHandler
    public void init(FMLInitializationEvent evt) {
    
    }
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
    
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent evt) {
    
    }
    
    }
    
    

    ma class SkinFMLLoadingPlugin

    
    package fr.fruitkit.robotykh.warfury.common;
    
    import java.io.File;
    import java.util.Map;
    
    import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
    
    public class SkinFMLLoadingPlugin implements IFMLLoadingPlugin {
    
    public String[] getLibraryRequestClass() {
    return null;
    }
    
    @Override
    public String[] getASMTransformerClass() {
    return new String[]{SkinClassTransformer.class.getName()};
    }
    
    @Override
    public String getModContainerClass() {
    return SkinDummyContainer.class.getName();
    }
    
    @Override
    public String getSetupClass() {
    return null;
    }
    
    @Override
    public void injectData(Map <string, object="">data) {
    
    }
    
    @Override
    public String getAccessTransformerClass() {
    return new String(SkinClassTransformer.class.getName());
    }
    
    }
    
    

    Bref, merci de donner un coup de main ! car la je galère un peu :P</string,></methodnode>


  • Moddeurs confirmés Rédacteurs Administrateurs

    toInject.add(new MethodInsnNode(INVOKESTATIC, "fr/fruitkit/robotykh/warfury/common/PlayerCustom", "getURLCapeCustom", "(Ljava/lang/String;)Ljava/lang/String;"));
    Tu es sûr que c'est bon ça ?
    Tu as pas mit tes packages donc je ne sais pas.



  • Bon je vais toute réedit les chose afin que vous aurez tout

    Mais oui c'est supposer d'être bon mon package s'appel vraiment comme sa


    EDIT : Voila tout est rédit


  • Moddeurs confirmés Rédacteurs Administrateurs

    Je ne pas t'aider, je ne maîtrise pas l'asm 😕 (faudrait vraiment que j'apprenne ça quand j'aurai le temps)



  • Ok pas grave mais quelqu'un s'aurait sa serait quoi mon erreur ?



  • Pas personnes c'est quoi mon erreur ?


Log in to reply