mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 08:59:01 +00:00
Added vomiting, "-all" for Words
This commit is contained in:
@@ -62,13 +62,13 @@ public class BIngredients {
|
||||
new Brew(uid, quality, cookRecipe, new BIngredients(ingredients, cookedTime));
|
||||
|
||||
cookedName = cookRecipe.getName(quality);
|
||||
potion.setDurability(Brew.PotionColor.valueOf(cookRecipe.getColor()).getColorId(false));
|
||||
potion.setDurability(Brew.PotionColor.valueOf(cookRecipe.getColor()).getColorId(true));
|
||||
|
||||
} else {
|
||||
// new base potion
|
||||
new Brew(uid, new BIngredients(ingredients, cookedTime));
|
||||
|
||||
if (state == 0) {// TODO sonst 1
|
||||
if (state == 1) {
|
||||
cookedName = "Schlammiger Sud";
|
||||
potion.setDurability(Brew.PotionColor.BLUE.getColorId(false));
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.util.HashMap;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -15,6 +17,9 @@ import com.dre.brewery.Brew;
|
||||
|
||||
public class BPlayer {
|
||||
public static Map<String, BPlayer> players = new HashMap<String, BPlayer>();// Players name and BPlayer
|
||||
private static Map<Player, Integer> pTasks = new HashMap<Player, Integer>();// Player and count
|
||||
private static int taskId;
|
||||
public static int pukeItemId;
|
||||
|
||||
private int quality = 0;// = quality of drunkeness * drunkeness
|
||||
private int drunkeness = 0;// = amount of drunkeness
|
||||
@@ -92,6 +97,7 @@ public class BPlayer {
|
||||
} else {
|
||||
bPlayer.quality = bPlayer.getQuality() * 100;
|
||||
bPlayer.drunkeness = 100;
|
||||
addPuke(player, 60 + (int) (Math.random() * 60));
|
||||
P.p.msg(player, "Du kannst nicht mehr trinken");
|
||||
}
|
||||
}
|
||||
@@ -253,6 +259,66 @@ public class BPlayer {
|
||||
PotionEffectType.HUNGER.createEffect(duration, amplifier).apply(player);
|
||||
}
|
||||
|
||||
// Chance that players puke on big drunkeness
|
||||
// runs every 6 sec, average chance is 10%, so should puke about every 60 sec
|
||||
// good quality can decrease the chance by up to 10%
|
||||
public void drunkPuke(Player player) {
|
||||
if (drunkeness >= 80) {
|
||||
if (drunkeness >= 90) {
|
||||
if (Math.random() < 0.15 - (getQuality() / 100)) {
|
||||
addPuke(player, 20 + (int) (Math.random() * 40));
|
||||
}
|
||||
} else {
|
||||
if (Math.random() < 0.08 - (getQuality() / 100)) {
|
||||
addPuke(player, 10 + (int) (Math.random() * 30));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make a Player puke "count" items
|
||||
public static void addPuke(Player player, int count) {
|
||||
if (!P.p.getConfig().getBoolean("enablePuke", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pTasks.isEmpty()) {
|
||||
taskId = P.p.getServer().getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() {
|
||||
public void run() {
|
||||
pukeTask();
|
||||
}
|
||||
}, 1L, 1L);
|
||||
}
|
||||
pTasks.put(player, count);
|
||||
}
|
||||
|
||||
public static void pukeTask() {
|
||||
for (Player player : pTasks.keySet()) {
|
||||
puke(player);
|
||||
int newCount = pTasks.get(player) - 1;
|
||||
if (newCount == 0) {
|
||||
pTasks.remove(player);
|
||||
} else {
|
||||
pTasks.put(player, newCount);
|
||||
}
|
||||
}
|
||||
if (pTasks.isEmpty()) {
|
||||
P.p.getServer().getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void puke(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
Vector direction = loc.getDirection();
|
||||
direction.multiply(0.5);
|
||||
loc.setY(loc.getY() + 1.5);
|
||||
loc.setPitch(loc.getPitch() + 10);
|
||||
loc.add(direction);
|
||||
Item item = player.getWorld().dropItem(loc, new ItemStack(pukeItemId));
|
||||
item.setVelocity(direction);
|
||||
item.setPickupDelay(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void drunkEffects(Player player) {
|
||||
int duration = 10 - getQuality();
|
||||
duration += drunkeness / 2;
|
||||
@@ -293,11 +359,18 @@ public class BPlayer {
|
||||
public static void drunkeness() {
|
||||
for (String name : players.keySet()) {
|
||||
BPlayer bplayer = players.get(name);
|
||||
|
||||
if (bplayer.drunkeness > 30) {
|
||||
if (bplayer.offlineDrunk == 0) {
|
||||
Player player = getPlayer(name);
|
||||
if (player != null) {
|
||||
|
||||
bplayer.drunkEffects(player);
|
||||
|
||||
if (P.p.getConfig().getBoolean("enablePuke", false)) {
|
||||
bplayer.drunkPuke(player);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ public class P extends JavaPlugin {
|
||||
|
||||
// various Settings
|
||||
autosave = config.getInt("autosave", 3);
|
||||
BPlayer.pukeItemId = Material.matchMaterial(config.getString("pukeItem", "SOUL_SAND")).getId();
|
||||
|
||||
// loading recipes
|
||||
ConfigurationSection configSection = config.getConfigurationSection("recipes");
|
||||
@@ -112,8 +113,9 @@ public class P extends JavaPlugin {
|
||||
configSection = config.getConfigurationSection("cooked");
|
||||
if (configSection != null) {
|
||||
for (String ingredient : configSection.getKeys(false)) {
|
||||
BIngredients.cookedNames.put(Material.matchMaterial(ingredient), (configSection.getString(ingredient)));
|
||||
BIngredients.possibleIngredients.add(Material.matchMaterial(ingredient));
|
||||
Material mat = Material.matchMaterial(ingredient);
|
||||
BIngredients.cookedNames.put(mat, (configSection.getString(ingredient, null)));
|
||||
BIngredients.possibleIngredients.add(mat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,8 @@ public class Words {
|
||||
} else if (from.equalsIgnoreCase("-start")) {
|
||||
from = words;
|
||||
to = to + words;
|
||||
} else if (from.equalsIgnoreCase("-all")) {
|
||||
from = words;
|
||||
} else if (from.equalsIgnoreCase("-space")) {
|
||||
from = " ";
|
||||
} else if (from.equalsIgnoreCase("-random")) {
|
||||
|
||||
Reference in New Issue
Block a user