2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.hotelview ;
import com.eu.habbo.Emulator ;
import gnu.trove.set.hash.THashSet ;
2018-09-28 21:25:00 +02:00
import java.sql.Connection ;
import java.sql.ResultSet ;
import java.sql.SQLException ;
import java.sql.Statement ;
2018-07-06 15:30:00 +02:00
public class NewsList
{
private final THashSet < NewsWidget > newsWidgets ;
public NewsList ( )
{
2018-09-28 21:25:00 +02:00
this . newsWidgets = new THashSet < > ( ) ;
2018-07-06 15:30:00 +02:00
this . reload ( ) ;
}
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public void reload ( )
{
synchronized ( this . newsWidgets )
{
this . newsWidgets . clear ( ) ;
try ( Connection connection = Emulator . getDatabase ( ) . getDataSource ( ) . getConnection ( ) ; Statement statement = connection . createStatement ( ) ; ResultSet set = statement . executeQuery ( " SELECT * FROM hotelview_news ORDER BY id DESC LIMIT 10 " ) )
{
while ( set . next ( ) )
{
this . newsWidgets . add ( new NewsWidget ( set ) ) ;
}
}
catch ( SQLException e )
{
Emulator . getLogging ( ) . logSQLException ( e ) ;
}
}
}
2018-07-08 23:32:00 +02:00
2018-07-06 15:30:00 +02:00
public THashSet < NewsWidget > getNewsWidgets ( )
{
return newsWidgets ;
}
}