mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-14 10:15:38 +01:00
Handle negative alcohol values
This commit is contained in:
parent
cb86a9000a
commit
a848ba4e8d
@ -180,21 +180,25 @@ public class BPlayer {
|
||||
int quality = drinkEvent.getQuality();
|
||||
List<PotionEffect> effects = getBrewEffects(brew.getEffects(), quality);
|
||||
|
||||
if (brewAlc < 1) {
|
||||
if (brewAlc == 0) {
|
||||
//no alcohol so we dont need to add a BPlayer
|
||||
applyEffects(effects, player, PlayerEffectEvent.EffectType.DRINK);
|
||||
if (bPlayer.drunkeness <= 0) {
|
||||
bPlayer.remove();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bPlayer.drunkeness += brewAlc;
|
||||
if (quality > 0) {
|
||||
bPlayer.quality += quality * brewAlc;
|
||||
if (brewAlc > 0) {
|
||||
bPlayer.drunkeness += brewAlc;
|
||||
if (quality > 0) {
|
||||
bPlayer.quality += quality * brewAlc;
|
||||
} else {
|
||||
bPlayer.quality += brewAlc;
|
||||
}
|
||||
} else {
|
||||
bPlayer.quality += brewAlc;
|
||||
bPlayer.drainAndRemove(player, -brewAlc);
|
||||
}
|
||||
|
||||
applyEffects(effects, player, PlayerEffectEvent.EffectType.DRINK);
|
||||
applyEffects(getQualityEffects(quality, brewAlc), player, PlayerEffectEvent.EffectType.QUALITY);
|
||||
|
||||
@ -202,6 +206,7 @@ public class BPlayer {
|
||||
bPlayer.drinkCap(player);
|
||||
}
|
||||
bPlayer.syncToSQL(false);
|
||||
|
||||
if (BConfig.showStatusOnDrink) {
|
||||
bPlayer.showDrunkeness(player);
|
||||
}
|
||||
@ -336,7 +341,11 @@ public class BPlayer {
|
||||
// Eat something to drain the drunkeness
|
||||
public void drainByItem(Player player, Material mat) {
|
||||
int strength = BConfig.drainItems.get(mat);
|
||||
if (drain(player, strength)) {
|
||||
drainAndRemove(player, strength);
|
||||
}
|
||||
|
||||
public void drainAndRemove(Player player, int amount) {
|
||||
if (drain(player, amount)) {
|
||||
remove(player);
|
||||
}
|
||||
}
|
||||
|
@ -338,10 +338,6 @@ public class BRecipe {
|
||||
P.p.errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getRecipeName());
|
||||
return false;
|
||||
}
|
||||
if (alcohol < 0) {
|
||||
P.p.errorLog("Invalid alcohol '" + alcohol + "' in Recipe: " + getRecipeName());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user