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