Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implementation of CommandFilters, replacing cooldowns and costs#3886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
FrankHeijden wants to merge15 commits intoEssentialsX:2.x
base:2.x
Choose a base branch
Loading
fromFrankHeijden:extract-command-filters
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
15 commits
Select commitHold shift + click to select a range
7739d94
Implementation of CommandFilters, replacing cooldowns and costs
FrankHeijdenDec 29, 2020
0a03e50
Add command-filters.yml to .gitignore
FrankHeijdenDec 30, 2020
76e45fd
Change automatic upgrading of command-costs to 'command' instead
FrankHeijdenDec 30, 2020
dfda202
@FrankHeijden
FrankHeijdenDec 31, 2020
78f0ea2
Merge branch '2.x' into extract-command-filters
FrankHeijdenJan 2, 2021
20f5bbf
Merge branch '2.x' into extract-command-filters
FrankHeijdenJan 16, 2021
6825aff
Merge branch '2.x' into extract-command-filters
FrankHeijdenFeb 21, 2021
8e66e8b
Merge branch '2.x' into extract-command-filters
FrankHeijdenJun 15, 2021
b681c1c
Convert to sponge config
FrankHeijdenJun 15, 2021
2712e41
Merge branch '2.x' into extract-command-filters
FrankHeijdenDec 3, 2021
9dbd5dd
Update to configurate
FrankHeijdenDec 3, 2021
a2ad09b
Merge branch '2.x' into extract-command-filters
JRoyOct 14, 2022
96a95be
Merge branch 'EssentialsX:2.x' into extract-command-filters
FrankHeijdenOct 30, 2022
2103974
Merge remote-tracking branch 'upstream/2.x' into extract-command-filters
JRoyNov 11, 2023
2b8c8bf
Fix build
JRoyNov 11, 2023
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
PrevPrevious commit
Fix build
  • Loading branch information
@JRoy
JRoy committedNov 11, 2023
commit2b8c8bf8bde9aaf279dc01b2c57fd190d32f4b51
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,13 +18,13 @@

public class CommandFilters implements IConf {

private final IEssentialsessentials;
private final IEssentialsess;
private final EssentialsConfiguration config;
private Map<CommandFilter.Type, List<CommandFilter>> commandFilters;

public CommandFilters(final IEssentialsessentials) {
this.essentials =essentials;
config = new EssentialsConfiguration(new File(essentials.getDataFolder(), "command-filters.yml"), "/command-filters.yml");
public CommandFilters(final IEssentialsess) {
this.ess =ess;
config = new EssentialsConfiguration(new File(ess.getDataFolder(), "command-filters.yml"), "/command-filters.yml");

reloadConfig();
}
Expand All@@ -45,12 +45,12 @@ private Map<CommandFilter.Type, List<CommandFilter>> parseCommandFilters(Essenti
final String command = section.node("command").getString();

if (pattern == null && command == null) {
EssentialsConf.LOGGER.warning("Invalid command filter '" + filterItem + "', filter must either define 'pattern' or 'command'!");
ess.getLogger().warning("Invalid command filter '" + filterItem + "', filter must either define 'pattern' or 'command'!");
continue;
}

if (pattern != null && command != null) {
EssentialsConf.LOGGER.warning("Invalid command filter '" + filterItem + "', filter can't have both 'pattern' and 'command'!");
ess.getLogger().warning("Invalid command filter '" + filterItem + "', filter can't have both 'pattern' and 'command'!");
continue;
}

Expand All@@ -62,7 +62,7 @@ private Map<CommandFilter.Type, List<CommandFilter>> parseCommandFilters(Essenti
}

final boolean persistentCooldown = section.node("persistent-cooldown").getBoolean(true);
final BigDecimal cost =EssentialsConf.toBigDecimal(section.node("cost").getString(), null);
final BigDecimal cost =ConfigurateUtil.toBigDecimal(section.node("cost").getString(), null);

final String filterItemName = filterItem.toLowerCase(Locale.ENGLISH);

Expand All@@ -80,7 +80,7 @@ private Pattern compileRegex(String regex) {
try {
return Pattern.compile(regex.substring(1));
} catch (final PatternSyntaxException e) {
essentials.getLogger().warning("Command cooldown error: " + e.getMessage());
ess.getLogger().warning("Command cooldown error: " + e.getMessage());
return null;
}
} else {
Expand DownExpand Up@@ -112,8 +112,8 @@ private CommandFilter getFilter(final String label, CommandFilter.Type type, Pre
if (!filterPredicate.test(filter)) continue;

final boolean matches = filter.getPattern().matcher(label).matches();
if (essentials.getSettings().isDebug()) {
essentials.getLogger().info(String.format("Checking command '%s' against filter '%s': %s", label, filter.getName(), matches));
if (ess.getSettings().isDebug()) {
ess.getLogger().info(String.format("Checking command '%s' against filter '%s': %s", label, filter.getName(), matches));
}

if (matches) {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -470,32 +470,32 @@ public void convertCommandFilters() {
return;
}

LOGGER.info("Attempting to convert old command-cooldowns and -costs in config.yml to new command-filters.yml");
ess.getLogger().info("Attempting to convert old command-cooldowns and -costs in config.yml to new command-filters.yml");

final CommentedConfigurationNode commandCooldowns = ess.getSettings().getCommandCooldowns();
if (commandCooldowns != null) {
convertCommandCooldowns(commandCooldowns, config);
} else {
LOGGER.info("No command cooldowns found to migrate.");
ess.getLogger().info("No command cooldowns found to migrate.");
}

final Map<String, BigDecimal> commandCosts = ess.getSettings().getCommandCosts();
if (commandCosts != null) {
convertCommandCosts(commandCosts, config);
} else {
LOGGER.info("No command costs found to migrate.");
ess.getLogger().info("No command costs found to migrate.");
}

config.save();
doneFile.setProperty("commandFiltersYml", true);
doneFile.save();
LOGGER.info("Done converting command filters.");
ess.getLogger().info("Done converting command filters.");
}

private void convertCommandCooldowns(CommentedConfigurationNode commandCooldowns, EssentialsConfiguration config) {
final boolean persistent = ess.getSettings().isCommandCooldownPersistent("dummy");
for (Map.Entry<String, Object> entry : ConfigurateUtil.getRawMap(commandCooldowns).entrySet()) {
LOGGER.info("Converting cooldown \"" + entry.getKey() + "\"");
ess.getLogger().info("Converting cooldown \"" + entry.getKey() + "\"");

final String key = entry.getKey().replace("\\.", "{dot}"); // Convert periods
config.setProperty("filters." + key + ".pattern", entry.getKey());
Expand All@@ -511,7 +511,7 @@ private void convertCommandCooldowns(CommentedConfigurationNode commandCooldowns

private void convertCommandCosts(Map<String, BigDecimal> commandCosts, EssentialsConfiguration config) {
for (Map.Entry<String, BigDecimal> entry : commandCosts.entrySet()) {
LOGGER.info("Converting cost \"" + entry.getKey() + "\"");
ess.getLogger().info("Converting cost \"" + entry.getKey() + "\"");

config.setProperty("filters." + entry.getKey() + ".command", entry.getKey());
config.setProperty("filters." + entry.getKey() + ".cost", entry.getValue().toString());
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp