The API

Setup the API

To actually use the API you first have to implement it to your Project. In eclipse you have to go to Properties -> Java Build Path -> Libraries -> Add External Jar. Now select the TerminalAPI.jar and go to your main Class. Now Initialize the TerminalAPI Variable by typing this into your Class:

TerminalAPI TAPI;

Now go to the onEnable Part in your Project and paste this Code here:

TAPI = (TerminalAPI)Bukkit.getServer().getPluginManager().getPlugin("TerminalAPI");

And that was it for the first Part! you now installed the API in your Project.

Using the API

Now we can start using the API. Just type TAPI. and you will get several methods to execute. Here are all of these in a List with description:

TAPI.RunCommand(String command, Player player, ChatColor color);
  • This method Runs a simple command and displays the output in the Chat
  • You need a command (String), a player (Player) and the ChatColor
TAPI.RunScript(String scriptpath);
  • This method Runs a script. You have to specify the Path with the filename
  • Example Path: "C:\Users\User1\Desktop\script.bat"
  • The method only runs the script. There is no output in the Chat
TAPI.RunScriptDisplayOutput(String script, Player player, ChatColor color);
  • This runs a script with output in the Chat
TAPI.RunScriptRecordOutput(String script);
  • This method runs a script and record the output from it to a String
  • You can get the output by Typing:
    String output = TAPI.output;
    
TAPI.SetSystem(String system);
  • With this method you can change the system settings for the Plugin. Valid system strings are: "Windows" and "Linux"

I hope you enjoy the API and create cool stuff with it :) Thanks a Lot for using my plugin!


Comments

Posts Quoted:
Reply
Clear All Quotes