mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-01 21:11:23 +01:00
Enum Additions (Phrase, Setitngs) [2.3.2-DEV]
- Added lot of Enums to clean-up code - Added silent Analysis config setting
This commit is contained in:
parent
baabac9d4c
commit
f532f075c2
@ -9,13 +9,24 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
*/
|
||||
public enum Phrase {
|
||||
PREFIX("[Plan] "),
|
||||
ENABLED("Player Analytics Enabled."),
|
||||
DISABLED("Player Analytics Disabled."),
|
||||
SAVE_CACHE("Saving cached data.."),
|
||||
ADD_TO_CACHE("Added #1 to Cache."),
|
||||
CONFIG_HEADER("Plan Config | More info at https://www.spigotmc.org/wiki/plan-configuration/"),
|
||||
DATABASE_TYPE_DOES_NOT_EXIST("That database type doesn't exist."),
|
||||
DATABASE_FAILURE_DISABLE("Database initialization has failed, disabling Plan."),
|
||||
NOTIFY_EMPTY_IP(ChatColor.YELLOW+""+PREFIX+"IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!"),
|
||||
//
|
||||
VERSION_NEW_AVAILABLE("New Version (#1) is availible at https://www.spigotmc.org/resources/plan-player-analytics.32536/"),
|
||||
VERSION_LATEST("You're running the latest version"),
|
||||
VERSION_CHECK_ERROR("Failed to compare versions."),
|
||||
VERSION_FAIL("Failed to get newest version number."),
|
||||
//
|
||||
USERNAME_NOT_VALID(ChatColor.RED + "" + PREFIX + "This Player doesn't exist."),
|
||||
USERNAME_NOT_SEEN(ChatColor.RED + "" + PREFIX + "This Player has not played on this server."),
|
||||
USERNAME_NOT_KNOWN(ChatColor.RED + "" + PREFIX + "Player not found from the database."),
|
||||
|
||||
//
|
||||
COLOR_MAIN(ChatColor.getByChar(getPlugin(Plan.class).getConfig().getString("Customization.Colors.Commands.Main").charAt(1))),
|
||||
COLOR_SEC(ChatColor.getByChar(getPlugin(Plan.class).getConfig().getString("Customization.Colors.Commands.Secondary").charAt(1))),
|
||||
COLOR_TER(ChatColor.getByChar(getPlugin(Plan.class).getConfig().getString("Customization.Colors.Commands.Highlight").charAt(1))),
|
||||
@ -29,25 +40,31 @@ public enum Phrase {
|
||||
HCOLOR_ACTP_BAN(getPlugin(Plan.class).getConfig().getString("Customization.Colors.HTML.ActivityPie.Banned")),
|
||||
HCOLOR_ACTP_INA(getPlugin(Plan.class).getConfig().getString("Customization.Colors.HTML.ActivityPie.Inactive")),
|
||||
HCOLOR_ACTP_JON(getPlugin(Plan.class).getConfig().getString("Customization.Colors.HTML.ActivityPie.JoinedOnce")),
|
||||
//
|
||||
ARROWS_RIGHT("»"),
|
||||
BALL("•"),
|
||||
|
||||
GRABBING_DATA_MESSAGE(COLOR_TER+""+ARROWS_RIGHT+COLOR_MAIN+" Fetching data to cache.."),
|
||||
|
||||
GRABBING_DATA_MESSAGE(COLOR_TER + "" + ARROWS_RIGHT + COLOR_MAIN + " Fetching data to cache.."),
|
||||
//
|
||||
DEM_UNKNOWN("Not Known"),
|
||||
NOT_IN_TOWN("Not in a town"),
|
||||
NOT_IN_FAC("Not in a faction"),
|
||||
//
|
||||
ANALYSIS("Analysis | "),
|
||||
ANALYSIS_START(ANALYSIS + "Beginning analysis of user data.."),
|
||||
ANALYSIS_BOOT_NOTIFY(ANALYSIS + "Boot analysis in 30 seconds.."),
|
||||
ANALYSIS_BOOT(ANALYSIS + "Starting Boot Analysis.."),
|
||||
ANALYSIS_FETCH_PLAYERS(ANALYSIS + "Checking for available players.."),
|
||||
ANALYSIS_FETCH_DATA(ANALYSIS + "Fetching Data.."),
|
||||
ANALYSIS_FAIL_NO_PLAYERS(ANALYSIS + "Analysis failed, no known players."),
|
||||
ANALYSIS_FAIL_NO_DATA(ANALYSIS + "Analysis failed, no data in the database."),
|
||||
ANALYSIS_BEGIN_ANALYSIS(ANALYSIS + "Data Fetched, beginning Analysis of data.."),
|
||||
ANALYSIS_COMPLETE(ANALYSIS + "Analysis Complete."),
|
||||
|
||||
//
|
||||
ERROR_PLANLITE("PlanLite not found, if you're have plugins using PlanAPI v1.6.0 download PlanLite."),
|
||||
ERROR_NO_DATA_VIEW(ChatColor.YELLOW + "Webserver disabled but Alternative IP/PlanLite not used, no way to view data!"),
|
||||
ERROR_WEBSERVER_OFF_ANALYSIS(ChatColor.YELLOW + "" + PREFIX + "This command can be only used if the webserver is running on this server."),
|
||||
ERROR_WEBSERVER_OFF_INSPECT(ChatColor.YELLOW + "" + PREFIX + "This command can be only used if webserver/planlite is enabled on this server."),
|
||||
|
||||
//
|
||||
MANAGE_ERROR_INCORRECT_PLUGIN(ChatColor.RED + "" + PREFIX + "Plugin not supported: "),
|
||||
MANAGE_ERROR_PLUGIN_NOT_ENABLED(ChatColor.RED + "" + PREFIX + "Plugin is not enabled: "),
|
||||
MANAGE_ERROR_INCORRECT_DB(ChatColor.RED + "" + PREFIX + "Incorrect database! (sqlite/mysql accepted): "),
|
||||
@ -57,7 +74,19 @@ public enum Phrase {
|
||||
MANAGE_ERROR_NO_PLAYERS(ChatColor.RED + "" + PREFIX + "Database has no player data!"),
|
||||
MANAGE_MOVE_SUCCESS(ChatColor.GREEN + "" + PREFIX + "All data moved successfully!"),
|
||||
MANAGE_CLEAR_SUCCESS(ChatColor.GREEN + "" + PREFIX + "All data cleared successfully!"),
|
||||
|
||||
//
|
||||
CMD_FOOTER(COLOR_TER.color() + "" + ARROWS_RIGHT),
|
||||
CMD_BALL(COLOR_SEC.color() + " " + Phrase.BALL.toString() + COLOR_MAIN.color()),
|
||||
CMD_ANALYZE_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Analysis results"),
|
||||
CMD_INSPECT_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Inspect results: "),
|
||||
CMD_SEARCH_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Search results for: "),
|
||||
CMD_CLICK_ME("Click Me"),
|
||||
CMD_LINK(COLOR_SEC.color() + " " + BALL + COLOR_MAIN.color() + " Link: " + COLOR_TER.color()),
|
||||
CMD_PASS_PLANLITE(ChatColor.YELLOW + "" + PREFIX + "Passing to PlanLite.."),
|
||||
CMD_RESULTS_AVAILABLE(COLOR_SEC.color() + " Results will be available for " + COLOR_TER.color() + "#1" + COLOR_SEC.color() + " minutes."),
|
||||
CMD_NO_RESULTS(CMD_BALL + " No results for " + COLOR_SEC.color() + "#1" + COLOR_MAIN.color() + "."),
|
||||
CMD_MATCH(COLOR_SEC.color() + " Matching player: " + COLOR_TER.color()),
|
||||
//
|
||||
COMMAND_SENDER_NOT_PLAYER(ChatColor.RED + "" + PREFIX + "This command can be only used as a player."),
|
||||
COMMAND_REQUIRES_ARGUMENTS(ChatColor.RED + "" + PREFIX + "Command requires arguments."),
|
||||
COMMAND_ADD_CONFIRMATION_ARGUMENT(ChatColor.RED + "" + PREFIX + "Add -a to confirm execution!"),
|
||||
@ -81,6 +110,10 @@ public enum Phrase {
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public String parse(String replace) {
|
||||
return text.replaceAll("#1", replace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Color of the COLOR_ENUM
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -31,12 +32,10 @@ Top 20 most active 25%
|
||||
Clear setting multiper (InspectCache)
|
||||
Clear check for existing clear task. (InspectCache)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
||||
public class Plan extends JavaPlugin {
|
||||
|
||||
private API api;
|
||||
@ -50,7 +49,7 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* OnEnable method.
|
||||
*
|
||||
*
|
||||
* Initiates the plugin with database, webserver, commands & listeners.
|
||||
*/
|
||||
@Override
|
||||
@ -70,7 +69,7 @@ public class Plan extends JavaPlugin {
|
||||
log(MiscUtils.checkVersion());
|
||||
log("Database init..");
|
||||
if (initDatabase()) {
|
||||
log(db.getConfigName()+"-database connection established.");
|
||||
log(db.getConfigName() + "-database connection established.");
|
||||
} else {
|
||||
logError(Phrase.DATABASE_FAILURE_DISABLE.toString());
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
@ -88,27 +87,29 @@ public class Plan extends JavaPlugin {
|
||||
this.api = new API(this);
|
||||
handler.handleReload();
|
||||
|
||||
if (getConfig().getBoolean("Settings.WebServer.Enabled")) {
|
||||
if (Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||
uiServer = new WebSocketServer(this);
|
||||
uiServer.initServer();
|
||||
if (getConfig().getBoolean("Settings.Cache.AnalysisCache.RefreshAnalysisCacheOnEnable")) {
|
||||
log("Analysis | Boot analysis in 30 seconds..");
|
||||
if (Settings.ANALYSIS_REFRESH_ON_ENABLE.isTrue()) {
|
||||
log(Phrase.ANALYSIS_BOOT_NOTIFY + "");
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
log("Analysis | Starting Boot Analysis..");
|
||||
log(Phrase.ANALYSIS_BOOT + "");
|
||||
analysisCache.updateCache();
|
||||
this.cancel();
|
||||
}
|
||||
}).runTaskLater(this, 30 * 20);
|
||||
}
|
||||
} else if (!(getConfig().getBoolean("Settings.WebServer.ShowAlternativeServerIP")
|
||||
|| (getConfig().getBoolean("Settings.PlanLite.UseAsAlternativeUI")
|
||||
&& planLiteHook.isEnabled()))) {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage("[Plan] "
|
||||
+ Phrase.ERROR_NO_DATA_VIEW);
|
||||
} else if (!(Settings.SHOW_ALTERNATIVE_IP.isTrue())
|
||||
|| (Settings.USE_ALTERNATIVE_UI.isTrue()
|
||||
&& planLiteHook.isEnabled())) {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(Phrase.PREFIX + "" + Phrase.ERROR_NO_DATA_VIEW);
|
||||
}
|
||||
log("Player Analytics Enabled.");
|
||||
if (!Settings.SHOW_ALTERNATIVE_IP.isTrue() && getServer().getIp().isEmpty()) {
|
||||
log(Phrase.NOTIFY_EMPTY_IP+"");
|
||||
}
|
||||
log(Phrase.ENABLED+"");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,8 +125,8 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Disables the plugin.
|
||||
*
|
||||
* Stops the webserver, cancels all tasks and saves cache to the database. *
|
||||
*
|
||||
* Stops the webserver, cancels all tasks and saves cache to the database. *
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
@ -134,7 +135,7 @@ public class Plan extends JavaPlugin {
|
||||
}
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
if (handler != null) {
|
||||
log("Saving cached data..");
|
||||
log(Phrase.SAVE_CACHE+"");
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
scheduler.execute(() -> {
|
||||
handler.saveCacheOnDisable();
|
||||
@ -142,11 +143,12 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
scheduler.shutdown();
|
||||
}
|
||||
log("Player Analytics Disabled.");
|
||||
log(Phrase.DISABLED+"");
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the message to the console.
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public void log(String message) {
|
||||
@ -155,6 +157,7 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Logs an error message to the console.
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public void logError(String message) {
|
||||
@ -173,14 +176,14 @@ public class Plan extends JavaPlugin {
|
||||
pluginManager.registerEvents(new PlanChatListener(this), this);
|
||||
pluginManager.registerEvents(new PlanPlayerListener(this), this);
|
||||
pluginManager.registerEvents(new PlanGamemodeChangeListener(this), this);
|
||||
pluginManager.registerEvents(new PlanCommandPreprocessListener(this), this);
|
||||
if (getConfig().getBoolean("Settings.Data.GatherLocations")) {
|
||||
pluginManager.registerEvents(new PlanCommandPreprocessListener(this), this);
|
||||
if (Settings.GATHERLOCATIONS.isTrue()) {
|
||||
pluginManager.registerEvents(new PlanPlayerMoveListener(this), this);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean initDatabase() {
|
||||
String type = getConfig().getString("database.type");
|
||||
String type = Settings.DB_TYPE+"";
|
||||
|
||||
db = null;
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.djrapitops.planlite.api.API;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.handlers.PlanLiteDataPushHook;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
@ -33,8 +34,7 @@ public class PlanLiteHook {
|
||||
*/
|
||||
public PlanLiteHook(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
FileConfiguration config = plugin.getConfig();
|
||||
if (config.getBoolean("Settings.PlanLite.Enabled")) {
|
||||
if (Settings.PLANLITE_ENABLED.isTrue()) {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlanLite")) {
|
||||
try {
|
||||
this.planLite = getPlugin(PlanLite.class);
|
||||
@ -43,7 +43,7 @@ public class PlanLiteHook {
|
||||
}
|
||||
enabled = true;
|
||||
planLiteApi = planLite.getAPI();
|
||||
if (config.getBoolean("Settings.PlanLite.UseAsAlternativeUI")) {
|
||||
if (Settings.USE_ALTERNATIVE_UI.isTrue()) {
|
||||
planLite.addExtraHook("Plan", new PlanLiteDataPushHook(plugin));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
66
Plan/src/main/java/com/djrapitops/plan/Settings.java
Normal file
66
Plan/src/main/java/com/djrapitops/plan/Settings.java
Normal file
@ -0,0 +1,66 @@
|
||||
package main.java.com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum Settings {
|
||||
WEBSERVER_ENABLED(getPlugin(Plan.class).getConfig().getBoolean("Settings.WebServer.Enabled")),
|
||||
WEBSERVER_PORT(getPlugin(Plan.class).getConfig().getInt("Settings.WebServer.Port")),
|
||||
ANALYSIS_REFRESH_ON_ENABLE(getPlugin(Plan.class).getConfig().getBoolean("Settings.Cache.AnalysisCache.RefreshAnalysisCacheOnEnable")),
|
||||
ANALYSIS_LOG_TO_CONSOLE(getPlugin(Plan.class).getConfig().getBoolean("Settings.Analysis.LogProgressOnConsole")),
|
||||
ANALYSIS_MINUTES_FOR_ACTIVE(getPlugin(Plan.class).getConfig().getInt("Settings.Analysis.MinutesPlayedUntilConsidiredActive")),
|
||||
SHOW_ALTERNATIVE_IP(getPlugin(Plan.class).getConfig().getBoolean("Settings.WebServer.ShowAlternativeServerIP")),
|
||||
ALTERNATIVE_IP(getPlugin(Plan.class).getConfig().getString("Settings.WebServer.AlternativeIP")),
|
||||
USE_ALTERNATIVE_UI(getPlugin(Plan.class).getConfig().getBoolean("Settings.PlanLite.UseAsAlternativeUI")),
|
||||
PLANLITE_ENABLED(getPlugin(Plan.class).getConfig().getBoolean("Settings.PlanLite.Enabled")),
|
||||
GATHERLOCATIONS(getPlugin(Plan.class).getConfig().getBoolean("Settings.Data.GatherLocations")),
|
||||
DB_TYPE(getPlugin(Plan.class).getConfig().getString("database.type")),
|
||||
SAVE_CACHE_MIN(getPlugin(Plan.class).getConfig().getInt("Settings.Cache.DataCache.SaveEveryXMinutes")),
|
||||
SAVE_SERVER_MIN(getPlugin(Plan.class).getConfig().getInt("Settings.Cache.DataCache.SaveServerDataEveryXMinutes")),
|
||||
CLEAR_INSPECT_CACHE(getPlugin(Plan.class).getConfig().getInt("Settings.Cache.InspectCache.ClearFromInspectCacheAfterXMinutes")),
|
||||
CLEAR_CACHE_X_SAVES(getPlugin(Plan.class).getConfig().getInt("Settings.Cache.DataCache.ClearCacheEveryXSaves")),
|
||||
DEM_TRIGGERS(getPlugin(Plan.class).getConfig().getString("Customization.DemographicsTriggers.Trigger")),
|
||||
DEM_FEMALE(getPlugin(Plan.class).getConfig().getString("Customization.DemographicsTriggers.Female")),
|
||||
DEM_MALE(getPlugin(Plan.class).getConfig().getString("Customization.DemographicsTriggers.Male")),
|
||||
DEM_IGNORE(getPlugin(Plan.class).getConfig().getString("Customization.DemographicsTriggers.IgnoreWhen")),
|
||||
;
|
||||
|
||||
private final String text;
|
||||
private final boolean bool;
|
||||
private final int number;
|
||||
|
||||
private Settings(final String text) {
|
||||
this.text = text;
|
||||
this.bool = false;
|
||||
this.number = -1;
|
||||
}
|
||||
|
||||
private Settings(final boolean bool) {
|
||||
this.bool = bool;
|
||||
this.text = "";
|
||||
this.number = -1;
|
||||
}
|
||||
|
||||
private Settings(final int number) {
|
||||
this.bool = false;
|
||||
this.text = "";
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public boolean isTrue() {
|
||||
return this.bool;
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
}
|
@ -6,12 +6,11 @@ import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.data.cache.AnalysisCacheHandler;
|
||||
import java.util.Date;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@ -48,14 +47,13 @@ public class AnalyzeCommand extends SubCommand {
|
||||
* @return true in all cases.
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
FileConfiguration config = plugin.getConfig();
|
||||
if (!config.getBoolean("Settings.WebServer.Enabled")) {
|
||||
if (!config.getBoolean("Settings.WebServer.ShowAlternativeServerIP")) {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||
if (!Settings.SHOW_ALTERNATIVE_IP.isTrue()) {
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_ANALYSIS.toString());
|
||||
return true;
|
||||
} else {
|
||||
sendAnalysisMessage(sender, config);
|
||||
sendAnalysisMessage(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -70,7 +68,7 @@ public class AnalyzeCommand extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
if (analysisCache.isCached()) {
|
||||
sendAnalysisMessage(sender, config);
|
||||
sendAnalysisMessage(sender);
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
@ -81,23 +79,18 @@ public class AnalyzeCommand extends SubCommand {
|
||||
/**
|
||||
* Used to send the message after /plan analysis.
|
||||
* @param sender Command sender.
|
||||
* @param config Plan config.
|
||||
* @throws CommandException
|
||||
*/
|
||||
public void sendAnalysisMessage(CommandSender sender, FileConfiguration config) throws CommandException {
|
||||
ChatColor oColor = Phrase.COLOR_MAIN.color();
|
||||
ChatColor tColor = Phrase.COLOR_SEC.color();
|
||||
ChatColor hColor = Phrase.COLOR_TER.color();
|
||||
final boolean useAlternativeIP = config.getBoolean("Settings.WebServer.ShowAlternativeServerIP");
|
||||
final int port = config.getInt("Settings.WebServer.Port");
|
||||
final String alternativeIP = config.getString("Settings.WebServer.AlternativeIP").replaceAll("%port%", "" + port);
|
||||
// Header
|
||||
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString() + oColor
|
||||
+ " Player Analytics - Analysis results");
|
||||
public void sendAnalysisMessage(CommandSender sender) throws CommandException {
|
||||
final boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||
final int port = Settings.WEBSERVER_PORT.getNumber();
|
||||
final String alternativeIP = Settings.ALTERNATIVE_IP.toString().replaceAll("%port%", "" + port);
|
||||
|
||||
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER+"");
|
||||
// Link
|
||||
String url = "http://" + (useAlternativeIP ? alternativeIP : plugin.getServer().getIp() + ":" + port)
|
||||
+ "/server";
|
||||
String message = tColor + " " + Phrase.BALL.toString() + oColor + " Link: " + hColor;
|
||||
String message = Phrase.CMD_LINK+"";
|
||||
boolean console = !(sender instanceof Player);
|
||||
if (console) {
|
||||
sender.sendMessage(message + url);
|
||||
@ -106,10 +99,9 @@ public class AnalyzeCommand extends SubCommand {
|
||||
Player player = (Player) sender;
|
||||
Bukkit.getServer().dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw " + player.getName() + " [\"\",{\"text\":\"Click Me\",\"underlined\":true,"
|
||||
"tellraw " + player.getName() + " [\"\",{\"text\":\""+Phrase.CMD_CLICK_ME+"\",\"underlined\":true,"
|
||||
+ "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]");
|
||||
}
|
||||
// Footer
|
||||
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString());
|
||||
sender.sendMessage(Phrase.CMD_FOOTER+"");
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,12 @@ import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.data.cache.InspectCacheHandler;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
@ -57,15 +56,15 @@ public class InspectCommand extends SubCommand {
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
FileConfiguration config = plugin.getConfig();
|
||||
if (!config.getBoolean("Settings.WebServer.Enabled")) {
|
||||
if (!config.getBoolean("Settings.WebServer.ShowAlternativeServerIP")) {
|
||||
final boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||
if (!useAlternativeIP) {
|
||||
PlanLiteHook planLiteHook = plugin.getPlanLiteHook();
|
||||
if (config.getBoolean("Settings.PlanLite.UseAsAlternativeUI") && planLiteHook.isEnabled()) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "[Plan] Passing to PlanLite..");
|
||||
if (Settings.USE_ALTERNATIVE_UI.isTrue() && planLiteHook.isEnabled()) {
|
||||
sender.sendMessage(Phrase.CMD_PASS_PLANLITE + "");
|
||||
planLiteHook.passCommand(sender, cmd, commandLabel, args);
|
||||
} else {
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_INSPECT.toString());
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_INSPECT + "");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -91,17 +90,11 @@ public class InspectCommand extends SubCommand {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_KNOWN.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ChatColor oColor = Phrase.COLOR_MAIN.color();
|
||||
ChatColor tColor = Phrase.COLOR_SEC.color();
|
||||
ChatColor hColor = Phrase.COLOR_TER.color();
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE+"");
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||
inspectCache.cache(uuid);
|
||||
final boolean useAlternativeIP = config.getBoolean("Settings.WebServer.ShowAlternativeServerIP");
|
||||
final int port = config.getInt("Settings.WebServer.Port");
|
||||
final String alternativeIP = config.getString("Settings.WebServer.AlternativeIP").replaceAll("%port%", "" + port);
|
||||
int configValue = config.getInt("Settings.Cache.InspectCache.ClearFromInspectCacheAfterXMinutes");
|
||||
final int port = Settings.WEBSERVER_PORT.getNumber();
|
||||
final String alternativeIP = Settings.ALTERNATIVE_IP.toString().replaceAll("%port%", "" + port);
|
||||
int configValue = Settings.CLEAR_INSPECT_CACHE.getNumber();
|
||||
if (configValue <= 0) {
|
||||
configValue = 4;
|
||||
}
|
||||
@ -110,13 +103,11 @@ public class InspectCommand extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
if (inspectCache.isCached(uuid)) {
|
||||
// Header
|
||||
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString() + oColor
|
||||
+ " Player Analytics - Inspect results: " + oColor + playerName);
|
||||
sender.sendMessage(Phrase.CMD_INSPECT_HEADER + playerName);
|
||||
// Link
|
||||
String url = "http://" + (useAlternativeIP ? alternativeIP : plugin.getServer().getIp() + ":" + port)
|
||||
+ "/player/" + playerName;
|
||||
String message = tColor + " " + Phrase.BALL.toString() + oColor + " Link: " + hColor;
|
||||
String message = Phrase.CMD_LINK+"";
|
||||
boolean console = !(sender instanceof Player);
|
||||
if (console) {
|
||||
sender.sendMessage(message + url);
|
||||
@ -125,13 +116,12 @@ public class InspectCommand extends SubCommand {
|
||||
Player player = (Player) sender;
|
||||
Bukkit.getServer().dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw " + player.getName() + " [\"\",{\"text\":\"Click Me\",\"underlined\":true,"
|
||||
"tellraw " + player.getName() + " [\"\",{\"text\":\""+Phrase.CMD_CLICK_ME+"\",\"underlined\":true,"
|
||||
+ "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]");
|
||||
}
|
||||
|
||||
sender.sendMessage(tColor + " Results will be available for " + hColor + available + tColor + " minutes.");
|
||||
// Footer
|
||||
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString());
|
||||
sender.sendMessage(Phrase.CMD_RESULTS_AVAILABLE.parse(available+""));
|
||||
sender.sendMessage(Phrase.CMD_FOOTER+"");
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,11 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
@ -52,7 +51,7 @@ public class SearchCommand extends SubCommand {
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
if (!plugin.getConfig().getBoolean("Settings.WebServer.Enabled")) {
|
||||
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_ANALYSIS.toString());
|
||||
return true;
|
||||
}
|
||||
@ -61,11 +60,7 @@ public class SearchCommand extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
ChatColor oColor = Phrase.COLOR_MAIN.color();
|
||||
ChatColor tColor = Phrase.COLOR_SEC.color();
|
||||
ChatColor hColor = Phrase.COLOR_TER.color();
|
||||
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE+"");
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||
Set<OfflinePlayer> matches = MiscUtils.getMatchingDisplaynames(args[0]);
|
||||
Set<UUID> uuids = new HashSet<>();
|
||||
for (OfflinePlayer match : matches) {
|
||||
@ -76,32 +71,30 @@ public class SearchCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
FileConfiguration config = plugin.getConfig();
|
||||
final boolean useAlternativeIP = config.getBoolean("Settings.WebServer.ShowAlternativeServerIP");
|
||||
final int port = config.getInt("Settings.WebServer.Port");
|
||||
final String alternativeIP = config.getString("Settings.WebServer.AlternativeIP").replaceAll("%port%", "" + port);
|
||||
int configValue = config.getInt("Settings.Cache.InspectCache.ClearFromInspectCacheAfterXMinutes");
|
||||
final boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||
final int port = Settings.WEBSERVER_PORT.getNumber();
|
||||
final String alternativeIP = Settings.ALTERNATIVE_IP.toString().replaceAll("%port%", "" + port);
|
||||
int configValue = Settings.CLEAR_INSPECT_CACHE.getNumber();
|
||||
if (configValue <= 0) {
|
||||
configValue = 4;
|
||||
}
|
||||
final int available = configValue;
|
||||
|
||||
// Header
|
||||
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString() + oColor + " Player Analytics - Search results for: " + args[0]);
|
||||
sender.sendMessage(Phrase.CMD_SEARCH_HEADER + args[0]);
|
||||
// Results
|
||||
if (uuids.isEmpty()) {
|
||||
sender.sendMessage(tColor + " " + Phrase.BALL.toString() + oColor + "No results for " + tColor + Arrays.toString(args) + oColor + ".");
|
||||
sender.sendMessage(Phrase.CMD_NO_RESULTS.parse(Arrays.toString(args)));
|
||||
} else {
|
||||
for (OfflinePlayer match : matches) {
|
||||
if (!uuids.contains(match.getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
String name = match.getName();
|
||||
sender.sendMessage(tColor + " Matching player: " + hColor + name);
|
||||
sender.sendMessage(Phrase.CMD_MATCH + name);
|
||||
// Link
|
||||
String url = "http://" + (useAlternativeIP ? alternativeIP : plugin.getServer().getIp() + ":" + port)
|
||||
+ "/player/" + name;
|
||||
String message = tColor + " " + Phrase.BALL.toString() + oColor + " Link: " + hColor;
|
||||
String message = Phrase.CMD_LINK+"";
|
||||
boolean console = !(sender instanceof Player);
|
||||
if (console) {
|
||||
sender.sendMessage(message + url);
|
||||
@ -115,9 +108,8 @@ public class SearchCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.sendMessage(tColor + " Results will be available for " + hColor + available + tColor + " minutes.");
|
||||
// Footer
|
||||
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString());
|
||||
sender.sendMessage(Phrase.CMD_RESULTS_AVAILABLE.parse(available+""));
|
||||
sender.sendMessage(Phrase.CMD_FOOTER+"");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,12 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -17,6 +17,12 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.djrapitops.plan.data;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.api.Gender;
|
||||
|
||||
/**
|
||||
@ -29,7 +30,7 @@ public class DemographicsData {
|
||||
* Creates new demographics data object with default parameters.
|
||||
*/
|
||||
public DemographicsData() {
|
||||
this(-1, Gender.UNKNOWN, "Not Known");
|
||||
this(-1, Gender.UNKNOWN, Phrase.DEM_UNKNOWN+"");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.djrapitops.plan.data.cache;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.database.Database;
|
||||
import com.djrapitops.plan.data.*;
|
||||
@ -10,6 +11,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -65,16 +67,16 @@ public class DataCacheHandler {
|
||||
timesSaved = 0;
|
||||
maxPlayers = plugin.getServer().getMaxPlayers();
|
||||
|
||||
int minutes = plugin.getConfig().getInt("Settings.Cache.DataCache.SaveEveryXMinutes");
|
||||
int minutes = Settings.SAVE_CACHE_MIN.getNumber();
|
||||
if (minutes <= 0) {
|
||||
minutes = 5;
|
||||
}
|
||||
int sMinutes = plugin.getConfig().getInt("Settings.Cache.DataCache.SaveServerDataEveryXMinutes");
|
||||
int sMinutes = Settings.SAVE_SERVER_MIN.getNumber();
|
||||
if (sMinutes <= 0) {
|
||||
sMinutes = 5;
|
||||
}
|
||||
final int clearAfterXsaves;
|
||||
int configValue = plugin.getConfig().getInt("Settings.Cache.DataCache.ClearCacheEveryXSaves");
|
||||
int configValue = Settings.CLEAR_CACHE_X_SAVES.getNumber();
|
||||
if (configValue <= 1) {
|
||||
clearAfterXsaves = 2;
|
||||
} else {
|
||||
@ -122,7 +124,7 @@ public class DataCacheHandler {
|
||||
getPlanLiteHandler().handleEvents(uData.getName(), uData);
|
||||
}
|
||||
dataCache.put(uuid, uData);
|
||||
plugin.log("Added " + uuid.toString() + " to Cache.");
|
||||
plugin.log(Phrase.ADD_TO_CACHE.parse(uuid.toString()));
|
||||
}
|
||||
}
|
||||
return dataCache.get(uuid);
|
||||
|
@ -5,6 +5,7 @@ import com.djrapitops.plan.data.UserData;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
@ -37,7 +38,7 @@ public class InspectCacheHandler {
|
||||
* @param uuid UUID of the player
|
||||
*/
|
||||
public void cache(UUID uuid) {
|
||||
int minutes = plugin.getConfig().getInt("Settings.Cache.InspectCache.ClearFromInspectCacheAfterXMinutes");
|
||||
int minutes = Settings.CLEAR_INSPECT_CACHE.getNumber();
|
||||
if (minutes <= 0) {
|
||||
minutes = 3;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.djrapitops.plan.data.handlers;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.Gender;
|
||||
@ -11,6 +12,7 @@ import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
@ -44,10 +46,10 @@ public class DemographicsHandler {
|
||||
* @param data UserData corresponding to player of this event.
|
||||
*/
|
||||
public void handleChatEvent(AsyncPlayerChatEvent event, UserData data) {
|
||||
List<String> triggers = Arrays.asList(plugin.getConfig().getString("Customization.DemographicsTriggers.Trigger").split(", "));
|
||||
List<String> female = Arrays.asList(plugin.getConfig().getString("Customization.DemographicsTriggers.Female").split(", "));
|
||||
List<String> male = Arrays.asList(plugin.getConfig().getString("Customization.DemographicsTriggers.Male").split(", "));
|
||||
List<String> ignore = Arrays.asList(plugin.getConfig().getString("Customization.DemographicsTriggers.IgnoreWhen").split(", "));
|
||||
List<String> triggers = Arrays.asList(Settings.DEM_TRIGGERS.toString().split(", "));
|
||||
List<String> female = Arrays.asList(Settings.DEM_FEMALE.toString().split(", "));
|
||||
List<String> male = Arrays.asList(Settings.DEM_MALE.toString().split(", "));
|
||||
List<String> ignore = Arrays.asList(Settings.DEM_IGNORE.toString().split(", "));
|
||||
|
||||
String message = event.getMessage();
|
||||
String[] messageA = message.toLowerCase().split("\\s+");
|
||||
@ -127,7 +129,7 @@ public class DemographicsHandler {
|
||||
demData.setGeoLocation(results[2]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
demData.setGeoLocation("Not Known");
|
||||
demData.setGeoLocation(Phrase.DEM_UNKNOWN+"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.djrapitops.plan.data.handlers;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanLiteHook;
|
||||
import com.djrapitops.plan.data.UserData;
|
||||
@ -8,6 +9,7 @@ import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.PlanLitePlayerData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@ -75,7 +77,7 @@ public class PlanLiteHandler {
|
||||
PlanLitePlayerData plData = new PlanLitePlayerData();
|
||||
|
||||
// Avoiding StackOverFlow
|
||||
if (plugin.getConfig().getBoolean("Settings.PlanLite.UseAsAlternativeUI")
|
||||
if (Settings.USE_ALTERNATIVE_UI.isTrue()
|
||||
&& plugin.getPlanLiteHook().isEnabled()) {
|
||||
data.setPlanLiteFound(false);
|
||||
plData.setTowny(false);
|
||||
@ -92,7 +94,7 @@ public class PlanLiteHandler {
|
||||
plData.setVault(enabledHooks.contains("Vault"));
|
||||
if (plData.hasTowny()) {
|
||||
DataPoint town = liteData.get("TOW-TOWN");
|
||||
plData.setTown((town != null) ? town.data() : "Not in a town");
|
||||
plData.setTown((town != null) ? town.data() : Phrase.NOT_IN_TOWN+"");
|
||||
DataPoint friends = liteData.get("TOW-FRIENDS");
|
||||
plData.setFriends((town != null) ? friends.data() : "");
|
||||
DataPoint perms = liteData.get("TOW-PLOT PERMS");
|
||||
@ -102,7 +104,7 @@ public class PlanLiteHandler {
|
||||
}
|
||||
if (plData.hasFactions()) {
|
||||
DataPoint faction = liteData.get("FAC-FACTION");
|
||||
plData.setFaction((faction != null) ? faction.data() : "Not in a faction");
|
||||
plData.setFaction((faction != null) ? faction.data() : Phrase.NOT_IN_FAC+"");
|
||||
}
|
||||
if (plData.hasSuperbVote()) {
|
||||
try {
|
||||
|
@ -10,6 +10,7 @@ import java.io.OutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
@ -36,7 +37,7 @@ public class WebSocketServer {
|
||||
*/
|
||||
public WebSocketServer(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
this.PORT = plugin.getConfig().getInt("Settings.WebServer.Port");
|
||||
this.PORT = Settings.WEBSERVER_PORT.getNumber();
|
||||
shutdown = false;
|
||||
dataReqHandler = new DataRequestHandler(plugin);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.PlanLiteAnalyzedData;
|
||||
import main.java.com.djrapitops.plan.data.PlanLitePlayerData;
|
||||
import org.bukkit.GameMode;
|
||||
@ -56,7 +57,7 @@ public class Analysis {
|
||||
public void analyze(AnalysisCacheHandler analysisCache) {
|
||||
rawData.clear();
|
||||
added.clear();
|
||||
plugin.log(Phrase.ANALYSIS_START + "");
|
||||
log(Phrase.ANALYSIS_START + "");
|
||||
OfflinePlayer[] offlinePlayers;
|
||||
try {
|
||||
offlinePlayers = plugin.getServer().getOfflinePlayers();
|
||||
@ -65,7 +66,7 @@ public class Analysis {
|
||||
return;
|
||||
}
|
||||
final List<UUID> uuids = new ArrayList<>();
|
||||
plugin.log(Phrase.ANALYSIS_FETCH_PLAYERS + "");
|
||||
log(Phrase.ANALYSIS_FETCH_PLAYERS + "");
|
||||
for (OfflinePlayer p : offlinePlayers) {
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (plugin.getDB().wasSeenBefore(uuid)) {
|
||||
@ -76,17 +77,16 @@ public class Analysis {
|
||||
plugin.log(Phrase.ANALYSIS_FAIL_NO_DATA + "");
|
||||
return;
|
||||
}
|
||||
FileConfiguration config = plugin.getConfig();
|
||||
final boolean useAlternativeIP = config.getBoolean("Settings.WebServer.ShowAlternativeServerIP");
|
||||
final int port = config.getInt("Settings.WebServer.Port");
|
||||
final String alternativeIP = config.getString("Settings.WebServer.AlternativeIP").replaceAll("%port%", "" + port);
|
||||
final boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||
final int port = Settings.WEBSERVER_PORT.getNumber();
|
||||
final String alternativeIP = Settings.ALTERNATIVE_IP.toString().replaceAll("%port%", "" + port);
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
uuids.stream().forEach((uuid) -> {
|
||||
inspectCache.cache(uuid, 8);
|
||||
});
|
||||
plugin.log(Phrase.ANALYSIS_FETCH_DATA + "");
|
||||
log(Phrase.ANALYSIS_FETCH_DATA + "");
|
||||
while (rawData.size() != uuids.size()) {
|
||||
uuids.stream()
|
||||
.filter((uuid) -> (!added.contains(uuid)))
|
||||
@ -99,7 +99,7 @@ public class Analysis {
|
||||
});
|
||||
}
|
||||
rawServerData = plugin.getDB().getServerDataHashMap();
|
||||
plugin.log(Phrase.ANALYSIS_BEGIN_ANALYSIS + "");
|
||||
log(Phrase.ANALYSIS_BEGIN_ANALYSIS + "");
|
||||
AnalysisData data = new AnalysisData();
|
||||
|
||||
createPlayerActivityGraphs(data);
|
||||
@ -280,4 +280,10 @@ public class Analysis {
|
||||
}
|
||||
}).runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
private void log(String msg) {
|
||||
if (Settings.ANALYSIS_LOG_TO_CONSOLE.isTrue()) {
|
||||
plugin.log(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanLiteHook;
|
||||
import com.djrapitops.plan.data.AnalysisData;
|
||||
@ -11,6 +12,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.PlanLiteAnalyzedData;
|
||||
import main.java.com.djrapitops.plan.data.PlanLitePlayerData;
|
||||
import main.java.com.djrapitops.plan.ui.graphs.ActivityPieChartCreator;
|
||||
@ -66,7 +68,7 @@ public class AnalysisUtils {
|
||||
replaceMap.put("%active%", AnalysisUtils.isActive(data.getLastPlayed(), data.getPlayTime(), data.getLoginTimes())
|
||||
? "| Player is Active" : "| Player is inactive");
|
||||
int age = data.getDemData().getAge();
|
||||
replaceMap.put("%age%", (age != -1) ? "" + age : "Not known");
|
||||
replaceMap.put("%age%", (age != -1) ? "" + age : Phrase.DEM_UNKNOWN+"");
|
||||
replaceMap.put("%gender%", "" + data.getDemData().getGender().name().toLowerCase());
|
||||
HashMap<GameMode, Long> gmTimes = data.getGmTimes();
|
||||
replaceMap.put("%gmpiechart%", createGMPieChart(gmTimes));
|
||||
@ -137,7 +139,7 @@ public class AnalysisUtils {
|
||||
replaceMap.put("%playerchartweek%", data.getPlayersChartImgHtmlWeek());
|
||||
replaceMap.put("%playerchartday%", data.getPlayersChartImgHtmlDay());
|
||||
replaceMap.put("%top50commands%", data.getTop50CommandsListHtml());
|
||||
replaceMap.put("%avgage%", (data.getAverageAge() != -1) ? "" + data.getAverageAge() : "Not Known");
|
||||
replaceMap.put("%avgage%", (data.getAverageAge() != -1) ? "" + data.getAverageAge() : Phrase.DEM_UNKNOWN+"");
|
||||
replaceMap.put("%avgplaytime%", FormatUtils.formatTimeAmount("" + data.getAveragePlayTime()));
|
||||
replaceMap.put("%totalplaytime%", FormatUtils.formatTimeAmount("" + data.getTotalPlayTime()));
|
||||
replaceMap.put("%ops%", "" + data.getOps());
|
||||
@ -156,7 +158,7 @@ public class AnalysisUtils {
|
||||
|
||||
static boolean isActive(long lastPlayed, long playTime, int loginTimes) {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
int timeToActive = plugin.getConfig().getInt("Settings.Analysis.MinutesPlayedUntilConsidiredActive");
|
||||
int timeToActive = Settings.ANALYSIS_MINUTES_FOR_ACTIVE.getNumber();
|
||||
if (timeToActive < 0) {
|
||||
timeToActive = 0;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.data.DemographicsData;
|
||||
import com.djrapitops.plan.data.ServerData;
|
||||
import com.djrapitops.plan.data.UserData;
|
||||
@ -69,7 +70,7 @@ public class DataCombineUtils {
|
||||
if (tDemData.getAge() > fDemData.getAge()) {
|
||||
fDemData.setAge(tDemData.getAge());
|
||||
}
|
||||
if (fDemData.getGeoLocation().equals("Not Known")) {
|
||||
if (fDemData.getGeoLocation().equals(Phrase.DEM_UNKNOWN+"")) {
|
||||
fDemData.setGeoLocation(tDemData.getGeoLocation());
|
||||
}
|
||||
fData.setDemData(fDemData);
|
||||
|
@ -2,6 +2,7 @@ package com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -46,14 +47,14 @@ public class MiscUtils {
|
||||
cVersion = plugin.getDescription().getVersion();
|
||||
int currentVersionNumber = FormatUtils.parseVersionNumber(cVersion);
|
||||
if (newestVersionNumber > currentVersionNumber) {
|
||||
return "New Version (" + versionString + ") is availible at https://www.spigotmc.org/resources/plan-player-analytics.32536/";
|
||||
return Phrase.VERSION_NEW_AVAILABLE.parse(versionString);
|
||||
} else {
|
||||
return "You're running the latest version";
|
||||
return Phrase.VERSION_LATEST+"";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.logError("Failed to compare versions.");
|
||||
} catch (IOException | NumberFormatException e) {
|
||||
plugin.logError(Phrase.VERSION_CHECK_ERROR+"");
|
||||
}
|
||||
return "Failed to get newest version number.";
|
||||
return Phrase.VERSION_FAIL+"";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ Settings:
|
||||
Data:
|
||||
GatherLocations: true
|
||||
Analysis:
|
||||
LogProgressOnConsole: true
|
||||
MinutesPlayedUntilConsidiredActive: 10
|
||||
Cache:
|
||||
AnalysisCache:
|
||||
|
Loading…
Reference in New Issue
Block a user