This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
AliasXNeo's profile picture

[Idea] Bukkit peripheral

Started by AliasXNeo, 16 May 2012 - 01:14 AM
AliasXNeo #1
Posted 16 May 2012 - 03:14 AM
Hey,

http://www.computercraft.info/forums2/index.php?/topic/1744-communicating-with-bukkit-tekkit/

Figured I would make a new topic in here in case anyone was interested in developing this. Something as simple as a peripheral with an API to run console commands would be amazing!
AliasXNeo #2
Posted 16 May 2012 - 03:30 AM
Alternatively if someone is willing to point me in the direction of a down-to-earth tutorial or possibly chat with me on Skype and answer a few questions then I would be more than willing to do it myself :P/>/>
AliasXNeo #3
Posted 28 May 2012 - 02:58 AM
Bump. Willing to pay money if necessary to get this built :)/>/>
Noodle #4
Posted 28 May 2012 - 05:46 AM
I doubt it. Not many people know how to code Java and/or even make a plugin for bukkit.
Xfel #5
Posted 28 May 2012 - 09:52 AM
I know how to do it, but I don't really have the time for it and I'm working on two mods already…
I could provide the important part of the code (the peripheral tile entity) if someone else makes the graphics and the framework around it.

public class TileCommandPeripheral extends TileEntity implements IPeripheral {

static class CommandCallback implements ICommandListener {
  private IComputerAccess computer;
 
  private String uname;
 
  CommandCallback(IComputerAccess computer) {
   this.computer = computer;
   uname = "Computer-#"+computer.getID();
  }
 
  public void log(String message)
  {
   computer.postEvent("command_reply", message);
  }
 
  public String getUsername()
  {
   return uname;
  }
}

public String[] getMethods() {
  return new String[]{"issueCommand"};
}

public Object[] call(IComputerAccess computer, int method, Object[] args) throws Exception {
  // only one method, no big choice
 
  if(args.length < 1 || !(args[0] instanceof String)) {
   throw new IllegalArgumentException("arg 1: string expected");
  }
 
  String message = (String) args[0];
 
  ModLoader.getMinecraftServerInstance().addCommand(message, new CommandCallback(computer));
 
  return null;
}
}