
Shopkeeper config resets when i change the regex
GrenFlem opened this issue · 10 comments
Idk what it is, it just does it. i tried teh one from the default config listed as an example "[A-Za-z0-9&§# ]{3,25}"
doesnt work.
[15:16:09 INFO]: GrenFlem issued server command: /shopkeepers reload
[15:16:09 INFO]: [Shopkeepers] Loading config.
[15:16:09 INFO]: [Shopkeepers] Loading language file: language-en-default.yml
[15:16:09 INFO]: [Shopkeepers] Registering defaults.
[15:16:09 INFO]: [Shopkeepers] Loading the data of 34 shopkeepers ...
logs
Can you upload your actual non-working edited config file. Maybe there is some encoding issue when you edited it.
my regex works perfect here https://regex101.com
[A-Za-z0-9!@#$&()*\\-`.+,\/"]{1,50}
When i put that in the config file, and reload the plugin, my config resets and i need to configure EVERYTHING else again
config-version: 9
debug: false
debug-options: []
enable-metrics: true
language: en-default
save-instantly: true
convert-player-items: false
convert-all-player-items: true
convert-player-items-exceptions: []
ignore-failed-server-assumption-tests: false
bypass-spawn-blocking: true
check-shop-interaction-result: false
enable-world-guard-restrictions: false
require-world-guard-allow-shop-flag: false
register-world-guard-allow-shop-flag: true
enable-towny-restrictions: false
check-spawn-location-interaction-result: false
disable-inventory-verification: false
shop-creation-item:
type: SPAWNER
display-name: '{"text":"Shopkeeper Spawner","italic":false,"bold":true,"color":"green"}'
add-shop-creation-item-tag: true
identify-shop-creation-item-by-tag: true
prevent-shop-creation-item-regular-usage: true
invert-shop-type-and-object-type-selection: false
deleting-player-shop-returns-creation-item: false
create-player-shop-with-command: false
require-container-recently-placed: true
max-container-distance: 15
max-shops-per-player: -1
max-shops-perm-options: 5,15,25
protect-containers: true
prevent-item-movement: true
delete-shopkeeper-on-break-container: false
player-shopkeeper-inactive-days: 0
enabled-living-shops:
- VILLAGER
- ALLAY
- ARMADILLO
- AXOLOTL
- BEE
- BLAZE
- BOGGED
- BREEZE
- CAT
- CAVE_SPIDER
- CHICKEN
- COW
- CREAKING
- CREEPER
- DROWNED
- ENDERMAN
- EVOKER
- FOX
- FROG
- GOAT
- HUSK
- ILLUSIONER
- IRON_GOLEM
- MOOSHROOM
- OCELOT
- PANDA
- PARROT
- PHANTOM
- PIG
- PIGLIN
- PIGLIN_BRUTE
- PILLAGER
- RABBIT
- SHEEP
- SHULKER
- SILVERFISH
- SKELETON
- SNOW_GOLEM
- SPIDER
- SQUID
- STRAY
- STRIDER
- TURTLE
- VEX
- VINDICATOR
- WANDERING_TRADER
- WARDEN
- WITCH
- WITHER_SKELETON
- WOLF
- ZOMBIE
- ZOMBIE_VILLAGER
- ZOMBIFIED_PIGLIN
disable-gravity: false
gravity-chunk-range: 4
mob-behavior-tick-period: 3
shulker-peek-if-player-nearby: true
shulker-peek-height: 0.3
silence-living-shop-entities: true
show-nameplates: true
always-show-nameplates: false
enable-citizen-shops: true
default-citizen-npc-type: PLAYER
set-citizen-npc-owner-of-player-shops: false
citizen-npc-fluid-pushable: false
cancel-citizen-npc-interactions: true
save-citizen-npcs-instantly: false
snapshots-save-citizen-npc-data: true
delete-invalid-citizen-shopkeepers: false
enable-sign-shops: true
enable-sign-post-shops: false
enable-hanging-sign-shops: false
name-regex: "[A-Za-z0-9!@#$&()*\\-`.+,\/"]{1,50}"
naming-of-player-shops-via-item: false
allow-renaming-of-player-npc-shops: false
selling-empty-trade-result-item: GRAY_STAINED_GLASS_PANE
selling-empty-trade-item1: GRAY_STAINED_GLASS_PANE
selling-empty-trade-item2: GRAY_STAINED_GLASS_PANE
selling-empty-item1: BARRIER
selling-empty-item2: BARRIER
buying-empty-trade-result-item: GRAY_STAINED_GLASS_PANE
buying-empty-trade-item1: GRAY_STAINED_GLASS_PANE
buying-empty-trade-item2: AIR
buying-empty-result-item: BARRIER
buying-empty-item2: AIR
trading-empty-trade-result-item: GRAY_STAINED_GLASS_PANE
trading-empty-trade-item1: GRAY_STAINED_GLASS_PANE
trading-empty-trade-item2: GRAY_STAINED_GLASS_PANE
trading-empty-result-item: BARRIER
trading-empty-item1: BARRIER
trading-empty-item2: BARRIER
book-empty-trade-result-item: GRAY_STAINED_GLASS_PANE
book-empty-trade-item1: GRAY_STAINED_GLASS_PANE
book-empty-trade-item2: GRAY_STAINED_GLASS_PANE
book-empty-item1: BARRIER
book-empty-item2: BARRIER
max-trades-pages: 5
previous-page-item: WRITABLE_BOOK
next-page-item: WRITABLE_BOOK
current-page-item: WRITABLE_BOOK
trade-setup-item: PAPER
placeholder-item: PAPER
name-item: NAME_TAG
enable-all-equipment-editor-slots: false
enable-moving-of-player-shops: true
move-item: ENDER_PEARL
enable-container-option-on-player-shop: true
container-item: CHEST
trade-notifications-item: BELL
delete-item: BONE
disable-other-villagers: false
block-villager-spawns: false
disable-zombie-villager-curing: false
hire-other-villagers: false
disable-wandering-traders: false
block-wandering-trader-spawns: false
hire-wandering-traders: false
edit-regular-villagers: false
edit-regular-wandering-traders: false
hire-item: EMERALD
hire-other-villagers-costs: 1
hire-require-creation-permission: true
prevent-trading-with-own-shop: true
prevent-trading-while-owner-is-online: false
use-strict-item-comparison: false
increment-villager-statistics: false
simulate-villager-trading-sounds: true
simulate-villager-ambient-sounds: false
simulate-wandering-trader-trading-sounds: true
simulate-wandering-trader-ambient-sounds: false
simulate-trading-sounds-only-for-the-trading-player: true
trade-succeeded-sound:
sound: minecraft:ui.button.click
pitch: 2.0
volume: 0.3
trade-failed-sound:
sound: minecraft:block.barrel.close
pitch: 2.0
volume: 0.5
tax-rate: 0
tax-round-up: false
notify-players-about-trades: false
trade-notification-sound: ''
notify-shop-owners-about-trades: true
shop-owner-trade-notification-sound:
sound: minecraft:entity.experience_orb.pickup
volume: 0.25
trade-log-storage: DISABLED
trade-log-merge-duration-ticks: 300
trade-log-next-merge-timeout-ticks: 100
log-item-metadata: false
currency-item: EMERALD
high-currency-item: EMERALD_BLOCK
high-currency-value: 9
high-currency-min-cost: 20
my regex works perfect here https://regex101.com
[A-Za-z0-9!@#$&()*\\-`.+,\/"]{1,50}
Can you upload your actual non-working edited config file. Maybe there is some encoding issue when you edited it.
yeah sorryryyy ll get it
The config fails to load due to the "
character inside the regex value: It conflicts with the surrounding double quotes.
Here is the respective error from the console:
[20:00:26] [Server thread/ERROR]: Cannot load plugins\Shopkeepers\config.yml
org.bukkit.configuration.InvalidConfigurationException: while scanning a double-quoted scalar
in 'reader', line 455, column 13:
name-regex: "[A-Za-z0-9!@#$&()*\\-`.+,\/"]{1 ...
^
found unknown escape character /(47)
in 'reader', line 455, column 40:
... gex: "[A-Za-z0-9!@#$&()*\\-`.+,\/"]{1,50}"
^
at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:111) ~[spigot-api-1.21.5-R0.1-SNAPSHOT.jar:?]
at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:160) ~[spigot-api-1.21.5-R0.1-SNAPSHOT.jar:?]
at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:128) ~[spigot-api-1.21.5-R0.1-SNAPSHOT.jar:?]
at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:309) ~[spigot-api-1.21.5-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:161) ~[spigot-api-1.21.5-R0.1-SNAPSHOT.jar:?]
at com.nisovin.shopkeepers.config.Settings.loadConfig(Settings.java:776) ~[?:?]
at com.nisovin.shopkeepers.SKShopkeepersPlugin.onEnable(SKShopkeepersPlugin.java:296) ~[?:?]
at com.nisovin.shopkeepers.SKShopkeepersPlugin.reload(SKShopkeepersPlugin.java:553) ~[?:?]
at com.nisovin.shopkeepers.commands.shopkeepers.CommandReload.execute(CommandReload.java:34) ~[?:?]
at com.nisovin.shopkeepers.commands.lib.Command.processCommand(Command.java:619) ~[?:?]
at com.nisovin.shopkeepers.commands.lib.Command.processCommand(Command.java:606) ~[?:?]
at com.nisovin.shopkeepers.commands.lib.Command.handleCommand(Command.java:509) ~[?:?]
at com.nisovin.shopkeepers.commands.lib.BaseCommand.onCommand(BaseCommand.java:92) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.21.5-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:150) ~[spigot-api-1.21.5-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_21_R4.CraftServer.dispatchCommand(CraftServer.java:924) ~[spigot-1.21.5-R0.1-SNAPSHOT.jar:4489-Spigot-3dafb73-d63a32e]
at org.bukkit.craftbukkit.v1_21_R4.CraftServer.dispatchServerCommand(CraftServer.java:909) ~[spigot-1.21.5-R0.1-SNAPSHOT.jar:4489-Spigot-3dafb73-d63a32e]
at net.minecraft.server.dedicated.DedicatedServer.br(DedicatedServer.java:398) ~[spigot-1.21.5-R0.1-SNAPSHOT.jar:4489-Spigot-3dafb73-d63a32e]
at net.minecraft.server.dedicated.DedicatedServer.G(DedicatedServer.java:374) ~[spigot-1.21.5-R0.1-SNAPSHOT.jar:4489-Spigot-3dafb73-d63a32e]
at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:1532) ~[spigot-1.21.5-R0.1-SNAPSHOT.jar:4489-Spigot-3dafb73-d63a32e]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1362) ~[spigot-1.21.5-R0.1-SNAPSHOT.jar:4489-Spigot-3dafb73-d63a32e]
at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1068) ~[spigot-1.21.5-R0.1-SNAPSHOT.jar:4489-Spigot-3dafb73-d63a32e]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:325) ~[spigot-1.21.5-R0.1-SNAPSHOT.jar:4489-Spigot-3dafb73-d63a32e]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning a double-quoted scalar
in 'reader', line 455, column 13:
name-regex: "[A-Za-z0-9!@#$&()*\\-`.+,\/"]{1 ...
^
found unknown escape character /(47)
in 'reader', line 455, column 40:
... gex: "[A-Za-z0-9!@#$&()*\\-`.+,\/"]{1,50}"
^
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalarNonSpaces(ScannerImpl.java:1954) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalar(ScannerImpl.java:1882) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchFlowScalar(ScannerImpl.java:1057) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchDouble(ScannerImpl.java:1039) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:427) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:669) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:161) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:57) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:43) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:136) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:116) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.composer.Composer.composeScalarNode(Composer.java:241) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:205) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.composer.Composer.composeKeyNode(Composer.java:359) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:344) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:131) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:157) ~[snakeyaml-2.2.jar:?]
at org.yaml.snakeyaml.Yaml.compose(Yaml.java:575) ~[snakeyaml-2.2.jar:?]
at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:104) ~[spigot-api-1.21.5-R0.1-SNAPSHOT.jar:?]
... 23 more
The server logs the error but otherwise ignores it. From the plugin's perspective it appears as if the loaded config file is empty, so the Shopkeepers plugin inserts the default values and saves the updated config back to file, replacing your config file with the defaults.
You can get the config loading by replacing the surrounding double quotes with single quotes, i.e.:
name-regex: '[A-Za-z0-9!@#$&()*\\-`.+,\/"]{1,50}'
Edit: Actually, the issue is not the "
character, but that yaml handles escape sequences differently for double quoted values versus single quoted values. To get the regex working with double quotes surrounding the value all special characters need to be "double escaped": Once to escape it for yaml parser, and once to escape it for the regex parser, like so:
name-regex: "[A-Za-z0-9!@#$&()*\\\\-`.+,\\/\"]{1,50}"