mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-06 10:49:44 +01:00
Replaces 'for' and 'while' loops with 'foreach'
This commit is contained in:
parent
7e03c1dcc0
commit
6966ed2206
@ -1,15 +1,5 @@
|
||||
package main.java.com.djrapitops.plan.database.tables;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.database.Container;
|
||||
@ -18,6 +8,11 @@ import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.ManageUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
@ -291,9 +286,7 @@ public class SessionsTable extends Table {
|
||||
Log.debug("Sessions after: " + after);
|
||||
if (before - after > 50) {
|
||||
Benchmark.start("Database: Save combined sessions");
|
||||
Iterator<Integer> iterator = new HashSet<>(allSessions.keySet()).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
int id = iterator.next();
|
||||
for (Integer id : new HashSet<>(allSessions.keySet())) {
|
||||
if (afterM.get(id) < beforeM.get(id)) {
|
||||
removeUserSessions(id);
|
||||
} else {
|
||||
|
@ -35,9 +35,7 @@ public class ScatterGraphCreator {
|
||||
Point lastPoint = null;
|
||||
|
||||
Set<Point> toAdd = new HashSet<>();
|
||||
Iterator<Point> iterator = points.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Point point = iterator.next();
|
||||
for (Point point : points) {
|
||||
if (Verify.notNull(point, lastPoint)) {
|
||||
long date = (long) point.getX();
|
||||
long lastDate = (long) lastPoint.getX();
|
||||
|
@ -1,16 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
@ -19,6 +9,10 @@ import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
@ -120,9 +114,7 @@ public class ManageUtils {
|
||||
}
|
||||
List<SessionData> newSessions = new ArrayList<>();
|
||||
List<SessionData> removed = new ArrayList<>();
|
||||
Iterator<SessionData> iterator = sessions.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
SessionData session = iterator.next();
|
||||
for (SessionData session : sessions) {
|
||||
if (removed.contains(session)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
@ -18,6 +14,11 @@ import main.java.com.djrapitops.plan.ui.html.tables.SessionTableCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
@ -78,10 +79,10 @@ public class PlaceholderUtils {
|
||||
GamemodePart gmPart = new GamemodePart(null);
|
||||
Map<String, Long> gmTimes = data.getGmTimes();
|
||||
String[] gms = new String[]{"SURVIVAL", "CREATIVE", "ADVENTURE", "SPECTATOR"};
|
||||
for (int i = 0; i < gms.length; i++) {
|
||||
Long time = gmTimes.get(gms[i]);
|
||||
for (String gm : gms) {
|
||||
Long time = gmTimes.get(gm);
|
||||
if (time != null) {
|
||||
gmPart.addTo(gms[i], time);
|
||||
gmPart.addTo(gm, time);
|
||||
}
|
||||
}
|
||||
gmPart.analyse();
|
||||
|
Loading…
Reference in New Issue
Block a user