mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-09-26 03:42:38 +02: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
|
# 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)
|
# 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)
|
# 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:
|
recipes:
|
||||||
1:
|
1:
|
||||||
@ -108,7 +108,8 @@ recipes:
|
|||||||
COLOR: ORANGE
|
COLOR: ORANGE
|
||||||
difficulty: 4
|
difficulty: 4
|
||||||
alcohol: 12
|
alcohol: 12
|
||||||
effect: WATER_BREATHING/150
|
effects:
|
||||||
|
- WATER_BREATHING/150
|
||||||
6:
|
6:
|
||||||
name: Bitterer Rum/Würziger Rum/Goldener Rum
|
name: Bitterer Rum/Würziger Rum/Goldener Rum
|
||||||
ingredients:
|
ingredients:
|
||||||
@ -120,7 +121,10 @@ recipes:
|
|||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
difficulty: 6
|
difficulty: 6
|
||||||
alcohol: 30
|
alcohol: 30
|
||||||
effect: FIRE_RESISTANCE/100
|
effects:
|
||||||
|
- FIRE_RESISTANCE/100
|
||||||
|
- WEAKNESS/30
|
||||||
|
- POISON/20
|
||||||
7:
|
7:
|
||||||
name: Abgeranzter Vodka/Vodka/Russischer Vodka
|
name: Abgeranzter Vodka/Vodka/Russischer Vodka
|
||||||
ingredients:
|
ingredients:
|
||||||
@ -131,7 +135,8 @@ recipes:
|
|||||||
color: BRIGHT_GREY
|
color: BRIGHT_GREY
|
||||||
difficulty: 4
|
difficulty: 4
|
||||||
alcohol: 20
|
alcohol: 20
|
||||||
effect: WEAKNESS/15
|
effects:
|
||||||
|
- WEAKNESS/15
|
||||||
8:
|
8:
|
||||||
name: minderwertiger Absinth/Absinth/Starker Absinth
|
name: minderwertiger Absinth/Absinth/Starker Absinth
|
||||||
ingredients:
|
ingredients:
|
||||||
@ -141,7 +146,8 @@ recipes:
|
|||||||
color: GREEN
|
color: GREEN
|
||||||
difficulty: 8
|
difficulty: 8
|
||||||
alcohol: 45
|
alcohol: 45
|
||||||
effect: POISON/10
|
effects:
|
||||||
|
- POISON/10
|
||||||
9:
|
9:
|
||||||
name: Kartoffelsuppe
|
name: Kartoffelsuppe
|
||||||
ingredients:
|
ingredients:
|
||||||
@ -150,7 +156,8 @@ recipes:
|
|||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
color: PINK
|
color: PINK
|
||||||
difficulty: 1
|
difficulty: 1
|
||||||
effect: HEAL
|
effects:
|
||||||
|
- HEAL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,7 +125,8 @@ public class BCauldron {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//unloads cauldrons that are in a unloading world
|
// 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) {
|
public static void onUnload(String name) {
|
||||||
for (BCauldron bcauldron : bcauldrons) {
|
for (BCauldron bcauldron : bcauldrons) {
|
||||||
if (bcauldron.block.getWorld().getName().equals(name)) {
|
if (bcauldron.block.getWorld().getName().equals(name)) {
|
||||||
|
@ -130,12 +130,12 @@ public class BIngredients {
|
|||||||
cookingQuality = getCookingQuality(recipe, distilled);
|
cookingQuality = getCookingQuality(recipe, distilled);
|
||||||
|
|
||||||
if (ingredientQuality > -1) {
|
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()) {
|
if (recipe.needsToAge()) {
|
||||||
// needs riping in barrel
|
// needs riping in barrel
|
||||||
ageQuality = getAgeQuality(recipe, time);
|
ageQuality = getAgeQuality(recipe, time);
|
||||||
woodQuality = getWoodQuality(recipe, wood);
|
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?
|
// is this recipe better than the previous best?
|
||||||
if ((((float) ingredientQuality + cookingQuality + woodQuality + ageQuality) / 4) > quality) {
|
if ((((float) ingredientQuality + cookingQuality + woodQuality + ageQuality) / 4) > quality) {
|
||||||
@ -143,6 +143,7 @@ public class BIngredients {
|
|||||||
bestRecipe = recipe;
|
bestRecipe = recipe;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
P.p.log("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " for " + recipe.getName(5));
|
||||||
// calculate quality without age and barrel
|
// calculate quality without age and barrel
|
||||||
if ((((float) ingredientQuality + cookingQuality) / 2) > quality) {
|
if ((((float) ingredientQuality + cookingQuality) / 2) > quality) {
|
||||||
quality = ((float) ingredientQuality + cookingQuality) / 2;
|
quality = ((float) ingredientQuality + cookingQuality) / 2;
|
||||||
@ -230,9 +231,6 @@ public class BIngredients {
|
|||||||
// calculate the quality
|
// calculate the quality
|
||||||
quality -= (((float) Math.abs(count - recipe.amountOf(ingredient)) / recipe.allowedCountDiff(recipe.amountOf(ingredient))) * 10.0);
|
quality -= (((float) Math.abs(count - recipe.amountOf(ingredient)) / recipe.allowedCountDiff(recipe.amountOf(ingredient))) * 10.0);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* if(quality != 0){ quality /= ingredients.size(); }
|
|
||||||
*/
|
|
||||||
if (quality >= 0) {
|
if (quality >= 0) {
|
||||||
return Math.round(quality);
|
return Math.round(quality);
|
||||||
}
|
}
|
||||||
|
@ -353,14 +353,19 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void addBrewEffects(Brew brew, Player player) {
|
public static void addBrewEffects(Brew brew, Player player) {
|
||||||
if (brew.getEffect() != null) {
|
Map<String, Integer> effects = brew.getEffects();
|
||||||
int duration = (brew.getEffectDur() / 8) * brew.getQuality() * 20;
|
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;
|
int amplifier = brew.getQuality() / 3;
|
||||||
|
|
||||||
PotionEffectType type = PotionEffectType.getByName(brew.getEffect());
|
|
||||||
type.createEffect(duration, amplifier).apply(player);
|
type.createEffect(duration, amplifier).apply(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void drunkeness() {
|
public static void drunkeness() {
|
||||||
for (String name : players.keySet()) {
|
for (String name : players.keySet()) {
|
||||||
@ -404,7 +409,7 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (bplayer.drunkeness <= (-1) * bplayer.offlineDrunk) {
|
} 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 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 difficulty;// difficulty to brew the potion, how exact the instruction has to be followed
|
||||||
private int alcohol;// Alcohol in perfect potion
|
private int alcohol;// Alcohol in perfect potion
|
||||||
private String effect;// Special Effect
|
private Map<String, Integer> effects = new HashMap<String, Integer>(); // Special Effect, Duration
|
||||||
private int effectDur;// Duration of the special effect
|
|
||||||
|
|
||||||
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
|
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
|
||||||
String[] name = configSectionRecipes.getString(recipeId + ".name").split("/");
|
String[] name = configSectionRecipes.getString(recipeId + ".name").split("/");
|
||||||
@ -43,12 +42,16 @@ public class BRecipe {
|
|||||||
this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty");
|
this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty");
|
||||||
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol");
|
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol");
|
||||||
|
|
||||||
String effectString = configSectionRecipes.getString(recipeId + ".effect");
|
List<String> effectStringList = configSectionRecipes.getStringList(recipeId + ".effects");
|
||||||
if (effectString != null) {
|
if (effectStringList != null) {
|
||||||
|
for (String effectString : effectStringList) {
|
||||||
String[] effectSplit = effectString.split("/");
|
String[] effectSplit = effectString.split("/");
|
||||||
this.effect = effectSplit[0];
|
P.p.log("effekt: " + effectSplit[0]);
|
||||||
if (effectSplit.length > 1) {
|
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;
|
return alcohol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEffect() {
|
public Map<String, Integer> getEffects() {
|
||||||
return effect;
|
return effects;
|
||||||
}
|
|
||||||
|
|
||||||
public int getEffectDur() {
|
|
||||||
return effectDur;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -153,20 +153,13 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return special effect
|
// return special effect
|
||||||
public String getEffect() {
|
public Map<String, Integer> getEffects() {
|
||||||
if (currentRecipe != null) {
|
if (currentRecipe != null) {
|
||||||
return currentRecipe.getEffect();
|
return currentRecipe.getEffects();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEffectDur() {
|
|
||||||
if (currentRecipe != null) {
|
|
||||||
return currentRecipe.getEffectDur();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Distilling section ---------------
|
// Distilling section ---------------
|
||||||
|
|
||||||
// distill all custom potions in the brewer
|
// 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
|
// Saves all data
|
||||||
public static void save(ConfigurationSection config) {
|
public static void save(ConfigurationSection config) {
|
||||||
for (int uid : potions.keySet()) {
|
for (int uid : potions.keySet()) {
|
||||||
|
@ -319,6 +319,7 @@ public class P extends JavaPlugin {
|
|||||||
|
|
||||||
// save all Data
|
// save all Data
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
|
long time = System.nanoTime();
|
||||||
File datafile = new File(p.getDataFolder(), "data.yml");
|
File datafile = new File(p.getDataFolder(), "data.yml");
|
||||||
|
|
||||||
FileConfiguration oldData = YamlConfiguration.loadConfiguration(datafile);
|
FileConfiguration oldData = YamlConfiguration.loadConfiguration(datafile);
|
||||||
@ -334,25 +335,56 @@ public class P extends JavaPlugin {
|
|||||||
|
|
||||||
FileConfiguration configFile = new YamlConfiguration();
|
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()) {
|
if (!Brew.potions.isEmpty()) {
|
||||||
Brew.save(configFile.createSection("Brew"));
|
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")) {
|
if (!BCauldron.bcauldrons.isEmpty() || oldData.contains("BCauldron")) {
|
||||||
BCauldron.save(configFile.createSection("BCauldron"), oldData.getConfigurationSection("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")) {
|
if (!Barrel.barrels.isEmpty() || oldData.contains("Barrel")) {
|
||||||
Barrel.save(configFile.createSection("Barrel"), oldData.getConfigurationSection("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()) {
|
if (!BPlayer.players.isEmpty()) {
|
||||||
BPlayer.save(configFile.createSection("Player"));
|
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")) {
|
if (!Wakeup.wakeups.isEmpty() || oldData.contains("Wakeup")) {
|
||||||
Wakeup.save(configFile.createSection("Wakeup"), oldData.getConfigurationSection("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 {
|
try {
|
||||||
configFile.save(datafile);
|
configFile.save(datafile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -360,6 +392,10 @@ public class P extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastSave = 1;
|
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() {
|
public String white() {
|
||||||
return ChatColor.WHITE + "";
|
return ChatColor.WHITE.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user