mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 07:49:03 +00:00
Implemented saving
This commit is contained in:
@@ -8,6 +8,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.dre.brewery.BIngredients;
|
||||
|
||||
@@ -26,6 +27,14 @@ public class BCauldron {
|
||||
bcauldrons.add(this);
|
||||
}
|
||||
|
||||
//loading from file
|
||||
public BCauldron(Block block,BIngredients ingredients,int state){
|
||||
this.block = block;
|
||||
this.state = state;
|
||||
this.ingredients = ingredients;
|
||||
bcauldrons.add(this);
|
||||
}
|
||||
|
||||
|
||||
public void onUpdate(){
|
||||
//Check if fire still alive
|
||||
@@ -98,6 +107,20 @@ public class BCauldron {
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(ConfigurationSection config){
|
||||
int id = 0;
|
||||
for(BCauldron cauldron:bcauldrons){
|
||||
//cauldrons are randomly listed
|
||||
ConfigurationSection section = config.createSection(""+id);
|
||||
section.set("block",cauldron.block.getWorld().getName()+"/"+cauldron.block.getX()+"/"+cauldron.block.getY()+"/"+cauldron.block.getZ());
|
||||
if(cauldron.state != 1){
|
||||
section.set("state",cauldron.state);
|
||||
}
|
||||
cauldron.ingredients.save(section.createSection("ingredients"));
|
||||
id++;
|
||||
}
|
||||
}
|
||||
|
||||
//bukkit bug not updating the inventory while executing event, have to schedule the give
|
||||
public static void giveItem(final Player player,final ItemStack item){
|
||||
P.p.getServer().getScheduler().runTaskLater(P.p, new Runnable() {
|
||||
|
||||
Reference in New Issue
Block a user