Include Bukkit server in another application

Discussion in 'Bukkit Discussion' started by natinusala, Oct 24, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    natinusala

    Hello,

    I'm making a Java application, and I would like to embed a Bukkit server into it. I've already added the 1.3.2-R2.0 JAR file.

    How can I create a server ? I've seen things like Bukkit server = new Bukkit(); but it says it's private...

    How am I supposed to do to launch a Bukkit server in my application and to have access to all the API's features ?

    Thanks !

    Edit : Okay, I succeed launching the server with org.bukkit.craftbukkit.Main.main(args); ! Now, how could I access to all the API's features ?
     
  2. Offline

    Royal_Soda

    natinusala
    Not sure how you can access the APIs features without a plugin. I'd recommend having your application automatically install a custom plugin, from which you can complete your task.
     
  3. Offline

    TnT

    natinusala
    You are not allowed to redistribute CraftBukkit or Bukkit. I suggest making whatever application you are creating download it from dl.bukkit.org.
     
  4. Offline

    natinusala

    I found how can I do whatever I want, it's actually the same as I could do in a plugin, exactly the same.

    It's strange but it works :D
     
  5. Offline

    LEOcab

    Then five years from now someone tries to use his program and can't because the website is long gone, then he has to spend 10 hours tracking down a 5 year old version of Bukkit. You have no idea how many times s**t like that happened to me. :/
     
  6. Offline

    TnT

    Still, you are not allowed to redistribute CraftBukkit.
     
  7. Offline

    md_5

    I don't want to get involved in flying against the colours or anything. I know we don't support modified builds of CraftBukkit, but I don't see anything in the license that prevents the above given that the appropriate guidelines are followed, could you please clarify the above statement?

    natinusala just saw you succeeded launching it, regardless of the outcome of the above question, you can still use the dl.bukkit.org api to download craftbukkit.jar and then load it using a UrlClassloader. If you start Main.main(args) in a new thread, then you can simply use Bukkit.getServer().whatever
    But make sure the server has started up first (the reason I say new thread is iirc craftbukkit never rejoins the main thread.)
     
  8. Offline

    TnT

  9. Offline

    natinusala

    Hey, wait a minute, it's not a modified build ! It's a program like Bukkit GUI !

    md_5 I think I can use Bukkit.isRunning to see if the server is running or not ?

    edit : hey, could you help me to do a multi-threading thing ? Here is the code I'm using to run the server in a separate thread :

    Code:
            Thread thread = new Thread(new Runnable()
            {
                public void run()
                {
                org.bukkit.craftbukkit.Main.main(args);
                System.out.println("Server running!");
                }
            });
            thread.start();
    
    Unfortunately, when I call Bukkit.shutdown(); it also closes the main thread and frame "BUILD SUCCESSFUL (total time, etc)"... How can I fix this ?
     
  10. Offline

    Afforess

    Incorrect. You are totally free to redistribute. The bukkit.org community and bukkitdev community sites do not allow you to provide downloads to non official builds, but if you write your own website, you can absolutely provide downloads to your own builds, distributions.

    Don't take my word, read the licenses.
     
  11. Offline

    TnT

    Nothing that redistributes CraftBukkit is allowed on our forums. This is what he is looking to do, and this is what I have addressed.

    You can do whatever you please on your community, but anyone who gets CraftBukkit from anywhere other than dl.bukkit.org, or repo.bukkit.org can look for support for their product elsewhere.
     
  12. Offline

    natinusala

    Okaaaaay, I'll tell the users of my thing to download their own copy of CraftBukkit, even if it's not a mod.

    So, could we focus on the Java part of my problem, please ? ^^'
     
  13. Offline

    md_5

    Add a Thread.sleep(Long.MAX_VALUE) to the end of run()
     
  14. Offline

    natinusala

    Like this ?

    Code:
            Thread thread = new Thread(new Runnable()
            {
                public void run()
                {
                org.bukkit.craftbukkit.Main.main(args);
                System.out.println("Server running!");
                    try {
                        Thread.sleep(Long.MAX_VALUE);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    }
                }
            });
            thread.start();
    Same problem here =/
     
Thread Status:
Not open for further replies.

Share This Page