diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java index ef392d113..8375cc790 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java @@ -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. ; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/NickChangeActionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java similarity index 71% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/NickChangeActionProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java index a48e9aacd..31dd6192b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/NickChangeActionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java @@ -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); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java index 72297aa4e..ababd450e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java @@ -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 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 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); }