Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java

44 lines
1.1 KiB
Java
Raw Normal View History

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;
import java.sql.*;
public class NewsList
{
private final THashSet<NewsWidget> newsWidgets;
public NewsList()
{
this.newsWidgets = new THashSet<NewsWidget>();
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;
}
}