mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-02-20 16:49:36 +01:00
Move duplicate player checks to checkStructure()
This commit is contained in:
parent
82f8022f54
commit
bbf16d8058
@ -11,6 +11,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -497,20 +498,12 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
try {
|
try {
|
||||||
in = new BufferedReader(new FileReader(usersFilePath));
|
in = new BufferedReader(new FileReader(usersFilePath));
|
||||||
String line = "";
|
String line = "";
|
||||||
ArrayList<String> players = new ArrayList<String>();
|
|
||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
String[] data = line.split(":");
|
String[] data = line.split(":");
|
||||||
String playerName = data[0];
|
String playerName = data[0];
|
||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
|
|
||||||
// Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...)
|
|
||||||
if (players.contains(playerName)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
players.add(playerName);
|
|
||||||
|
|
||||||
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
||||||
|
|
||||||
powerLevel += putStat(acrobatics, playerName, skills.get(SkillType.ACROBATICS));
|
powerLevel += putStat(acrobatics, playerName, skills.get(SkillType.ACROBATICS));
|
||||||
@ -581,6 +574,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
in = new BufferedReader(new FileReader(usersFilePath));
|
in = new BufferedReader(new FileReader(usersFilePath));
|
||||||
StringBuilder writer = new StringBuilder();
|
StringBuilder writer = new StringBuilder();
|
||||||
String line = "";
|
String line = "";
|
||||||
|
HashSet<String> players = new HashSet<String>();
|
||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
// Length checks depend on last character being ':'
|
// Length checks depend on last character being ':'
|
||||||
@ -589,6 +583,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
|
|
||||||
|
// Prevent the same player from being present multiple times
|
||||||
|
if (!players.add(character[0])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// If they're valid, rewrite them to the file.
|
// If they're valid, rewrite them to the file.
|
||||||
if (character.length > 38) {
|
if (character.length > 38) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user