Added optional Player argument to /brew create

adds #73 allowing /brew create in command blocks
This commit is contained in:
Sn0wStorm 2016-06-27 23:57:58 +02:00
parent ad53ecf8b8
commit ae1ef10ccb
7 changed files with 60 additions and 121 deletions

View File

@ -55,23 +55,23 @@ Etc_Usage: 'Benutzung:'
Etc_Barrel: Fass
# Help
Help_Copy: '&6/brew Copy <Anzahl>&9 Kopiert den Trank in deiner Hand'
Help_Copy: '&6/brew Copy [Anzahl]&9 Kopiert den Trank in deiner Hand'
Help_Delete: '&6/brew Delete &9Entfernt den Trank in deiner Hand'
Help_Help: '&6/brew help <Seite> &9Zeigt eine bestimmte Hilfeseite an'
Help_Help: '&6/brew help [Seite] &9Zeigt eine bestimmte Hilfeseite an'
Help_Info: '&6/brew Info&9 Zeigt deine aktuelle Trunkenheit und Qualität an'
Help_InfoOther: '&6/brew Info <Spieler>&9 Zeigt die aktuelle Trunkenheit und Qualität von <Spieler> an'
Help_Player: '&6/brew <Spieler> <%Trunkenheit> <Qualität>&9 Setzt Trunkenheit (und Qualität) eines Spielers'
Help_InfoOther: '&6/brew Info [Spieler]&9 Zeigt die aktuelle Trunkenheit und Qualität von [Spieler] an'
Help_Player: '&6/brew <Spieler> <%Trunkenheit> [Qualität]&9 Setzt Trunkenheit (und Qualität) eines Spielers'
Help_Reload: '&6/brew reload &9Config neuladen'
Help_UnLabel: '&6/brew UnLabel &9Entfernt die genaue Beschriftung des Trankes'
Help_Wakeup: '&6/brew Wakeup List <Seite>&9 Listet alle Aufwachpunkte auf'
Help_WakeupAdd: '&6/brew Wakeup Add &9Setzt einen Aufwachpunkt and deiner Position'
Help_WakeupCheck: '&6/brew Wakeup Check &9Teleportiert zu allen Aufwachpunkten'
Help_WakeupCheckSpecific: '&6/brew Wakeup Check <id> &9Teleportiert zu einem Aufwachpunkt'
Help_WakeupList: '&6/brew Wakeup List <Seite> <Welt>&9 Listet die Aufwachpunkte einer Welt auf'
Help_WakeupList: '&6/brew Wakeup List <Seite> [Welt]&9 Listet die Aufwachpunkte einer Welt auf'
Help_WakeupRemove: '&6/brew Wakeup Remove <id> &9Entfernt einen Aufwachpunkt'
Help_Persist: '&6/brew Persist &9Trankdaten permanent machen -> Kopierbar durch andere Plugins'
Help_Static: '&6/brew Static &9Trank unveränderlich machen -> Kein weiteres reifen oder destillieren möglich'
Help_Create: '&6/brew Create <Rezept> <Qualität> &9Erstellt einen Trank mit optionaler Qualität (1-10)'
Help_Create: '&6/brew Create <Rezept> [Qualität] [Spieler] &9Erstellt einen Trank mit optionaler Qualität (1-10)'
# Player
Player_BarrelCreated: Fass erfolgreich erstellt

View File

@ -48,14 +48,14 @@ Etc_Page: Page
Etc_Usage: 'Usage:'
# Help
Help_Copy: '&6/brew copy <Quanitiy>&9 Copies the potion in your hand'
Help_Create: '&6/brew create <Recipe> <Quality> &9Create a Brew with optional quality (1-10)'
Help_Copy: '&6/brew copy [Quantity]&9 Copies the potion in your hand'
Help_Create: '&6/brew create <Recipe> [Quality] [Player] &9Create a Brew with optional quality (1-10)'
Help_Delete: '&6/brew delete &9Deletes the potion in your hand'
Help_Help: '&6/brew help <Page> &9Shows a specific help-page'
Help_Help: '&6/brew help [Page] &9Shows a specific help-page'
Help_Info: '&6/brew info&9 Displays your current Drunkeness and Quality'
Help_InfoOther: '&6/brew info <Player>&9 Displays the current Drunkeness and Quality of <Player>'
Help_InfoOther: '&6/brew info [Player]&9 Displays the current Drunkeness and Quality of [Player]'
Help_Persist: '&6/brew persist &9Make Brew persistent -> copyable by any plugin and technique'
Help_Player: '&6/brew <Player> <%Drunkeness> <Quality>&9 Sets Drunkeness (and Quality) of a Player'
Help_Player: '&6/brew <Player> <%Drunkeness> [Quality]&9 Sets Drunkeness (and Quality) of a Player'
Help_Reload: '&6/brew reload &9Reload config'
Help_Static: '&6/brew static &9Make Brew static -> No further ageing or distilling'
Help_UnLabel: '&6/brew unlabel &9Removes the detailled label of a potion'
@ -63,7 +63,7 @@ Help_Wakeup: '&6/brew wakeup list <Page>&9 Lists all wakeup points'
Help_WakeupAdd: '&6/brew wakeup add &9Adds a wakeup point at your current position'
Help_WakeupCheck: '&6/brew wakeup check &9Teleports to all wakeup points'
Help_WakeupCheckSpecific: '&6/brew wakeup check <id> &9Teleports to the wakeup point with <id>'
Help_WakeupList: '&6/brew wakeup list <Page> <World>&9 Lists all wakeup points of <world>'
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>'
# Perms

View File

@ -48,14 +48,14 @@ Etc_Page: Page
Etc_Usage: 'Utilise:'
# Aide
Help_Copy: '&6/brew copy <Quanitiy>&9 Copie la potion qui est dans votre main'
Help_Create: '&6/brew create <Recipe> <Quality> &9Crée une boisson avec une qualité optionelle (1-10)'
Help_Copy: '&6/brew copy [Quantity]&9 Copie la potion qui est dans votre main'
Help_Create: '&6/brew create <Recipe> [Quality] [Player] &9Crée une boisson avec une qualité optionelle (1-10)'
Help_Delete: '&6/brew delete &9Supprime la potion qui est dans votre main'
Help_Help: '&6/brew help <Page> &9Affiche une page spécifique de l´aide'
Help_Help: '&6/brew help [Page] &9Affiche une page spécifique de l´aide'
Help_Info: '&6/brew info&9 Affiche votre ivresse actuelle ainsi que sa qualité'
Help_InfoOther: '&6/brew info <Player>&9 Affiche l´ivresse actuelle de <PLAYER>, cette commande affiche aussi sa qualité.<Player>'
Help_InfoOther: '&6/brew info [Player]&9 Affiche l´ivresse actuelle de <PLAYER>, cette commande affiche aussi sa qualité.<Player>'
Help_Persist: '&6/brew persist &9Crée une boisson persistante -> peut être copiée par n´importe quel plugin et technique'
Help_Player: '&6/brew <Player> <%Drunkeness> <Quality>&9 Définit l´ivresse (et la qualité) du joueur'
Help_Player: '&6/brew <Player> <%Drunkeness> [Quality]&9 Définit l´ivresse (et la qualité) du joueur'
Help_Reload: '&6/brew reload &9Reload la config'
Help_Static: '&6/brew static &9Rend une boisson statique -> Plus affectée par l´âge ou la distillation'
Help_UnLabel: '&6/brew unlabel &9Supprime l´étiquette détaillée d´une potion'
@ -63,7 +63,7 @@ Help_Wakeup: '&6/brew wakeup list <Page>&9 Affiche une liste de tous les points
Help_WakeupAdd: '&6/brew wakeup add &9Ajoute un point de réveil à votre position'
Help_WakeupCheck: '&6/brew wakeup check &9Téléportation vers tous les points de réveil'
Help_WakeupCheckSpecific: '&6/brew wakeup check <id> &9Téléportation vers le point de réveil avec l´ID <id>'
Help_WakeupList: '&6/brew wakeup list <Page> <World>&9 Affiche une liste de tous les points de réveil de <world>'
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>'
# Permissions

View File

@ -1,74 +0,0 @@
Brew_-times: -times
Brew_BadPotion: Ruined Potion
Brew_BarrelRiped: Barrel aged
Brew_DistillUndefined: Indefinable Distillate
Brew_Distilled: Distilled
Brew_HundredsOfYears: Hundreds of Years
Brew_Ingredients: Ingredients
Brew_MinutePluralPostfix: s
Brew_OneYear: One Year
Brew_ThickBrew: Muddy Brewxxxxx
Brew_Undefined: Indefinable Brew
Brew_Woodtype: Woodtype
Brew_Years: Years
Brew_fermented: fermented
Brew_minute: minute
CMD_Copy_Error: '&6&v1 &cPotions did not fit into your inventory'
CMD_Info_Drunk: '&v1 is &6&v2% &fdrunk, with a quality of &6&v3'
CMD_Info_NotDrunk: '&v1 is not drunk'
CMD_Player: '&a&v1 is now &6&v2% &adrunk, with a quality of &6&v3'
CMD_Player_Error: '&cThe Quality has to be between 1 and 10!'
CMD_Reload: '&aConfig was successfully reloaded'
CMD_UnLabel: '&aLabel removed!'
Error_ConfigUpdate: 'Unknown Brewery Config version: v&v1, Config was not Updated!'
Error_ItemNotPotion: '&cThe Item in your hand could not be identified as Potion'
Error_NoPermissions: '&cYou have no permission to do this!'
Error_PlayerCommand: '&cThis command can only be executed as player'
Error_Recipeload: '&cNot all recipes could be restored: More information in the Serverlog!'
Error_ShowHelp: use &6/brew help &fto display the help
Error_UnknownCommand: Unknown Command
Etc_Barrel: Barrel
Etc_Page: Page
Etc_Usage: 'Usage:'
Help_Copy: '&6/brew Copy <Quanitiy>&9 Copies the Potion in your Hand'
Help_Delete: '&6/brew Delete &9Deletes the Potion in your Hand'
Help_Help: '&6/brew help <Page> &9Shows a specific help-page'
Help_Info: '&6/brew Info&9 Displays your current Drunkeness and Quality'
Help_InfoOther: '&6/brew Info <Player>&9 Displays the current Drunkeness and Quality
of <Player>'
Help_Player: '&6/brew <Player> <%Drunkeness> <Quality>&9 Sets Drunkeness (and Quality)
of a Player'
Help_Reload: '&6/brew reload &9Reload config'
Help_UnLabel: '&6/brew UnLabel &9Removes the detailled label of a Potion'
Help_Wakeup: '&6/brew Wakeup List <Page>&9 Lists all Wakeup Points'
Help_WakeupAdd: '&6/brew Wakeup Add &9Adds a Wakeup Point at your current Position'
Help_WakeupCheck: '&6/brew Wakeup Check &9Teleports to all Wakeup Points'
Help_WakeupCheckSpecific: '&6/brew Wakeup Check <id> &9Teleports to the Wakeup Point
with <id>'
Help_WakeupList: '&6/brew Wakeup List <Page> <World>&9 Lists all Wakeup Points of a
World'
Help_WakeupRemove: '&6/brew Wakeup Remove <id> &9Removes the Wakeup Point with <id>'
Player_BarrelCreated: Barrel created
Player_CantDrink: You can't drink any more
Player_CauldronInfo1: This Cauldron seethes since &v1 minutes
Player_CauldronInfo2: This Cauldron seethes since less than one minute
Player_DrunkPassOut: You have drunken too much and fainted!
Player_LoginDeny: Your character is drunk and does not react. Try again!
Player_LoginDenyLong: Your character is really drunk and unconscious. Try again in 10 minutes!
Player_TriedToSay: '&v1 tried to say: &0&v2'
Player_Wake: Ohh no! I cannot remember how I got here...
Player_WakeAlreadyDeleted: '&cThe Wakeup Point with the id: &6&v1 &chas already been
deleted!'
Player_WakeCancel: '&6Wakeup Point Check was cancelled'
Player_WakeCreated: '&aWakeup Point with id: &6&v1 &awas created successfully!'
Player_WakeDeleted: '&aThe Wakeup Point with the id: &6&v1 &awas successfully deleted!'
Player_WakeFilled: '&cThe Wakeup Point with the id: &6&v1&c at position &6&v2 &v3,
&v4, &v5&c is filled with Blocks!'
Player_WakeHint1: 'To Next Wakeup Point: Punch your fist in the air'
Player_WakeHint2: 'To Cancel: &9/brew wakeup cancel'
Player_WakeLast: '&aThis was the last Wakeup Point'
Player_WakeNoCheck: '&cNo Wakeup Point Check is currently active'
Player_WakeNoPoints: '&cThere are no Wakeup Points!'
Player_WakeNotExist: '&cThe Wakeup Point with the id: &6&v1 &cdoesn''t exist!'
Player_WakeTeleport: 'Teleport to Wakeup Point with the id: &6&v1&f At position: &6&v2
&v3, &v4, &v5'

View File

@ -615,7 +615,7 @@ public class P extends JavaPlugin {
File languages = new File(getDataFolder(), "languages");
if (!languages.exists()) {
String lang[] = new String[] {"de", "en", "fr", "no"};
String lang[] = new String[] {"de", "en", "fr"};
for (String l : lang) {
try {
saveFile(getResource("languages/" + l + ".yml"), languages, l + ".yml", false);

View File

@ -110,15 +110,15 @@ public class LanguageReader {
defaults.put("Perms_NoCauldronFill", "&cYou don't have permissions to fill bottles from this cauldron!");
/* Help */
defaults.put("Help_Help", "&6/brew help <Page> &9Shows a specific help-page");
defaults.put("Help_Player", "&6/brew <Player> <%Drunkeness> <Quality>&9 Sets Drunkeness (and Quality) of a Player");
defaults.put("Help_Help", "&6/brew help [Page] &9Shows a specific help-page");
defaults.put("Help_Player", "&6/brew <Player> <%Drunkeness> [Quality]&9 Sets Drunkeness (and Quality) of a Player");
defaults.put("Help_Info", "&6/brew info&9 Displays your current Drunkeness and Quality");
defaults.put("Help_UnLabel", "&6/brew unlabel &9Removes the detailled label of a potion");
defaults.put("Help_Copy", "&6/brew copy <Quanitiy>&9 Copies the potion in your hand");
defaults.put("Help_Copy", "&6/brew copy [Quantity]>&9 Copies the potion in your hand");
defaults.put("Help_Delete", "&6/brew delete &9Deletes the potion in your hand");
defaults.put("Help_InfoOther", "&6/brew info <Player>&9 Displays the current Drunkeness and Quality of <Player>");
defaults.put("Help_InfoOther", "&6/brew info [Player]&9 Displays the current Drunkeness and Quality of [Player]");
defaults.put("Help_Wakeup", "&6/brew wakeup list <Page>&9 Lists all wakeup points");
defaults.put("Help_WakeupList", "&6/brew wakeup list <Page> <World>&9 Lists all wakeup points of <world>");
defaults.put("Help_WakeupList", "&6/brew wakeup list <Page> [World]&9 Lists all wakeup points of [world]");
defaults.put("Help_WakeupCheck", "&6/brew wakeup check &9Teleports to all wakeup points");
defaults.put("Help_WakeupCheckSpecific", "&6/brew wakeup check <id> &9Teleports to the wakeup point with <id>");
defaults.put("Help_WakeupAdd", "&6/brew wakeup add &9Adds a wakeup point at your current position");
@ -126,7 +126,7 @@ public class LanguageReader {
defaults.put("Help_Reload", "&6/brew reload &9Reload config");
defaults.put("Help_Persist", "&6/brew persist &9Make Brew persistent -> copyable by any plugin and technique");
defaults.put("Help_Static", "&6/brew static &9Make Brew static -> No further ageing or distilling");
defaults.put("Help_Create", "&6/brew create <Recipe> <Quality> &9Create a Brew with optional quality (1-10)");
defaults.put("Help_Create", "&6/brew create <Recipe> [Quality] [Player] &9Create a Brew with optional quality (1-10)");
/* Etc. */
defaults.put("Etc_Usage", "Usage:");

View File

@ -499,29 +499,45 @@ public class CommandListener implements CommandExecutor {
public void cmdCreate(CommandSender sender, String[] args) {
if (sender instanceof Player) {
if (args.length < 2) {
p.msg(sender, p.languageReader.get("Etc_Usage"));
p.msg(sender, p.languageReader.get("Help_Create"));
return;
}
if (args.length < 2) {
p.msg(sender, p.languageReader.get("Etc_Usage"));
p.msg(sender, p.languageReader.get("Help_Create"));
return;
}
int quality = 10;
boolean hasQuality = false;
if (args.length > 2) {
quality = p.parseInt(args[args.length - 1]);
if (quality > 0 && quality <= 10) {
hasQuality = true;
} else {
quality = 10;
int quality = 10;
boolean hasQuality = false;
String pName = null;
if (args.length > 2) {
quality = p.parseInt(args[args.length - 1]);
if (quality <= 0 || quality > 10) {
pName = args[args.length - 1];
if (args.length > 3) {
quality = p.parseInt(args[args.length - 2]);
}
}
int stringLength;
if (hasQuality) {
stringLength = args.length - 2;
if (quality > 0 && quality <= 10) {
hasQuality = true;
} else {
stringLength = args.length - 1;
quality = 10;
}
}
Player player = null;
if (pName != null) {
player = p.getServer().getPlayer(pName);
}
if (sender instanceof Player || player != null) {
if (player == null) {
player = ((Player) sender);
}
int stringLength = args.length - 1;
if (pName != null) {
stringLength--;
}
if (hasQuality) {
stringLength--;
}
String name;
@ -536,9 +552,6 @@ public class CommandListener implements CommandExecutor {
name = args[1];
}
Player player = (Player) sender;
if (player.getInventory().firstEmpty() == -1) {
p.msg(sender, p.languageReader.get("CMD_Copy_Error", "1"));
return;