Closed ShayBox closed 1 year ago
How about the current permission filter? If the player loaded the resource pack you can add a permission to him. Or do you need a new API? I can add Properties to ReplacerConfig.
Oh that could work, I'll try that out and let you know
I'm getting this error when trying to use the parse command
[21:08:44 WARN]: [ProtocolStringReplacer] Plugin ProtocolStringReplacer v2.14.1 generated an exception while executing task 94
java.lang.NullPointerException: Cannot invoke "me.rothes.protocolstringreplacer.libs.org.neosearch.stringsearcher.StringSearcher.parseText(java.lang.CharSequence)" because the return value of "me.rothes.protocolstringreplacer.api.replacer.ReplacerConfig.getReplacesStringSearcher(me.rothes.protocolstringreplacer.replacer.ReplaceMode)" is null
at me.rothes.protocolstringreplacer.commands.subcommands.Parse.equalResult(Parse.java:176) ~[ProtocolStringReplacer v2.14.1.jar:?]
at me.rothes.protocolstringreplacer.commands.subcommands.Parse.startParse(Parse.java:92) ~[ProtocolStringReplacer v2.14.1.jar:?]
at me.rothes.protocolstringreplacer.commands.subcommands.Parse.lambda$onExecute$0(Parse.java:73) ~[ProtocolStringReplacer v2.14.1.jar:?]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.3.jar:git-Paper-384]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[paper-1.19.3.jar:git-Paper-384]
at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[paper-1.19.3.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
I'm getting this error when trying to use the parse command
[21:08:44 WARN]: [ProtocolStringReplacer] Plugin ProtocolStringReplacer v2.14.1 generated an exception while executing task 94 java.lang.NullPointerException: Cannot invoke "me.rothes.protocolstringreplacer.libs.org.neosearch.stringsearcher.StringSearcher.parseText(java.lang.CharSequence)" because the return value of "me.rothes.protocolstringreplacer.api.replacer.ReplacerConfig.getReplacesStringSearcher(me.rothes.protocolstringreplacer.replacer.ReplaceMode)" is null at me.rothes.protocolstringreplacer.commands.subcommands.Parse.equalResult(Parse.java:176) ~[ProtocolStringReplacer v2.14.1.jar:?] at me.rothes.protocolstringreplacer.commands.subcommands.Parse.startParse(Parse.java:92) ~[ProtocolStringReplacer v2.14.1.jar:?] at me.rothes.protocolstringreplacer.commands.subcommands.Parse.lambda$onExecute$0(Parse.java:73) ~[ProtocolStringReplacer v2.14.1.jar:?] at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.3.jar:git-Paper-384] at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[paper-1.19.3.jar:git-Paper-384] at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[paper-1.19.3.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] at java.lang.Thread.run(Thread.java:833) ~[?:?]
Parse command has a year old and I always forget to update it.
Every message in chat this error comes up
[21:51:41 ERROR]: [ProtocolStringReplacer] Unhandled exception occurred in onPacketSending(PacketEvent) for ProtocolStringReplacer
com.comphenix.protocol.reflect.FieldAccessException: Field index 0 is out of bounds for length 0
at com.comphenix.protocol.reflect.FieldAccessException.fromFormat(FieldAccessException.java:49) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:218) ~[ProtocolLib.jar:?]
at me.rothes.protocolstringreplacer.packetlisteners.server.chat.Chat.convert(Chat.java:153) ~[ProtocolStringReplacer v2.14.1.jar:?]
at me.rothes.protocolstringreplacer.packetlisteners.server.chat.Chat.process(Chat.java:52) ~[ProtocolStringReplacer v2.14.1.jar:?]
at me.rothes.protocolstringreplacer.packetlisteners.server.AbstractServerPacketListener.access$100(AbstractServerPacketListener.java:32) ~[ProtocolStringReplacer v2.14.1.jar:?]
at me.rothes.protocolstringreplacer.packetlisteners.server.AbstractServerPacketListener$1.onPacketSending(AbstractServerPacketListener.java:49) ~[ProtocolStringReplacer v2.14.1.jar:?]
at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.PacketFilterManager.postPacketToListeners(PacketFilterManager.java:547) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:521) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.manager.NetworkManagerInjector.onPacketSending(NetworkManagerInjector.java:99) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector.processOutbound(NettyChannelInjector.java:571) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector$2.doProxyRunnable(NettyChannelInjector.java:472) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.channel.NettyEventLoopProxy.proxyRunnable(NettyEventLoopProxy.java:43) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.channel.NettyEventLoopProxy.execute(NettyEventLoopProxy.java:252) ~[ProtocolLib.jar:?]
at net.minecraft.network.Connection.sendPacket(Connection.java:432) ~[?:?]
at net.minecraft.network.Connection.send(Connection.java:379) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.send(ServerGamePacketListenerImpl.java:2157) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.send(ServerGamePacketListenerImpl.java:2143) ~[?:?]
at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:23) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector.sendServerPacket(NettyChannelInjector.java:292) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector.lambda$processOutbound$6(NettyChannelInjector.java:565) ~[ProtocolLib.jar:?]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.3.jar:git-Paper-384]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1473) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:440) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1397) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-384]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
[21:51:41 ERROR]: Parameters:
net.minecraft.network.protocol.game.ClientboundPlayerChatPacket@36ccd2f1[
a=1d735cda-671f-4866-b11f-2f51f799867b
b=0
c=<null>
d=a[content=test, timeStamp=2023-01-25T21:51:41.110284187Z, salt=0, lastSeen=a[entries=[]]]
e=literal{[Plots] [Owner] <ShayBox> test}[style={}]
f=net.minecraft.network.chat.FilterMask@6daee2ae
g=b[chatType=7, name=io.papermc.paper.adventure.AdventureComponent@505f26cf, targetName=null]
]
This is my config
# The settings of this replacer config.
Options:
# Whether this config is enabled or not. Plugin will not process this config
# if configured false. By default, it's false if undefined.
Enable: true
# Priority of this config. If there are multiple replacer configs,
# the higher priority, the earlier replaces. Default is 5.
Priority: 5
# Optional parameter.
Version: '4.20'
# Optional parameter.
Author: ShayBox
# The method PSR will use to match the strings. Options:
# 'Contain' : Replace all contained (Default)
# 'Equal' : The original string must equal you set
# 'Regex' : Use Java Regex
# This is not case-sensitive.
Match-Mode: Equal
# Filter function. Used to specify the conditions for replacing strings in this config.
Filter:
# Listen types.
# Specify where to replace the string. All by default. Options:
# 'Chat' : Replace strings in chat|actionbar
# 'Chat-Preview' : Replace strings in Chat Preview
# 'Tab-Complete' : Replace strings in Tab Complete
# 'Sign' : Replace strings on signs
# 'Title' : Replace strings in title|subtitle
# 'Entity' : Replace strings of entity display name, itemframe name, etc.
# 'Boss-Bar' : Replace strings of Boss health bar
# 'ItemStack' : Replace strings in item such as display name|Lore|author of the book|content of the book
# 'Window-Title' : Replace strings of containers name
# 'ScoreBoard' : Replace strings in scoreboard title|entity name
# 'Console' : Replace strings in console
# 'Kick-Disconnect' : Replace strings in kick message on client when kicking player
# 'Combat-Kill' : Replace strings in death message on respawn screen
# This is not case-sensitive.
Listen-Types:
- Chat
- Sign
- Title
- Entity
- Boss-Bar
- ItemStack
- Window-Title
- ScoreBoard
- Combat-Kill
# Specific filtering for scoreboard replacement.
ScoreBoard:
# Whether replace for scoreboard title. Default is false.
Replace-Title: false
# Whether replace for entities' name in scoreboard. Default is false.
# Note: For players, entity name is player's name, else is entity UUID.
Replace-Entity-Name: false
User:
# Required permission. If set, user must have this permission
# to make this replacer config take effects.
Permission: custom.resourcepack
# Required client locales. Will only handle for the listed locales here.
# Set it to an empty list or null to skip the check.
# Locale list: https://minecraft.fandom.com/wiki/Language#Languages
Locales: []
# PSR will ignore the string (but not the whole packet) whose length exceeds the number defined here.
# Set -1 to disable the feature.
Max-Length:
# Text. (Or Common)
Text: -1
# Json.
Json: -1
# Direct.
Direct: -1
# List of replace strings.
# Replace mode priority: Json > Common. This ignores priority in replacer configs.
Replaces:
# Common string replace mode.
Common:
- Original: [Owner]
Replacement:
- Original: [Admin]
Replacement:
- Original: [Mod]
Replacement:
- Original: [Helper]
Replacement:
# Json replace mode, for advanced users.
# The listen types that doesn't support Json replace:
# ItemStack(Except content of the book on 1.12 and upper server)、Console messages,
# entity name in ScoreBoard、Scoreboard title in ScoreBoard on server version 1.12 or below 1.12.
Json:
# This can modify the furnace title on players' client.
- Original: [Owner]
Replacement:
- Original: [Admin]
Replacement:
- Original: [Mod]
Replacement:
- Original: [Helper]
Replacement:
# Direct replace mode. Suitable for users who are not familiar with Json replacement.
# By default, If any content is replaced here, Json and Common replace modes
# will no longer take effect for this packet. You can disable it in Config.yml.
# In addition to Json, this also supports 1.16+ HEX.
# Note: If direct replace mod replaced the string, it will break non-text component display in Json.
# ^ This means that after the replacement the message will cause the side effects that the message being
# ^ not clickable, remove mouseover display and translation effects, etc. (if it originally has)
Direct:
- Original: [Owner]
Replacement:
- Original: [Admin]
Replacement:
- Original: [Mod]
Replacement:
- Original: [Helper]
Replacement:
# The string list to block. If any string in a packet is matched by these,
# PSR will block the entire packet sending to the player.
# This feature also applies to console messages.
Blocks:
Common: []
Json: []
Direct: []
Every message in chat this error comes up
[21:51:41 ERROR]: [ProtocolStringReplacer] Unhandled exception occurred in onPacketSending(PacketEvent) for ProtocolStringReplacer com.comphenix.protocol.reflect.FieldAccessException: Field index 0 is out of bounds for length 0 at com.comphenix.protocol.reflect.FieldAccessException.fromFormat(FieldAccessException.java:49) ~[ProtocolLib.jar:?] at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:218) ~[ProtocolLib.jar:?] at me.rothes.protocolstringreplacer.packetlisteners.server.chat.Chat.convert(Chat.java:153) ~[ProtocolStringReplacer v2.14.1.jar:?] at me.rothes.protocolstringreplacer.packetlisteners.server.chat.Chat.process(Chat.java:52) ~[ProtocolStringReplacer v2.14.1.jar:?] at me.rothes.protocolstringreplacer.packetlisteners.server.AbstractServerPacketListener.access$100(AbstractServerPacketListener.java:32) ~[ProtocolStringReplacer v2.14.1.jar:?] at me.rothes.protocolstringreplacer.packetlisteners.server.AbstractServerPacketListener$1.onPacketSending(AbstractServerPacketListener.java:49) ~[ProtocolStringReplacer v2.14.1.jar:?] at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.PacketFilterManager.postPacketToListeners(PacketFilterManager.java:547) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:521) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.netty.manager.NetworkManagerInjector.onPacketSending(NetworkManagerInjector.java:99) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector.processOutbound(NettyChannelInjector.java:571) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector$2.doProxyRunnable(NettyChannelInjector.java:472) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.netty.channel.NettyEventLoopProxy.proxyRunnable(NettyEventLoopProxy.java:43) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.netty.channel.NettyEventLoopProxy.execute(NettyEventLoopProxy.java:252) ~[ProtocolLib.jar:?] at net.minecraft.network.Connection.sendPacket(Connection.java:432) ~[?:?] at net.minecraft.network.Connection.send(Connection.java:379) ~[?:?] at net.minecraft.server.network.ServerGamePacketListenerImpl.send(ServerGamePacketListenerImpl.java:2157) ~[?:?] at net.minecraft.server.network.ServerGamePacketListenerImpl.send(ServerGamePacketListenerImpl.java:2143) ~[?:?] at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:23) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector.sendServerPacket(NettyChannelInjector.java:292) ~[ProtocolLib.jar:?] at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector.lambda$processOutbound$6(NettyChannelInjector.java:565) ~[ProtocolLib.jar:?] at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.3.jar:git-Paper-384] at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.3.jar:git-Paper-384] at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1473) ~[paper-1.19.3.jar:git-Paper-384] at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:440) ~[paper-1.19.3.jar:git-Paper-384] at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1397) ~[paper-1.19.3.jar:git-Paper-384] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.3.jar:git-Paper-384] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-384] at java.lang.Thread.run(Thread.java:833) ~[?:?] [21:51:41 ERROR]: Parameters: net.minecraft.network.protocol.game.ClientboundPlayerChatPacket@36ccd2f1[ a=1d735cda-671f-4866-b11f-2f51f799867b b=0 c=<null> d=a[content=test, timeStamp=2023-01-25T21:51:41.110284187Z, salt=0, lastSeen=a[entries=[]]] e=literal{[Plots] [Owner] <ShayBox> test}[style={}] f=net.minecraft.network.chat.FilterMask@6daee2ae g=b[chatType=7, name=io.papermc.paper.adventure.AdventureComponent@505f26cf, targetName=null] ]
This is my config
# The settings of this replacer config. Options: # Whether this config is enabled or not. Plugin will not process this config # if configured false. By default, it's false if undefined. Enable: true # Priority of this config. If there are multiple replacer configs, # the higher priority, the earlier replaces. Default is 5. Priority: 5 # Optional parameter. Version: '4.20' # Optional parameter. Author: ShayBox # The method PSR will use to match the strings. Options: # 'Contain' : Replace all contained (Default) # 'Equal' : The original string must equal you set # 'Regex' : Use Java Regex # This is not case-sensitive. Match-Mode: Equal # Filter function. Used to specify the conditions for replacing strings in this config. Filter: # Listen types. # Specify where to replace the string. All by default. Options: # 'Chat' : Replace strings in chat|actionbar # 'Chat-Preview' : Replace strings in Chat Preview # 'Tab-Complete' : Replace strings in Tab Complete # 'Sign' : Replace strings on signs # 'Title' : Replace strings in title|subtitle # 'Entity' : Replace strings of entity display name, itemframe name, etc. # 'Boss-Bar' : Replace strings of Boss health bar # 'ItemStack' : Replace strings in item such as display name|Lore|author of the book|content of the book # 'Window-Title' : Replace strings of containers name # 'ScoreBoard' : Replace strings in scoreboard title|entity name # 'Console' : Replace strings in console # 'Kick-Disconnect' : Replace strings in kick message on client when kicking player # 'Combat-Kill' : Replace strings in death message on respawn screen # This is not case-sensitive. Listen-Types: - Chat - Sign - Title - Entity - Boss-Bar - ItemStack - Window-Title - ScoreBoard - Combat-Kill # Specific filtering for scoreboard replacement. ScoreBoard: # Whether replace for scoreboard title. Default is false. Replace-Title: false # Whether replace for entities' name in scoreboard. Default is false. # Note: For players, entity name is player's name, else is entity UUID. Replace-Entity-Name: false User: # Required permission. If set, user must have this permission # to make this replacer config take effects. Permission: custom.resourcepack # Required client locales. Will only handle for the listed locales here. # Set it to an empty list or null to skip the check. # Locale list: https://minecraft.fandom.com/wiki/Language#Languages Locales: [] # PSR will ignore the string (but not the whole packet) whose length exceeds the number defined here. # Set -1 to disable the feature. Max-Length: # Text. (Or Common) Text: -1 # Json. Json: -1 # Direct. Direct: -1 # List of replace strings. # Replace mode priority: Json > Common. This ignores priority in replacer configs. Replaces: # Common string replace mode. Common: - Original: [Owner] Replacement: - Original: [Admin] Replacement: - Original: [Mod] Replacement: - Original: [Helper] Replacement: # Json replace mode, for advanced users. # The listen types that doesn't support Json replace: # ItemStack(Except content of the book on 1.12 and upper server)、Console messages, # entity name in ScoreBoard、Scoreboard title in ScoreBoard on server version 1.12 or below 1.12. Json: # This can modify the furnace title on players' client. - Original: [Owner] Replacement: - Original: [Admin] Replacement: - Original: [Mod] Replacement: - Original: [Helper] Replacement: # Direct replace mode. Suitable for users who are not familiar with Json replacement. # By default, If any content is replaced here, Json and Common replace modes # will no longer take effect for this packet. You can disable it in Config.yml. # In addition to Json, this also supports 1.16+ HEX. # Note: If direct replace mod replaced the string, it will break non-text component display in Json. # ^ This means that after the replacement the message will cause the side effects that the message being # ^ not clickable, remove mouseover display and translation effects, etc. (if it originally has) Direct: - Original: [Owner] Replacement: - Original: [Admin] Replacement: - Original: [Mod] Replacement: - Original: [Helper] Replacement: # The string list to block. If any string in a packet is matched by these, # PSR will block the entire packet sending to the player. # This feature also applies to console messages. Blocks: Common: [] Json: [] Direct: []
Seems there was some internal changes when they update to 1.19.3. Thanks for the report.
FieldAccessException
fixed on dd78eceb838d11614690bff78a2d7389029d3375
The chat error is fixed :+1: but it's still not replacing for me, is my config wrong or something? I have the permission explicitly and I'm op
The chat error is fixed 👍 but it's still not replacing for me, is my config wrong or something? I have the permission explicitly and I'm op
I think it's because of the Equal
Match-Mode. There should be a color format code before your string, you can capture it using /psr capture
command.
And you can add a color code after your string on chat/prefix plugin to make sure the common entries are splited here. like &c[Helper]&f <name>
Ah thank you, now it works :+1:
It seems the permission check doesn't work, not having the permission or denying the permission doesn't stop the string replacement
It seems op provides every permission even though LuckPerms said it wasn't provided by op
~It seems the permission check doesn't work, not having the permission or denying the permission doesn't stop the string replacement~ It seems op provides every permission even though LuckPerms said it wasn't provided by op
Yes op has all permission in permission check and it's breaking the filter. I'll fix that
I'm trying to make a plugin for my server that replaces prefixes with Unicode characters if the player has the server resource pack loaded, which are then replaced with bitmap textures via the server resource pack.
Suggestion: Some way to use this in my own plugin or a plugin API to provide logic for when to replace strings.