Skip to content
This repository was archived by the owner on Feb 7, 2022. It is now read-only.

Commit d04b6f4

Browse files
committed
Check that the player has permission for the book itself before allowing them to edit it.
1 parent d3424fd commit d04b6f4

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/main/java/com/mstiles92/plugins/bookrules/commands/BookRulesCommands.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ public void edit(Arguments args) {
278278

279279
if (book == null) {
280280
args.getSender().sendMessage(Strings.PLUGIN_TAG + ChatColor.RED + Localization.getString(Strings.BOOK_NOT_FOUND));
281+
} else if (!book.checkPermission(args.getPlayer())) {
282+
//TODO: refactor into localization system
283+
args.getSender().sendMessage(Strings.PLUGIN_TAG + ChatColor.RED + "You do not have permission to edit this book!");
281284
} else {
282285
book.giveToPlayer(args.getPlayer(), true);
283286
//TODO: refactor into localization system

src/main/java/com/mstiles92/plugins/bookrules/listeners/PlayerListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void onPlayerEditBook(PlayerEditBookEvent event) {
9898

9999
if (!event.getPlayer().hasPermission("bookrules.edit.book")) {
100100
//TODO: refactor into localization system
101-
event.getPlayer().sendMessage(Strings.PLUGIN_TAG + ChatColor.RED + "You do not have permission to edit this book!");;
101+
event.getPlayer().sendMessage(Strings.PLUGIN_TAG + ChatColor.RED + "You do not have permission to edit this book!");
102102
return;
103103
}
104104

0 commit comments

Comments
 (0)