Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object Versions {

const val XSERIES = "13.7.1"

const val LUCKPERMS = "5.5.0"
const val LUCKPERMS = "5.5.71"

const val BSTATS = "3.2.1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.eternalcode.core.configuration.AbstractConfigurationFile;
import com.eternalcode.core.database.DatabaseConfig;
import com.eternalcode.core.database.DatabaseSettings;
import com.eternalcode.core.feature.itemedit.ItemEditConfig;
import com.eternalcode.core.feature.itemedit.ItemEditSettings;
import com.eternalcode.core.teleport.settings.TeleportConfig;
import com.eternalcode.core.teleport.settings.TeleportSettings;
import com.eternalcode.core.util.date.DateConfig;
Expand Down Expand Up @@ -216,6 +218,12 @@ public static class Format extends OkaeriConfig {
@Comment("# Settings for automatic message broadcasting")
AutoMessageConfig autoMessage = new AutoMessageConfig();

@Bean(proxied = ItemEditSettings.class)
@Comment("")
@Comment("# Item Edit Configuration")
@Comment("# Settings for itemlore and itemname command")
ItemEditConfig itemEditConfig = new ItemEditConfig();

@Bean(proxied = JailSettings.class)
@Comment("")
@Comment("# Jail Configuration")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.eternalcode.core.feature.itemedit;

import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;
import lombok.experimental.Accessors;

@Getter
@Accessors(fluent = true)
public class ItemEditConfig extends OkaeriConfig implements ItemEditSettings {
@Comment("# Blacklist words that cannot be added to the item lore using /ItemLore command. Leave empty if none")
public List<String> itemLoreBlacklistWords = Arrays.asList(
"DUPA",
"KURWA",
"CHUJ",
"PIERDOL",
"SUKA",
"KUPA",
"FUCK",
"SHIT",
"BITCH",
"ASS",
"FAGGOT",
"BASTARD",
"KYS"
);

@Comment("# Blacklist words that cannot be added to the item lore using /itemname command. Leave empty if none")
public List<String> itemNameBlacklistWords = Arrays.asList(
"DUPA",
"KURWA",
"CHUJ",
"PIERDOL",
"SUKA",
"KUPA",
"FUCK",
"SHIT",
"BITCH",
"ASS",
"FAGGOT",
"BASTARD",
"KYS"
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.eternalcode.core.feature.itemedit;

import java.util.List;

public interface ItemEditSettings {

List<String> itemLoreBlacklistWords();
List<String> itemNameBlacklistWords();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.eternalcode.core.feature.itemedit;

import com.eternalcode.annotations.scan.command.DescriptionDocs;
import com.eternalcode.annotations.scan.permission.PermissionDocs;
import com.eternalcode.commons.adventure.AdventureUtil;
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.notice.NoticeService;
Expand All @@ -18,16 +19,25 @@
import org.bukkit.inventory.meta.ItemMeta;

@Command(name = "itemlore")
@PermissionDocs(
name = "Item lore blacklist bypass permission",
permission = ItemLoreCommand.ITEM_LORE_BYPASS_PERMISSION,
description = "Permission that allows user to use blacklisted words in /itemlore command"
)
@Permission("eternalcore.itemlore")
class ItemLoreCommand {

private final NoticeService noticeService;
private final MiniMessage miniMessage;
private final ItemEditSettings itemEditSettings;

static final String ITEM_LORE_BYPASS_PERMISSION = "eternalcore.itemlore.bypass";

@Inject
ItemLoreCommand(NoticeService noticeService, MiniMessage miniMessage) {
ItemLoreCommand(NoticeService noticeService, MiniMessage miniMessage, ItemEditSettings itemEditSettings) {
this.noticeService = noticeService;
this.miniMessage = miniMessage;
this.itemEditSettings = itemEditSettings;
}

@Execute
Expand All @@ -48,6 +58,25 @@ void execute(@Sender Player player, @Arg(ItemLoreArgument.KEY) int line, @Join S
lore.add("");
}


List<String> blacklistedWords = this.itemEditSettings.itemLoreBlacklistWords();

if (blacklistedWords != null && !player.hasPermission(ITEM_LORE_BYPASS_PERMISSION)) {
String lowerCaseCommandText = text.toLowerCase();

for (String word : blacklistedWords) {
String lowerCaseBlacklistedWord = word.toLowerCase();
if (lowerCaseCommandText.contains(lowerCaseBlacklistedWord)) {
this.noticeService.create()
.notice(translation -> translation.itemEdit().itemLoreBlacklistedWord())
.player(player.getUniqueId())
.placeholder("{WORD}", word)
.send();
return;
}
}
}

lore.set(line, AdventureUtil.SECTION_SERIALIZER.serialize(AdventureUtil.resetItalic(this.miniMessage.deserialize(text))));

itemMeta.setLore(lore);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.eternalcode.core.feature.itemedit;

import com.eternalcode.annotations.scan.command.DescriptionDocs;
import com.eternalcode.annotations.scan.permission.PermissionDocs;
import com.eternalcode.commons.adventure.AdventureUtil;
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.notice.NoticeService;
Expand All @@ -9,22 +10,32 @@
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.join.Join;
import dev.rollczi.litecommands.annotations.permission.Permission;
import java.util.List;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

@Command(name = "itemname", aliases = { "itemrename" })
@PermissionDocs(
name = "Item Name blacklist bypass permission",
permission = ItemNameCommand.ITEM_NAME_BYPASS_PERMISSION,
description = "Permission that allows user to use blacklisted words in /itemname command"
)
@Permission("eternalcore.itemname")
class ItemNameCommand {

static final String ITEM_NAME_BYPASS_PERMISSION = "eternalcore.itemname.bypass";

private final NoticeService noticeService;
private final MiniMessage miniMessage;
private final ItemEditSettings itemEditSettings;

@Inject
ItemNameCommand(NoticeService noticeService, MiniMessage miniMessage) {
ItemNameCommand(NoticeService noticeService, MiniMessage miniMessage, ItemEditSettings itemEditSettings) {
this.noticeService = noticeService;
this.miniMessage = miniMessage;
this.itemEditSettings = itemEditSettings;
}

@Execute
Expand All @@ -37,6 +48,24 @@ void execute(@Sender Player player, @Join String name) {
return;
}

List<String> blacklistedWords = this.itemEditSettings.itemNameBlacklistWords();

if (blacklistedWords != null && !player.hasPermission(ITEM_NAME_BYPASS_PERMISSION)) {
String lowerCaseCommandText = name.toLowerCase();

for (String word : blacklistedWords) {
String lowerCaseBlacklistedWord = word.toLowerCase();
if (lowerCaseCommandText.contains(lowerCaseBlacklistedWord)) {
this.noticeService.create()
.notice(translation -> translation.itemEdit().itemNameBlacklistedWord())
.player(player.getUniqueId())
.placeholder("{WORD}", word)
.send();
return;
}
}
}

ItemMeta itemMeta = itemStack.getItemMeta();
String serialized = AdventureUtil.SECTION_SERIALIZER.serialize(this.miniMessage.deserialize(name));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ public class ENItemEditMessages extends OkaeriConfig implements ItemEditMessages

@Comment(" ")
Notice invalidLoreLine = Notice.chat("<red>✘ <dark_red>Invalid lore line number!");

@Comment({" ", "# {WORD} - Explicit word that cannot be used"})
Notice itemLoreBlacklistedWord = Notice.chat("<red>✘ <dark_red>This word: <white>\"{WORD}\" <dark_red>cannot be used with this item lore command!");

@Comment({" ", "# {WORD} - Explicit word that cannot be used"})
Notice itemNameBlacklistedWord = Notice.chat("<red>✘ <dark_red>This word: <white>\"{WORD}\" <dark_red>cannot be used with this item lore command!");
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ public interface ItemEditMessages {
// Validation
Notice noLore();
Notice invalidLoreLine();

// Blacklist
Notice itemLoreBlacklistedWord();
Notice itemNameBlacklistedWord();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,10 @@ public class PLItemEditMessages extends OkaeriConfig implements ItemEditMessages

@Comment(" ")
Notice invalidLoreLine = Notice.chat("<red>✘ <dark_red>Nieprawidłowy numer linii opisu!");

@Comment({" ", "# {WORD} - Słowo znajdujące się na czarnej liście zakazanych słów"})
Notice itemLoreBlacklistedWord = Notice.chat("<red>✘ <dark_red>Słowo: <white>\"{WORD}\" <dark_red> nie może być użyte z komendą itemlore!");

@Comment({" ", "# {WORD} - Słowo znajdujące się na czarnej liście zakazanych słów"})
Notice itemNameBlacklistedWord = Notice.chat("<red>✘ <dark_red>Słowo: <white>\"{WORD}\" <dark_red> nie może być użyte z komendą itemname!");
}
2 changes: 1 addition & 1 deletion eternalcore-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tasks {
languageVersion.set(JavaLanguageVersion.of(25))
})

minecraftVersion("1.21.11")
minecraftVersion("26.3")
downloadPlugins.modrinth("luckperms", "v${Versions.LUCKPERMS}-bukkit")
downloadPlugins.modrinth("placeholderapi", Versions.PLACEHOLDER_API)
}
Expand Down
Loading