Jump to content

Recommended Posts

Posted

***

SQL

***

CREATE TABLE IF NOT EXISTS character_color (
    obj_id decimal(11,0) NOT NULL default '0',
    name_color CHAR(6) NOT NULL DEFAULT 'FFFFFF',
    title_color CHAR(6) NOT NULL DEFAULT 'FFFF77',
    PRIMARY KEY  (obj_Id)
);

 

***

Core

***

private void restoreColor()
    {

        ThreadConnection con = null;

        try
        {
            con = L2DatabaseFactory.getInstance().getConnection();
            FiltredPreparedStatement statement = con.prepareStatement("SELECT name_color,title_color FROM character_color WHERE obj_id=?");
            statement.setInt(1, getObjectId());
            ResultSet rset = statement.executeQuery();
            while (rset.next())
            {
                setNameColor(Integer.decode((new StringBuilder()).append("0x").append(rset.getString("name_color")).toString()).intValue());
                setTitleColor(Integer.decode((new StringBuilder()).append("0x").append(rset.getString("title_color")).toString()).intValue());
            }
            DatabaseUtils.closeDatabaseCSR(con,statement,rset);

        }
        catch (SQLException e)
        {
            setNameColor(0xFFFFFF);
            setTitleColor(0xFFFF77);
        }

    }
     private void storeColor()
    {

        if(getNameColor() == 0xFFFFFF && getTitleColor() == 0xFFFF77)
                    return;
        ThreadConnection con = null;
        FiltredPreparedStatement statement=null;

        try
        {
            
            con = L2DatabaseFactory.getInstance().getConnection();
            statement = con.prepareStatement("UPDATE character_color SET name_color=?,title_color=? WHERE obj_id=?");
            statement.setString(1, Integer.toHexString(getNameColor()).toUpperCase());
            statement.setString(2, Integer.toHexString(getTitleColor()).toUpperCase());
            statement.setInt(3, getObjectId());
            statement.execute();

            DatabaseUtils.closeDatabaseCS(con,statement);


        }
        catch (SQLException e)
        {
            con = L2DatabaseFactory.getInstance().getConnection();
            statement = con.prepareStatement("INSERT INTO character_color(obj_id, name_color, title_color) VALUES (?,?,?)");
            statement.setInt(1, getObjectId());
            statement.setString(2, Integer.toHexString(getNameColor()).toUpperCase());
            statement.setString(3, Integer.toHexString(getTitleColor()).toUpperCase());
            statement.execute();

            DatabaseUtils.closeDatabaseCS(con,statement); 
        }

    }

 

Gredits botvans l2jfree forum

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..