mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 07:49:03 +00:00
Changed alcohol calculation
This commit is contained in:
@@ -114,7 +114,7 @@ public class BCauldron {
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(ConfigurationSection config, ConfigurationSection oldConfig) {
|
||||
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
||||
int id = 0;
|
||||
for (BCauldron cauldron : bcauldrons) {
|
||||
// cauldrons are sorted in worldUUID.randomId
|
||||
@@ -128,9 +128,11 @@ public class BCauldron {
|
||||
id++;
|
||||
}
|
||||
// copy cauldrons that are not loaded
|
||||
for (String uuid : oldConfig.getKeys(false)) {
|
||||
if (!config.contains(uuid)) {
|
||||
config.set(uuid, oldConfig.get(uuid));
|
||||
if (oldData != null){
|
||||
for (String uuid : oldData.getKeys(false)) {
|
||||
if (!config.contains(uuid)) {
|
||||
config.set(uuid, oldData.get(uuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,10 +101,12 @@ public class BPlayer {
|
||||
// decreasing drunkeness over time
|
||||
public static void onUpdate() {
|
||||
if (!players.isEmpty()) {
|
||||
for (BPlayer bplayer : players.values()) {
|
||||
for (String name : players.keySet()) {
|
||||
BPlayer bplayer = players.get(name);
|
||||
bplayer.quality -= bplayer.getQuality();
|
||||
bplayer.drunkeness -= 2;
|
||||
if (bplayer.drunkeness <= 0) {
|
||||
players.remove(bplayer);
|
||||
players.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class Barrel {
|
||||
}
|
||||
|
||||
// Saves all data
|
||||
public static void save(ConfigurationSection config, ConfigurationSection oldConfig) {
|
||||
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
||||
int id = 0;
|
||||
for (Barrel barrel : barrels) {
|
||||
// barrels are sorted in worldUUID.randomId
|
||||
@@ -187,9 +187,11 @@ public class Barrel {
|
||||
id++;
|
||||
}
|
||||
// also save barrels that are not loaded
|
||||
for (String uuid : oldConfig.getKeys(false)) {
|
||||
if (!config.contains(uuid)) {
|
||||
config.set(uuid, oldConfig.get(uuid));
|
||||
if (oldData != null){
|
||||
for (String uuid : oldData.getKeys(false)) {
|
||||
if (!config.contains(uuid)) {
|
||||
config.set(uuid, oldData.get(uuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,8 +111,10 @@ public class Brew {
|
||||
if (distillRuns == 0) {
|
||||
distillRuns = 1;
|
||||
}
|
||||
alc /= distillRuns;
|
||||
alc *= distillRuns * ((float) quality / 10.0);
|
||||
alc *= ((float) quality / 10.0);
|
||||
if (distillRuns > 1) {
|
||||
alc *= (float) distillRuns / 2.0;
|
||||
}
|
||||
return alc;
|
||||
}
|
||||
|
||||
@@ -121,7 +123,10 @@ public class Brew {
|
||||
// calculate quality from all of the factors
|
||||
float quality = (
|
||||
|
||||
ingredients.getIngredientQuality(recipe) + ingredients.getCookingQuality(recipe) + ingredients.getWoodQuality(recipe, wood) + ingredients.getAgeQuality(recipe, ageTime));
|
||||
ingredients.getIngredientQuality(recipe) +
|
||||
ingredients.getCookingQuality(recipe) +
|
||||
ingredients.getWoodQuality(recipe, wood) +
|
||||
ingredients.getAgeQuality(recipe, ageTime));
|
||||
|
||||
quality /= 4;
|
||||
return (int) Math.round(quality);
|
||||
|
||||
@@ -232,7 +232,7 @@ public class P extends JavaPlugin {
|
||||
public void saveData() {
|
||||
File datafile = new File(p.getDataFolder(), "data.yml");
|
||||
|
||||
FileConfiguration oldConfig = YamlConfiguration.loadConfiguration(datafile);
|
||||
FileConfiguration oldData = YamlConfiguration.loadConfiguration(datafile);
|
||||
|
||||
if (datafile.exists()) {
|
||||
if (lastBackup > 10) {
|
||||
@@ -249,11 +249,11 @@ public class P extends JavaPlugin {
|
||||
Brew.save(configFile.createSection("Brew"));
|
||||
}
|
||||
if (!BCauldron.bcauldrons.isEmpty()) {
|
||||
BCauldron.save(configFile.createSection("BCauldron"), oldConfig.getConfigurationSection("BCauldron"));
|
||||
BCauldron.save(configFile.createSection("BCauldron"), oldData.getConfigurationSection("BCauldron"));
|
||||
}
|
||||
|
||||
if (!Barrel.barrels.isEmpty()) {
|
||||
Barrel.save(configFile.createSection("Barrel"), oldConfig.getConfigurationSection("Barrel"));
|
||||
Barrel.save(configFile.createSection("Barrel"), oldData.getConfigurationSection("Barrel"));
|
||||
}
|
||||
|
||||
if (!BPlayer.players.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user