mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 06:38:56 +00:00
Handle negative alcohol values
This commit is contained in:
@@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (brewAlc > 0) {
|
||||||
bPlayer.drunkeness += brewAlc;
|
bPlayer.drunkeness += brewAlc;
|
||||||
if (quality > 0) {
|
if (quality > 0) {
|
||||||
bPlayer.quality += quality * brewAlc;
|
bPlayer.quality += quality * brewAlc;
|
||||||
} else {
|
} else {
|
||||||
bPlayer.quality += brewAlc;
|
bPlayer.quality += brewAlc;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user