2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.rooms ;
import com.eu.habbo.Emulator ;
import java.sql.Connection ;
import java.sql.PreparedStatement ;
import java.sql.ResultSet ;
import java.sql.SQLException ;
public class RoomBan
{
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public final int roomId ;
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public final int userId ;
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public final String username ;
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public final int endTimestamp ;
public RoomBan ( int roomId , int userId , String username , int endTimestamp )
{
this . roomId = roomId ;
this . userId = userId ;
this . username = username ;
this . endTimestamp = endTimestamp ;
}
public RoomBan ( ResultSet set ) throws SQLException
{
this . roomId = set . getInt ( " room_id " ) ;
this . userId = set . getInt ( " user_id " ) ;
this . username = set . getString ( " username " ) ;
this . endTimestamp = set . getInt ( " ends " ) ;
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void insert ( )
{
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " INSERT INTO room_bans (room_id, user_id, ends) VALUES (?, ?, ?) " ) )
{
statement . setInt ( 1 , this . roomId ) ;
statement . setInt ( 2 , this . userId ) ;
statement . setInt ( 3 , this . endTimestamp ) ;
statement . execute ( ) ;
}
catch ( SQLException e )
{
Emulator . getLogging ( ) . logSQLException ( e ) ;
}
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void delete ( )
{
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; PreparedStatement statement = connection . prepareStatement ( " DELETE FROM room_bans WHERE room_id = ? AND user_id = ? " ) )
{
statement . setInt ( 1 , this . roomId ) ;
statement . setInt ( 2 , this . userId ) ;
statement . execute ( ) ;
}
catch ( SQLException e )
{
Emulator . getLogging ( ) . logSQLException ( e ) ;
}
}
}