Update 1.12.2 to 1.13 PropertyManager

Discussion in 'Spigot Plugin Development' started by JohnPoliakov, Sep 10, 2018.

  1. JohnPoliakov

    JohnPoliakov Previously punisher5

    Hi, I'm updating a plugin to the latest spigot version, and I don't understand how to fix those lignes

    Code (Java):
    PropertyManager propertyManager = ((CraftServer)Bukkit.getServer()).getServer().getPropertyManager();
        propertyManager.setProperty("difficulty", "2");
        propertyManager.setProperty("spawn-protection", "0");
        propertyManager.setProperty("announce-player-achievements", "false");
        propertyManager.setProperty("force-gamemode", "true");
        propertyManager.setProperty("gamemode", "0");
  2. You're setting all of the objects as strings

    the setProperty method is probably (object, object) so for example

    PropertyManager propertyManager = ((CraftServer)Bukkit.getServer()).getServer().getPropertyManager();
    propertyManager.setProperty("difficulty", 2);
    propertyManager.setProperty("spawn-protection", 0);
    propertyManager.setProperty("announce-player-achievements", false);
    propertyManager.setProperty("force-gamemode", true);
    propertyManager.setProperty("gamemode", 0);

    Otherwise; what is your error? I am not familiar with this way
  3. Choco


    Replaceable with Bukkit#setDefaultGameMode(GameMode.SURVIVAL)

    Replaceable with World#setDifficulty(Difficulty.HARD)

    The rest is handled through NMS. Bukkit doesn't have a property API (for some reason?). Any particular reason as to why you're modifying the properties like this? I'm sure the server owner is more than capable of doing this for themselves.

    Thread moved to Spigot Plugin Development
    • Agree Agree x 1