Added %quality% placeholder & Bottled Materials

issue #259
This commit is contained in:
Sn0wStorm 2020-04-13 13:52:57 +02:00
parent 2cd52955a0
commit 786a3c5741
19 changed files with 56 additions and 32 deletions

View File

@ -221,8 +221,8 @@ cauldron:
# alcohol: Alkoholgehalt 0-100 in absoluter Menge bei perfektem Getränk (wird dem Spieler hinzugefügt, bei 100 = tot)
# lore: Auflistung von zusätzlichem Text auf dem fertigen Trank. (Farbcodes möglich: z.b. &6)
# Lore nur für bestimmte Qualität möglich mit + Schlecht, ++ Mittel, +++ Gut, vorne anhängen.
# servercommands: Liste von Befehlen ausgeführt vom -Server- wenn der Trank getrunken wird (%player_name% benutzbar)
# playercommands: Liste von Befehlen ausgeführt vom -Spieler- wenn der Trank getrunken wird (%player_name% benutzbar)
# servercommands: Liste von Befehlen ausgeführt vom -Server- wenn der Trank getrunken wird (%player_name% %quality% benutzbar)
# playercommands: Liste von Befehlen ausgeführt vom -Spieler- wenn der Trank getrunken wird (%player_name% %quality% benutzbar)
# drinkmessage: Nachricht im Chat beim trinken des Trankes
# drinktitle: Nachricht als Titel auf dem Bildschirm an den Spieler beim trinken des Trankes
# customModelData: Custom Model Data Modelldaten. Mit dieser Zahl kann die Tranktextur mit einem Resourcepack geändert werden

View File

@ -222,8 +222,8 @@ cauldron:
# alcohol: Absolute amount of alcohol 0-100 in a perfect potion (will be added directly to the player, where 100 means fainting)
# lore: List of additional text on the finished brew. (Formatting codes possible: such as &6)
# Specific lore for quality possible, using + bad, ++ normal, +++ good, added to the front of the line.
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name%)
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name% %quality%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name% %quality%)
# drinkmessage: Chat-message to the Player when drinking the Brew
# drinktitle: Title on Screen to the Player when drinking the Brew
# customModelData: Custom Model Data Tag. This is a number that can be used to add custom textures to the item.

View File

@ -225,8 +225,8 @@ cauldron:
# alcohol: Le montant d'alcool absolu dans une boisson parfaite (cela sera ajouté directement au joueur, où 100% entraînera l'évanouissement), un degré d'alcooléisme en fait
# lore: Liste des textes supplémentaires sur le breuvage fini. (Codes de formatage possibles : tels que &6)
# Texte spécifique de qualité possible, en utilisant + mauvais, ++ normal, +++ bon, ajouté à l'avant de la ligne.
# servercommands: Liste des commandes exécutées par le serveur lors de la consommation de la potion (Peut utiliser %player_name%)
# playercommands: Liste des commandes exécutées par le joueur lors de la consommation de la potion (Peut utiliser %player_name%)
# servercommands: Liste des commandes exécutées par le serveur lors de la consommation de la potion (Peut utiliser %player_name% %quality%)
# playercommands: Liste des commandes exécutées par le joueur lors de la consommation de la potion (Peut utiliser %player_name% %quality%)
# drinkmessage: Chat-message au joueur lorsqu'il boit la potion
# drinktitle: Titre à l'écran du joueur lorsqu'il boit la potion
# customModelData: Custom Model Data Tag. This is a number that can be used to add custom textures to the item.

View File

@ -220,8 +220,8 @@ cauldron:
# alcohol: Volume alcolico da 0 a 100 nella versione perfetta (sarà aggiunta direttamente al giocatore, dove 100 è la quantità massima di alcohol assorbibile.
# lore: List of additional text on the finished brew. (Formatting codes possible: such as &6)
# Specific lore for quality possible, using + bad, ++ normal, +++ good, added to the front of the line.
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name%)
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name% %quality%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name% %quality%)
# drinkmessage: Chat-message to the Player when drinking the Brew
# drinktitle: Title on Screen to the Player when drinking the Brew
# customModelData: Custom Model Data Tag. This is a number that can be used to add custom textures to the item.

View File

@ -354,8 +354,8 @@ cauldron:
# alcohol: Alkoholgehalt 0-100 in absoluter Menge bei perfektem Getränk (wird dem Spieler hinzugefügt, bei 100 = tot)
# lore: Auflistung von zusätzlichem Text auf dem fertigen Trank. (Farbcodes möglich: z.b. &6)
# Lore nur für bestimmte Qualität möglich mit + Schlecht, ++ Mittel, +++ Gut, vorne anhängen.
# servercommands: Liste von Befehlen ausgeführt vom -Server- wenn der Trank getrunken wird (%player_name% benutzbar)
# playercommands: Liste von Befehlen ausgeführt vom -Spieler- wenn der Trank getrunken wird (%player_name% benutzbar)
# servercommands: Liste von Befehlen ausgeführt vom -Server- wenn der Trank getrunken wird (%player_name% %quality% benutzbar)
# playercommands: Liste von Befehlen ausgeführt vom -Spieler- wenn der Trank getrunken wird (%player_name% %quality% benutzbar)
# drinkmessage: Nachricht im Chat beim trinken des Trankes
# drinktitle: Nachricht als Titel auf dem Bildschirm an den Spieler beim trinken des Trankes
# customModelData: Custom Model Data Modelldaten. Mit dieser Zahl kann die Tranktextur mit einem Resourcepack geändert werden

View File

@ -354,8 +354,8 @@ cauldron:
# alcohol: Absolute amount of alcohol 0-100 in a perfect potion (will be added directly to the player, where 100 means fainting)
# lore: List of additional text on the finished brew. (Formatting codes possible: such as &6)
# Specific lore for quality possible, using + bad, ++ normal, +++ good, added to the front of the line.
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name%)
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name% %quality%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name% %quality%)
# drinkmessage: Chat-message to the Player when drinking the Brew
# drinktitle: Title on Screen to the Player when drinking the Brew
# customModelData: Custom Model Data Tag. This is a number that can be used to add custom textures to the item.

View File

@ -358,8 +358,8 @@ cauldron:
# alcohol: Le montant d'alcool absolu dans une boisson parfaite (cela sera ajouté directement au joueur, où 100% entraînera l'évanouissement), un degré d'alcooléisme en fait
# lore: Liste des textes supplémentaires sur le breuvage fini. (Codes de formatage possibles : tels que &6)
# Texte spécifique de qualité possible, en utilisant + mauvais, ++ normal, +++ bon, ajouté à l'avant de la ligne.
# servercommands: Liste des commandes exécutées par le serveur lors de la consommation de la potion (Peut utiliser %player_name%)
# playercommands: Liste des commandes exécutées par le joueur lors de la consommation de la potion (Peut utiliser %player_name%)
# servercommands: Liste des commandes exécutées par le serveur lors de la consommation de la potion (Peut utiliser %player_name% %quality%)
# playercommands: Liste des commandes exécutées par le joueur lors de la consommation de la potion (Peut utiliser %player_name% %quality%)
# drinkmessage: Chat-message au joueur lorsqu'il boit la potion
# drinktitle: Titre à l'écran du joueur lorsqu'il boit la potion
# customModelData: Custom Model Data Tag. This is a number that can be used to add custom textures to the item.

View File

@ -354,8 +354,8 @@ cauldron:
# alcohol: Volume alcolico da 0 a 100 nella versione perfetta (sarà aggiunta direttamente al giocatore, dove 100 è la quantità massima di alcohol assorbibile.
# lore: List of additional text on the finished brew. (Formatting codes possible: such as &6)
# Specific lore for quality possible, using + bad, ++ normal, +++ good, added to the front of the line.
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name%)
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name% %quality%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name% %quality%)
# drinkmessage: Chat-message to the Player when drinking the Brew
# drinktitle: Title on Screen to the Player when drinking the Brew
# customModelData: Custom Model Data Tag. This is a number that can be used to add custom textures to the item.

View File

@ -357,8 +357,8 @@ cauldron:
# alcohol: 完美质量的饮品所含有的酒精度(百分数, 会被直接添加到玩家身上, 100意为直接昏迷)
# lore: List of additional text on the finished brew. (Formatting codes possible: such as &6)
# Specific lore for quality possible, using + bad, ++ normal, +++ good, added to the front of the line.
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name%)
# servercommands: List of Commands executed by the -Server- when drinking the brew (Can use %player_name% %quality%)
# playercommands: List of Commands executed by the -Player- when drinking the brew (Can use %player_name% %quality%)
# drinkmessage: Chat-message to the Player when drinking the Brew
# drinktitle: Title on Screen to the Player when drinking the Brew
# customModelData: Custom Model Data Tag. This is a number that can be used to add custom textures to the item.

View File

@ -44,7 +44,7 @@ Error_PlayerCommand: '&cDieser Befehl kann nur als Spieler ausgeführt werden'
Error_Recipeload: '&cEs konnten nicht alle Rezepte wiederhergesellt werden: Siehe Serverlog!'
Error_ShowHelp: 'Benutze &6/brew help &fum die Hilfe anzuzeigen'
Error_UnknownCommand: Unbekannter Befehl
Error_YmlRead: 'config.yml konnte nicht gelesen werden, ist die Datei im korrekten yml-Format (korrekte Leerzeichen usw.)?'
Error_YmlRead: 'config.yml konnte nicht gelesen werden, ist die Datei im korrekten yml-Format (korrekte Leerzeichen, Strings mit '' '' usw.)?'
# Etc
Etc_Page: Seite

View File

@ -44,7 +44,7 @@ Error_PlayerCommand: '&cThis command can only be executed as a player!'
Error_Recipeload: '&cNot all recipes could be restored: More information in the server log!'
Error_ShowHelp: Use &6/brew help &fto display the help
Error_UnknownCommand: Unknown Command
Error_YmlRead: 'Could not read file config.yml, please make sure the file is in valid yml format (correct spaces etc.)'
Error_YmlRead: 'Could not read file config.yml, please make sure the file is in valid yml format (correct spaces, using '' '' etc.)'
# Etc
Etc_Barrel: Barrel

View File

@ -44,7 +44,7 @@ Error_PlayerCommand: '&cCette commande ne peut être executée que par un joueur
Error_Recipeload: '&cToutes les recettes n´ont pu être restaurées: Plus d´informations dans les logs du serveur !'
Error_ShowHelp: Utilisez &6/brew help &fpour regarder l´aide
Error_UnknownCommand: Commande inconnue
Error_YmlRead: 'Could not read file config.yml, please make sure the file is in valid yml format (correct spaces etc.)'
Error_YmlRead: 'Could not read file config.yml, please make sure the file is in valid yml format (correct spaces, using '' '' etc.)'
# Etc
Etc_Barrel: Baril

View File

@ -44,7 +44,7 @@ Error_PlayerCommand: '&cQuesto comando può essere eseguito solo da un giocatore
Error_Recipeload: '&cNon è stato possibile recuperare tutte le ricette: ulteriori informazioni nel file log!'
Error_ShowHelp: Usa &6/brew help &fper visualizzare l''aiuto
Error_UnknownCommand: Comando sconosciuto
Error_YmlRead: 'Could not read file config.yml, please make sure the file is in valid yml format (correct spaces etc.)'
Error_YmlRead: 'Could not read file config.yml, please make sure the file is in valid yml format (correct spaces, using '' '' etc.)'
# Varie
Etc_Barrel: Barile

View File

@ -44,7 +44,7 @@ Error_PlayerCommand: '&c這個指令只能由玩家執行'
Error_Recipeload: '&c並非所有配方都可以有用服務器日誌中的更多信息'
Error_ShowHelp: 使用 &6/brew help &f顯示幫助
Error_UnknownCommand: 未知的指令
Error_YmlRead: 'Could not read file config.yml, please make sure the file is in valid yml format (correct spaces etc.)'
Error_YmlRead: 'Could not read file config.yml, please make sure the file is in valid yml format (correct spaces, using '' '' etc.)'
# Etc
Etc_Barrel: 釀造桶

View File

@ -281,18 +281,21 @@ public class BCauldron {
return;
}
if (ingredientAdd(clickedBlock, item, player)) {
boolean isBucket = item.getType().equals(Material.WATER_BUCKET)
|| item.getType().equals(Material.LAVA_BUCKET)
|| item.getType().equals(Material.MILK_BUCKET);
boolean isBucket = item.getType().name().endsWith("_BUCKET");
boolean isBottle = LegacyUtil.isBottle(item.getType());
if (item.getAmount() > 1) {
item.setAmount(item.getAmount() - 1);
if (isBucket) {
giveItem(player, new ItemStack(Material.BUCKET));
} else if (isBottle) {
giveItem(player, new ItemStack(Material.GLASS_BOTTLE));
}
} else {
if (isBucket) {
setItemInHand(event, Material.BUCKET, handSwap);
} else if (isBottle) {
setItemInHand(event, Material.GLASS_BOTTLE, handSwap);
} else {
setItemInHand(event, Material.AIR, handSwap);
}

View File

@ -167,7 +167,7 @@ public class BPlayer {
}
if (brew.hasRecipe()) {
brew.getCurrentRecipe().applyDrinkFeatures(player);
brew.getCurrentRecipe().applyDrinkFeatures(player, brew.getQuality());
}
P.p.metricsForDrink(brew);

View File

@ -448,22 +448,22 @@ public class BRecipe {
return false;
}
public void applyDrinkFeatures(Player player) {
public void applyDrinkFeatures(Player player, int quality) {
if (playercmds != null && !playercmds.isEmpty()) {
for (String cmd : playercmds) {
player.performCommand(cmd.replaceAll("%player_name%", player.getName()));
player.performCommand(BUtil.applyPlaceholders(cmd, player.getName(), quality));
}
}
if (servercmds != null && !servercmds.isEmpty()) {
for (String cmd : servercmds) {
P.p.getServer().dispatchCommand(P.p.getServer().getConsoleSender(), cmd.replaceAll("%player_name%", player.getName()));
P.p.getServer().dispatchCommand(P.p.getServer().getConsoleSender(), BUtil.applyPlaceholders(cmd, player.getName(), quality));
}
}
if (drinkMsg != null) {
player.sendMessage(drinkMsg.replaceAll("%player_name%", player.getName()));
player.sendMessage(BUtil.applyPlaceholders(drinkMsg, player.getName(), quality));
}
if (drinkTitle != null) {
player.sendTitle("", drinkTitle.replaceAll("%player_name%", player.getName()), 10, 90, 30);
player.sendTitle("", BUtil.applyPlaceholders(drinkTitle, player.getName(), quality), 10, 90, 30);
}
}

View File

@ -164,6 +164,18 @@ public class BUtil {
return -1;
}
/**
* Replaces the Placeholders %player_name% and %quality% in the given input string
*
* @param input The String to replace the placeholders in
* @param player Player Name to replace %player_name%
* @param quality Quality to replace %quality%
* @return The String with all placeholders replaced
*/
public static String applyPlaceholders(String input, String player, int quality) {
return input.replaceAll("%player_name%", player).replaceAll("%quality%", String.valueOf(quality));
}
/* **************************************** */
/* ********* ********* */
/* ********* Brewery Utils ********* */

View File

@ -129,6 +129,15 @@ public class LegacyUtil {
return false;
}
public static boolean isBottle(Material type) {
if (type == Material.POTION) return true;
if (!P.use1_9) return false;
if (type == Material.LINGERING_POTION || type == Material.SPLASH_POTION) return true;
if (!P.use1_13) return false;
if (type == Material.EXPERIENCE_BOTTLE) return true;
return type.name().equals("HONEY_BOTTLE");
}
public static boolean areStairsInverted(Block block) {
if (!P.use1_13) {
@SuppressWarnings("deprecation")