How Do I Save Scores So They Won't Reset?

Discussion in 'Plugin Development' started by Mr. Sandwich, Aug 30, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Mr. Sandwich

    Hey, when the server(the server with my plugin) reloads or restarting all of the scoreboard scores are getting reset, is there a way to save them?

    Class:

    package me.RossomeSandwich;

    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerRespawnEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Scoreboard;

    public class Test extends JavaPlugin implements Listener {

    private Scoreboard board;
    private Objective o;

    public void onEnable() {
    Bukkit.getServer().getPluginManager().registerEvents(this, this);

    board = Bukkit.getServer().getScoreboardManager().getNewScoreboard();

    o = board.registerNewObjective("Test", "dummy");

    }

    @SuppressWarnings("deprecation")
    @EventHandler
    public void onPlayerMove(PlayerRespawnEvent e) {

    o.getScore(e.getPlayer()).setScore(15);
    }
    }
     
  2. Offline

    meguy26

    @Mr. Sandwich
    No, you unfortunately cannot just save a scoreboard object, what you have to do instead is save the values for each player in a config/yml file and load them onEnable
     
  3. Offline

    Mr. Sandwich

    and how do I do that
     
  4. Offline

    teej107

  5. Offline

    Mr. Sandwich

  6. Offline

    teej107

    @Mr. Sandwich It explains how to save information to a config. You decide how and what that information will be like when it's stored.
     
  7. Offline

    Mr. Sandwich

    I read this page but I still dont know how to make scores for players, (I dont want all of them to have the same score, I want to create something like Essentials' money system)
     
  8. Offline

    Mr. Sandwich

    its been like 12 days and I still dont have an answer, can someone help me?
     
  9. Offline

    boomboompower

  10. Get the scores of the players and save them in a file. Loop trough the scores and save them with a path like scores.uuid.
     
  11. Offline

    Mr. Sandwich

    I have a problem with reading a lot, its just hard for me and I cant remember what was in the page after I finished reading, and Mr01Luki, I asked for a code
     
  12. Offline

    Irantwomiles

    No one will spoon feed code. I'll tell you that much.
     
  13. Offline

    boomboompower

    Yes but when you read something, and actually try reading it. You will remember it. Also, you can just read the parts you need and copy the codes for it.
     
  14. Offline

    FabeGabeMC

    @Mr. Sandwich If people spoonfeed you code, you will not understand what the code does.
    But if you read the Config API Reference on the wiki (http://wiki.bukkit.org/Configuration_API_Reference), you will understand what each method does.
    Go ahead and give it a read and you shouldn't need to ask this question anymore, as this will solve every config problem you might have in the future.
     
Thread Status:
Not open for further replies.

Share This Page