Rename KillData -> PlayerKill

This commit is contained in:
Rsl1122 2017-08-24 10:56:35 +03:00
parent 263891d1f1
commit e74c19a28f
10 changed files with 40 additions and 40 deletions

View File

@ -11,20 +11,20 @@ import java.util.UUID;
*
* @author Rsl1122
*/
public class KillData {
public class PlayerKill {
private final UUID victim;
private final long time;
private final String weapon;
/**
* Creates a KillData object with given parameters.
* Creates a PlayerKill object with given parameters.
*
* @param victim UUID of the victim.
* @param weapon Weapon used.
* @param time Epoch millisecond at which the kill occurred.
*/
public KillData(UUID victim, String weapon, long time) {
public PlayerKill(UUID victim, String weapon, long time) {
this.victim = victim;
this.weapon = weapon;
this.time = time;
@ -74,7 +74,7 @@ public class KillData {
if (getClass() != obj.getClass()) {
return false;
}
final KillData other = (KillData) obj;
final PlayerKill other = (PlayerKill) obj;
return this.time == other.time
&& Objects.equals(this.weapon, other.weapon)
&& Objects.equals(this.victim, other.victim);

View File

@ -30,7 +30,7 @@ public class Session {
private WorldTimes worldTimes;
private final long sessionStart;
private long sessionEnd;
private List<KillData> playerKills;
private List<PlayerKill> playerKills;
private int mobKills;
private int deaths;
@ -87,7 +87,7 @@ public class Session {
worldTimes.updateState(world, gm, time);
}
public void playerKilled(KillData kill) {
public void playerKilled(PlayerKill kill) {
playerKills.add(kill);
}
@ -130,7 +130,7 @@ public class Session {
return worldTimes;
}
public List<KillData> getPlayerKills() {
public List<PlayerKill> getPlayerKills() {
return playerKills;
}
@ -185,7 +185,7 @@ public class Session {
this.worldTimes = worldTimes;
}
public void setPlayerKills(List<KillData> playerKills) {
public void setPlayerKills(List<PlayerKill> playerKills) {
this.playerKills = playerKills;
}

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.data.analysis;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.data.KillData;
import main.java.com.djrapitops.plan.data.PlayerKill;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.util.HashMap;
@ -24,7 +24,7 @@ import java.util.UUID;
*/
public class KillPart extends RawData {
private final Map<UUID, List<KillData>> playerKills;
private final Map<UUID, List<PlayerKill>> playerKills;
private long mobKills;
private long deaths;
@ -49,7 +49,7 @@ public class KillPart extends RawData {
* @param kills all kills of a player
* @throws IllegalArgumentException if kills is null
*/
public void addKills(UUID uuid, List<KillData> kills) {
public void addKills(UUID uuid, List<PlayerKill> kills) {
Verify.nullCheck(kills);
playerKills.put(uuid, kills);
}
@ -62,11 +62,11 @@ public class KillPart extends RawData {
deaths += amount;
}
public Map<UUID, List<KillData>> getPlayerKills() {
public Map<UUID, List<PlayerKill>> getPlayerKills() {
return playerKills;
}
public List<KillData> getAllPlayerKills() {
public List<PlayerKill> getAllPlayerKills() {
return MiscUtils.flatMap(playerKills.values());
}

View File

@ -2,7 +2,7 @@ package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.data.KillData;
import main.java.com.djrapitops.plan.data.PlayerKill;
import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.sql.Sql;
@ -74,7 +74,7 @@ public class KillsTable extends UserIDTable {
}
}
public void savePlayerKills(UUID uuid, long sessionID, List<KillData> playerKills) throws SQLException {
public void savePlayerKills(UUID uuid, long sessionID, List<PlayerKill> playerKills) throws SQLException {
if (Verify.isEmpty(playerKills)) {
return;
}
@ -90,7 +90,7 @@ public class KillsTable extends UserIDTable {
+ usersTable.statementSelectID + ", "
+ usersTable.statementSelectID + ", "
+ "?, ?, ?)");
for (KillData kill : playerKills) {
for (PlayerKill kill : playerKills) {
UUID victim = kill.getVictim();
long date = kill.getTime();
String weapon = kill.getWeapon();
@ -133,7 +133,7 @@ public class KillsTable extends UserIDTable {
UUID victim = UUID.fromString(uuidS);
long date = set.getLong(columnDate);
String weapon = set.getString(columnWeapon);
session.getPlayerKills().add(new KillData(victim, weapon, date));
session.getPlayerKills().add(new PlayerKill(victim, weapon, date));
}
} finally {
close(set, statement);

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.systems.processing.player;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.KillData;
import main.java.com.djrapitops.plan.data.PlayerKill;
import main.java.com.djrapitops.plan.data.Session;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ import java.util.UUID;
* Processor Class for KillEvent information when the killer is a
* player.
* <p>
* Adds KillData or a Mob kill to the active Session.
* Adds PlayerKill or a Mob kill to the active Session.
*
* @author Rsl1122
* @since 4.0.0
@ -53,7 +53,7 @@ public class KillProcessor extends PlayerProcessor {
if (dead instanceof Player) {
Player deadPlayer = (Player) dead;
session.playerKilled(new KillData(deadPlayer.getUniqueId(), weaponName, time));
session.playerKilled(new PlayerKill(deadPlayer.getUniqueId(), weaponName, time));
} else {
session.mobKilled();
}

View File

@ -289,7 +289,7 @@ public class Analysis {
// } else {
// activity.addInActive(uuid);
// }
//TODO List<KillData> playerKills = uData.getPlayerKills();
//TODO List<PlayerKill> playerKills = uData.getPlayerKills();
// List<Session> sessions = uData.getSessions();
// joinInfo.addSessions(uuid, sessions);

View File

@ -1,16 +1,16 @@
package main.java.com.djrapitops.plan.utilities.comparators;
import main.java.com.djrapitops.plan.data.KillData;
import main.java.com.djrapitops.plan.data.PlayerKill;
import java.util.Comparator;
/**
* @author Fuzzlemann
*/
public class KillDataComparator implements Comparator<KillData> {
public class KillDataComparator implements Comparator<PlayerKill> {
@Override
public int compare(KillData o1, KillData o2) {
public int compare(PlayerKill o1, PlayerKill o2) {
return Long.compare(o1.getTime(), o2.getTime());
}

View File

@ -2,7 +2,7 @@ package main.java.com.djrapitops.plan.utilities.html.tables;
import com.djrapitops.plugin.utilities.player.Fetch;
import com.djrapitops.plugin.utilities.player.IOfflinePlayer;
import main.java.com.djrapitops.plan.data.KillData;
import main.java.com.djrapitops.plan.data.PlayerKill;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
@ -26,20 +26,20 @@ public class KillsTableCreator {
}
/**
* @param killData The list of the {@link KillData} Objects from which the kill table should be created
* @param playerKills The list of the {@link PlayerKill} Objects from which the kill table should be created
* @return The created kills table
*/
public static String createKillsTable(List<KillData> killData) {
public static String createKillsTable(List<PlayerKill> playerKills) {
StringBuilder html = new StringBuilder(Html.TABLE_KILLS_START.parse());
if (killData.isEmpty()) {
if (playerKills.isEmpty()) {
html.append(Html.TABLELINE_3.parse(Locale.get(Msg.HTML_TABLE_NO_KILLS).parse(), "", ""));
} else {
killData.sort(new KillDataComparator());
Collections.reverse(killData);
playerKills.sort(new KillDataComparator());
Collections.reverse(playerKills);
int i = 0;
for (KillData kill : killData) {
for (PlayerKill kill : playerKills) {
if (i >= 20) {
break;
}

View File

@ -5,7 +5,7 @@
*/
package test.java.main.java.com.djrapitops.plan.data;
import main.java.com.djrapitops.plan.data.KillData;
import main.java.com.djrapitops.plan.data.PlayerKill;
import org.junit.Before;
import org.junit.Test;
@ -16,21 +16,21 @@ import static org.junit.Assert.assertEquals;
/**
* @author Rsl1122
*/
public class KillDataTest {
public class PlayerKillTest {
private KillData test;
private PlayerKill test;
private UUID testUUID;
/**
*
*/
public KillDataTest() {
public PlayerKillTest() {
}
@Before
public void setUp() throws Exception {
testUUID = UUID.fromString("71cfb6f0-c3ef-4954-8abe-13fa07afc340");
test = new KillData(testUUID, "TestWeapon", 100L);
test = new PlayerKill(testUUID, "TestWeapon", 100L);
}
/**

View File

@ -311,10 +311,10 @@ public class DatabaseTest {
return new WorldTimes(times);
}
private List<KillData> createKills() {
List<KillData> kills = new ArrayList<>();
kills.add(new KillData(uuid2, "Iron Sword", 4321L));
kills.add(new KillData(uuid2, "Gold Sword", 5321L));
private List<PlayerKill> createKills() {
List<PlayerKill> kills = new ArrayList<>();
kills.add(new PlayerKill(uuid2, "Iron Sword", 4321L));
kills.add(new PlayerKill(uuid2, "Gold Sword", 5321L));
return kills;
}