BGHDDevelopment / PlayerBalancer

The repository for the plugin PlayerBalancer
https://www.spigotmc.org/resources/55011/
MIT License
28 stars 25 forks source link

How to express sequence of numbers of servers in sections? #9

Closed netherstar closed 4 years ago

netherstar commented 4 years ago

Sorry for my bad English. i have a list of sequence of number of uhc servers in bungeecord like that, from uhc25, uhc26, uhc27... to uhc47

  uhc25:
    motd: uhc
    address: 192.168.0.1:28025
    restricted: false
....................
.................
  uhca47:
    motd: uhca
    address: 192.168.0.1:280047
    restricted: false

and this is section config on PlayerBalancer

      uhc {
        parent="uhc-lobby"
        provider=RANDOM_FILLER
        servers=[
          "uhc[25-47]"
         ]
        section-server=playuhc
        section-command {
          name=playuhc
          permission=""
          aliases=[]
        }
      }

but when "balancer reload" it always show this error

[15:52:48] [main/INFO] [PlayerBalancer]: Executing stage "Resolving servers"
[15:52:48] [main/ERROR] [PlayerBalancer]: The plugin could not continue loading due to an unexpected exception
[15:52:48] [main/ERROR]: java.util.regex.PatternSyntaxException: Illegal character range near index 8
[15:52:48] [main/ERROR]: uhca[25-47]
[15:52:48] [main/ERROR]:         ^
[15:52:48] [main/ERROR]:    at java.util.regex.Pattern.error(Pattern.java:1957)
[15:52:48] [main/ERROR]:    at java.util.regex.Pattern.range(Pattern.java:2657)
[15:52:48] [main/ERROR]:    at java.util.regex.Pattern.clazz(Pattern.java:2564)
[15:52:48] [main/ERROR]:    at java.util.regex.Pattern.sequence(Pattern.java:2065)
[15:52:48] [main/ERROR]:    at java.util.regex.Pattern.expr(Pattern.java:1998)
[15:52:48] [main/ERROR]:    at java.util.regex.Pattern.compile(Pattern.java:1698)
[15:52:48] [main/ERROR]:    at java.util.regex.Pattern.<init>(Pattern.java:1351)
[15:52:48] [main/ERROR]:    at java.util.regex.Pattern.compile(Pattern.java:1028)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.section.SectionManager.lambda$calculateServers$5(SectionManager.java:261)
[15:52:48] [main/ERROR]:    at java.util.ArrayList.forEach(ArrayList.java:1257)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.section.SectionManager.calculateServers(SectionManager.java:260)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.section.SectionManager$7.execute(SectionManager.java:123)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.section.SectionManager$SectionStage.lambda$execute$0(SectionManager.java:382)
[15:52:48] [main/ERROR]:    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.section.SectionManager$SectionStage.execute(SectionManager.java:381)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.section.SectionManager.lambda$load$0(SectionManager.java:160)
[15:52:48] [main/ERROR]:    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
[15:52:48] [main/ERROR]:    at java.util.Collections$SynchronizedMap.forEach(Collections.java:2649)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.section.SectionManager.load(SectionManager.java:158)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.PlayerBalancer.execStart(PlayerBalancer.java:133)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.PlayerBalancer.reloadPlugin(PlayerBalancer.java:264)
[15:52:48] [main/ERROR]:    at com.jaimemartz.playerbalancer.commands.MainCommand.execute(MainCommand.java:119)
[15:52:48] [main/ERROR]:    at net.md_5.bungee.api.plugin.PluginManager.dispatchCommand(PluginManager.java:192)
[15:52:48] [main/ERROR]:    at net.md_5.bungee.api.plugin.PluginManager.dispatchCommand(PluginManager.java:142)
[15:52:48] [main/ERROR]:    at io.github.waterfallmc.waterfall.console.WaterfallConsole.runCommand(WaterfallConsole.java:30)
[15:52:48] [main/ERROR]:    at net.minecrell.terminalconsole.SimpleTerminalConsole.processInput(SimpleTerminalConsole.java:87)
[15:52:48] [main/ERROR]:    at net.minecrell.terminalconsole.SimpleTerminalConsole.readCommands(SimpleTerminalConsole.java:168)
[15:52:48] [main/ERROR]:    at net.minecrell.terminalconsole.SimpleTerminalConsole.start(SimpleTerminalConsole.java:141)
[15:52:48] [main/ERROR]:    at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67)
[15:52:48] [main/ERROR]:    at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
[15:52:48] [main/INFO]: Something went badly while reloading the plugin
[15:53:00] [main/INFO]: Reloading the configuration, this may take a while...

If i tried uhc[1-47] then "balancer reload" work but "section info uhc" show no servers Now i temporary fix it by adding servers like this but i have a plan to make hundred servers so this it not good solution.

      uhc {
        parent="uhc-lobby"
        provider=PROGRESSIVE_FILLER
        servers=[
            "uhc25",
            "uhc26",
            "uhc27",
            "uhc28",
            "uhc29",
            "uhc30",
            "uhc31",
            "uhc32",
            "uhc33",
            "uhc34",
            "uhc35",
            "uhc36",
            "uhc37",
            "uhc38",
            "uhc39",
            "uhc40",
            "uhc41",
            "uhc42",
            "uhc43",
            "uhc44",
            "uhc45",
            "uhc46",
            "uhc47"         
        ]

other question: can this plugin handle hundreds of mini game server? i also recommend you change this default setting to more than 5, i tried many time to know that 5 is too low so player sometimes can't get server so change to 30 and everything work perfect.

    # The attempts before giving up on getting a server for a player
    attempts=5
netherstar commented 4 years ago

Also plugin PlayerBalancerAddon seem to be need to update, it is not work with PlaceholderAPI 2.10.3

jamezrin commented 4 years ago

Hi, thank you for actually taking the time to write a good issue.

PlayerBalancer uses RegEx, so you can't just do ranges of numbers, you will have to do something more involved, like this:

servers=[
    "uhc[2-4][0-9]" 
]

That will match from 20 to 49, which should work for your use case. It's definitely possible to do a range from 25 to 47 but it's verbose and at first, complicated.

You can also do the following

servers=[
   "uhc.*"
]

which will match any server that starts with uhc, be careful because it will also match things like uhclobby or uhcother1. I would use the first one.

Regarding the default attempts, I will set what you say, it shouldn't cause problems.

And regarding the addon, I will try and update it today, I have gotten multiple reports that it doesn't work in the latest version.

jamezrin commented 4 years ago

Try updating to: https://www.spigotmc.org/resources/bungeecord-playerbalancer.10788/ https://www.spigotmc.org/resources/playerbalanceraddon.51220/

netherstar commented 4 years ago

@jamezrin Thank you very very much! But you upload wrong file to playerbalanceraddon?

jamezrin commented 4 years ago

Sorry, fixed.

netherstar commented 4 years ago

Thank you, it works perfectly now!

jamezrin commented 4 years ago

Great, I'm glad that fixed it.