File tree Expand file tree Collapse file tree
src/main/kotlin/me/zavdav/zcore Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ plugins {
55}
66
77group = " me.zavdav"
8- version = " 0.23.4 "
8+ version = " 0.23.5 "
99
1010repositories {
1111 mavenCentral()
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import me.zavdav.zcore.player.OfflinePlayer
2525import me.zavdav.zcore.statistic.Statistic
2626import me.zavdav.zcore.util.Materials
2727import me.zavdav.zcore.util.getField
28+ import me.zavdav.zcore.util.wildcardMatchesIgnoreCase
2829import me.zavdav.zcore.version.ZCoreVersion
2930import org.bukkit.Bukkit
3031import org.bukkit.Location
@@ -161,9 +162,7 @@ class ZCore : JavaPlugin() {
161162 matches.clear()
162163 matches.add(player)
163164 break
164- }
165-
166- if (player.name.startsWith(partialName, true )) {
165+ } else if (player.name.wildcardMatchesIgnoreCase(partialName)) {
167166 matches.add(player)
168167 }
169168 }
Original file line number Diff line number Diff line change 1+ package me.zavdav.zcore.util
2+
3+ import java.util.regex.Pattern
4+
5+ internal fun String.wildcardMatchesIgnoreCase (regex : String ): Boolean {
6+ if (regex.isEmpty()) {
7+ return this .isEmpty()
8+ }
9+
10+ val sanitizedRegex = " ^" + regex
11+ .replace(" [\\\\\\ [(){^$|?+.]" .toRegex(), " \\\\ $0" )
12+ .replace(Pattern .quote(" *" ).toRegex(), " .+" ) + " $"
13+
14+
15+ return Pattern .compile(sanitizedRegex, Pattern .CASE_INSENSITIVE )
16+ .matcher(this )
17+ .find()
18+ }
You can’t perform that action at this time.
0 commit comments