mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-01 00:10:12 +01:00
[2.7.1] Inspect page additoins
- Fix for #25 - Removed manage combine command - Added stuff to inspect page - Factions power now rounded to two decimals
This commit is contained in:
parent
4ca64e05e4
commit
814f6771a8
@ -33,8 +33,6 @@ import java.util.Date;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import main.java.com.djrapitops.plan.api.API;
|
import main.java.com.djrapitops.plan.api.API;
|
||||||
import main.java.com.djrapitops.plan.command.PlanCommand;
|
import main.java.com.djrapitops.plan.command.PlanCommand;
|
||||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||||
|
@ -32,7 +32,6 @@ public class ManageCommand extends SubCommand {
|
|||||||
commands = new ArrayList<>();
|
commands = new ArrayList<>();
|
||||||
commands.add(new ManageHelpCommand(plugin, this));
|
commands.add(new ManageHelpCommand(plugin, this));
|
||||||
commands.add(new ManageMoveCommand(plugin));
|
commands.add(new ManageMoveCommand(plugin));
|
||||||
commands.add(new ManageCombineCommand(plugin));
|
|
||||||
commands.add(new ManageHotswapCommand(plugin));
|
commands.add(new ManageHotswapCommand(plugin));
|
||||||
commands.add(new ManageBackupCommand(plugin));
|
commands.add(new ManageBackupCommand(plugin));
|
||||||
commands.add(new ManageRestoreCommand(plugin));
|
commands.add(new ManageRestoreCommand(plugin));
|
||||||
|
@ -1,169 +0,0 @@
|
|||||||
package main.java.com.djrapitops.plan.command.commands.manage;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import main.java.com.djrapitops.plan.Phrase;
|
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
|
||||||
import main.java.com.djrapitops.plan.command.CommandType;
|
|
||||||
import main.java.com.djrapitops.plan.command.SubCommand;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
|
||||||
import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
|
|
||||||
import main.java.com.djrapitops.plan.database.Database;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.DataCombineUtils;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Rsl1122
|
|
||||||
*/
|
|
||||||
public class ManageCombineCommand extends SubCommand {
|
|
||||||
|
|
||||||
private Plan plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Constructor.
|
|
||||||
*
|
|
||||||
* @param plugin Current instance of Plan
|
|
||||||
*/
|
|
||||||
public ManageCombineCommand(Plan plugin) {
|
|
||||||
super("combine", "plan.manage", Phrase.CMD_USG_MANAGE_COMBINE + "", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_MOVE + "");
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subcommand inspect.
|
|
||||||
*
|
|
||||||
* Adds player's data from DataCache/DB to the InspectCache for amount of
|
|
||||||
* time specified in the config, and clears the data from Cache with a timer
|
|
||||||
* task.
|
|
||||||
*
|
|
||||||
* @param sender
|
|
||||||
* @param cmd
|
|
||||||
* @param commandLabel
|
|
||||||
* @param args Player's name or nothing - if empty sender's name is used.
|
|
||||||
* @return true in all cases.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
|
||||||
if (args.length < 2) {
|
|
||||||
sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_COMBINE + ""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String fromDB = args[0].toLowerCase();
|
|
||||||
String toDB = args[1].toLowerCase();
|
|
||||||
if (!fromDB.equals("mysql") && !fromDB.equals("sqlite")) {
|
|
||||||
sender.sendMessage(Phrase.MANAGE_ERROR_INCORRECT_DB + fromDB);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!toDB.equals("mysql") && !toDB.equals("sqlite")) {
|
|
||||||
sender.sendMessage(Phrase.MANAGE_ERROR_INCORRECT_DB + toDB);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (fromDB.equals(toDB)) {
|
|
||||||
sender.sendMessage(Phrase.MANAGE_ERROR_SAME_DB + "");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!Arrays.asList(args).contains("-a")) {
|
|
||||||
sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REWRITE.parse(args[1])));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Database fromDatabase = null;
|
|
||||||
Database toDatabase = null;
|
|
||||||
for (Database database : plugin.getDatabases()) {
|
|
||||||
if (fromDB.equalsIgnoreCase(database.getConfigName())) {
|
|
||||||
fromDatabase = database;
|
|
||||||
fromDatabase.init();
|
|
||||||
}
|
|
||||||
if (toDB.equalsIgnoreCase(database.getConfigName())) {
|
|
||||||
toDatabase = database;
|
|
||||||
toDatabase.init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fromDatabase == null) {
|
|
||||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
|
|
||||||
plugin.logError(fromDB + " was null!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (toDatabase == null) {
|
|
||||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
|
|
||||||
plugin.logError(toDB + " was null!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
final Set<UUID> fromUUIDS = fromDatabase.getSavedUUIDs();
|
|
||||||
final Set<UUID> toUUIDS = toDatabase.getSavedUUIDs();
|
|
||||||
if (fromUUIDS.isEmpty() && toUUIDS.isEmpty()) {
|
|
||||||
sender.sendMessage(Phrase.MANAGE_ERROR_NO_PLAYERS + " (" + fromDB + ")");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Database moveFromDB = fromDatabase;
|
|
||||||
final Database moveToDB = toDatabase;
|
|
||||||
BukkitTask asyncDBCombineTask = (new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
|
|
||||||
HashMap<UUID, UserData> allFromUserData = new HashMap<>();
|
|
||||||
HashMap<UUID, UserData> allToUserData = new HashMap<>();
|
|
||||||
for (UUID uuid : fromUUIDS) {
|
|
||||||
moveFromDB.giveUserDataToProcessors(uuid, new DBCallableProcessor() {
|
|
||||||
@Override
|
|
||||||
public void process(UserData data) {
|
|
||||||
allFromUserData.put(uuid, data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
for (UUID uuid : toUUIDS) {
|
|
||||||
moveToDB.giveUserDataToProcessors(uuid, new DBCallableProcessor() {
|
|
||||||
@Override
|
|
||||||
public void process(UserData data) {
|
|
||||||
allToUserData.put(uuid, data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
while (fromUUIDS.size() > allFromUserData.size() || toUUIDS.size() > allToUserData.size()) {
|
|
||||||
|
|
||||||
}
|
|
||||||
Set<UUID> uuids = new HashSet<>();
|
|
||||||
uuids.addAll(toUUIDS);
|
|
||||||
uuids.addAll(fromUUIDS);
|
|
||||||
|
|
||||||
List<UserData> combinedUserData = DataCombineUtils.combineUserDatas(allFromUserData, allToUserData, uuids);
|
|
||||||
|
|
||||||
HashMap<String, Integer> commandUse = DataCombineUtils.combineCommandUses(moveFromDB.getCommandUse(), moveToDB.getCommandUse());
|
|
||||||
|
|
||||||
moveToDB.removeAllData();
|
|
||||||
|
|
||||||
moveToDB.saveMultipleUserData(combinedUserData);
|
|
||||||
moveToDB.saveCommandUse(commandUse);
|
|
||||||
|
|
||||||
sender.sendMessage(Phrase.MANAGE_MOVE_SUCCESS + "");
|
|
||||||
if (!toDB.equals(plugin.getDB().getConfigName())) {
|
|
||||||
sender.sendMessage(Phrase.MANAGE_DB_CONFIG_REMINDER + "");
|
|
||||||
}
|
|
||||||
} catch (SQLException | NullPointerException e) {
|
|
||||||
plugin.toLog(this.getClass().getName(), e);
|
|
||||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
|
|
||||||
}
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
}).runTaskAsynchronously(plugin);
|
|
||||||
} catch (SQLException | NullPointerException e) {
|
|
||||||
plugin.toLog(this.getClass().getName(), e);
|
|
||||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -13,6 +13,7 @@ import java.util.stream.Collectors;
|
|||||||
import main.java.com.djrapitops.plan.Phrase;
|
import main.java.com.djrapitops.plan.Phrase;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.ui.Html;
|
import main.java.com.djrapitops.plan.ui.Html;
|
||||||
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.comparators.FactionComparator;
|
import main.java.com.djrapitops.plan.utilities.comparators.FactionComparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +61,7 @@ public class FactionsHook extends Hook {
|
|||||||
*
|
*
|
||||||
* @param factionName Name of the faction.
|
* @param factionName Name of the faction.
|
||||||
* @return HashMap containing boolean, number & string: LEADER String, POWER
|
* @return HashMap containing boolean, number & string: LEADER String, POWER
|
||||||
* double, LAND int
|
* String, LAND int
|
||||||
*/
|
*/
|
||||||
public HashMap<String, Serializable> getFactionInfo(String factionName) {
|
public HashMap<String, Serializable> getFactionInfo(String factionName) {
|
||||||
HashMap<String, Serializable> info = new HashMap<>();
|
HashMap<String, Serializable> info = new HashMap<>();
|
||||||
@ -72,7 +73,8 @@ public class FactionsHook extends Hook {
|
|||||||
} else {
|
} else {
|
||||||
info.put("LEADER", Html.FACTION_NO_LEADER.parse());
|
info.put("LEADER", Html.FACTION_NO_LEADER.parse());
|
||||||
}
|
}
|
||||||
info.put("POWER", faction.getPower());
|
|
||||||
|
info.put("POWER", FormatUtils.cutDecimals(faction.getPower()));
|
||||||
info.put("LAND", faction.getLandCount());
|
info.put("LAND", faction.getLandCount());
|
||||||
} else {
|
} else {
|
||||||
info.put("LEADER", Html.FACTION_NOT_FOUND.parse());
|
info.put("LEADER", Html.FACTION_NOT_FOUND.parse());
|
||||||
@ -94,17 +96,17 @@ public class FactionsHook extends Hook {
|
|||||||
HashMap<String, Serializable> info = new HashMap<>();
|
HashMap<String, Serializable> info = new HashMap<>();
|
||||||
MPlayer mPlayer = MPlayer.get(uuid);
|
MPlayer mPlayer = MPlayer.get(uuid);
|
||||||
if (mPlayer != null) {
|
if (mPlayer != null) {
|
||||||
info.put("POWER", mPlayer.getPower());
|
info.put("POWER", FormatUtils.cutDecimals(mPlayer.getPower()));
|
||||||
info.put("MAXPOWER", mPlayer.getPowerMax());
|
info.put("MAXPOWER", mPlayer.getPowerMax());
|
||||||
if (mPlayer.hasFaction()) {
|
if (mPlayer.hasFaction()) {
|
||||||
info.put("FACTION", mPlayer.getFactionName());
|
info.put("FACTION", mPlayer.getFactionName());
|
||||||
} else {
|
} else {
|
||||||
info.put("FACTION", Phrase.NOT_IN_FAC+"");
|
info.put("FACTION", Phrase.NOT_IN_FAC + "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info.put("POWER", 0);
|
info.put("POWER", 0);
|
||||||
info.put("MAXPOWER", 0);
|
info.put("MAXPOWER", 0);
|
||||||
info.put("FACTION", Phrase.NOT_IN_FAC+"");
|
info.put("FACTION", Phrase.NOT_IN_FAC + "");
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ public enum Html {
|
|||||||
TABLE_START_3("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th><th>REPLACE2</th></tr></thead><tbody>"),
|
TABLE_START_3("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th><th>REPLACE2</th></tr></thead><tbody>"),
|
||||||
TABLE_START_4("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th><th>REPLACE2</th><th>REPLACE3</th></tr></thead><tbody>"),
|
TABLE_START_4("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th><th>REPLACE2</th><th>REPLACE3</th></tr></thead><tbody>"),
|
||||||
TABLE_SESSIONS_START(TABLE_START_3.parse("Session Started", "Session Ended", "Session Length")),
|
TABLE_SESSIONS_START(TABLE_START_3.parse("Session Started", "Session Ended", "Session Length")),
|
||||||
|
TABLE_KILLS_START(TABLE_START_3.parse("Date", "Killed", "With")),
|
||||||
TABLE_FACTIONS_START(TABLE_START_4.parse("Faction", "Power", "Land", "Leader")),
|
TABLE_FACTIONS_START(TABLE_START_4.parse("Faction", "Power", "Land", "Leader")),
|
||||||
TABLE_TOWNS_START(TABLE_START_4.parse("Town", "Residents", "Land", "Mayor")),
|
TABLE_TOWNS_START(TABLE_START_4.parse("Town", "Residents", "Land", "Mayor")),
|
||||||
TABLELINE_2("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td></tr>"),
|
TABLELINE_2("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td></tr>"),
|
||||||
@ -82,9 +83,11 @@ public enum Html {
|
|||||||
TABLELINE_4("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td><td>REPLACE2</td><td>REPLACE3</td></tr>"),
|
TABLELINE_4("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td><td>REPLACE2</td><td>REPLACE3</td></tr>"),
|
||||||
TABLELINE_PLAYERS("<tr><td>REPLACE0</td><td>REPLACE1</td><td sorttable_customkey=\"REPLACE2\">REPLACE3</td><td>REPLACE4</td><td sorttable_customkey=\"REPLACE5\">REPLACE6</td>" + "<td sorttable_customkey=\"REPLACE7\">REPLACE8</td><td>REPLACE9</td></tr>"),
|
TABLELINE_PLAYERS("<tr><td>REPLACE0</td><td>REPLACE1</td><td sorttable_customkey=\"REPLACE2\">REPLACE3</td><td>REPLACE4</td><td sorttable_customkey=\"REPLACE5\">REPLACE6</td>" + "<td sorttable_customkey=\"REPLACE7\">REPLACE8</td><td>REPLACE9</td></tr>"),
|
||||||
TABLELINE_3_CUSTOMKEY("<tr><td sorttable_customkey=\"REPLACE0\">REPLACE1</td><td sorttable_customkey=\"REPLACE2\">REPLACE3</td><td sorttable_customkey=\"REPLACE4\">REPLACE5</td></tr>"),
|
TABLELINE_3_CUSTOMKEY("<tr><td sorttable_customkey=\"REPLACE0\">REPLACE1</td><td sorttable_customkey=\"REPLACE2\">REPLACE3</td><td sorttable_customkey=\"REPLACE4\">REPLACE5</td></tr>"),
|
||||||
|
TABLELINE_3_CUSTOMKEY_1("<tr><td sorttable_customkey=\"REPLACE0\">REPLACE1</td><td>REPLACE2</td><td>REPLACE3</td></tr>"),
|
||||||
ERROR_TABLE_2(TABLELINE_2.parse("No data", "No data")),
|
ERROR_TABLE_2(TABLELINE_2.parse("No data", "No data")),
|
||||||
TABLE_END("</tbody></table>"),
|
TABLE_END("</tbody></table>"),
|
||||||
SESSIONDATA_NONE("No Session Data available"),;
|
SESSIONDATA_NONE("No Session Data available"),
|
||||||
|
KILLDATA_NONE("No Kills"),;
|
||||||
|
|
||||||
private String html;
|
private String html;
|
||||||
|
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package main.java.com.djrapitops.plan.ui.tables;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import main.java.com.djrapitops.plan.data.KillData;
|
||||||
|
import main.java.com.djrapitops.plan.ui.Html;
|
||||||
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
|
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||||
|
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||||
|
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class SortableKillsTableCreator {
|
||||||
|
|
||||||
|
public static String createSortedSessionDataTable10(List<KillData> killData) {
|
||||||
|
String html = Html.TABLE_KILLS_START.parse();
|
||||||
|
if (killData.isEmpty()) {
|
||||||
|
html += Html.TABLELINE_3.parse(Html.KILLDATA_NONE.parse(), "", "");
|
||||||
|
} else {
|
||||||
|
int i = 0;
|
||||||
|
for (KillData kill : killData) {
|
||||||
|
if (i >= 10) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
long date = kill.getDate();
|
||||||
|
OfflinePlayer victim = getOfflinePlayer(kill.getVictim());
|
||||||
|
String name = victim.getName();
|
||||||
|
html += Html.TABLELINE_3_CUSTOMKEY_1.parse(
|
||||||
|
date+"", FormatUtils.formatTimeStamp(date+""),
|
||||||
|
Html.LINK.parse(HtmlUtils.getInspectUrl(name), name),
|
||||||
|
kill.getWeapon()
|
||||||
|
);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html += Html.TABLE_END.parse();
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
}
|
@ -16,17 +16,20 @@ public class SortablePlayersTableCreator {
|
|||||||
public static String createSortablePlayersTable(Collection<UserData> data) {
|
public static String createSortablePlayersTable(Collection<UserData> data) {
|
||||||
String html = "";
|
String html = "";
|
||||||
for (UserData uData : data) {
|
for (UserData uData : data) {
|
||||||
String bORaORi = uData.isBanned() ? Html.GRAPH_BANNED.parse() :
|
try {
|
||||||
(AnalysisUtils.isActive(uData.getLastPlayed(), uData.getPlayTime(), uData.getLoginTimes())
|
String bORaORi = uData.isBanned() ? Html.GRAPH_BANNED.parse()
|
||||||
|
: (AnalysisUtils.isActive(uData.getLastPlayed(), uData.getPlayTime(), uData.getLoginTimes())
|
||||||
? Html.GRAPH_ACTIVE.parse() : Html.GRAPH_INACTIVE.parse());
|
? Html.GRAPH_ACTIVE.parse() : Html.GRAPH_INACTIVE.parse());
|
||||||
|
|
||||||
html += Html.TABLELINE_PLAYERS.parse(Html.LINK.parse(HtmlUtils.getInspectUrl(uData.getName()), uData.getName()), bORaORi,
|
html += Html.TABLELINE_PLAYERS.parse("<img style=\"float: left; padding: 2px 2px 0px 2px\" alt=\""+uData.getName()+"\" src=\"https://minotar.net/avatar/"+uData.getName()+"/19\"> "+Html.LINK.parse(HtmlUtils.getInspectUrl(uData.getName()), uData.getName()), bORaORi,
|
||||||
uData.getPlayTime() + "", FormatUtils.formatTimeAmount(uData.getPlayTime() + ""),
|
uData.getPlayTime() + "", FormatUtils.formatTimeAmount(uData.getPlayTime() + ""),
|
||||||
uData.getLoginTimes()+"",
|
uData.getLoginTimes() + "",
|
||||||
uData.getRegistered() + "", FormatUtils.formatTimeStamp(uData.getRegistered() + ""),
|
uData.getRegistered() + "", FormatUtils.formatTimeStamp(uData.getRegistered() + ""),
|
||||||
uData.getLastPlayed() + "", FormatUtils.formatTimeStamp(uData.getLastPlayed() + ""),
|
uData.getLastPlayed() + "", FormatUtils.formatTimeStamp(uData.getLastPlayed() + ""),
|
||||||
uData.getDemData().getGeoLocation()
|
uData.getDemData().getGeoLocation()
|
||||||
);
|
);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ import main.java.com.djrapitops.plan.utilities.comparators.SessionDataComparator
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class SortabeSessionTableCreator {
|
public class SortableSessionTableCreator {
|
||||||
|
|
||||||
public static String createSortedSessionDataTable5(List<SessionData> sessionData) {
|
public static String createSortedSessionDataTable10(List<SessionData> sessionData) {
|
||||||
String html = Html.TABLE_SESSIONS_START.parse();
|
String html = Html.TABLE_SESSIONS_START.parse();
|
||||||
if (sessionData.isEmpty()) {
|
if (sessionData.isEmpty()) {
|
||||||
html += Html.TABLELINE_3.parse(Html.SESSIONDATA_NONE.parse(), "", "");
|
html += Html.TABLELINE_3.parse(Html.SESSIONDATA_NONE.parse(), "", "");
|
||||||
@ -22,7 +22,7 @@ public class SortabeSessionTableCreator {
|
|||||||
Collections.reverse(sessionData);
|
Collections.reverse(sessionData);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (SessionData session : sessionData) {
|
for (SessionData session : sessionData) {
|
||||||
if (i > 4) {
|
if (i >= 10) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
long start = session.getSessionStart();
|
long start = session.getSessionStart();
|
||||||
@ -33,6 +33,7 @@ public class SortabeSessionTableCreator {
|
|||||||
end+"", FormatUtils.formatTimeStamp(end+""),
|
end+"", FormatUtils.formatTimeStamp(end+""),
|
||||||
length+"", FormatUtils.formatTimeAmount(length+"")
|
length+"", FormatUtils.formatTimeAmount(length+"")
|
||||||
);
|
);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
html += Html.TABLE_END.parse();
|
html += Html.TABLE_END.parse();
|
@ -1,115 +0,0 @@
|
|||||||
package main.java.com.djrapitops.plan.utilities;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import main.java.com.djrapitops.plan.Phrase;
|
|
||||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Rsl1122
|
|
||||||
*/
|
|
||||||
public class DataCombineUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Combines two conflicting UserDatasets from databases.
|
|
||||||
*
|
|
||||||
* @param allFromUserData First Dataset
|
|
||||||
* @param allToUserData Second Dataset
|
|
||||||
* @param uuids UUIDs from both Datasets
|
|
||||||
* @return Combined UserDataset
|
|
||||||
*/
|
|
||||||
public static List<UserData> combineUserDatas(HashMap<UUID, UserData> allFromUserData, HashMap<UUID, UserData> allToUserData, Set<UUID> uuids) {
|
|
||||||
List<UserData> combinedData = new ArrayList<>();
|
|
||||||
uuids.forEach((UUID uuid) -> {
|
|
||||||
UserData fData = allFromUserData.get(uuid);
|
|
||||||
UserData tData = allToUserData.get(uuid);
|
|
||||||
if (fData == null) {
|
|
||||||
combinedData.add(tData);
|
|
||||||
} else if (tData == null) {
|
|
||||||
combinedData.add(fData);
|
|
||||||
} else {
|
|
||||||
combinedData.add(combineUserData(fData, tData));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return combinedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static UserData combineUserData(UserData fData, UserData tData) {
|
|
||||||
if (fData.getLastGmSwapTime() < tData.getLastGmSwapTime()) {
|
|
||||||
fData.setLastGmSwapTime(tData.getLastGmSwapTime());
|
|
||||||
fData.setLastGamemode(tData.getLastGamemode());
|
|
||||||
}
|
|
||||||
HashMap<GameMode, Long> gmTimes = fData.getGmTimes();
|
|
||||||
HashMap<GameMode, Long> tGmTimes = tData.getGmTimes();
|
|
||||||
gmTimes.keySet().stream().forEach((GameMode gm) -> {
|
|
||||||
long fTime = gmTimes.get(gm);
|
|
||||||
if (tGmTimes.get(gm) != null) {
|
|
||||||
long tTime = tGmTimes.get(gm);
|
|
||||||
gmTimes.put(gm, fTime + tTime);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (fData.getLastPlayed() < tData.getLastPlayed()) {
|
|
||||||
fData.setLastPlayed(tData.getLastPlayed());
|
|
||||||
}
|
|
||||||
fData.setPlayTime(fData.getPlayTime() + tData.getPlayTime());
|
|
||||||
fData.setTimesKicked(fData.getTimesKicked() + tData.getTimesKicked());
|
|
||||||
fData.setLoginTimes(fData.getLoginTimes() + tData.getLoginTimes());
|
|
||||||
fData.addLocations(tData.getLocations());
|
|
||||||
fData.addNicknames(tData.getNicknames());
|
|
||||||
fData.addIpAddresses(tData.getIps());
|
|
||||||
DemographicsData tDemData = tData.getDemData();
|
|
||||||
DemographicsData fDemData = fData.getDemData();
|
|
||||||
if (tDemData.getAge() > fDemData.getAge()) {
|
|
||||||
fDemData.setAge(tDemData.getAge());
|
|
||||||
}
|
|
||||||
if (fDemData.getGeoLocation().equals(Phrase.DEM_UNKNOWN+"")) {
|
|
||||||
fDemData.setGeoLocation(tDemData.getGeoLocation());
|
|
||||||
}
|
|
||||||
fData.setDemData(fDemData);
|
|
||||||
return fData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Combines Two conflicting command usage datasets.
|
|
||||||
*
|
|
||||||
* @param fData First Dataset
|
|
||||||
* @param tData Second Dataset
|
|
||||||
* @return Combined Dataset
|
|
||||||
*/
|
|
||||||
public static HashMap<String, Integer> combineCommandUses(HashMap<String, Integer> fData, HashMap<String, Integer> tData) {
|
|
||||||
HashMap<String, Integer> combinedData = new HashMap<>();
|
|
||||||
Set<String> allCommands = new HashSet<>();
|
|
||||||
if (fData != null) {
|
|
||||||
allCommands.addAll(fData.keySet());
|
|
||||||
}
|
|
||||||
if (tData != null) {
|
|
||||||
allCommands.addAll(tData.keySet());
|
|
||||||
}
|
|
||||||
for (String command : allCommands) {
|
|
||||||
boolean fDataHasCommand = false;
|
|
||||||
if (fData != null) {
|
|
||||||
fDataHasCommand = fData.keySet().contains(command);
|
|
||||||
}
|
|
||||||
boolean tDataHasCommand = false;
|
|
||||||
if (tData != null) {
|
|
||||||
tDataHasCommand = tData.keySet().contains(command);
|
|
||||||
}
|
|
||||||
int value = 0;
|
|
||||||
if (fDataHasCommand) {
|
|
||||||
value += fData.get(command);
|
|
||||||
}
|
|
||||||
if (tDataHasCommand) {
|
|
||||||
value += tData.get(command);
|
|
||||||
}
|
|
||||||
combinedData.put(command, value);
|
|
||||||
}
|
|
||||||
return combinedData;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,7 @@
|
|||||||
package main.java.com.djrapitops.plan.utilities;
|
package main.java.com.djrapitops.plan.utilities;
|
||||||
|
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import main.java.com.djrapitops.plan.ui.Html;
|
import main.java.com.djrapitops.plan.ui.Html;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -157,13 +159,18 @@ public class FormatUtils {
|
|||||||
Html.COLOR_a, Html.COLOR_b, Html.COLOR_c, Html.COLOR_d, Html.COLOR_e, Html.COLOR_f};
|
Html.COLOR_a, Html.COLOR_b, Html.COLOR_c, Html.COLOR_d, Html.COLOR_e, Html.COLOR_f};
|
||||||
|
|
||||||
for (Html html : replacer) {
|
for (Html html : replacer) {
|
||||||
string = string.replaceAll("§"+html.name().charAt(6), html.parse());
|
string = string.replaceAll("§" + html.name().charAt(6), html.parse());
|
||||||
}
|
}
|
||||||
int spans = string.split("<span").length-1;
|
int spans = string.split("<span").length - 1;
|
||||||
for (int i = 0; i < spans; i++) {
|
for (int i = 0; i < spans; i++) {
|
||||||
string = Html.SPAN.parse(string);
|
string = Html.SPAN.parse(string);
|
||||||
}
|
}
|
||||||
return string.replaceAll("§r", "");
|
return string.replaceAll("§r", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String cutDecimals(double d) {
|
||||||
|
DecimalFormat df = new DecimalFormat("#.##");
|
||||||
|
df.setRoundingMode(RoundingMode.CEILING);
|
||||||
|
return df.format(d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ public class MiscUtils {
|
|||||||
cVersion = plugin.getDescription().getVersion();
|
cVersion = plugin.getDescription().getVersion();
|
||||||
int currentVersionNumber = FormatUtils.parseVersionNumber(cVersion);
|
int currentVersionNumber = FormatUtils.parseVersionNumber(cVersion);
|
||||||
if (newestVersionNumber > currentVersionNumber) {
|
if (newestVersionNumber > currentVersionNumber) {
|
||||||
|
plugin.getConfig().set("Settins.Locale", "default");
|
||||||
return Phrase.VERSION_NEW_AVAILABLE.parse(versionString);
|
return Phrase.VERSION_NEW_AVAILABLE.parse(versionString);
|
||||||
} else {
|
} else {
|
||||||
return Phrase.VERSION_LATEST + "";
|
return Phrase.VERSION_LATEST + "";
|
||||||
|
@ -11,7 +11,9 @@ import main.java.com.djrapitops.plan.Settings;
|
|||||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.ui.Html;
|
import main.java.com.djrapitops.plan.ui.Html;
|
||||||
import main.java.com.djrapitops.plan.ui.tables.SortabeSessionTableCreator;
|
import main.java.com.djrapitops.plan.ui.graphs.PlayerActivityGraphCreator;
|
||||||
|
import main.java.com.djrapitops.plan.ui.tables.SortableKillsTableCreator;
|
||||||
|
import main.java.com.djrapitops.plan.ui.tables.SortableSessionTableCreator;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||||
|
|
||||||
@ -150,10 +152,16 @@ public class PlaceholderUtils {
|
|||||||
replaceMap.put("%deaths%", deaths + "");
|
replaceMap.put("%deaths%", deaths + "");
|
||||||
replaceMap.put("%playerkills%", data.getPlayerKills().size() + "");
|
replaceMap.put("%playerkills%", data.getPlayerKills().size() + "");
|
||||||
replaceMap.put("%mobkills%", data.getMobKills() + "");
|
replaceMap.put("%mobkills%", data.getMobKills() + "");
|
||||||
replaceMap.put("%sessionstable%", SortabeSessionTableCreator.createSortedSessionDataTable5(data.getSessions()));
|
replaceMap.put("%sessionstable%", SortableSessionTableCreator.createSortedSessionDataTable10(data.getSessions()));
|
||||||
|
replaceMap.put("%killstable%", SortableKillsTableCreator.createSortedSessionDataTable10(data.getPlayerKills()));
|
||||||
Plan plugin = getPlugin(Plan.class);
|
Plan plugin = getPlugin(Plan.class);
|
||||||
replaceMap.put("%version%", plugin.getDescription().getVersion());
|
replaceMap.put("%version%", plugin.getDescription().getVersion());
|
||||||
replaceMap.put("%planlite%", "");
|
replaceMap.put("%planlite%", "");
|
||||||
|
String[] playersDataArray = PlayerActivityGraphCreator.generateDataArray(data.getSessions(), (long) 604800 * 1000);
|
||||||
|
replaceMap.put("%dataweek%", playersDataArray[0].replace("20]", "2]"));
|
||||||
|
replaceMap.put("%labelsweek%", playersDataArray[1]);
|
||||||
|
replaceMap.put("%playersgraphcolor%", Settings.HCOLOR_ACT_ONL + "");
|
||||||
|
replaceMap.put("%playersgraphfill%", Settings.HCOLOR_ACT_ONL_FILL + "");
|
||||||
replaceMap.put("%inaccuratedatawarning%", (new Date().getTime() - data.getRegistered() < 180000) ? Html.WARN_INACCURATE.parse() : "");
|
replaceMap.put("%inaccuratedatawarning%", (new Date().getTime() - data.getRegistered() < 180000) ? Html.WARN_INACCURATE.parse() : "");
|
||||||
replaceMap.putAll(plugin.getHookHandler().getAdditionalInspectReplaceRules(uuid));
|
replaceMap.putAll(plugin.getHookHandler().getAdditionalInspectReplaceRules(uuid));
|
||||||
return replaceMap;
|
return replaceMap;
|
||||||
|
@ -126,8 +126,7 @@
|
|||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
%inaccuratedatawarning%
|
%inaccuratedatawarning%
|
||||||
<div class="column info">
|
<div class="column info">
|
||||||
|
<h4>Information</h4> <img style="float: right; padding: 5px" alt="%name%" src="http://cravatar.eu/head/%name%/128.png">
|
||||||
<h4>Information</h4>
|
|
||||||
<p>Last seen: %lastseen% %active% %isonline% %essentials%<br/>
|
<p>Last seen: %lastseen% %active% %isonline% %essentials%<br/>
|
||||||
Nicknames: %nicknames% | Has connected from ips: %ips%<br/>
|
Nicknames: %nicknames% | Has connected from ips: %ips%<br/>
|
||||||
Geolocation: %geoloc%<br/>
|
Geolocation: %geoloc%<br/>
|
||||||
@ -137,11 +136,15 @@
|
|||||||
Player kills: %playerkills% | Mob kills: %mobkills% | Deaths: %deaths%<br/>
|
Player kills: %playerkills% | Mob kills: %mobkills% | Deaths: %deaths%<br/>
|
||||||
UUID: %uuid%
|
UUID: %uuid%
|
||||||
%achievements%%votes%%faction%%town%</p>
|
%achievements%%votes%%faction%%town%</p>
|
||||||
<h4>Last 5 Play Sessions</h4>
|
<h4>Last 10 Play Sessions</h4>
|
||||||
%sessionstable%
|
%sessionstable%
|
||||||
|
<h4>Last 10 Player Kills</h4>
|
||||||
|
%killstable%
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column graphs">
|
<div class="column graphs">
|
||||||
|
<h4>Player Activity | Last 7 days</h4>
|
||||||
|
<canvas id="playerChartWeek" width="1000" height="350" style="width: 95%;"></canvas>
|
||||||
<h4>Gamemode Usage - Total: %gmtotal%</h4>
|
<h4>Gamemode Usage - Total: %gmtotal%</h4>
|
||||||
<p>Survival: %gm0% | Creative: %gm1% | Adventure: %gm2% | Spectator: %gm3%</p>
|
<p>Survival: %gm0% | Creative: %gm1% | Adventure: %gm2% | Spectator: %gm3%</p>
|
||||||
<canvas id="gmPie" width="1000" height="600" style="width: 95%;"></canvas>
|
<canvas id="gmPie" width="1000" height="600" style="width: 95%;"></canvas>
|
||||||
@ -154,13 +157,14 @@
|
|||||||
<script>
|
<script>
|
||||||
// Script for All charts using Chart.js
|
// Script for All charts using Chart.js
|
||||||
var ctxgmpie = document.getElementById("gmPie");
|
var ctxgmpie = document.getElementById("gmPie");
|
||||||
|
var ctxweek = document.getElementById("playerChartWeek");
|
||||||
var dataGmPie = {
|
var dataGmPie = {
|
||||||
labels: %gmlabels%,
|
labels: %gmlabels% ,
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
data: %gmdata%,
|
data: %gmdata% ,
|
||||||
backgroundColor: [%gmcolors%],
|
backgroundColor: [ %gmcolors% ],
|
||||||
hoverBackgroundColor: [%gmcolors%]
|
hoverBackgroundColor: [ %gmcolors% ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -176,6 +180,42 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
var dataweek = {
|
||||||
|
labels: %labelsweek% ,
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
label: "Players Online",
|
||||||
|
fill: true,
|
||||||
|
lineTension: 0.1,
|
||||||
|
backgroundColor: "#%playersgraphfill%",
|
||||||
|
borderColor: "#%playersgraphcolor%",
|
||||||
|
borderCapStyle: 'butt',
|
||||||
|
borderDash: [],
|
||||||
|
borderDashOffset: 0.0,
|
||||||
|
borderJoinStyle: 'miter',
|
||||||
|
pointBorderColor: "#%playersgraphcolor%",
|
||||||
|
pointBackgroundColor: "#fff",
|
||||||
|
pointBorderWidth: 1,
|
||||||
|
pointHoverRadius: 5,
|
||||||
|
pointHoverBackgroundColor: "#%playersgraphcolor%",
|
||||||
|
pointHoverBorderColor: "#8fabc6",
|
||||||
|
pointHoverBorderWidth: 2,
|
||||||
|
pointRadius: 1,
|
||||||
|
pointHitRadius: 10,
|
||||||
|
spanGaps: false,
|
||||||
|
data: %dataweek% ,
|
||||||
|
}]};
|
||||||
|
var playersChartWeek = new Chart(ctxweek, {
|
||||||
|
type: 'line',
|
||||||
|
data: dataweek,
|
||||||
|
options: {
|
||||||
|
scales: {
|
||||||
|
xAxes: [{
|
||||||
|
display: false
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -1,7 +1,7 @@
|
|||||||
name: Plan
|
name: Plan
|
||||||
author: Rsl1122
|
author: Rsl1122
|
||||||
main: main.java.com.djrapitops.plan.Plan
|
main: main.java.com.djrapitops.plan.Plan
|
||||||
version: 2.7.0
|
version: 2.7.1
|
||||||
|
|
||||||
softdepend:
|
softdepend:
|
||||||
- OnTime
|
- OnTime
|
||||||
|
Loading…
Reference in New Issue
Block a user