Fixes #324 (Does not remove incorrect data)

This commit is contained in:
Rsl1122 2017-10-07 20:11:57 +03:00
parent 5771218857
commit edbc7d67f1
3 changed files with 12 additions and 22 deletions

View File

@ -15,7 +15,7 @@ public enum Actions {
UNKNOWN(-1),
FIRST_SESSION(1),
FIRST_LOGOUT(2),
CHANGED_NAME(3),
NEW_NICKNAME(3),
KILLED(-2), // Not stored in ActionsTable.
;

View File

@ -10,7 +10,6 @@ import main.java.com.djrapitops.plan.data.Action;
import main.java.com.djrapitops.plan.database.tables.Actions;
import main.java.com.djrapitops.plan.systems.processing.player.PlayerProcessor;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.html.Html;
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
import java.sql.SQLException;
@ -22,30 +21,24 @@ import java.util.UUID;
* @author Rsl1122
* @since 4.0.0
*/
public class NickChangeActionProcessor extends PlayerProcessor {
public class NewNickActionProcessor extends PlayerProcessor {
private final String displayName;
private final String inDB;
public NickChangeActionProcessor(UUID uuid, String displayName, String inDB) {
public NewNickActionProcessor(UUID uuid, String displayName) {
super(uuid);
this.displayName = displayName;
this.inDB = inDB;
}
@Override
public void process() {
UUID uuid = getUUID();
if (displayName.equals(inDB)) {
return;
}
String old = HtmlUtils.swapColorsToSpan(inDB);
String n = HtmlUtils.swapColorsToSpan(displayName);
String info = HtmlUtils.removeXSS(old + " " + Html.FONT_AWESOME_ICON.parse("long-arrow-right") + " " + n);
String info = HtmlUtils.removeXSS(n);
Action action = new Action(MiscUtils.getTime(), Actions.CHANGED_NAME, info);
Action action = new Action(MiscUtils.getTime(), Actions.NEW_NICKNAME, info);
try {
Plan.getInstance().getDB().getActionsTable().insertAction(uuid, action);

View File

@ -9,7 +9,7 @@ import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.tables.NicknamesTable;
import main.java.com.djrapitops.plan.systems.cache.DataCache;
import main.java.com.djrapitops.plan.systems.processing.NickChangeActionProcessor;
import main.java.com.djrapitops.plan.systems.processing.NewNickActionProcessor;
import java.sql.SQLException;
import java.util.List;
@ -47,7 +47,7 @@ public class NameProcessor extends PlayerProcessor {
Database db = plugin.getDB();
NicknamesTable nicknamesTable = db.getNicknamesTable();
cueNameChangeActionProcessor(uuid, plugin, sameAsCached, nicknamesTable);
cueNameChangeActionProcessor(uuid, plugin, nicknamesTable);
try {
db.getUsersTable().updateName(uuid, playerName);
@ -60,16 +60,13 @@ public class NameProcessor extends PlayerProcessor {
dataCache.updateNames(uuid, playerName, displayName);
}
private void cueNameChangeActionProcessor(UUID uuid, Plan plugin, boolean sameAsCached, NicknamesTable nicknamesTable) {
private void cueNameChangeActionProcessor(UUID uuid, Plan plugin, NicknamesTable nicknamesTable) {
try {
if (!sameAsCached) {
List<String> nicknames = nicknamesTable.getNicknames(uuid, Plan.getServerUUID());
if (!nicknames.isEmpty()) {
plugin.addToProcessQueue(new NickChangeActionProcessor(uuid, displayName, nicknames.get(nicknames.size() - 1)));
} else {
plugin.addToProcessQueue(new NickChangeActionProcessor(uuid, displayName, playerName));
}
List<String> nicknames = nicknamesTable.getNicknames(uuid, Plan.getServerUUID());
if (nicknames.contains(displayName)) {
return;
}
plugin.addToProcessQueue(new NewNickActionProcessor(uuid, displayName));
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
}