Idea on storing admin data

Discussion in 'Spigot Plugin Help' started by Nighterance, Apr 14, 2017.

  1. Hello!
    I know that there are a lot of freeze plugins, but none of them actually worked as I wanted and I wanted to learn how to develop them, and thats why I made it. Currently the plugin can just freez & unfreez any player. I want for it to check in config.yml file, for admin name and his skype. When the plugin finds that p = adminname on config file, it takes his skype from config.yml and I can use it to broadcast to which skype should member call.

    So there are 2 questions.
    1) What would be best way to store admin info? Like this?
    2) How would I make so it check every of them?

    Thanks guys!
  2. Strahan


    So you just want a list of admins and their Skype names? How should it know which admin to use from the list of admins for the broadcast?
  3. So admin executes command /freeze player. I get admin nickname and it compares it to variables in config.yml
  4. If you're saying you want the admin who runs the command /freeze [player] to have his skype sent to the player you could use;
    Code (Text):
    player.sendMessage(Colour("Please skype " + sender.getName().toString() + " at " + getConfig().getString(sender.getName())));

    Heraldry: HeraldrySkype
    Sorry if this si wrong I just made it quickly
  5. Strahan


    Oh I see, it goes by whomever does the command. Well, I'd populate my config.yml as such:

    Code (Text):
      Strahan: strahan74
      Darrellon: dmansk
      Rhiannon201: rhw187
    Then in the command, I'd do:

    Code (Text):
    if (sender instanceof Player) {
        Player p = (Player)sender;
        String mySkype = this.getConfig().getString("adminskype." + p.getName());
        if (mySkype != null) {
            Player tp = Bukkit.getPlayerExact(args[0]);
            if (tp != null) {
                tp.sendMessage("You froze, bitch.  Skype " + mySkype + " to get unlocked.");
                p.sendMessage("I froze " + args[0]);
            } else {
                p.sendMessage(args[0] + " isn't on, idiot.");
        return true;
  6. Strahan


    That'd work, but you aren't validating the data so it could potentially throw a NPE. Also, what the hell is the "Colour" method?
  7. Code (Text):
        public String Colour(String text){

        return ChatColor.translateAlternateColorCodes('&', text);

    I didn't use colourcodes because I was writing this pretty fast
    And yeah I know it could possibly throw an error but really it'd not be that bad considering it should definitely have a value.
  8. Strahan


    Ahh heh. Not saying this applies to the OP, but bear in mind a lot of "coders" on here copy and paste examples given so you shouldn't use pseudocode unless you specify that it is such.
  9. Strahan thank you, going to test it as soon as I can and tell if it worked!

    E: worked, thanks!
    #9 Nighterance, Apr 14, 2017
    Last edited: Apr 14, 2017
  10. Would probably be better to store in a database than a file, but it's your choice.
  11. You put the details on a REST API, then you have to handle with OutputStreams and you look like a pro doing this.
    I'm being sarcastic but the config file system(s) would be much easier than dealing with databases