Skip to content

Commit 1dbaf8b

Browse files
committed
Add warning when trying to add a disabled listen type capture
1 parent 4a30d72 commit 1dbaf8b

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/main/java/me/rothes/protocolstringreplacer/commands/subcommands/Capture.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.rothes.protocolstringreplacer.commands.subcommands;
22

3+
import com.comphenix.protocol.ProtocolLibrary;
34
import me.rothes.protocolstringreplacer.PsrLocalization;
45
import me.rothes.protocolstringreplacer.ProtocolStringReplacer;
56
import me.rothes.protocolstringreplacer.api.capture.CaptureInfo;
@@ -61,6 +62,12 @@ private void addCommand(@Nonnull PsrUser user, @Nonnull String[] args) {
6162
"Sender.Commands.Capture.Children.Add.Listen-Type-Cannot-Be-Captured"));
6263
return;
6364
}
65+
if (!ProtocolStringReplacer.getInstance().getConfig()
66+
.getBoolean("Options.Features.Packet-Listener.Listen-Type-Enabled." + listenType.getName(), false)) {
67+
user.sendFilteredText(PsrLocalization.getPrefixedLocaledMessage(
68+
"Sender.Commands.Capture.Children.Add.Listen-Type-Not-Enabled"));
69+
return;
70+
}
6471
if (user.isCapturing(listenType)) {
6572
user.sendFilteredText(PsrLocalization.getPrefixedLocaledMessage(
6673
"Sender.Commands.Capture.Children.Add.Already-Capturing-Listen-Type", listenType.getName()));

src/main/resources/Languages/en-US/Locales/Locale.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Sender:
6363
Simple-Help: '&7 * &e/psr capture add &7- &bEnable capture of listen type'
6464
Detailed-Help: '&7 * &e/psr capture add <Listen type> &7- &bEnable capture of listen type'
6565
Listen-Type-Cannot-Be-Captured: '&cThis listen type is not capturable for you.'
66+
Listen-Type-Not-Enabled: '&cThis listen type is not enabled in config.'
6667
Capture-Added: '&aEnabled capture of &f%0% &a.'
6768
Already-Capturing-Listen-Type: '&cYou have already enabled capture of &f%0% &c.'
6869
Remove:

src/main/resources/Languages/zh-CN/Locales/Locale.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Sender:
6363
Simple-Help: '&7 * &e/psr capture add &7- &b启用监听类型的文本捕获'
6464
Detailed-Help: '&7 * &e/psr capture add <监听类型> &7- &b启用监听类型的文本捕获'
6565
Listen-Type-Cannot-Be-Captured: '&c您不可捕获此监听类型.'
66+
Listen-Type-Not-Enabled: '&c此监听类型未配置为启用.'
6667
Capture-Added: '&a已启用 &f%0% &a的捕获.'
6768
Already-Capturing-Listen-Type: '&c您已经启用了 &f%0% &c的捕获了.'
6869
Remove:

0 commit comments

Comments
 (0)