mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-05 10:20:23 +01:00
BanData interface to LiteBansData
This commit is contained in:
parent
1da0b9e9a7
commit
26f42be2d3
@ -11,16 +11,15 @@ import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData for LiteBans plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class LiteBansData extends PluginData {
|
||||
public class LiteBansData extends PluginData implements BanData {
|
||||
|
||||
private final LiteBansDatabaseQueries db;
|
||||
|
||||
@ -91,4 +90,30 @@ public class LiteBansData extends PluginData {
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned(UUID uuid) {
|
||||
try {
|
||||
return !db.getBans(uuid).isEmpty();
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<UUID> filterBanned(Collection<UUID> collection) {
|
||||
try {
|
||||
List<BanObject> bans = db.getBans();
|
||||
Set<UUID> banned = new HashSet<>();
|
||||
for (BanObject ban : bans) {
|
||||
banned.add(ban.getUuid());
|
||||
}
|
||||
|
||||
return collection.stream().filter(banned::contains).collect(Collectors.toSet());
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user