Merge pull request #259 from GunfighterJ/patch-2

Added more book commands for editing author and title
This commit is contained in:
KHobbits 2013-01-13 14:57:35 -08:00
commit f82d7e806f
14 changed files with 188 additions and 26 deletions

View File

@ -1,9 +1,11 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.ItemMeta;
@ -14,32 +16,88 @@ public class Commandbook extends EssentialsCommand
super("book");
}
//TODO: Translate this
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
ItemStack item = user.getItemInHand();
String player = user.getName();
if (item.getType() == Material.WRITTEN_BOOK)
{
ItemMeta meta = item.getItemMeta();
ItemStack newItem = new ItemStack(Material.BOOK_AND_QUILL, item.getAmount());
newItem.setItemMeta(meta);
user.setItemInHand(newItem);
user.sendMessage("You can now edit the contents of this book.");
BookMeta bmeta = (BookMeta)meta;
if (args[0].equalsIgnoreCase("author"))
{
if (user.isAuthorized("essentals.book.author"))
{
ItemStack newbook = new ItemStack(Material.WRITTEN_BOOK, 1);
bmeta.setAuthor(args[1]);
newbook.setItemMeta(bmeta);
user.setItemInHand(newbook);
user.sendMessage(_("bookAuthorSet", args[1]));
}
else
{
user.sendMessage(_("denyChangeAuthor"));
}
}
else if (args[0].equalsIgnoreCase("title"))
{
if (user.isAuthorized("essentials.book.title"))
{
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.title.others"))
{
ItemStack newbook = new ItemStack(Material.WRITTEN_BOOK, 1);
bmeta.setTitle(args[1]);
newbook.setItemMeta(bmeta);
user.setItemInHand(newbook);
user.sendMessage(_("bookTitleSet", args[1]));
}
else
{
user.sendMessage(_("denyChangeTitle"));
}
}
else
{
user.sendMessage(_("denyChangeTitle"));
}
}
else
{
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))
{
ItemStack newItem = new ItemStack(Material.BOOK_AND_QUILL, item.getAmount());
newItem.setItemMeta(meta);
user.setItemInHand(newItem);
user.sendMessage(_("editBookContents"));
}
else
{
user.sendMessage(_("denyBookEdit"));
}
}
}
else if (item.getType() == Material.BOOK_AND_QUILL)
{
ItemMeta meta = item.getItemMeta();
BookMeta bmeta = (BookMeta)meta;
bmeta.setAuthor(player);
ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
newItem.setItemMeta(meta);
newItem.setItemMeta(bmeta);
user.setItemInHand(newItem);
user.sendMessage("This book is now locked and signed.");
user.sendMessage(_("bookLocked"));
}
else
{
throw new Exception("You are not holding a writable book.");
throw new Exception(_("holdBook"));
}
}
private boolean isAuthor(BookMeta bmeta, String player)
{
return bmeta.getAuthor().equalsIgnoreCase(player);
}
}

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -481,3 +481,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book

View File

@ -5,15 +5,15 @@
action=* {0} {1}
addedToAccount=\u00a7a{0} har blivit tillagt p\u00e5 ditt konto.
addedToOthersAccount=\u00a7a{0} har blivit tillagt p\u00e5 {1}\u00a7a konto. Ny balans: {2}
adventure = \u00E4ventyr
adventure = \u00e4ventyr
alertBroke=gjorde s\u00f6nder:
alertFormat=\u00a73[{0}] \u00a7f {1} \u00a76 {2} at: {3}
alertPlaced=placerade:
alertUsed=anv\u00e4nde:
antiBuildBreak=\u00a74Du har inte till\u00E5telse att ta s\u00F6nder {0} blocks h\u00E4r.
antiBuildInteract=\u00a74Du har inte till\u00E5telse att p\u00E5verka {0}.
antiBuildPlace=\u00a74Du har inte till\u00E5telse att placera {0} h\u00E4r.
antiBuildUse=\u00a74Du har inte till\u00E5telse att anv\u00E4nda {0}.
antiBuildBreak=\u00a74Du har inte till\u00e5telse att ta s\u00f6nder {0} blocks h\u00e4r.
antiBuildInteract=\u00a74Du har inte till\u00e5telse att p\u00e5verka {0}.
antiBuildPlace=\u00a74Du har inte till\u00e5telse att placera {0} h\u00e4r.
antiBuildUse=\u00a74Du har inte till\u00e5telse att anv\u00e4nda {0}.
autoAfkKickReason=Du har blivit utsparkad f\u00f6r att ha varit inaktiv i mer \u00e4n {0} minuter.
backAfterDeath=\u00a77Anv\u00e4nd /back kommandot f\u00f6r att komma tillbaka till din d\u00f6dsplats.
backUsageMsg=\u00a77Tar dig tillbaka till din f\u00f6reg\u00e5ende position.
@ -115,7 +115,7 @@ godDisabledFor=inaktiverat f\u00f6r {0}
godEnabledFor=aktiverat f\u00f6r {0}
godMode=\u00a77Od\u00f6dlighet {0}.
hatArmor=\u00a7cFel, du kan inte anv\u00e4nda den h\u00e4r saken som en hatt!
hatEmpty=\u00a7cDu har inte p\u00E5 dig en hatt.
hatEmpty=\u00a7cDu har inte p\u00e5 dig en hatt.
hatFail=\u00a7cDu m\u00e5ste ha n\u00e5gonting att b\u00e4ra i din hand.
hatPlaced=\u00a7eNjut av din nya hatt!
hatRemoved=\u00a7eDin hatt har tagits bort.
@ -157,7 +157,7 @@ inventoryClearedOthers=\u00a77F\u00f6rr\u00e5det av \u00a7c{0}\u00a77 \u00e4r re
is=\u00e4r
itemCannotBeSold=Det objektet kan inte s\u00e4ljas till servern.
itemMustBeStacked=Objektet m\u00e5ste k\u00f6pas i staplar. En m\u00e4ngd av 2s kommer bli 2 staplar, etc.
itemNames=F\u00F6rkortning p\u00E5 objekt: {0}
itemNames=F\u00f6rkortning p\u00e5 objekt: {0}
itemNotEnough1=\u00a7cDu har inte tillr\u00e4ckligt av den saken f\u00f6r att s\u00e4lja.
itemNotEnough2=\u00a77Om du ville s\u00e4lja alla block av den typen, anv\u00e4nd /sell blocknamn
itemNotEnough3=\u00a77/sell blocknamn -1 kommer att s\u00e4lja allt av den blocktypen f\u00f6rutom 1 o.s.v.
@ -218,7 +218,7 @@ moneyTaken={0} \u00e4r taget fr\u00e5n ditt bankkonto.
month=m\u00e5nad
months=m\u00e5nader
moreThanZero=M\u00e5ngden m\u00e5ste vara st\u00f6rre \u00e4n 0.
moveSpeed=\u00a77Satte {0}fart till {1} f\u00F6r {2}.
moveSpeed=\u00a77Satte {0}fart till {1} f\u00f6r {2}.
msgFormat=\u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
muteExempt=\u00a7cDu kan inte tysta den spelaren.
mutedPlayer=Spelaren {0} \u00e4r tystad.
@ -373,8 +373,8 @@ timeSet=Tid inst\u00e4lld i alla v\u00e4rldar.
timeSetPermission=\u00a7cDu har inte tillst\u00e5nd att st\u00e4lla in tiden.
timeWorldCurrent=Den nuvarande tiden i {0} \u00e4r \u00a73{1}
timeWorldSet=Tiden \u00e4r nu {0} i: \u00a7c{1}
totalWorthAll=\u00a7aS\u00E5lde alla objekt f\u00F6r ett totalt v\u00E4rde av {1}.
totalWorthBlocks=\u00a7aS\u00E5lde alla blocks f\u00F6r ett totalt v\u00E4rde av {1}.
totalWorthAll=\u00a7aS\u00e5lde alla objekt f\u00f6r ett totalt v\u00e4rde av {1}.
totalWorthBlocks=\u00a7aS\u00e5lde alla blocks f\u00f6r ett totalt v\u00e4rde av {1}.
tps=Nuvarande TPS = {0}
tradeCompleted=\u00a77K\u00f6p avslutat.
tradeSignEmpty=K\u00f6pskylten har inget tillg\u00e4ngligt f\u00f6r dig.
@ -447,24 +447,24 @@ year=\u00e5r
years=\u00e5r
youAreHealed=\u00a77Du har blivit l\u00e4kt.
youHaveNewMail=\u00a7cDu har {0} meddelanden!\u00a7f Skriv \u00a77/mail read\u00a7f f\u00f6r att l\u00e4sa dina meddelanden.
posX=\u00a76X: {0} (+\u00D6ster <-> -V\u00e4st)
posX=\u00a76X: {0} (+\u00d6ster <-> -V\u00e4st)
posY=\u00a76Y: {0} (+Upp <-> -Ner)
posZ=\u00a76Z: {0} (+Syd <-> -Nort)
posYaw=\u00a76Girning: {0} (Rotation)
posPitch=\u00a76Pitch: {0} (Huvudvinkel)
distance=\u00a76Avst\u00E5nd: {0}
distance=\u00a76Avst\u00e5nd: {0}
giveSpawn=\u00a76Ger\u00a7c {0} \u00a76av\u00a7c {1} till\u00a7c {2}\u00a76.
warpList={0}
uptime=\u00a76Upptid:\u00a7c {0}
antiBuildCraft=\u00a74Du har inte till\u00E5telse att skapa\u00a7c {0}\u00a74.
antiBuildDrop=\u00a74Du har inte till\u00E5telse att kasta ut\u00a7c {0}\u00a74.
antiBuildCraft=\u00a74Du har inte till\u00e5telse att skapa\u00a7c {0}\u00a74.
antiBuildDrop=\u00a74Du har inte till\u00e5telse att kasta ut\u00a7c {0}\u00a74.
gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 bitar, \u00a7c{3}\u00a76 enheter
invalidHomeName=\u00a74Ogiltigt hemnamn
invalidWarpName=\u00a74Ogiltigt warpnamn
userUnknown=\u00a74Varning: Anv\u00E4ndaren '\u00a7c{0}\u00a74' har aldrig varit inne p\u00E5 denna server tidigare.
teleportationEnabledFor=\u00a76TTeleportering aktiverat f\u00F6r {0}
teleportationDisabledFor=\u00a76Teleportering inaktiverat f\u00F6r {0}
kitOnce=\u00a74Du kan inte av\u00E4nda det kitet igen.
userUnknown=\u00a74Varning: Anv\u00e4ndaren '\u00a7c{0}\u00a74' har aldrig varit inne p\u00e5 denna server tidigare.
teleportationEnabledFor=\u00a76TTeleportering aktiverat f\u00f6r {0}
teleportationDisabledFor=\u00a76Teleportering inaktiverat f\u00f6r {0}
kitOnce=\u00a74Du kan inte av\u00e4nda det kitet igen.
fullStack=\u00a74Du har redan en full stapel
oversizedTempban=\u00a74Du kan inte banna en spelare just vid denna tidpunkt.
recipeNone=No recipes exist for {0}
@ -478,3 +478,11 @@ recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1}
recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2}
recipeWhere=\u00a76Where: {0}
recipeShapeless=\u00a76Combine \u00a7c{0}
editBookContents=\u00a7eYou may now edit the contents of this book
bookAuthorSet=\u00a76Author of the book set to {0}
bookTitleSet=\u00a76Title of the book set to {0}
denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
holdBook=\u00a74You are not holding a writable book