mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-24 21:31:22 +01:00
Brew Drink command to simulate drinking a brew
This commit is contained in:
parent
2471628e2d
commit
4111ceec81
@ -30,6 +30,8 @@ CMD_Configname_Error: '&cDu hast kein Item in der Hand'
|
||||
CMD_UnLabel: '&aDas Label wurde entfernt'
|
||||
CMD_Static: '&aTrank ist nun unveränderlich und kann nicht weiter gereift oder destilliert werden.'
|
||||
CMD_NonStatic: '&eTrank ist wieder veränderlich und kann normal gereift oder destilliert werden'
|
||||
CMD_Drink: '&aDu trinkst &v1'
|
||||
CMD_DrinkOther: '&a&v1 trinkt &v2'
|
||||
|
||||
# Error
|
||||
Error_ConfigUpdate: 'Unbekannte Brewery Config Version: v&v1, Config wurde nicht geupdated!'
|
||||
@ -73,7 +75,8 @@ Help_WakeupRemove: '&6/brew Wakeup Remove <id> &9Entfernt einen Aufwachpunkt'
|
||||
Help_Static: '&6/brew Static &9Trank unveränderlich machen -> Kein weiteres reifen oder destillieren möglich'
|
||||
Help_Create: '&6/brew Create <Rezept> [Qualität] [Spieler] &9Erstellt einen Trank mit optionaler Qualität (1-10)'
|
||||
Help_Give: '&6/brew give <Rezept> [Qualität] [Spieler] &9Alias für /brew create'
|
||||
Help_Puke: '&6/brew puke [Spieler] [Menge] &9Bringt dich, oder [Player] zum erbrechen'
|
||||
Help_Puke: '&6/brew puke [Spieler] [Menge] &9Bringt [Spieler] zum erbrechen'
|
||||
Help_Drink: '&6/brew drink <Rezept> [Qualität] [Spieler] &9Simuliert das Trinken eines Trankes bei [Spieler]'
|
||||
|
||||
# Permission
|
||||
Perms_NoBarrelCreate: '&cDu hast keine Rechte Fässer zu erstellen!'
|
||||
|
@ -30,6 +30,8 @@ CMD_Configname: '&aName for the Config is: &f&v1'
|
||||
CMD_Configname_Error: '&cCould not find item in your hand'
|
||||
CMD_Static: '&aPotion is now static and will not change in barrels or brewing stands.'
|
||||
CMD_UnLabel: '&aLabel removed!'
|
||||
CMD_Drink: '&aYou drank one &v1'
|
||||
CMD_DrinkOther: '&a&v1 drinks one &v2'
|
||||
|
||||
# Error
|
||||
Error_ConfigUpdate: 'Unknown Brewery config version: v&v1, config was not updated!'
|
||||
@ -74,6 +76,7 @@ Help_WakeupCheckSpecific: '&6/brew wakeup check <id> &9Teleports to the wakeup p
|
||||
Help_WakeupList: '&6/brew wakeup list <Page> [World]&9 Lists all wakeup points of <world>'
|
||||
Help_WakeupRemove: '&6/brew wakeup remove <id> &9Removes the wakeup point with <id>'
|
||||
Help_Puke: '&6/brew puke [Player] [Amount] &9Makes you or [Player] puke'
|
||||
Help_Drink: '&6/brew drink <Recipe> [Quality] [Player] &9Simulates [Player] drinking a Brew'
|
||||
|
||||
# Perms
|
||||
Perms_NoBarrelCreate: '&cYou don''t have permissions to create barrels!'
|
||||
|
@ -31,6 +31,8 @@ CMD_Configname: '&aEl nombre de la configuración es: &f&v1'
|
||||
CMD_Configname_Error: '&cNo se pudo encontrar el artículo en tu mano'
|
||||
CMD_Static: '&aLa poción ahora es estática y no cambiará en barriles o puestos de elaboración.'
|
||||
CMD_UnLabel: '&aEtiqueta eliminada!'
|
||||
CMD_Drink: '&aYou drank one &v1'
|
||||
CMD_DrinkOther: '&a&v1 drinks one &v2'
|
||||
|
||||
# Error
|
||||
Error_ConfigUpdate: 'Versión de configuración de Brewery desconocida: v&v1, ¡la configuración no se actualizó!'
|
||||
@ -75,6 +77,7 @@ Help_WakeupCheckSpecific: '&6/brew wakeup check <id> &9Teletransporta al punto d
|
||||
Help_WakeupList: '&6/brew wakeup list <Página> [Mundo]&9 Enumera todos los puntos de activación del <Mundo>'
|
||||
Help_WakeupRemove: '&6/brew wakeup remove <id> &9Elimina el punto de activación con <id>'
|
||||
Help_Puke: '&6/brew puke [Player] [Amount] &9Makes you or [Player] puke'
|
||||
Help_Drink: '&6/brew drink <Recipe> [Quality] [Player] &9Simulates [Player] drinking a Brew'
|
||||
|
||||
# Perms
|
||||
Perms_NoBarrelCreate: '&c¡No tienes permisos para crear barriles!'
|
||||
|
@ -30,6 +30,8 @@ CMD_Configname: '&aName for the Config is: &f&v1'
|
||||
CMD_Configname_Error: '&cN´a pas pu trouver d´objet dans votre main'
|
||||
CMD_Static: '&aLa boisson est maintenant statique et ne changera pas dans les barils ou les stands d´alchimie.'
|
||||
CMD_UnLabel: '&aLabel supprimé!'
|
||||
CMD_Drink: '&aYou drank one &v1'
|
||||
CMD_DrinkOther: '&a&v1 drinks one &v2'
|
||||
|
||||
# Erreurs
|
||||
Error_ConfigUpdate: 'La version de la configuration de Brewery est inconnue: v&v1, la config n´a pas été mise à jour !'
|
||||
@ -74,6 +76,7 @@ Help_WakeupCheckSpecific: '&6/brew wakeup check <id> &9Téléportation vers le p
|
||||
Help_WakeupList: '&6/brew wakeup list <Page> [World]&9 Affiche une liste de tous les points de réveil de [world]'
|
||||
Help_WakeupRemove: '&6/brew wakeup remove <id> &9Enlève le point de réveil avec l´ID <id>'
|
||||
Help_Puke: '&6/brew puke [Player] [Amount] &9Makes you or [Player] puke'
|
||||
Help_Drink: '&6/brew drink <Recipe> [Quality] [Player] &9Simulates [Player] drinking a Brew'
|
||||
|
||||
# Permissions
|
||||
Perms_NoBarrelCreate: '&cVous n´avez pas la permission de créer des barils !'
|
||||
|
@ -30,6 +30,8 @@ CMD_Configname: '&aName for the Config is: &f&v1'
|
||||
CMD_Configname_Error: '&cCould not find item in your hand'
|
||||
CMD_Static: '&aLa pozione è ora statica e non cambierà né nei barili né negli alambicchi.'
|
||||
CMD_UnLabel: '&aEtichetta rimossa!'
|
||||
CMD_Drink: '&aYou drank one &v1'
|
||||
CMD_DrinkOther: '&a&v1 drinks one &v2'
|
||||
|
||||
# Errori
|
||||
Error_ConfigUpdate: 'Versione della configurazione di Brewery sconosciuta: v&v1, la configurazione non è stato aggiornata!'
|
||||
@ -74,6 +76,7 @@ Help_WakeupCheckSpecific: '&6/brew wakeup check <ID> &9Ti teletrasporta al punto
|
||||
Help_WakeupList: '&6/brew wakeup list <Pagina> <Mondo>&9 Elenca tutti i punti di risveglio di <Mondo>'
|
||||
Help_WakeupRemove: '&6/brew wakeup remove <ID> &9Rimuove il punto di risveglio con id <id>'
|
||||
Help_Puke: '&6/brew puke [Player] [Amount] &9Makes you or [Player] puke'
|
||||
Help_Drink: '&6/brew drink <Recipe> [Quality] [Player] &9Simulates [Player] drinking a Brew'
|
||||
|
||||
# Permessi
|
||||
Perms_NoBarrelCreate: '&cNon hai il permesso di costruire barili!'
|
||||
|
@ -30,6 +30,8 @@ CMD_Configname: '&aName for the Config is: &f&v1'
|
||||
CMD_Configname_Error: '&cНет предмета в руке.'
|
||||
CMD_Static: '&aБражка заморожена и не будет портиться в бочках.'
|
||||
CMD_UnLabel: '&aLabel removed!'
|
||||
CMD_Drink: '&aYou drank one &v1'
|
||||
CMD_DrinkOther: '&a&v1 drinks one &v2'
|
||||
|
||||
# Error
|
||||
Error_ConfigUpdate: 'Неизвестная версия конфига Brewery: v&v1, конфиг не обновлён!'
|
||||
@ -74,6 +76,7 @@ Help_WakeupCheckSpecific: '&6/brew wakeup check <id> &9Телепортация
|
||||
Help_WakeupList: '&6/brew wakeup list <Page> [World]&9 Список всех точек пробуждения в <world>'
|
||||
Help_WakeupRemove: '&6/brew wakeup remove <id> &9Удаление всех точек пробуждения с айди <id>'
|
||||
Help_Puke: '&6/brew puke [Player] [Amount] &9Makes you or [Player] puke'
|
||||
Help_Drink: '&6/brew drink <Recipe> [Quality] [Player] &9Simulates [Player] drinking a Brew'
|
||||
|
||||
# Perms
|
||||
Perms_NoBarrelCreate: '&cУ тебя нет прав на создание бочек!'
|
||||
|
@ -30,6 +30,8 @@ CMD_Configname: '&aName for the Config is: &f&v1'
|
||||
CMD_Configname_Error: '&cCould not find item in your hand'
|
||||
CMD_Static: '&a藥水現在是靜止的,不會在桶或釀造台上變化.'
|
||||
CMD_UnLabel: '&a標籤已刪除!'
|
||||
CMD_Drink: '&aYou drank one &v1'
|
||||
CMD_DrinkOther: '&a&v1 drinks one &v2'
|
||||
|
||||
# Error
|
||||
Error_ConfigUpdate: '未知 釀酒 設定檔版本: v&v1,設定檔沒有更新!'
|
||||
@ -74,6 +76,7 @@ Help_WakeupCheckSpecific: '&6/brew wakeup check <id> &9使用<id>傳送到喚醒
|
||||
Help_WakeupList: '&6/brew wakeup list <頁數> [World]&9 列出<world>的所有喚醒點'
|
||||
Help_WakeupRemove: '&6/brew wakeup remove <id> &9使用<id>刪除喚醒點'
|
||||
Help_Puke: '&6/brew puke [Player] [Amount] &9Makes you or [Player] puke'
|
||||
Help_Drink: '&6/brew drink <Recipe> [Quality] [Player] &9Simulates [Player] drinking a Brew'
|
||||
|
||||
# Perms
|
||||
Perms_NoBarrelCreate: '&c您沒有權限創建釀造桶!'
|
||||
|
@ -30,6 +30,8 @@ CMD_Configname: '配置文件中&aName的名字是: &f&v1'
|
||||
CMD_Configname_Error: '&c无法找到物品名称'
|
||||
CMD_Static: '&a饮品已被静滞, 现在其无法被蒸馏或进行木桶熟成.'
|
||||
CMD_UnLabel: '&a标签已被去除!'
|
||||
CMD_Drink: '&aYou drank one &v1'
|
||||
CMD_DrinkOther: '&a&v1 drinks one &v2'
|
||||
|
||||
# Error
|
||||
Error_ConfigUpdate: '未知的配置版本:v&v1, 插件配置未更新!'
|
||||
@ -74,6 +76,7 @@ Help_WakeupCheckSpecific: '&6/brew wakeup check <id> &9传送至指定苏醒处.
|
||||
Help_WakeupList: '&6/brew wakeup list <页数> [世界] &9列出该世界所有的苏醒处.'
|
||||
Help_WakeupRemove: '&6/brew wakeup remove <页数> &9移除指定id的苏醒处.'
|
||||
Help_Puke: '&6/brew puke [Player] [Amount] &9Makes you or [Player] puke'
|
||||
Help_Drink: '&6/brew drink <Recipe> [Quality] [Player] &9Simulates [Player] drinking a Brew'
|
||||
|
||||
# Perms
|
||||
Perms_NoBarrelCreate: '&c你没有权限创造木桶!'
|
||||
|
@ -161,12 +161,14 @@ public class BPlayer {
|
||||
bPlayer = addPlayer(player);
|
||||
}
|
||||
BrewDrinkEvent drinkEvent = new BrewDrinkEvent(brew, meta, player, bPlayer);
|
||||
P.p.getServer().getPluginManager().callEvent(drinkEvent);
|
||||
if (drinkEvent.isCancelled()) {
|
||||
if (bPlayer.drunkeness <= 0) {
|
||||
bPlayer.remove();
|
||||
if (meta != null) {
|
||||
P.p.getServer().getPluginManager().callEvent(drinkEvent);
|
||||
if (drinkEvent.isCancelled()) {
|
||||
if (bPlayer.drunkeness <= 0) {
|
||||
bPlayer.remove();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (brew.hasRecipe()) {
|
||||
|
@ -779,7 +779,7 @@ public class Brew implements Cloneable {
|
||||
* @param recipe Recipe is required if the brew doesn't have a currentRecipe
|
||||
* @return The created Item, null if the Event is cancelled
|
||||
*/
|
||||
public ItemStack createItem(BRecipe recipe) {
|
||||
public ItemStack createItem(@Nullable BRecipe recipe) {
|
||||
return createItem(recipe, true);
|
||||
}
|
||||
|
||||
@ -791,7 +791,7 @@ public class Brew implements Cloneable {
|
||||
* @return The created Item, null if the Event is cancelled
|
||||
*/
|
||||
@Contract("_, false -> !null")
|
||||
public ItemStack createItem(BRecipe recipe, boolean event) {
|
||||
public ItemStack createItem(@Nullable BRecipe recipe, boolean event) {
|
||||
if (recipe == null) {
|
||||
recipe = getCurrentRecipe();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.dre.brewery.recipe.BRecipe;
|
||||
import com.dre.brewery.recipe.Ingredient;
|
||||
import com.dre.brewery.recipe.RecipeItem;
|
||||
import com.dre.brewery.utility.BUtil;
|
||||
import com.dre.brewery.utility.Tuple;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -16,6 +17,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
@ -140,6 +142,10 @@ public class CommandListener implements CommandExecutor {
|
||||
|
||||
cmdPuke(sender, args);
|
||||
|
||||
} else if (cmd.equalsIgnoreCase("drink")) {
|
||||
|
||||
cmdDrink(sender, args);
|
||||
|
||||
} else {
|
||||
|
||||
if (p.getServer().getPlayerExact(cmd) != null || BPlayer.hasPlayerbyName(cmd)) {
|
||||
@ -214,6 +220,10 @@ public class CommandListener implements CommandExecutor {
|
||||
cmds.add(p.languageReader.get("Help_Give"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("brewery.cmd.drink") || sender.hasPermission("brewery.cmd.drinkOther")) {
|
||||
cmds.add(p.languageReader.get("Help_Drink"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("brewery.cmd.reload")) {
|
||||
cmds.add(p.languageReader.get("Help_Configname"));
|
||||
cmds.add(p.languageReader.get("Help_Reload"));
|
||||
@ -615,13 +625,35 @@ public class CommandListener implements CommandExecutor {
|
||||
}
|
||||
|
||||
public void cmdCreate(CommandSender sender, String[] args) {
|
||||
|
||||
if (args.length < 2) {
|
||||
p.msg(sender, p.languageReader.get("Etc_Usage"));
|
||||
p.msg(sender, p.languageReader.get("Help_Create"));
|
||||
return;
|
||||
}
|
||||
|
||||
Tuple<Brew, Player> brewForPlayer = getFromCommand(sender, args);
|
||||
|
||||
if (brewForPlayer != null) {
|
||||
if (brewForPlayer.b().getInventory().firstEmpty() == -1) {
|
||||
p.msg(sender, p.languageReader.get("CMD_Copy_Error", "1"));
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = brewForPlayer.a().createItem(null);
|
||||
if (item != null) {
|
||||
brewForPlayer.b().getInventory().addItem(item);
|
||||
p.msg(sender, p.languageReader.get("CMD_Created"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Tuple<Brew, Player> getFromCommand(CommandSender sender, String[] args) {
|
||||
if (args.length < 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int quality = 10;
|
||||
boolean hasQuality = false;
|
||||
String pName = null;
|
||||
@ -647,7 +679,7 @@ public class CommandListener implements CommandExecutor {
|
||||
|
||||
if (!(sender instanceof Player) && player == null) {
|
||||
p.msg(sender, p.languageReader.get("Error_PlayerCommand"));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (player == null) {
|
||||
@ -675,22 +707,13 @@ public class CommandListener implements CommandExecutor {
|
||||
}
|
||||
name = name.replaceAll("\"", "");
|
||||
|
||||
if (player.getInventory().firstEmpty() == -1) {
|
||||
p.msg(sender, p.languageReader.get("CMD_Copy_Error", "1"));
|
||||
return;
|
||||
}
|
||||
|
||||
BRecipe recipe = BRecipe.getMatching(name);
|
||||
if (recipe != null) {
|
||||
ItemStack item = recipe.create(quality);
|
||||
if (item != null) {
|
||||
player.getInventory().addItem(item);
|
||||
p.msg(sender, p.languageReader.get("CMD_Created"));
|
||||
}
|
||||
return new Tuple<>(recipe.createBrew(quality), player);
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Error_NoBrewName", name));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void cmdPuke(CommandSender sender, String[] args) {
|
||||
@ -728,7 +751,37 @@ public class CommandListener implements CommandExecutor {
|
||||
count = 20 + (int) (Math.random() * 40);
|
||||
}
|
||||
BPlayer.addPuke(player, count);
|
||||
return;
|
||||
}
|
||||
|
||||
public void cmdDrink(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("brewery.cmd.drink") || !sender.hasPermission("brewery.cmd.drink")) {
|
||||
p.msg(sender, p.languageReader.get("Error_NoPermissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
p.msg(sender, p.languageReader.get("Etc_Usage"));
|
||||
p.msg(sender, p.languageReader.get("Help_Drink"));
|
||||
return;
|
||||
}
|
||||
|
||||
Tuple<Brew, Player> brewForPlayer = getFromCommand(sender, args);
|
||||
if (brewForPlayer != null) {
|
||||
Player player = brewForPlayer.b();
|
||||
if ((!sender.equals(player) && !sender.hasPermission("brewery.cmd.drinkOther")) ||
|
||||
(sender.equals(player) && !sender.hasPermission("brewery.cmd.drink"))) {
|
||||
p.msg(sender, p.languageReader.get("Error_NoPermissions"));
|
||||
} else {
|
||||
Brew brew = brewForPlayer.a();
|
||||
String brewName = brew.getCurrentRecipe().getName(brew.getQuality());
|
||||
BPlayer.drink(brew, null, player);
|
||||
|
||||
p.msg(player, p.languageReader.get("CMD_Drink", brewName));
|
||||
if (!sender.equals(player)) {
|
||||
p.msg(sender, p.languageReader.get("CMD_DrinkOther", player.getDisplayName(), brewName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user