Save something in Config File

Discussion in 'Plugin Development' started by 0verFull, Aug 14, 2015.

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

    0verFull

    Hi guys and girls,

    How to save a new instance of a custom constructor in config file, and load it in the onEnable() ?
    Code:
    public class Contract {
    
        private Player target;
        private Player sender;
        private int reward;
       
        public Contract(Player target, Player sender, int reward) {
            this.target = target;
            this.sender = sender;
            this.reward = reward;
        }
        
    For create a new contract, the user use /contract like this :
    Code:
    @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(label.equalsIgnoreCase("contract")){
                if(sender instanceof Player){
                    new Contract(Bukkit.getPlayer(args[0]), (Player) sender, Integer.valueOf(args[1]));
                }
            }
            return super.onCommand(sender, command, label, args);
        }
    Thanks for atention
     
  2. Look in the official config api tutorial under 'serializing / deserializing an object'
     
  3. Offline

    0verFull

Thread Status:
Not open for further replies.

Share This Page