Added option to limit amount of lore lines (#4773)

Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
Justin 2023-08-08 13:46:31 -05:00 committed by GitHub
parent 409af5d2aa
commit eb76cf0fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 0 deletions

View File

@ -406,6 +406,8 @@ public interface ISettings extends IConf {
boolean showZeroBaltop();
int getMaxItemLore();
enum KeepInvPolicy {
KEEP,
DELETE,

View File

@ -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);
}
}

View File

@ -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<String> lore = im.hasLore() ? im.getLore() : new ArrayList<>();
lore.add(line);

View File

@ -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.

View File

@ -586,6 +586,7 @@ itemloreCommandUsage2Description=Sets the specified line of the held item's lore
itemloreCommandUsage3=/<command> 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.