Spigot Community Server (1.13)

Discussion in 'News and Announcements' started by md_5, Feb 23, 2018.

  1. That's probably because a moderator hasn't promoted you yet.
     
    • Like Like x 1
  2. Hello.
    I wanna test out the Spigot Community Server on Creative.

    I have more than 100 posts.

    IGN: Darkman_Bree
     
  3. jzbakos

    Supporter

    Excited to check it out.

    IGN: jzbakos
     
  4. SlimeDog

    Patron

    Promoted to [Tester]. Find more bugs. ;)
     
    • Friendly Friendly x 1
  5. SlimeDog

    Patron

    Promoted to [Tester]. Find more bugs. :)
     
  6. Is it possible to use buildtools to create your own JAR for testing?
     
    • Creative Creative x 1
  7. That's literally the only purpose of buildtools... It's used to build the SpigotMC Jar that you use to build your server with. If you want to made changes to Spigot, it can be done through patch files that will be applied during buildtools, if I recall correctly. There's more info about this online if you Google around.
     
  8. MiniDigger

    Supporter

    nope, not yet. look up for prereleases by mojang, it is likely that spigot will do prereleases too.
    he means 1.13 builds :D
     
    • Like Like x 1
  9. SlimeDog

    Patron

    I assume you were looking for:
    Promoted to [Tester]. Find more bugs. :)
     
    #590 SlimeDog, Apr 16, 2018
    Last edited: Apr 16, 2018
    • Winner Winner x 1
  10. Loving 1.13 so far!

    IGN: Stimulation
     
  11. SlimeDog

    Patron

    Promoted to [Tester]. Find more bugs. :)
     
    • Winner Winner x 1
  12. at least patching Spigot is easier than patching the BuildTools jar >.>
     
  13. MiniDigger

    Supporter

    Not really. You just need to change some urls
     
  14. Code (Text):

    public static void patch(){
    try {
                ClassPool pool = ClassPool.getDefault();
                ClassPath path = pool.insertClassPath("data/BuildTools/BuildTools.jar");
                pool.importPackage("joptsimple");
                pool.importPackage("org.spigotmc.builder.Builder");
                pool.importPackage("java.io");
                CtClass cc = pool.get("org.spigotmc.builder.Builder");
                CtMethod method = cc.getDeclaredMethod("main");
                try {
                    //Gets added so i can detect when BuildTools is completely finished
                    CtMethod make = CtMethod.make("public static void a() throws Exception {}", cc);
                    cc.addMethod(make);
                    CtMethod a = cc.getDeclaredMethod("a");
                    a.setBody("{"
                        + "File file = new File(\"finished.txt\");\n"
                        + "try {\n"
                        + "file.createNewFile();\n"
                        + "} catch (IOException ex) {\n"
                        + " ex.printStackTrace();\n"
                        + "}}");
                    method.insertAfter("a();");
                    cc.writeFile();
                    byte[] b = cc.toBytecode();
                    pool.removeClassPath(path);
                    JarHandler handler = new JarHandler();
                    handler.replaceJarFile("data/BuildTools/BuildTools.jar", b, "org/spigotmc/builder/Builder.class");
                } catch (CannotCompileException | IOException ex) {
                    ex.printStackTrace();
                }
            } catch (NotFoundException ex) {
                ex.printStackTrace();
            }

    }

     public void replaceJarFile(String jarPathAndName, byte[] fileByteCode, String fileName) throws IOException {
            File jarFile = new File(jarPathAndName);
            File tempJarFile = new File(jarPathAndName + ".tmp");
            JarFile jar = new JarFile(jarFile);
            boolean jarWasUpdated = false;

            try {

                JarOutputStream tempJar = new JarOutputStream(new FileOutputStream(tempJarFile));

                // Allocate a buffer for reading entry data.
                byte[] buffer = new byte[1024];
                int bytesRead;

                try {
                    // Open the given file.

                    try {
                        // Create a jar entry and add it to the temp jar.

                        JarEntry entry = new JarEntry(fileName);
                        tempJar.putNextEntry(entry);
                        tempJar.write(fileByteCode);

                    } catch (Exception ex) {
                        System.out.println(ex);

                        // Add a stub entry here, so that the jar will close without an
                        // exception.
                        tempJar.putNextEntry(new JarEntry("stub"));
                    }

                    // Loop through the jar entries and add them to the temp jar,
                    // skipping the entry that was added to the temp jar already.
                    InputStream entryStream = null;
                    for (Enumeration entries = jar.entries(); entries.hasMoreElements();) {
                        // Get the next entry.

                        JarEntry entry = (JarEntry) entries.nextElement();

                        // If the entry has not been added already, so add it.
                        if (!entry.getName().equals(fileName)) {
                            // Get an input stream for the entry.

                            entryStream = jar.getInputStream(entry);
                            tempJar.putNextEntry(entry);

                            while ((bytesRead = entryStream.read(buffer)) != -1) {
                                tempJar.write(buffer, 0, bytesRead);
                            }
                        } else {
                            System.out.println("Does Equal");
                        }
                    }
                    if (entryStream != null) {
                        entryStream.close();
                    }
                    jarWasUpdated = true;
                } catch (Exception ex) {
                    System.out.println(ex);

                    // IMportant so the jar will close without an
                    // exception.
                    tempJar.putNextEntry(new JarEntry("stub"));
                } finally {
                    tempJar.close();
                }
            } finally {

                jar.close();

                if (!jarWasUpdated) {
                    tempJarFile.delete();
                }
            }

            if (jarWasUpdated) {
                if (jarFile.delete()) {
                    tempJarFile.renameTo(jarFile);
                    System.out.println(jarPathAndName + " updated.");
                } else {
                    System.out.println("Could Not Delete JAR File");
                }
            }

        }
     

    My Current method of adding my own code to the BuildTools jar, there's a few other things i'd like to add so if you happen to know an easier way, lemme know :eek:

    Kinda easier...but a bit more limiting >.>
    https://github.com/jboss-javassist/javassist
     
  15. MiniDigger

    Supporter

    wut. why don't you just fork it and edit the source? wow
     
  16. eh, i could do that...however i wanted to learn something new xD
    plus any time the official version gets updated, i would have to update mine, it's better for me to just download the offical version and then add the code automatically as soon as it finishes downloading

    Edit: plus when it comes to my current edit, i'm only doing one thing, and one thing only which is create a txt file once BuildTools is finished doing it's thing :p
     
    #598 Optic_Fusion1, Apr 17, 2018
    Last edited: Apr 17, 2018
  17. MiniDigger

    Supporter

    Updating would be a simple git merge, and it gets updated like once a year ^^
     
  18. read my edit <3 and hmm..not really sure how i'd go about forking BuildTools since it's https://hub.spigotmc.org/jenkins/job/BuildTools/ when it comes to storing it i could just keep a copy of my edit in the .jar file or something *shrug*
     

Share This Page