How to make the java file run another file

Discussion in 'Plugin Development' started by jay275475, Aug 22, 2013.

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

    jay275475

    Hello I was wondering is it possible if you If a command that ran a java file in the plugin I'm making?

    like if i did /help in the main java folder it would run another java folder called help.java jay275475
     
  2. Offline

    Saposhiente

  3. Offline

    jay275475

    No i mean like i have 2 files on Eclipse for my Plugin and How do i make the command i created run the file?
     
  4. Offline

    Saposhiente

    You're being unclear. What is running what, which thing(s) is/are Java?
     
  5. Offline

    CasparW

    You have to implement it by CommandExecutor and do all the stuff that creates, configs the command

    In the main class also type on the on enable:

    Code:
    this.getCommand("help").setExecutor(new help());
    
     
  6. Offline

    jay275475

    is java
     
  7. Offline

    Saposhiente

    Nominated Most Useless Plugin Development Post 2013
    I still have no idea what you want to do.
     
    Tirelessly likes this.
  8. Offline

    CasparW

    For example this what it would be like in the help.java:

    Code:
    package <your package>
     
    import <your import>
     
    public class help implements CommandExecutor {
           
           public boolean onCommand(CommandSender, sender, Command cmd, String commandLabel, String[] args){
                  Player player = (Player) sender;
                  if(player.hasPermission("<your plugin name>.help")){
                            player.sendMessage(ChatColor.GOLD + "Welcome to the help command!");
                 }
              return <false|true>;
    }
    
     
  9. Offline

    jay275475

    then it would run Help.java?
     
  10. Offline

    CasparW


    Yep if you registered it right
     
  11. Offline

    jay275475

    Im counfuse Im making a plugin where you have a virtual Inventory

    And I have Inventory.java
    and Main.java

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  12. Offline

    CasparW


    Remember don't put the:
    Code:
    if(commandLabel.equalsIgnoreCase("help")){
    
     
  13. Offline

    jay275475

    I need a command in Main.java to run Inventory.java

    CasparW
    Could you help me create a virtual inventory?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  14. Offline

    Tirelessly

    Good thing all of the bukkit inventories are virtual.. server.createInventory(...)
     
  15. Offline

    jay275475

    I mean virtual Chest like things
     
  16. Offline

    Saposhiente

    This is java running java: You don't need to run the files at all; just call methods.
    Eg:
    Help.java:
    ...
    public static void doHelpfulStuff(...) {
    stuff
    }
    ...
    MyPlugin.java:
    ...
    Help.doHelpfulStuff(...);
    ...
     
Thread Status:
Not open for further replies.

Share This Page