How to convert String seed to long seed?

Discussion in 'Plugin Development' started by RORAK, Apr 10, 2022.

  1. Offline

    RORAK

    Hi, I have this example.
    Code:
    String seed = "someseed example"; // this is defined in config
    
    new WorldCreator("seedexample).seed(/*this wants long seed!*\).createWorld();
    How do I convert the String seed, defined in config, to the long seed?

    Thanks!
     
  2. Online

    timtower Administrator Administrator Moderator

    @RORAK Why not just ask for a long in the config?
     
  3. Offline

    RORAK

    Some user may want to use String seed, because sometimes it's better.
    I just want to convert it, not to ask for long in the config.
     
  4. Offline

    CraftCreeper6

    @RORAK
    If the user doesn't enter a long then you can't miraculously convert to one if it's not numeric. Best bet, just add some validation before you pass the seed to your WorldCreator. Add some good user feedback for if they enter an invalid long.
     
  5. Online

    timtower Administrator Administrator Moderator

    The string is converted to a long somewhere in the mojang code though.
     

Share This Page