diff --git a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java index 823734ebc..ae7814153 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java @@ -406,6 +406,8 @@ public interface ISettings extends IConf { boolean showZeroBaltop(); + int getMaxItemLore(); + enum KeepInvPolicy { KEEP, DELETE, diff --git a/Essentials/src/main/java/com/earth2me/essentials/Settings.java b/Essentials/src/main/java/com/earth2me/essentials/Settings.java index 43d2109d7..628271bc9 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -1943,4 +1943,9 @@ public class Settings implements net.ess3.api.ISettings { public boolean showZeroBaltop() { return config.getBoolean("show-zero-baltop", true); } + + @Override + public int getMaxItemLore() { + return config.getInt("max-itemlore-lines", 10); + } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commanditemlore.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commanditemlore.java index 9f605023d..c754454af 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commanditemlore.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commanditemlore.java @@ -35,7 +35,12 @@ public class Commanditemlore extends EssentialsCommand { } final ItemMeta im = item.getItemMeta(); + final int loreSize = im.hasLore() ? im.getLore().size() : 0; if (args[0].equalsIgnoreCase("add") && args.length > 1) { + if (loreSize >= ess.getSettings().getMaxItemLore() && !user.isAuthorized("essentials.itemlore.bypass")) { + throw new Exception(tl("itemloreMaxLore")); + } + final String line = FormatUtil.formatString(user, "essentials.itemlore", getFinalArg(args, 1)).trim(); final List lore = im.hasLore() ? im.getLore() : new ArrayList<>(); lore.add(line); diff --git a/Essentials/src/main/resources/config.yml b/Essentials/src/main/resources/config.yml index ba35a3157..9ce30622d 100644 --- a/Essentials/src/main/resources/config.yml +++ b/Essentials/src/main/resources/config.yml @@ -732,6 +732,10 @@ log-command-block-commands: true # Set the maximum speed for projectiles spawned with /fireball. max-projectile-speed: 8 +# Set the maximum amount of lore lines a user can set with the /itemlore command. +# Users with the essentials.itemlore.bypass permission will be able to bypass this limit. +max-itemlore-lines: 10 + # Should EssentialsX check for updates? # If set to true, EssentialsX will show notifications when a new version is available. # This uses the public GitHub API and no identifying information is sent or stored. diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index 0892fbbaa..1e4fc2dcf 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -586,6 +586,7 @@ itemloreCommandUsage2Description=Sets the specified line of the held item's lore itemloreCommandUsage3=/ clear itemloreCommandUsage3Description=Clears the held item's lore itemloreInvalidItem=\u00a74You need to hold an item to edit its lore. +itemloreMaxLore=\u00a74You cannot add any more lore lines to this item. itemloreNoLine=\u00a74Your held item does not have lore text on line \u00a7c{0}\u00a74. itemloreNoLore=\u00a74Your held item does not have any lore text. itemloreSuccess=\u00a76You have added "\u00a7c{0}\u00a76" to your held item''s lore.