mn.EngineForge.module.player.java Source code

Java tutorial

Introduction

Here is the source code for mn.EngineForge.module.player.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package mn.EngineForge.module;

import java.io.FileWriter;
import java.io.IOException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

/**
 *
 * @author Lupino
 */
public class player {
    // <editor-fold defaultstate="collapsed" desc="Config">
    private final String path = config.path;
    // </editor-fold>

    private String username;
    private String password;
    private int id;

    public void setUsername(String USERNAME) {
        this.username = USERNAME;
    }

    public void setPassword(String PASSWORD) {
        this.password = general.encryptPass(PASSWORD);
    }

    public void setId(int ID) {
        this.id = ID;
    }

    /*Registeration*/
    public void saveRegisteration() throws IOException {
        JSONObject reg = new JSONObject();
        reg.put("ID", id);
        reg.put("USERNAME", username);
        reg.put("PASSWORD", password);
        reg.put("REG_DATE", null);
        reg.put("LAST_LOGIN", null);
        reg.put("POSITION", null);
        /* JSON ARRAY NOTE
        JSONArray company = new JSONArray();
        company.add("Compnay: eBay");
        company.add("Compnay: Paypal");
        company.add("Compnay: Google");
        reg.put("Company List", company);
        */
        FileWriter file = new FileWriter(this.path);
        try {
            file.write(reg.toJSONString());
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            file.flush();
            file.close();
        }
    }

    public int getId() throws IOException { //return ID
        general DataGen = new general();
        JSONArray Data = DataGen.decodeJSON();
        //Implement here
        return 0;
    }

    public boolean playerStatus() {
        return false;
    }

    public boolean playerIsActive() {
        return false;
    }

    public long playedTime() {
        return 0;
    }

}