[Release] No more MySQL editing for login

Junior Spellweaver
Joined
Jul 8, 2008
Messages
164
Reaction score
0
I made a shutdown hook for logging all accounts out. Takes away having to edit your database if you forced your batches shut.

Code:
public class MapleLogoutHook extends java.lang.Thread {
 public void run() {
  try {
    Connection con = DatabaseConnection.getConnection();
    PreparedStatement ps = con.prepareStatement("UPDATE accounts SET loggedin = 0");
    ps.executeUpdate();
    ps.close();
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
}
 
lol traitor your so damn lazy xD
but this is awsome
its so anoying to have to reset evreyone to 0
 
Simple and easy. you can just run the query anyway <_<.
 
Jvlaple, you'll have to give some info for these guys. They're not smart enough to actually add stuff, hence all the repacks -_-
Ummm Leech Protection FTW?

Anyways Nice release, I think I had tried to do this, back when I didn't know SQL and I failed, anyways Nice Release Again.

Code:
catch (Exception ex) {
    throw new RuntimeException(ex);
  }
Forgive me if I'm mistaken but shouldn't it be throw then catch?


By the way, you're missing a closing brace at the end.
 
OdinMS already sets loggedin to 0 on server start, so this was never needed anyway; and loggedin probably has some sort of use.

No it doesn't. Only some repacks do.

And that comment was in reply to the release. If you make a hook for resetting to 0 then you obviously have no use for it and thus it's better to just remove loggedin itself..
 
No it doesn't. Only some repacks do.
Code:
@Override
    public void run() {
        try {
            cwi = new ChannelWorldInterfaceImpl(this);
            wci = worldRegistry.registerChannelServer(key, cwi);
            props = wci.getGameProperties();
            expRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.exp"));
            mesoRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.meso"));
            dropRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.drop"));
            bossdropRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.bossdrop"));
            petExpRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.petExp"));
            serverMessage = props.getProperty("net.sf.odinms.world.serverMessage");
            dropUndroppables = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.alldrop", "false"));
            moreThanOne = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.morethanone", "false"));
            eventSM = new EventScriptManager(this, props.getProperty("net.sf.odinms.channel.events").split(","));
            gmWhiteText = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.gmWhiteText", "false"));
            cashshop = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.cashshop", "false"));
            Properties dbProp = new Properties();
            FileReader fileReader = new FileReader("db.properties");
            dbProp.load(fileReader);
            fileReader.close();
            DatabaseConnection.setProps(dbProp);
            DatabaseConnection.getConnection();
            Connection c = DatabaseConnection.getConnection();
            PreparedStatement ps;
            try {
                ps = c.prepareStatement("UPDATE accounts SET loggedin = 0");
                ps.executeUpdate();
                ps.close();
            } catch (SQLException ex) {
                log.error("Could not reset databases",ex);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
From Valhalla, and old version too.
 
Code:
@Override
    public void run() {
        try {
            cwi = new ChannelWorldInterfaceImpl(this);
            wci = worldRegistry.registerChannelServer(key, cwi);
            props = wci.getGameProperties();
            expRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.exp"));
            mesoRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.meso"));
            dropRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.drop"));
            bossdropRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.bossdrop"));
            petExpRate = Integer.parseInt(props.getProperty("net.sf.odinms.world.petExp"));
            serverMessage = props.getProperty("net.sf.odinms.world.serverMessage");
            dropUndroppables = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.alldrop", "false"));
            moreThanOne = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.morethanone", "false"));
            eventSM = new EventScriptManager(this, props.getProperty("net.sf.odinms.channel.events").split(","));
            gmWhiteText = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.gmWhiteText", "false"));
            cashshop = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.cashshop", "false"));
            Properties dbProp = new Properties();
            FileReader fileReader = new FileReader("db.properties");
            dbProp.load(fileReader);
            fileReader.close();
            DatabaseConnection.setProps(dbProp);
            DatabaseConnection.getConnection();
            Connection c = DatabaseConnection.getConnection();
            PreparedStatement ps;
            try {
                ps = c.prepareStatement("UPDATE accounts SET loggedin = 0");
                ps.executeUpdate();
                ps.close();
            } catch (SQLException ex) {
                log.error("Could not reset databases",ex);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
From Valhalla, and old version too.

You said OdinMS, not Valhalla.
 
Back