PlayersRegistry.java

mudlibs/tinylib/src/net/sourceforge/pain/tinylib/data/PlayersRegistry.java · 991 B

From the archive pain_0_45.tgz

Download the archive   « Back to the archive contents

package net.sourceforge.pain.tinylib.data;

import net.sourceforge.pain.db.*;
import net.sourceforge.pain.tinylib.data.type.*;

public final class PlayersRegistry extends DbObject {

    private static final int PLAYERS_BY_LOGIN = 0;
    private static final int NFIELDS = 1;

    public PlayersRegistry() {
    }

    public PlayersRegistry(PainDB db) {
        super(db);
    }

    protected DbClassSchema provideSchema() {
        byte types[] = new byte[NFIELDS];
        String names[] = new String[NFIELDS];

        types[PLAYERS_BY_LOGIN] = DbType.STRING_KEY_MAP;
        names[PLAYERS_BY_LOGIN] = "player_by_login";

        return new DbClassSchema(types, names);

    }

    /**
     * @param login - lowercase player name
     * @return
     */
    public Player getPlayer(String login) {
        return (Player) getStringKeyMap(PLAYERS_BY_LOGIN).get(login);
    }

    public void addPlayer(Player p) {
        getStringKeyMap(PLAYERS_BY_LOGIN).put(p.getLogin(), p);
    }


}

Site Stats

Snippets: 1791
Codebases: 571