Describes the give sign in the README and fixes some bugs regarding the give sign
This commit is contained in:
parent
c39fd7d7db
commit
931be7a61b
12
README.md
12
README.md
@ -25,3 +25,15 @@ Books without Borders has got your back!
|
||||
* Configurable option to require certain items or pay via Vault compatible economy to create books via command
|
||||
* Add lore to any item with a simple command
|
||||
* Supports adding and saving color to title, lore, and book contents
|
||||
|
||||
### Signs
|
||||
|
||||
This plugin supports several custom signs with special functionality.
|
||||
Each plugin sign must have [BwB] on its first line.
|
||||
|
||||
#### Give sign
|
||||
|
||||
The **_give_** sign must have **[Give]** on its second line.
|
||||
The third and fourth line contains the book to be loaded.
|
||||
This can either be a numerical id pointing to a publicly saved book,
|
||||
or the full text identifier of the book (book name, author).
|
@ -58,16 +58,15 @@ public class SignEventListener implements Listener {
|
||||
|
||||
//Mark the second line as valid
|
||||
event.setLine(1, ChatColor.DARK_BLUE + lines[1]);
|
||||
lines = event.getLines();
|
||||
|
||||
//Mark valid encryption/decryption sign
|
||||
if (lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Encrypt]") ||
|
||||
lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Decrypt]")) {
|
||||
event.setLine(2, ChatColor.MAGIC + lines[2]);
|
||||
event.setLine(3, ChatColor.DARK_BLUE + lines[3]);
|
||||
}
|
||||
|
||||
//Generate book giving sign
|
||||
if (lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Give]")) {
|
||||
} else if (lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Give]")) {
|
||||
//Generate book giving sign
|
||||
generateGiveSign(event, lines, player);
|
||||
}
|
||||
}
|
||||
@ -92,8 +91,7 @@ public class SignEventListener implements Listener {
|
||||
Tag.WALL_SIGNS.isTagged(clickedBlockType))) {
|
||||
//The player right-clicked a sign
|
||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||
if (signLineEquals(sign, 0, "[BooksWithoutBorders]", ChatColor.DARK_GREEN)) {
|
||||
|
||||
if (signLineEquals(sign, 0, "[BwB]", ChatColor.DARK_GREEN)) {
|
||||
if (signLineEquals(sign, 1, "[Encrypt]", ChatColor.DARK_BLUE)) {
|
||||
encryptHeldBookUsingSign(sign, heldItemType, player, hand);
|
||||
} else if (signLineEquals(sign, 1, "[Decrypt]", ChatColor.DARK_BLUE)) {
|
||||
@ -101,6 +99,9 @@ public class SignEventListener implements Listener {
|
||||
} else if (signLineEquals(sign, 1, "[Give]", ChatColor.DARK_BLUE) &&
|
||||
getSignLineColor(sign, 2) == ChatColor.DARK_GREEN) {
|
||||
giveBook(sign, player);
|
||||
} else {
|
||||
player.sendMessage("Sign command " + sign.getLine(1) + " " + sign.getLine(2) + " invalid");
|
||||
player.sendMessage(String.valueOf(getSignLineColor(sign, 2)));
|
||||
}
|
||||
}
|
||||
} else if (heldItemType == Material.WRITTEN_BOOK && (event.getAction() == Action.LEFT_CLICK_AIR
|
||||
@ -147,7 +148,12 @@ public class SignEventListener implements Listener {
|
||||
* @return <p>The color of the sign</p>
|
||||
*/
|
||||
private ChatColor getSignLineColor(Sign sign, int lineNumber) {
|
||||
return ChatColor.getByChar(sign.getLine(lineNumber).substring(0, 2));
|
||||
String line = sign.getLine(lineNumber);
|
||||
if (!ChatColor.stripColor(line).equals(line)) {
|
||||
return ChatColor.getByChar(sign.getLine(lineNumber).substring(1, 2));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,6 +188,7 @@ public class SignEventListener implements Listener {
|
||||
String signFile = getBookFolder() + lines[2] + lines[3];
|
||||
if (FileHelper.bookFileExists(signFile)) {
|
||||
markGiveSignValidity(event, true);
|
||||
return;
|
||||
} else {
|
||||
if (isBookListIndex(lines[2])) {
|
||||
List<String> availableFiles = FileHelper.listFiles(player, true, true);
|
||||
|
Loading…
Reference in New Issue
Block a user