This repository has been archived on 2021-07-14. You can view files and clone it, but cannot push or open issues or pull requests.
scriptcraft/src/main/js/modules/bukkit/items.js
walterhiggins 19162c3688 First phase of transition from Bukkit to Canary.
Some of the plugins are not yet supported.
If you're feeling brave you can build from source using ant.
2014-09-29 23:42:41 +01:00

29 lines
744 B
JavaScript

var bkItemStack = org.bukkit.inventory.ItemStack;
var items = function( material, amount ) {
material = material.toUpperCase();
return new bkItemStack(bukkit.material[material],amount);
};
var materials = bukkit.material.values();
for (var i = 0;i < materials.length; i++ ){
var name = (''+materials[i].name()).toLowerCase();
name = name.replace(/(_.)/g,function(a){ return a.replace(/_/,'').toUpperCase(); });
items[name] = (function(material){
return function(amount){
if (typeof amount == 'undefined'){
return material;
}
if (typeof amount == 'number'){
return new bkItemStack(material, amount);
} else {
return amount == material;
}
};
})(materials[i]);
}
module.exports = items;