Makes a string translatable
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
package net.knarcraft.bookswithoutborders.command;
|
package net.knarcraft.bookswithoutborders.command;
|
||||||
|
|
||||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||||
|
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||||
import net.knarcraft.bookswithoutborders.utility.BookFormatter;
|
import net.knarcraft.bookswithoutborders.utility.BookFormatter;
|
||||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||||
|
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -25,15 +27,16 @@ public class CommandAddTitlePage implements TabExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s,
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s,
|
||||||
@NotNull String[] arguments) {
|
@NotNull String[] arguments) {
|
||||||
|
StringFormatter stringFormatter = BooksWithoutBorders.getStringFormatter();
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
|
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_PLAYER_ONLY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ItemStack heldBook = InventoryHelper.getHeldBook(player);
|
ItemStack heldBook = InventoryHelper.getHeldBook(player);
|
||||||
if (heldBook == null) {
|
if (heldBook == null) {
|
||||||
BooksWithoutBorders.sendErrorMessage(sender, "You must be holding a book to perform this command");
|
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_NOT_HOLDING_ANY_BOOK);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -183,6 +183,11 @@ public enum Translatable implements TranslatableMessage {
|
|||||||
*/
|
*/
|
||||||
ERROR_GIVE_LOAD_FAILED,
|
ERROR_GIVE_LOAD_FAILED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error displayed when running a command without holding any book in the main hand
|
||||||
|
*/
|
||||||
|
ERROR_NOT_HOLDING_ANY_BOOK,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The header displayed before printing all commands
|
* The header displayed before printing all commands
|
||||||
*/
|
*/
|
||||||
|
@@ -11,6 +11,7 @@ en:
|
|||||||
ERROR_PLAYER_ONLY: "This command can only be used by a player!"
|
ERROR_PLAYER_ONLY: "This command can only be used by a player!"
|
||||||
ERROR_NOT_HOLDING_WRITTEN_BOOK: "You must be holding a written book to {action} it!"
|
ERROR_NOT_HOLDING_WRITTEN_BOOK: "You must be holding a written book to {action} it!"
|
||||||
ERROR_NOT_HOLDING_WRITABLE_BOOK: "You must be holding a writable book to {action} it!"
|
ERROR_NOT_HOLDING_WRITABLE_BOOK: "You must be holding a writable book to {action} it!"
|
||||||
|
ERROR_NOT_HOLDING_ANY_BOOK: "You must be holding a book to perform this command"
|
||||||
ERROR_ONLY_ONE_BOOK: "You cannot {action} two books at once!"
|
ERROR_ONLY_ONE_BOOK: "You cannot {action} two books at once!"
|
||||||
ACTION_COPY: "copy"
|
ACTION_COPY: "copy"
|
||||||
ACTION_CLEAR: "clear"
|
ACTION_CLEAR: "clear"
|
||||||
|
Reference in New Issue
Block a user