Describes the give sign in the README and fixes some bugs regarding the give sign
This commit is contained in:
parent
c39fd7d7db
commit
931be7a61b
14
README.md
14
README.md
@ -24,4 +24,16 @@ Books without Borders has got your back!
|
|||||||
* Give first time players a single book or a set of books when they join
|
* Give first time players a single book or a set of books when they join
|
||||||
* Configurable option to require certain items or pay via Vault compatible economy to create books via command
|
* 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
|
* Add lore to any item with a simple command
|
||||||
* Supports adding and saving color to title, lore, and book contents
|
* 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
|
//Mark the second line as valid
|
||||||
event.setLine(1, ChatColor.DARK_BLUE + lines[1]);
|
event.setLine(1, ChatColor.DARK_BLUE + lines[1]);
|
||||||
|
lines = event.getLines();
|
||||||
|
|
||||||
//Mark valid encryption/decryption sign
|
//Mark valid encryption/decryption sign
|
||||||
if (lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Encrypt]") ||
|
if (lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Encrypt]") ||
|
||||||
lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Decrypt]")) {
|
lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Decrypt]")) {
|
||||||
event.setLine(2, ChatColor.MAGIC + lines[2]);
|
event.setLine(2, ChatColor.MAGIC + lines[2]);
|
||||||
event.setLine(3, ChatColor.DARK_BLUE + lines[3]);
|
event.setLine(3, ChatColor.DARK_BLUE + lines[3]);
|
||||||
}
|
} else if (lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Give]")) {
|
||||||
|
//Generate book giving sign
|
||||||
//Generate book giving sign
|
|
||||||
if (lines[1].equalsIgnoreCase(ChatColor.DARK_BLUE + "[Give]")) {
|
|
||||||
generateGiveSign(event, lines, player);
|
generateGiveSign(event, lines, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,8 +91,7 @@ public class SignEventListener implements Listener {
|
|||||||
Tag.WALL_SIGNS.isTagged(clickedBlockType))) {
|
Tag.WALL_SIGNS.isTagged(clickedBlockType))) {
|
||||||
//The player right-clicked a sign
|
//The player right-clicked a sign
|
||||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
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)) {
|
if (signLineEquals(sign, 1, "[Encrypt]", ChatColor.DARK_BLUE)) {
|
||||||
encryptHeldBookUsingSign(sign, heldItemType, player, hand);
|
encryptHeldBookUsingSign(sign, heldItemType, player, hand);
|
||||||
} else if (signLineEquals(sign, 1, "[Decrypt]", ChatColor.DARK_BLUE)) {
|
} 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) &&
|
} else if (signLineEquals(sign, 1, "[Give]", ChatColor.DARK_BLUE) &&
|
||||||
getSignLineColor(sign, 2) == ChatColor.DARK_GREEN) {
|
getSignLineColor(sign, 2) == ChatColor.DARK_GREEN) {
|
||||||
giveBook(sign, player);
|
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
|
} 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>
|
* @return <p>The color of the sign</p>
|
||||||
*/
|
*/
|
||||||
private ChatColor getSignLineColor(Sign sign, int lineNumber) {
|
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];
|
String signFile = getBookFolder() + lines[2] + lines[3];
|
||||||
if (FileHelper.bookFileExists(signFile)) {
|
if (FileHelper.bookFileExists(signFile)) {
|
||||||
markGiveSignValidity(event, true);
|
markGiveSignValidity(event, true);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (isBookListIndex(lines[2])) {
|
if (isBookListIndex(lines[2])) {
|
||||||
List<String> availableFiles = FileHelper.listFiles(player, true, true);
|
List<String> availableFiles = FileHelper.listFiles(player, true, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user