mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-22 11:35:16 +01:00
Multiple Effects per Potion
This commit is contained in:
parent
62f1d7686a
commit
e2e6448cf6
19
config.yml
19
config.yml
@ -49,7 +49,7 @@ autosave: 3
|
||||
# color: Farbe des Getränks nach destillieren/reifen. DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY
|
||||
# difficulty: 1-10 Genauigkeit der Einhaltung der Vorgaben (1 = ungenau/einfach 10 = sehr genau/schwer)
|
||||
# alcohol: Alkoholgehalt 0-100 in absoluter Menge bei perfektem Getränk (wird dem Spieler hinzugefügt, bei 100 = tot)
|
||||
# effect: Effekt/Dauer Besonderer Trank-Effekt beim Trinken, Dauer in sek. Siehe: http://jd.bukkit.org/rb/apidocs/org/bukkit/potion/PotionEffectType.html
|
||||
# effect: Auflistung Effekt/Dauer Besonderere Trank-Effekte beim Trinken, Dauer in sek. Siehe: http://jd.bukkit.org/rb/apidocs/org/bukkit/potion/PotionEffectType.html
|
||||
|
||||
recipes:
|
||||
1:
|
||||
@ -108,7 +108,8 @@ recipes:
|
||||
COLOR: ORANGE
|
||||
difficulty: 4
|
||||
alcohol: 12
|
||||
effect: WATER_BREATHING/150
|
||||
effects:
|
||||
- WATER_BREATHING/150
|
||||
6:
|
||||
name: Bitterer Rum/Würziger Rum/Goldener Rum
|
||||
ingredients:
|
||||
@ -120,7 +121,10 @@ recipes:
|
||||
color: DARK_RED
|
||||
difficulty: 6
|
||||
alcohol: 30
|
||||
effect: FIRE_RESISTANCE/100
|
||||
effects:
|
||||
- FIRE_RESISTANCE/100
|
||||
- WEAKNESS/30
|
||||
- POISON/20
|
||||
7:
|
||||
name: Abgeranzter Vodka/Vodka/Russischer Vodka
|
||||
ingredients:
|
||||
@ -131,7 +135,8 @@ recipes:
|
||||
color: BRIGHT_GREY
|
||||
difficulty: 4
|
||||
alcohol: 20
|
||||
effect: WEAKNESS/15
|
||||
effects:
|
||||
- WEAKNESS/15
|
||||
8:
|
||||
name: minderwertiger Absinth/Absinth/Starker Absinth
|
||||
ingredients:
|
||||
@ -141,7 +146,8 @@ recipes:
|
||||
color: GREEN
|
||||
difficulty: 8
|
||||
alcohol: 45
|
||||
effect: POISON/10
|
||||
effects:
|
||||
- POISON/10
|
||||
9:
|
||||
name: Kartoffelsuppe
|
||||
ingredients:
|
||||
@ -150,7 +156,8 @@ recipes:
|
||||
cookingtime: 3
|
||||
color: PINK
|
||||
difficulty: 1
|
||||
effect: HEAL
|
||||
effects:
|
||||
- HEAL
|
||||
|
||||
|
||||
|
||||
|
@ -126,6 +126,7 @@ public class BCauldron {
|
||||
}
|
||||
|
||||
// unloads cauldrons that are in a unloading world
|
||||
// as they were written to file just before, this is safe to do
|
||||
public static void onUnload(String name) {
|
||||
for (BCauldron bcauldron : bcauldrons) {
|
||||
if (bcauldron.block.getWorld().getName().equals(name)) {
|
||||
|
@ -130,12 +130,12 @@ public class BIngredients {
|
||||
cookingQuality = getCookingQuality(recipe, distilled);
|
||||
|
||||
if (ingredientQuality > -1) {
|
||||
P.p.log("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " Wood Quality: " + getWoodQuality(recipe, wood) + " age Quality: "
|
||||
+ getAgeQuality(recipe, time) + " for " + recipe.getName(5));
|
||||
if (recipe.needsToAge()) {
|
||||
// needs riping in barrel
|
||||
ageQuality = getAgeQuality(recipe, time);
|
||||
woodQuality = getWoodQuality(recipe, wood);
|
||||
P.p.log("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " Wood Quality: " + getWoodQuality(recipe, wood) +
|
||||
" age Quality: " + getAgeQuality(recipe, time) + " for " + recipe.getName(5));
|
||||
|
||||
// is this recipe better than the previous best?
|
||||
if ((((float) ingredientQuality + cookingQuality + woodQuality + ageQuality) / 4) > quality) {
|
||||
@ -143,6 +143,7 @@ public class BIngredients {
|
||||
bestRecipe = recipe;
|
||||
}
|
||||
} else {
|
||||
P.p.log("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " for " + recipe.getName(5));
|
||||
// calculate quality without age and barrel
|
||||
if ((((float) ingredientQuality + cookingQuality) / 2) > quality) {
|
||||
quality = ((float) ingredientQuality + cookingQuality) / 2;
|
||||
@ -230,9 +231,6 @@ public class BIngredients {
|
||||
// calculate the quality
|
||||
quality -= (((float) Math.abs(count - recipe.amountOf(ingredient)) / recipe.allowedCountDiff(recipe.amountOf(ingredient))) * 10.0);
|
||||
}
|
||||
/*
|
||||
* if(quality != 0){ quality /= ingredients.size(); }
|
||||
*/
|
||||
if (quality >= 0) {
|
||||
return Math.round(quality);
|
||||
}
|
||||
|
@ -353,14 +353,19 @@ public class BPlayer {
|
||||
}
|
||||
|
||||
public static void addBrewEffects(Brew brew, Player player) {
|
||||
if (brew.getEffect() != null) {
|
||||
int duration = (brew.getEffectDur() / 8) * brew.getQuality() * 20;
|
||||
Map<String, Integer> effects = brew.getEffects();
|
||||
if (effects != null) {
|
||||
for (Map.Entry<String, Integer> entry : effects.entrySet()) {
|
||||
PotionEffectType type = PotionEffectType.getByName(entry.getKey());
|
||||
if (type != null) {
|
||||
int duration = (entry.getValue() / 8) * brew.getQuality() * 20;
|
||||
int amplifier = brew.getQuality() / 3;
|
||||
|
||||
PotionEffectType type = PotionEffectType.getByName(brew.getEffect());
|
||||
type.createEffect(duration, amplifier).apply(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void drunkeness() {
|
||||
for (String name : players.keySet()) {
|
||||
@ -404,7 +409,7 @@ public class BPlayer {
|
||||
}
|
||||
}
|
||||
} else if (bplayer.drunkeness <= (-1) * bplayer.offlineDrunk) {
|
||||
players.remove(name);
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,7 @@ public class BRecipe {
|
||||
private String color;// color of the destilled/finished potion
|
||||
private int difficulty;// difficulty to brew the potion, how exact the instruction has to be followed
|
||||
private int alcohol;// Alcohol in perfect potion
|
||||
private String effect;// Special Effect
|
||||
private int effectDur;// Duration of the special effect
|
||||
private Map<String, Integer> effects = new HashMap<String, Integer>(); // Special Effect, Duration
|
||||
|
||||
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
|
||||
String[] name = configSectionRecipes.getString(recipeId + ".name").split("/");
|
||||
@ -43,12 +42,16 @@ public class BRecipe {
|
||||
this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty");
|
||||
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol");
|
||||
|
||||
String effectString = configSectionRecipes.getString(recipeId + ".effect");
|
||||
if (effectString != null) {
|
||||
List<String> effectStringList = configSectionRecipes.getStringList(recipeId + ".effects");
|
||||
if (effectStringList != null) {
|
||||
for (String effectString : effectStringList) {
|
||||
String[] effectSplit = effectString.split("/");
|
||||
this.effect = effectSplit[0];
|
||||
P.p.log("effekt: " + effectSplit[0]);
|
||||
if (effectSplit.length > 1) {
|
||||
this.effectDur = P.p.parseInt(effectSplit[1]);
|
||||
effects.put(effectSplit[0], P.p.parseInt(effectSplit[1]));
|
||||
} else {
|
||||
effects.put(effectSplit[0], 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -189,12 +192,8 @@ public class BRecipe {
|
||||
return alcohol;
|
||||
}
|
||||
|
||||
public String getEffect() {
|
||||
return effect;
|
||||
}
|
||||
|
||||
public int getEffectDur() {
|
||||
return effectDur;
|
||||
public Map<String, Integer> getEffects() {
|
||||
return effects;
|
||||
}
|
||||
|
||||
}
|
@ -153,20 +153,13 @@ public class Brew {
|
||||
}
|
||||
|
||||
// return special effect
|
||||
public String getEffect() {
|
||||
public Map<String, Integer> getEffects() {
|
||||
if (currentRecipe != null) {
|
||||
return currentRecipe.getEffect();
|
||||
return currentRecipe.getEffects();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getEffectDur() {
|
||||
if (currentRecipe != null) {
|
||||
return currentRecipe.getEffectDur();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Distilling section ---------------
|
||||
|
||||
// distill all custom potions in the brewer
|
||||
@ -269,6 +262,10 @@ public class Brew {
|
||||
}
|
||||
}
|
||||
|
||||
public PotionMeta addQualityLore(PotionMeta meta, String prefix, String lore) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Saves all data
|
||||
public static void save(ConfigurationSection config) {
|
||||
for (int uid : potions.keySet()) {
|
||||
|
@ -319,6 +319,7 @@ public class P extends JavaPlugin {
|
||||
|
||||
// save all Data
|
||||
public void saveData() {
|
||||
long time = System.nanoTime();
|
||||
File datafile = new File(p.getDataFolder(), "data.yml");
|
||||
|
||||
FileConfiguration oldData = YamlConfiguration.loadConfiguration(datafile);
|
||||
@ -334,25 +335,56 @@ public class P extends JavaPlugin {
|
||||
|
||||
FileConfiguration configFile = new YamlConfiguration();
|
||||
|
||||
time = System.nanoTime() - time;
|
||||
float ftime = (float) (time / 1000000.0);
|
||||
p.log("Creating a savefile (" + ftime + "ms)");
|
||||
time = System.nanoTime();
|
||||
|
||||
if (!Brew.potions.isEmpty()) {
|
||||
Brew.save(configFile.createSection("Brew"));
|
||||
}
|
||||
|
||||
time = System.nanoTime() - time;
|
||||
ftime = (float) (time / 1000000.0);
|
||||
p.log("Saving Brew (" + ftime + "ms)");
|
||||
time = System.nanoTime();
|
||||
|
||||
if (!BCauldron.bcauldrons.isEmpty() || oldData.contains("BCauldron")) {
|
||||
BCauldron.save(configFile.createSection("BCauldron"), oldData.getConfigurationSection("BCauldron"));
|
||||
}
|
||||
|
||||
time = System.nanoTime() - time;
|
||||
ftime = (float) (time / 1000000.0);
|
||||
p.log("Saving BCauldrons (" + ftime + "ms)");
|
||||
time = System.nanoTime();
|
||||
|
||||
if (!Barrel.barrels.isEmpty() || oldData.contains("Barrel")) {
|
||||
Barrel.save(configFile.createSection("Barrel"), oldData.getConfigurationSection("Barrel"));
|
||||
}
|
||||
|
||||
time = System.nanoTime() - time;
|
||||
ftime = (float) (time / 1000000.0);
|
||||
p.log("Saving Barrels (" + ftime + "ms)");
|
||||
time = System.nanoTime();
|
||||
|
||||
if (!BPlayer.players.isEmpty()) {
|
||||
BPlayer.save(configFile.createSection("Player"));
|
||||
}
|
||||
|
||||
time = System.nanoTime() - time;
|
||||
ftime = (float) (time / 1000000.0);
|
||||
p.log("Saving players (" + ftime + "ms)");
|
||||
time = System.nanoTime();
|
||||
|
||||
if (!Wakeup.wakeups.isEmpty() || oldData.contains("Wakeup")) {
|
||||
Wakeup.save(configFile.createSection("Wakeup"), oldData.getConfigurationSection("Wakeup"));
|
||||
}
|
||||
|
||||
time = System.nanoTime() - time;
|
||||
ftime = (float) (time / 1000000.0);
|
||||
p.log("Saving Wakeups (" + ftime + "ms)");
|
||||
time = System.nanoTime();
|
||||
|
||||
try {
|
||||
configFile.save(datafile);
|
||||
} catch (IOException e) {
|
||||
@ -360,6 +392,10 @@ public class P extends JavaPlugin {
|
||||
}
|
||||
|
||||
lastSave = 1;
|
||||
|
||||
time = System.nanoTime() - time;
|
||||
ftime = (float) (time / 1000000.0);
|
||||
p.log("Writing Data to File (" + ftime + "ms)");
|
||||
}
|
||||
|
||||
|
||||
@ -420,7 +456,7 @@ public class P extends JavaPlugin {
|
||||
}
|
||||
|
||||
public String white() {
|
||||
return ChatColor.WHITE + "";
|
||||
return ChatColor.WHITE.toString();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user