Chimneys API

Chimneys API

What does it allow you to do?

There's not very much things which this API lets you do at the moment, but I believe there'll be more options.

  • Create chimneys
  • Delete chimneys
  • List all chimneys

How to?

To hook into chimneys, you first need to register, that chimneys were enabled or disabled. To do that, you need to listen for PluginEnableEvent and PluginDisableEvent. In both cases call setupChimneys (code below). The code below will help you with hooking into chimneys.

//Your plugin's main class
import sk.tomsik68.chimney.PluginChimney;
private PluginChimney chimneys;
public void setupChimneys(){
 Plugin test = getServer().getPluginManager().getPlugin("Chimneys");
 if(test == null){
  chimneys = null;
  System.out.println("[MyPlugin] Chimneys not found.");
  return;
 }
 try{
 chimneys = (PluginChimney)test;
 System.out.println("[MyPlugin] successfully hooked into Chimneys");
 }catch(ClassCastException cce){
  System.out.println("[MyPlugin] error while hooking into Chimneys");
  cce.printStackTrace();
 }
}
public boolean isChimneys(){
 return chimneys != null;
}

Then, manipulating is simple(continuing previous code):

import sk.tomsik68.chimney.Chimney;
import sk.tomsik68.chimney.CustomLocation;
public void createChimney(Block b,boolean redstone){
  chimneys.createChimney(block,redstone);
}
public void removeChimney(Block block){
  chimneys.removeChimney(block);
}
public Collection<Chimney> getChimneys(){
  return chimneys.getAllChimneys();
}
public void setSmokeCount(Block location,int smokes){
  Chimney chimney = getChimneyAt(new CustomLocation(block));
  if(chimney == null)
    return;
  removeChimney(location);
  chimney.setSmokeCount(smokes);
  createChimney(location,chimney.isRedstone());
}
}

That's pretty much all you can do. If you need any help, comment(please comment on project, not this page, since I can't subscribe to comments on this page),take a ticket, PM/email me. Simply, ask. :)


Comments

Posts Quoted:
Reply
Clear All Quotes