Application Code Generator v1.1 - Make plugins will little effort

Discussion in 'Bukkit Tools' started by bwfcwalshy, Sep 20, 2015.

Thread Status:
Not open for further replies.
  1. Hello! I have been getting into Swing a lot lately and I have made something I wanted to do for a while. A code generator. This program is early in development so please don't expect it to be the best right now. This program can create Java and Bukkit classes including, JFrame's, commands and events! It is designed to make classes with little effort in seconds! All you need to do is click and type a little!

    Images:
    Show Spoiler

    When you first start the program you are faced with the option of either Java or Bukkit.
    [​IMG]

    Java screen:
    [​IMG]

    Bukkit screen:
    [​IMG]

    Finished result:
    [​IMG]


    Any and all feedback is appreciated. As said earlier this is still early in development.

    Version: 1.1

    Download:
    https://www.dropbox.com/s/5h2oqxrw06xe646/CodeGenerator.jar?dl=0

    Changelog:
    • plugin.yml has been added.
    • config.yml has been added.
    • Changed save location from "Generated Classes" to "Generated Plugins"
    • Command is now registered in the main class and plugin.yml

    Old downloads (open)


    Notes:
    This is still early in development
    There are only player events currently, I will be adding them all shortly.
     
    Last edited: Sep 26, 2015
    0566, mine-care and MrBlackIsBack like this.
  2. Offline

    mine-care

  3. Offline

    MCnumi


    Amazing.
     
  4. Offline

    timtower Administrator Administrator Moderator

    @bwfcwalshy Does it also generate the plugin.yml and config.yml?
     
  5. @timtower It does not but that could be something I can add.
     
    0566 and timtower like this.
  6. Offline

    Binner_Done

    This sounds aweeeesomeee! Please keep working on this, I really want to see this used by servers and maybe in the future starting servers that need a custom plugin! KEEP UP GOOD WORK
    @bwfcwalshy!
     
  7. @Binner_Done Thank you, if you have any suggestions I would love to hear them.
     
  8. Offline

    LordDarthBob

    @bwfcwalshy
    Nice! I'm sure beginners to plugin-making will find this useful.

    A suggestion: Swing is extremely useful and portable, but if you had free time or the desire, you might want to consider adding support for SWT which can be more visually appealing. While SWT is platform dependent, I believe I have a way to package several SWT jars in one project, and then load the required one dynamically at runtime. If you'd like, I can provide the information you'd need to implement SWT.
     
  9. Offline

    Lolmewn

    Pretty sure JavaPlugin already implements CommandExecutor though ;)
     
    timtower likes this.
  10. Offline

    LordDarthBob

    @bwfcwalshy
    This code should theoretically work. It may require tweaks, though.
    Code:
    public static void main(String[] args){
       
            String jarname = "";
            String arch = "";
       
            switch (OSType.systemOS()){
       
            case WINDOWS:
                jarname = "swt_win";
                break;
            case OSX:
                jarname = "swt_osx";
                break;
            case LINUX:
                jarname = "swt_linux";
                break;
            case UNSUPPORTED:
                JOptionPane.showMessageDialog(null, "Unsupported operating system", "Error", JOptionPane.ERROR_MESSAGE);
                return;
            }
       
            arch = OSType.getArch();
       
            try
              {
                  URL url = new File("/classpath/to/jars/" + jarname + "_" + arch + ".jar").toURI().toURL();
                  URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
                  Class<?> urlClass = URLClassLoader.class;
                  Method method = urlClass.getDeclaredMethod("addURL", new Class<?>[] { URL.class });
                  method.setAccessible(true);    
                  method.invoke(urlClassLoader, new Object[] { url });        
              }
              catch (Throwable t)
              {
                  JOptionPane.showMessageDialog(null, "Error loading SWT jar for your operating system " + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
                    return;
              }
       
        }
    
    public enum OSType {
             OSX("osx"),
             LINUX("nix"),
             WINDOWS("windows"),
             UNSUPPORTED("?");
         
             private OSType(String os) {
             }
         
             public static OSType systemOS() {
                 String osname = System.getProperty("os.name");
             
                 if (osname.toLowerCase().contains("windows")){
                 
                     return OSType.WINDOWS;
                 
                 }
             
                 if (osname.toLowerCase().contains("osx")){
                 
                     return OSType.OSX;
                 
                 }
             
                 if (osname.toLowerCase().contains("nix")){
                 
                     return OSType.LINUX;
                 
                 }
             
                 return OSType.UNSUPPORTED;
             
            }
         
             public static String getArch()
             {
                String osArch = System.getProperty("os.arch");
    
                if (osArch != null && osArch.contains("64"))
                {
                    return "64";
                }
                else
                {
                    return "32";
                }
             }
    }
    
    The SWT jars are available for download:
    SWT_win_64
    SWT_win_32
    SWT_osx_64
    SWT_osx_32
    SWT_linux_64
    SWT_linux_32

    Hopefully this is helpful
     
    Last edited: Sep 21, 2015
  11. Offline

    teej107

    You do know that you can change the look and feel of Swing applications right? It's a lot easier to do than to try and incorporate SWT and have it work for the OS's.
     
    Last edited: Sep 22, 2015
    timtower likes this.
  12. Offline

    LordDarthBob

    There are pros and cons to both SWT and Swing. Simply because Swing and SWT both are options is by no means a reason to deny people either. Based on situation, each has its own benefits.

    Secondly, I've already included a way to incorporate SWT into a program with minimal effort. Using the aforementioned code:
    It is still cross platform, generally speaking, with the additional benefits of:
    • 100% native look and feel
    • Distributed memory cost due to use of native GUI
    • Faster interface responses

    However, this doesn't mean that SWT is by any means a complete solution. For custom look and feels, complete portability, and extreme convenience, Swing is there.

    All I meant was that SWT support could be added in tandem with Swing support for more variety in development for different applications.
     
  13. I'm working on a new version which will allow you to generate files like a plugin.yml and config.yml.
    @LordDarthBob I will also try out SWT but whether I will use it or not yet is undecided.
     
  14. Offline

    LordDarthBob

  15. Interesting...

    Will permissions you check for anywhere in the program be listed for (potential?) adding to the plugin.yml?
    Will it allow inserting custom code? Could be fun to have that too, though potentially very complicated (bind variable names etc)?
    Do you plan on making the whole API accessible?

    Just random questions :)
     
  16. I may, not sure yet though.

    Probably in the future.

    There is no api :p
     
  17. Update coming tomorrow, sorry it took so long I have just had such little time.
     
  18. Offline

    Binner_Done

    @bwfcwalshy
    WooHoo! Next version
    *Dad Dances in a cringe way*
    Oh yeah! Can't wait til' tomorrow now, I will literally be stuck to my computer working out how to make my own plugin.


    Hopefully...
     
  19. Offline

    Binner_Done

    @bwfcwalshy I would always contact the wonderful bwfcwalshy if I needed help with his things anyway :p
     
  20. Update is coming out soon! Just need to touch up a few things.

    Changelog:
    • plugin.yml has been added.
    • config.yml has been added.
    • Changed save location from "Generated Classes" to "Generated Plugins"
    • Command is now registered in plugin.yml
    Notes:
    Commands are registered in the main class because otherwise I need to use cmd.getName which would cause me to do a lot more work than needed.

    EDIT: Update is now out and post has been updated.

    If that's the main class you don't need to do the main class path, it will do it for you :)
     
    Last edited: Sep 26, 2015
  21. Offline

    tkuiyeager1

    @bwfcwalshy when i use the bukkit section its not generating anything but in the java section its generating the class
     
  22. Offline

    oceantheskatr

    Try making a "Generated Classes" folder in the directory the program is in (or on the desktop if that doesn't work).
     
  23. Offline

    tkuiyeager1

  24. @tkuiyeager1 So it seems it couldn't create the file.
    Could you please run the jar through cmd and see if it posts any errors when it is generating the class.
     
  25. Offline

    tkuiyeager1

    @bwfcwalshy can you explain to me how to do this?
    what do i need to right in the cmd?

    Edit:
    if i type the program name with .jar so it opens it but it doesnt right anything in the cmd
     
  26. Offline

    oceantheskatr

  27. Offline

    tkuiyeager1

    @oceantheskatr and @bwfcwalshy i tried what @oceantheskatr said:
    and i also got error, but when i create the folder myself it works.
     
Thread Status:
Not open for further replies.

Share This Page