Fixed Litebans ban status #608

This commit is contained in:
Rsl1122 2018-07-09 10:26:46 +03:00
parent 721c8ebe44
commit 3ecddd19f4

View File

@ -106,7 +106,7 @@ public class LiteBansData extends PluginData implements BanData {
} }
@Override @Override
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) throws Exception { public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) {
TableContainer banTable = getBanTable(); TableContainer banTable = getBanTable();
TableContainer muteTable = getMuteTable(); TableContainer muteTable = getMuteTable();
TableContainer warningTable = getWarningTable(); TableContainer warningTable = getWarningTable();
@ -200,7 +200,7 @@ public class LiteBansData extends PluginData implements BanData {
@Override @Override
public boolean isBanned(UUID uuid) { public boolean isBanned(UUID uuid) {
try { try {
return !db.getBans(uuid).isEmpty(); return db.getBans(uuid).stream().anyMatch(LiteBansDBObj::isActive);
} catch (DBOpException e) { } catch (DBOpException e) {
Log.toLog(this.getClass(), e); Log.toLog(this.getClass(), e);
} }
@ -210,11 +210,10 @@ public class LiteBansData extends PluginData implements BanData {
@Override @Override
public Collection<UUID> filterBanned(Collection<UUID> collection) { public Collection<UUID> filterBanned(Collection<UUID> collection) {
try { try {
List<LiteBansDBObj> bans = db.getBans(); Set<UUID> banned = db.getBans().stream()
Set<UUID> banned = new HashSet<>(); .filter(LiteBansDBObj::isActive)
for (LiteBansDBObj ban : bans) { .map(LiteBansDBObj::getUuid)
banned.add(ban.getUuid()); .collect(Collectors.toSet());
}
return collection.stream().filter(banned::contains).collect(Collectors.toSet()); return collection.stream().filter(banned::contains).collect(Collectors.toSet());
} catch (DBOpException e) { } catch (DBOpException e) {