mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-01 00:10:12 +01:00
Clean-up, Additions, PlanLite package change, Locations disabled, More Javadoc, Bugfixes
- Changed format of all BukkitRunnables to be the same. - Added a delayed task for cache clearing if data is being saved. - Changed PlanLite packages from com.djrapitops.plan to com.djrapitops.planlite - Moved useful utilities to com.djrapitops.plan.utilities and removed rest - Location Handling (and saving) disabled for now because of inefficient saving to SQL. - Added more javadocs Fixed bugs: - Locations not saved when player moves (Fixed, but location handling will be disabled for now) Known Bugs: - Times don't update on inspect (Just need to call update if player is online, one line missing.) - ClassCastException on start-up when PlanLite is not installed. (Will fix with try catch tomorrow.)
This commit is contained in:
parent
b7b6a0f05a
commit
f9fbf17fe6
@ -4,7 +4,7 @@ annotation.processing.processors.list=
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=Plan
|
||||
application.vendor=Risto
|
||||
application.vendor=Rsl1122
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
|
@ -2,6 +2,10 @@ package com.djrapitops.plan;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum Phrase {
|
||||
DATABASE_TYPE_DOES_NOT_EXIST("That database type doesn't exist."),
|
||||
DATABASE_FAILURE_DISABLE("Database initialization has failed, disabling Plan."),
|
||||
@ -13,7 +17,10 @@ public enum Phrase {
|
||||
COLOR_SEC(ChatColor.GRAY),
|
||||
COLOR_TER(ChatColor.DARK_GRAY),
|
||||
ERROR_PLANLITE("PlanLite not found, if you're have plugins using PlanAPI v1.6.0 download PlanLite."),
|
||||
ERROR_NO_USERNAME("INSPECT-GETNAME\nNo username given, returned empty username.\n");
|
||||
ERROR_NO_USERNAME("INSPECT-GETNAME\nNo username given, returned empty username.\n"),
|
||||
COMMAND_SENDER_NOT_PLAYER(ChatColor.RED + "[PLAN] This command can be only used as a player."),
|
||||
COMMAND_REQUIRES_ARGUMENTS(ChatColor.RED + "[PLAN] Command requires arguments."),
|
||||
COMMAND_NO_PERMISSION(ChatColor.RED + "[PLAN] You do not have the required permmission.");
|
||||
|
||||
private final String text;
|
||||
private final ChatColor color;
|
||||
@ -33,6 +40,9 @@ public enum Phrase {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Color of the COLOR_ENUM
|
||||
*/
|
||||
public ChatColor color() {
|
||||
return color;
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.command.PlanCommand;
|
||||
import com.djrapitops.plan.api.API;
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.command.utils.MiscUtils;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.database.Database;
|
||||
import com.djrapitops.plan.database.databases.MySQLDB;
|
||||
import com.djrapitops.plan.database.databases.SQLiteDB;
|
||||
import com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||
import com.djrapitops.plan.data.listeners.PlanChatListener;
|
||||
import com.djrapitops.plan.data.listeners.PlanCommandPreprocessListener;
|
||||
import com.djrapitops.plan.data.listeners.PlanGamemodeChangeListener;
|
||||
import com.djrapitops.plan.data.listeners.PlanPlayerListener;
|
||||
import com.djrapitops.plan.data.listeners.PlanPlayerMoveListener;
|
||||
import com.djrapitops.plan.data.cache.InspectCacheHandler;
|
||||
import com.djrapitops.plan.data.listeners.*;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -21,6 +19,9 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class Plan extends JavaPlugin {
|
||||
@ -28,6 +29,7 @@ public class Plan extends JavaPlugin {
|
||||
private API api;
|
||||
private PlanLiteHook planLiteHook;
|
||||
private DataCacheHandler handler;
|
||||
private InspectCacheHandler inspectCache;
|
||||
private Database db;
|
||||
private HashSet<Database> databases;
|
||||
|
||||
@ -70,6 +72,7 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
hookPlanLite();
|
||||
this.handler = new DataCacheHandler(this);
|
||||
this.inspectCache = new InspectCacheHandler(this);
|
||||
registerListeners();
|
||||
|
||||
log(MiscUtils.checkVersion());
|
||||
@ -99,9 +102,14 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
log("Saving cached data..");
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
scheduler.execute(() -> {
|
||||
handler.saveCacheOnDisable();
|
||||
db.close();
|
||||
});
|
||||
scheduler.shutdown();
|
||||
|
||||
log("Player Analytics Disabled.");
|
||||
}
|
||||
|
||||
@ -152,19 +160,8 @@ public class Plan extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new PlanPlayerListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new PlanGamemodeChangeListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new PlanCommandPreprocessListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new PlanPlayerMoveListener(this), this);
|
||||
}
|
||||
|
||||
public DataCacheHandler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public PlanLiteHook getPlanLiteHook() {
|
||||
return planLiteHook;
|
||||
}
|
||||
|
||||
public Database getDB() {
|
||||
return db;
|
||||
// Locations Removed from Build 2.0.0 for performance reasons.
|
||||
// getServer().getPluginManager().registerEvents(new PlanPlayerMoveListener(this), this);
|
||||
}
|
||||
|
||||
private boolean initDatabase() {
|
||||
@ -195,4 +192,20 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public InspectCacheHandler getInspectCache() {
|
||||
return inspectCache;
|
||||
}
|
||||
|
||||
public DataCacheHandler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public PlanLiteHook getPlanLiteHook() {
|
||||
return planLiteHook;
|
||||
}
|
||||
|
||||
public Database getDB() {
|
||||
return db;
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,31 @@
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.API;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.api.API;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import java.util.HashMap;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlanLiteHook {
|
||||
|
||||
private PlanLite planLite;
|
||||
private Plan plugin;
|
||||
private API planLiteApi;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*
|
||||
* Attempts to hook to PlanLite, if not present logs error.
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public PlanLiteHook(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
try {
|
||||
this.planLite = getPlugin(PlanLite.class);
|
||||
if (planLite == null) {
|
||||
@ -21,6 +34,7 @@ public class PlanLiteHook {
|
||||
planLiteApi = planLite.getAPI();
|
||||
} catch (Exception e) {
|
||||
plugin.logError(e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,10 @@ package com.djrapitops.plan.api;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanLiteHook;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -33,7 +36,7 @@ public class API {
|
||||
* @return String that is easily readable d:h:m:s
|
||||
*/
|
||||
public static String formatTimeSinceDate(Date before, Date after) {
|
||||
return DataFormatUtils.formatTimeAmountSinceDate(before, after);
|
||||
return FormatUtils.formatTimeAmountSinceDate(before, after);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +47,7 @@ public class API {
|
||||
* @return String that is easily readable d:h:m:s
|
||||
*/
|
||||
public static String formatTimeSinceString(String before, Date after) {
|
||||
return DataFormatUtils.formatTimeAmountSinceString(before, after);
|
||||
return FormatUtils.formatTimeAmountSinceString(before, after);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +57,7 @@ public class API {
|
||||
* @return String that is easily readable d:h:m:s
|
||||
*/
|
||||
public static String formatTimeAmount(String timeInMs) {
|
||||
return DataFormatUtils.formatTimeAmount(timeInMs);
|
||||
return FormatUtils.formatTimeAmount(timeInMs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +67,7 @@ public class API {
|
||||
* @return String that is easily readable date.
|
||||
*/
|
||||
public static String formatTimeStamp(String timeInMs) {
|
||||
return DataFormatUtils.formatTimeStamp(timeInMs);
|
||||
return FormatUtils.formatTimeStamp(timeInMs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,27 +1,52 @@
|
||||
package com.djrapitops.plan.api;
|
||||
|
||||
/**
|
||||
* Old API part.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @deprecated Moved to PlanLite plugin
|
||||
*/
|
||||
@Deprecated
|
||||
public class DataPoint {
|
||||
|
||||
private String data;
|
||||
private final DataType type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
* @param type
|
||||
* @deprecated Moved to PlanLite plugin
|
||||
*/
|
||||
@Deprecated
|
||||
public DataPoint(String data, DataType type) {
|
||||
this.data = data;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return @deprecated Moved to PlanLite plugin
|
||||
*/
|
||||
@Deprecated
|
||||
public String data() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
* @deprecated Moved to PlanLite plugin
|
||||
*/
|
||||
@Deprecated
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return @deprecated Moved to PlanLite plugin
|
||||
*/
|
||||
@Deprecated
|
||||
public DataType type() {
|
||||
return type;
|
||||
|
@ -1,6 +1,11 @@
|
||||
|
||||
package com.djrapitops.plan.api;
|
||||
|
||||
/**
|
||||
* Old API Part.
|
||||
* @author Rsl1122
|
||||
* @deprecated Moved to PlanLite plugin
|
||||
*/
|
||||
@Deprecated
|
||||
public enum DataType {
|
||||
STRING, // Any preformatted data & words
|
||||
|
@ -2,12 +2,31 @@ package com.djrapitops.plan.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Old API Part
|
||||
* @author Rsl1122
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Hook {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public HashMap<String, DataPoint> getData(String player) throws Exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public HashMap<String, DataPoint> getAllData(String player) throws Exception;
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.djrapitops.plan;
|
||||
package com.djrapitops.plan.command;
|
||||
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.command.commands.AnalyzeCommand;
|
||||
import com.djrapitops.plan.command.commands.DebugCommand;
|
||||
import com.djrapitops.plan.command.commands.HelpCommand;
|
||||
import com.djrapitops.plan.command.commands.InfoCommand;
|
||||
import com.djrapitops.plan.command.commands.InspectCommand;
|
||||
import com.djrapitops.plan.command.commands.ReloadCommand;
|
||||
import com.djrapitops.plan.command.commands.SearchCommand;
|
||||
import com.djrapitops.plan.command.utils.MiscUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -20,10 +19,21 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlanCommand implements CommandExecutor {
|
||||
|
||||
private final List<SubCommand> commands;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*
|
||||
* Initializes Subcommands
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public PlanCommand(Plan plugin) {
|
||||
commands = new ArrayList<>();
|
||||
|
||||
@ -33,13 +43,21 @@ public class PlanCommand implements CommandExecutor {
|
||||
commands.add(new SearchCommand(plugin));
|
||||
commands.add(new InfoCommand(plugin));
|
||||
commands.add(new ReloadCommand(plugin));
|
||||
commands.add(new DebugCommand(plugin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Initialized SubCommands
|
||||
*/
|
||||
public List<SubCommand> getCommands() {
|
||||
return this.commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks SubCommands for matching aliases.
|
||||
*
|
||||
* @param name SubCommand in text form that might match alias.
|
||||
* @return SubCommand, null if no match.
|
||||
*/
|
||||
public SubCommand getCommand(String name) {
|
||||
for (SubCommand command : commands) {
|
||||
String[] aliases = command.getName().split(",");
|
||||
@ -58,9 +76,19 @@ public class PlanCommand implements CommandExecutor {
|
||||
if (args.length < 1) {
|
||||
command = "help";
|
||||
}
|
||||
onCommand(sender, cmd, commandLabel, MiscUtils.mergeArrays(new String[]{command}, args));
|
||||
onCommand(sender, cmd, commandLabel, FormatUtils.mergeArrays(new String[]{command}, args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if Sender has rights to run the command and executes matching
|
||||
* subcommand.
|
||||
*
|
||||
* @param sender
|
||||
* @param cmd
|
||||
* @param commandLabel
|
||||
* @param args
|
||||
* @return true in all cases.
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
if (args.length < 1) {
|
||||
@ -78,21 +106,18 @@ public class PlanCommand implements CommandExecutor {
|
||||
boolean console = !(sender instanceof Player);
|
||||
|
||||
if (!sender.hasPermission(command.getPermission())) {
|
||||
// Phrase.NO_PERMISSION_FOR_COMMAND.sendWithPrefix( sender );
|
||||
sender.sendMessage(ChatColor.RED + "[PLAN] You do not have the required permmission.");
|
||||
sender.sendMessage("" + Phrase.COMMAND_NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (console && args.length < 2 && command.getCommandType() == CommandType.CONSOLE_WITH_ARGUMENTS) {
|
||||
// Phrase.COMMAND_NEEDS_ARGUMENTS.sendWithPrefix( sender );
|
||||
sender.sendMessage(ChatColor.RED + "[PLAN] Command requires arguments.");
|
||||
sender.sendMessage("" + Phrase.COMMAND_REQUIRES_ARGUMENTS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (console && command.getCommandType() == CommandType.PLAYER) {
|
||||
// Phrase.COMMAND_NOT_CONSOLE.sendWithPrefix( sender, commandLabel );
|
||||
sender.sendMessage(ChatColor.RED + "[PLAN] This command can be only used as a player.");
|
||||
if (console && command.getCommandType() == CommandType.PLAYER) {;
|
||||
sender.sendMessage("" + Phrase.COMMAND_SENDER_NOT_PLAYER);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command;
|
||||
|
||||
//import com.djrapitops.plan.Phrase;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
@ -3,24 +3,16 @@ package com.djrapitops.plan.command.commands;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.plan.command.utils.Analysis;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AnalyzeCommand extends SubCommand {
|
||||
|
||||
private Plan plugin;
|
||||
private HashMap<UUID, HashMap<String, DataPoint>> playerData;
|
||||
private HashMap<String, DataPoint> analyzedPlayerdata;
|
||||
private Date refreshDate;
|
||||
|
||||
public AnalyzeCommand(Plan plugin) {
|
||||
@ -32,40 +24,12 @@ public class AnalyzeCommand extends SubCommand {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
ChatColor operatorColor = ChatColor.DARK_GREEN;
|
||||
ChatColor textColor = ChatColor.GRAY;
|
||||
for (String arg : args) {
|
||||
if (arg.toLowerCase().equals("-refresh")) {
|
||||
if (sender.hasPermission("plan.analyze.refresh") || !(sender instanceof Player)) {
|
||||
refreshAnalysisData(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.playerData == null || this.refreshDate == null || this.analyzedPlayerdata == null || DataFormatUtils.formatTimeAmountSinceDate(refreshDate, new Date()).contains("m")) {
|
||||
refreshAnalysisData(sender);
|
||||
}
|
||||
|
||||
//header
|
||||
sender.sendMessage(textColor + "-- [" + operatorColor + "PLAN - Analysis results, refreshed "
|
||||
+ DataFormatUtils.formatTimeAmountSinceDate(refreshDate, new Date()) + " ago:" + textColor + "] --");
|
||||
+ FormatUtils.formatTimeAmountSinceDate(refreshDate, new Date()) + " ago:" + textColor + "] --");
|
||||
|
||||
List<String[]> dataList = DataFormatUtils.turnDataHashMapToSortedListOfArrays(analyzedPlayerdata);
|
||||
|
||||
sender.sendMessage("" + textColor + "Averages for " + this.playerData.size() + " player(s)");
|
||||
for (String[] dataString : dataList) {
|
||||
sender.sendMessage("" + operatorColor + dataString[0].charAt(4) + dataString[0].toLowerCase().substring(5) + ": " + textColor + dataString[1]);
|
||||
}
|
||||
sender.sendMessage(textColor + "-- o --");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void refreshAnalysisData(CommandSender sender) {
|
||||
ChatColor operatorColor = ChatColor.DARK_GREEN;
|
||||
ChatColor textColor = ChatColor.GRAY;
|
||||
sender.sendMessage(textColor + "[" + operatorColor + "Plan" + textColor + "] "
|
||||
+ "Refreshing playerData, this might take a while..");
|
||||
this.playerData = DataUtils.getTotalData(DataUtils.getMatchingDisplaynames(true));
|
||||
this.refreshDate = new Date();
|
||||
this.analyzedPlayerdata = Analysis.analyze(this.playerData);
|
||||
sender.sendMessage(textColor + "[" + operatorColor + "Plan" + textColor + "] "
|
||||
+ "Refreshed, took "+DataFormatUtils.formatTimeAmountSinceDate(refreshDate, new Date()));
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.djrapitops.plan.command.commands;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -2,8 +2,8 @@ package com.djrapitops.plan.command.commands;
|
||||
|
||||
//import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanCommand;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.PlanCommand;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -4,7 +4,7 @@ import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.command.utils.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -24,10 +24,14 @@ public class InfoCommand extends SubCommand {
|
||||
plugin.reloadConfig();
|
||||
ChatColor oColor = Phrase.COLOR_MAIN.color();
|
||||
ChatColor tColor = Phrase.COLOR_SEC.color();
|
||||
sender.sendMessage(tColor +"--["+oColor+"PLAN - Info"+tColor+"]--");
|
||||
sender.sendMessage(oColor+"Version: "+tColor+plugin.getDescription().getVersion());
|
||||
sender.sendMessage(tColor+MiscUtils.checkVersion());
|
||||
sender.sendMessage(oColor+"Cache\n"+tColor+"Cached users: "+plugin.getHandler().getDataCache().keySet().size());
|
||||
String[] messages = {
|
||||
tColor +"--["+oColor+"PLAN - Info"+tColor+"]--",
|
||||
oColor+"Version: "+tColor+plugin.getDescription().getVersion(),
|
||||
tColor+MiscUtils.checkVersion(),
|
||||
oColor+"Cache Size: "+tColor+plugin.getHandler().getDataCache().keySet().size(),
|
||||
oColor+"InspectCache Size: "+tColor+plugin.getInspectCache().getCache().keySet().size()
|
||||
};
|
||||
sender.sendMessage(messages);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,16 @@ package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.utilities.UUIDFetcher;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.plan.data.ServerData;
|
||||
|
||||
import java.util.Date;
|
||||
import com.djrapitops.plan.data.UserData;
|
||||
import com.djrapitops.plan.data.cache.InspectCacheHandler;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -20,21 +21,22 @@ 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;
|
||||
|
||||
public class InspectCommand extends SubCommand {
|
||||
|
||||
private Plan plugin;
|
||||
private InspectCacheHandler inspectCache;
|
||||
|
||||
public InspectCommand(Plan plugin) {
|
||||
super("inspect", "plan.inspect", "Inspect data /plan <player> [-a, -r].", CommandType.CONSOLE_WITH_ARGUMENTS);
|
||||
|
||||
this.plugin = plugin;
|
||||
inspectCache = plugin.getInspectCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
String playerName = DataUtils.getPlayerDisplayname(args, sender);
|
||||
String playerName = MiscUtils.getPlayerDisplayname(args, sender);
|
||||
|
||||
UUID uuid;
|
||||
try {
|
||||
@ -46,20 +48,19 @@ public class InspectCommand extends SubCommand {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_VALID.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
OfflinePlayer p = getOfflinePlayer(uuid);
|
||||
if (!p.hasPlayedBefore()) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_SEEN.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.getDB().wasSeenBefore(uuid)) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_KNOWN.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
Date refreshDate = new Date();
|
||||
UserData data = plugin.getHandler().getCurrentData(uuid);
|
||||
inspectCache.cache(uuid);
|
||||
UserData data = inspectCache.getFromCache(uuid);
|
||||
|
||||
ChatColor operatorColor = Phrase.COLOR_MAIN.color();
|
||||
ChatColor textColor = Phrase.COLOR_SEC.color();
|
||||
@ -74,6 +75,7 @@ public class InspectCommand extends SubCommand {
|
||||
msgs.add("Last gm swap time " + data.getLastGmSwapTime());
|
||||
msgs.add("Last Played " + data.getLastPlayed());
|
||||
msgs.add("Location " + data.getLocation().getBlockX());
|
||||
msgs.add("Locations "+data.getLocations().size());
|
||||
msgs.add("Nicknames " + data.getNicknames().toString());
|
||||
msgs.add("Registered " + data.getRegistered());
|
||||
msgs.add("TimesKicked " + data.getTimesKicked());
|
||||
@ -87,7 +89,7 @@ public class InspectCommand extends SubCommand {
|
||||
msgs.add("New Players " + sdata.getNewPlayers());
|
||||
msgs.add("Online Players " + sdata.getPlayersOnline());
|
||||
//header
|
||||
sender.sendMessage(textColor + "-- [" + operatorColor + "PLAN - Inspect results: " + playerName + " - took " + DataFormatUtils.formatTimeAmountSinceDate(refreshDate, new Date()) + textColor + "] --");
|
||||
sender.sendMessage(textColor + "-- [" + operatorColor + "PLAN - Inspect results: " + playerName + " - took " + FormatUtils.formatTimeAmountSinceDate(refreshDate, new Date()) + textColor + "] --");
|
||||
|
||||
for (String message : msgs) {
|
||||
sender.sendMessage(textColor + message);
|
||||
|
@ -4,10 +4,6 @@ import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.command.hooks.PlaceholderAPIHook;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -1,19 +1,13 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
@ -30,51 +24,19 @@ public class SearchCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
boolean playerFirst = false;
|
||||
for (String arg : args) {
|
||||
if (arg.equals("-p")) {
|
||||
playerFirst = true;
|
||||
}
|
||||
}
|
||||
Set<OfflinePlayer> matchingPlayers;
|
||||
if (playerFirst) {
|
||||
String[] playername = new String[1];
|
||||
playername[0] = args[0];
|
||||
matchingPlayers = DataUtils.getMatchingDisplaynames(playername, sender, false);
|
||||
} else {
|
||||
matchingPlayers = DataUtils.getMatchingDisplaynames(args, sender, false);
|
||||
}
|
||||
args = DataFormatUtils.parseSearchArgs(args);
|
||||
HashMap<UUID, HashMap<String, DataPoint>> data = DataUtils.getTotalData(matchingPlayers);
|
||||
|
||||
Date refreshDate = new Date();
|
||||
HashMap<String, List<String[]>> dataLists = new HashMap<>();
|
||||
for (UUID key : data.keySet()) {
|
||||
OfflinePlayer p = getOfflinePlayer(key);
|
||||
HashMap<String, DataPoint> dataMap = data.get(key);
|
||||
if (!dataMap.isEmpty()) {
|
||||
dataMap = DataFormatUtils.removeExtraDataPointsSearch(dataMap, args);
|
||||
}
|
||||
if (dataMap.isEmpty()) {
|
||||
dataMap.put("ERR-NO RESULTS", new DataPoint("No results were found.", DataType.OTHER));
|
||||
plugin.logToFile("SEARCH-Results\nNo results were found for: " + p.getName() + Arrays.toString(args));
|
||||
}
|
||||
dataLists.put(p.getName(), DataFormatUtils.turnDataHashMapToSortedListOfArrays(dataMap));
|
||||
}
|
||||
|
||||
ChatColor operatorColor = ChatColor.DARK_GREEN;
|
||||
ChatColor textColor = ChatColor.GRAY;
|
||||
ChatColor operatorColor = Phrase.COLOR_MAIN.color();
|
||||
ChatColor textColor = Phrase.COLOR_SEC.color();
|
||||
|
||||
//header
|
||||
sender.sendMessage(textColor + "-- [" + operatorColor + "PLAN - Search results: took " + DataFormatUtils.formatTimeAmountSinceDate(refreshDate, new Date()) + textColor + "] --");
|
||||
sender.sendMessage(textColor + "-- [" + operatorColor + "PLAN - Search results: took " + FormatUtils.formatTimeAmountSinceDate(refreshDate, new Date()) + textColor + "] --");
|
||||
sender.sendMessage(operatorColor + "Results for: " + Arrays.toString(args));
|
||||
for (String playerName : dataLists.keySet()) {
|
||||
sender.sendMessage(textColor + "Matching player: " + playerName);
|
||||
for (String[] dataString : dataLists.get(playerName)) {
|
||||
sender.sendMessage("" + operatorColor + dataString[0].charAt(4) + dataString[0].toLowerCase().substring(5) + ": " + textColor + dataString[1]);
|
||||
}
|
||||
}
|
||||
if (dataLists.isEmpty()) {
|
||||
|
||||
sender.sendMessage(textColor + "Matching player: ");
|
||||
|
||||
if (false) {
|
||||
sender.sendMessage(operatorColor + "No results for " + textColor + Arrays.toString(args) + operatorColor + ".");
|
||||
}
|
||||
sender.sendMessage(textColor + "-- o --");
|
||||
|
@ -1,95 +0,0 @@
|
||||
package com.djrapitops.plan.command.utils;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
public class Analysis {
|
||||
|
||||
public static HashMap<String, DataPoint> analyze(HashMap<UUID, HashMap<String, DataPoint>> playerData) {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
HashMap<String, List<String>> playerDataLists = new HashMap<>();
|
||||
HashMap<String, DataType> dataTypes = new HashMap<>();
|
||||
// Ignore following keys (Strings, unprocessable or irrelevant data)
|
||||
DataType[] ignoreType = {DataType.DEPRECATED, DataType.STRING, DataType.LOCATION, DataType.LINK, DataType.HEATMAP,
|
||||
DataType.MAP, DataType.OTHER, DataType.DATE, DataType.TIME_TIMESTAMP};
|
||||
String[] ignore = {"ESS-HEALTH", "ESS-HUNGER", "ESS-XP LEVEL", "ESS-OPPED"};
|
||||
List<String> ignoreKeys = new ArrayList<>();
|
||||
List<DataType> ignoreTypes = new ArrayList<>();
|
||||
ignoreKeys.addAll(Arrays.asList(ignore));
|
||||
ignoreTypes.addAll(Arrays.asList(ignoreType));
|
||||
|
||||
// Turn playerData into Hashmap of Lists sorted by keys.
|
||||
playerData.keySet().parallelStream().forEach((key) -> {
|
||||
playerData.get(key).keySet().parallelStream()
|
||||
.filter((dataKey) -> !(ignoreKeys.contains(dataKey)))
|
||||
.map((dataKey) -> {
|
||||
if (dataTypes.get(dataKey) == null) {
|
||||
dataTypes.put(dataKey, playerData.get(key).get(dataKey).type());
|
||||
}
|
||||
return dataKey;
|
||||
})
|
||||
.filter((dataKey) -> !(ignoreTypes.contains(dataTypes.get(dataKey))))
|
||||
.map((dataKey) -> {
|
||||
if (playerDataLists.get(dataKey) == null) {
|
||||
playerDataLists.put(dataKey, new ArrayList<>());
|
||||
}
|
||||
return dataKey;
|
||||
})
|
||||
.forEach((dataKey) -> {
|
||||
playerDataLists.get(dataKey).add(playerData.get(key).get(dataKey).data());
|
||||
});
|
||||
});
|
||||
|
||||
HashMap<String, DataPoint> analyzedData = new HashMap<>();
|
||||
|
||||
// Analyze
|
||||
playerDataLists.keySet().parallelStream().forEach((dataKey) -> {
|
||||
DataType type = dataTypes.get(dataKey);
|
||||
if (type == DataType.AMOUNT
|
||||
|| type == DataType.AMOUNT_WITH_LETTERS
|
||||
|| type == DataType.AMOUNT_WITH_MAX
|
||||
|| type == DataType.PERCENT) {
|
||||
// Get a clean list of dataPoints with only numbers
|
||||
List<String> dataPoints = playerDataLists.get(dataKey);
|
||||
if (null != type) {
|
||||
switch (type) {
|
||||
case AMOUNT_WITH_LETTERS:
|
||||
dataPoints = AnalysisUtils.parseWLetters(playerDataLists.get(dataKey));
|
||||
break;
|
||||
case PERCENT:
|
||||
dataPoints = AnalysisUtils.parseWLetters(playerDataLists.get(dataKey));
|
||||
break;
|
||||
case AMOUNT_WITH_MAX:
|
||||
dataPoints = AnalysisUtils.parseWMax(playerDataLists.get(dataKey));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (type == DataType.PERCENT) {
|
||||
String averageAmount = AnalysisUtils.AmountAverage(dataPoints);
|
||||
analyzedData.put(dataKey, new DataPoint(averageAmount + "%", DataType.PERCENT));
|
||||
} else {
|
||||
String averageAmount = AnalysisUtils.AmountAverage(dataPoints);
|
||||
analyzedData.put(dataKey, new DataPoint(averageAmount, DataType.AMOUNT));
|
||||
// String highestAmount = AnalysisUtils.AmountHighest(dataPoints);
|
||||
// analyzedData.put(dataKey + " (HIGHEST)", new DataPoint(highestAmount, DataType.AMOUNT));
|
||||
}
|
||||
} else if (type == DataType.TIME) {
|
||||
String averageTime = AnalysisUtils.TimeAverage(playerDataLists.get(dataKey));
|
||||
analyzedData.put(dataKey, new DataPoint(averageTime, DataType.TIME));
|
||||
} else if (type == DataType.BOOLEAN) {
|
||||
String percent = AnalysisUtils.BooleanPercent(playerDataLists.get(dataKey));
|
||||
analyzedData.put(dataKey, new DataPoint(percent, DataType.PERCENT));
|
||||
}
|
||||
});
|
||||
return DataFormatUtils.formatAnalyzed(analyzedData);
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package com.djrapitops.plan.command.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class AnalysisUtils {
|
||||
|
||||
static String AmountAverage(List<String> dataPoints) {
|
||||
double sum = 0;
|
||||
|
||||
for (String dataPoint : dataPoints) {
|
||||
try {
|
||||
sum += Double.parseDouble(dataPoint);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return "" + (sum * 1.0 / dataPoints.size());
|
||||
}
|
||||
|
||||
static List<String> parseWLetters(List<String> dataPoints) {
|
||||
List<String> parsed = new ArrayList<>();
|
||||
dataPoints.parallelStream().forEach((dataPoint) -> {
|
||||
parsed.add(DataFormatUtils.removeLetters(dataPoint));
|
||||
});
|
||||
return parsed;
|
||||
}
|
||||
|
||||
static List<String> parseWMax(List<String> dataPoints) {
|
||||
List<String> parsed = new ArrayList<>();
|
||||
dataPoints.parallelStream().forEach((dataPoint) -> {
|
||||
parsed.add(dataPoint.split(" ")[0]);
|
||||
});
|
||||
return parsed;
|
||||
}
|
||||
|
||||
static String TimeAverage(List<String> dataPoints) {
|
||||
Long time = Long.parseLong("0");
|
||||
for (String dataPoint : dataPoints) {
|
||||
try {
|
||||
time += Long.parseLong(dataPoint);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return "" + (time / dataPoints.size());
|
||||
}
|
||||
|
||||
static String BooleanPercent(List<String> dataPoints) {
|
||||
int amount = 0;
|
||||
for (String dataPoint : dataPoints) {
|
||||
try {
|
||||
if (Boolean.parseBoolean(dataPoint)) {
|
||||
amount++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return "" + ((amount * 1.0 / dataPoints.size())*100)+"%";
|
||||
}
|
||||
|
||||
static String AmountHighest(List<String> dataPoints) {
|
||||
int highest = 0;
|
||||
for (String dataPoint : dataPoints) {
|
||||
try {
|
||||
int value = Integer.parseInt(dataPoint);
|
||||
if (value > highest) {
|
||||
highest = value;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return ""+highest;
|
||||
}
|
||||
|
||||
}
|
@ -2,134 +2,20 @@ package com.djrapitops.plan.command.utils;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
public class DataFormatUtils {
|
||||
|
||||
public static HashMap<String, DataPoint> removeExtraDataPoints(HashMap<String, DataPoint> data) throws NumberFormatException {
|
||||
Date dateNow = new Date();
|
||||
List<String> remove = new ArrayList<>();
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
data.keySet().parallelStream().forEach((key) -> {
|
||||
try {
|
||||
// Process OnTime empty data (returns -1 if empty)
|
||||
if (key.subSequence(0, 3).equals("ONT")) {
|
||||
if ((data.get(key)).data().equals("-1") || (data.get(key)).data().equals("-1.0")) {
|
||||
remove.add(key);
|
||||
}
|
||||
}
|
||||
// Process failed PlaceholderAPI requests (%string%)
|
||||
if (key.subSequence(0, 3).equals("PHA")) {
|
||||
if ((data.get(key)).data().contains("%")) {
|
||||
remove.add(key);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.logToFile("FORMAT-Remove\n" + e + "\n" + key);
|
||||
}
|
||||
});
|
||||
// Remove faulty data to prevent TOW-LAST LOGIN from being removed with empty data
|
||||
remove.parallelStream().forEach((removedKey) -> {
|
||||
data.remove(removedKey);
|
||||
});
|
||||
remove.clear();
|
||||
// Process Towny data (Empty returns date with 1970 for REGISTERED)
|
||||
if (data.get("TOW-REGISTERED") != null) {
|
||||
if (data.get("TOW-REGISTERED").data().contains("1970")) {
|
||||
remove.add("TOW-REGISTERED");
|
||||
remove.add("TOW-ONLINE");
|
||||
remove.add("TOW-LAST LOGIN");
|
||||
remove.add("TOW-OWNER OF");
|
||||
if (data.get("TOW-FRIENDS") != null) {
|
||||
remove.add("TOW-FRIENDS");
|
||||
remove.add("TOW-PLOT PERMS");
|
||||
remove.add("TOW-PLOT OPTIONS");
|
||||
}
|
||||
}
|
||||
}
|
||||
// If both OnTime and Towny data found, OnTime priority.
|
||||
if (data.get("ONT-LAST LOGIN") != null) {
|
||||
remove.add("TOW-LAST LOGIN");
|
||||
remove.add("PLG-LAST LOGIN");
|
||||
}
|
||||
// Remove faulty Towny data
|
||||
remove.parallelStream().forEach((removeKey) -> {
|
||||
data.remove(removeKey);
|
||||
});
|
||||
// Remove faulty Essentials SINCE data, reload turns data to 0
|
||||
String[] keysRemoveIfZero = {"ESS-ONLINE SINCE", "ESS-OFFLINE SINCE"};
|
||||
for (String key : keysRemoveIfZero) {
|
||||
if (data.get(key) != null) {
|
||||
if (data.get(key).data().equals("0")) {
|
||||
data.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove OnTime Total Votes if SuperbVote is present
|
||||
if (data.get("SVO-VOTES") != null) {
|
||||
if (data.get("ONT-TOTAL VOTES") != null) {
|
||||
data.remove("ONT-TOTAL VOTES");
|
||||
}
|
||||
}
|
||||
// Remove Bukkit uuid points if essentials present
|
||||
if (data.get("ESS-UUID") != null) {
|
||||
data.remove("BUK-UUID");
|
||||
}
|
||||
// Remove colliding Player Logger Data
|
||||
if (data.get("TOW-LAST LOGIN") != null) {
|
||||
data.remove("PLG-LAST LOGIN");
|
||||
}
|
||||
// Saved in case I need these later on in development before release.
|
||||
|
||||
data.keySet().parallelStream()
|
||||
.filter((key) -> (data.get(key).type() == DataType.DEPRECATED))
|
||||
.forEach((key) -> {
|
||||
remove.add(key);
|
||||
});
|
||||
remove.parallelStream().forEach((key) -> {
|
||||
data.remove(key);
|
||||
});
|
||||
// Format TimeStamps and Time Amounts
|
||||
for (String key : data.keySet()) {
|
||||
DataPoint dataPoint = data.get(key);
|
||||
if (null != dataPoint.type()) switch (dataPoint.type()) {
|
||||
case DATE:{
|
||||
String formatted = formatTimeStamp(dataPoint.data());
|
||||
dataPoint.setData(formatted);
|
||||
break;
|
||||
}
|
||||
case TIME:{
|
||||
String formatted = formatTimeAmount(dataPoint.data());
|
||||
dataPoint.setData(formatted);
|
||||
break;
|
||||
}
|
||||
case TIME_TIMESTAMP:{
|
||||
String formatted = formatTimeAmountSinceString(dataPoint.data(), dateNow);
|
||||
dataPoint.setData(formatted);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// Analysis data Formatting, will be updated after more analysis is added
|
||||
public static HashMap<String, DataPoint> formatAnalyzed(HashMap<String, DataPoint> analyzedData) {
|
||||
return removeExtraDataPoints(analyzedData);
|
||||
}
|
||||
|
||||
// Format Search Results
|
||||
public static HashMap<String, DataPoint> removeExtraDataPointsSearch(HashMap<String, DataPoint> dataMap, String[] args) {
|
||||
@Deprecated
|
||||
public static void removeExtraDataPointsSearch(HashMap<String, DataPoint> dataMap, String[] args) {
|
||||
if (args.length <= 1) {
|
||||
return removeExtraDataPoints(dataMap);
|
||||
}
|
||||
HashMap<String, DataPoint> returnMap = new HashMap<>();
|
||||
String errors = "FORMAT-SEARCH\n";
|
||||
@ -151,142 +37,9 @@ public class DataFormatUtils {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
plugin.logToFile(errors);
|
||||
}
|
||||
return removeExtraDataPoints(returnMap);
|
||||
}
|
||||
|
||||
// Replace certain items of search terms with plugin tags and remove playername if -p
|
||||
public static String[] parseSearchArgs(String[] args) {
|
||||
String[] aacTerms = {"aac", "advanced", "achiev"};
|
||||
String[] svoTerms = {"svo", "superb", "vote"};
|
||||
String[] ontTerms = {"ont", "onoime", "time"};
|
||||
String[] ecoTerms = {"eco", "money", "bal"};
|
||||
String[] towTerms = {"tow", "town", "nation", "res", "plot", "perm"};
|
||||
|
||||
List<String> aac = new ArrayList<>();
|
||||
List<String> svo = new ArrayList<>();
|
||||
List<String> ont = new ArrayList<>();
|
||||
List<String> eco = new ArrayList<>();
|
||||
List<String> tow = new ArrayList<>();
|
||||
|
||||
aac.addAll(Arrays.asList(aacTerms));
|
||||
svo.addAll(Arrays.asList(svoTerms));
|
||||
ont.addAll(Arrays.asList(ontTerms));
|
||||
eco.addAll(Arrays.asList(ecoTerms));
|
||||
tow.addAll(Arrays.asList(towTerms));
|
||||
String[] returnArray = new String[args.length];
|
||||
argloop:
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
for (String s : aac) {
|
||||
if (args[i].toLowerCase().contains(s)) {
|
||||
returnArray[i] = "AAC";
|
||||
continue argloop;
|
||||
}
|
||||
}
|
||||
for (String s : svo) {
|
||||
if (args[i].toLowerCase().contains(s)) {
|
||||
returnArray[i] = "SVO";
|
||||
continue argloop;
|
||||
}
|
||||
}
|
||||
for (String s : ont) {
|
||||
if (args[i].toLowerCase().contains(s)) {
|
||||
returnArray[i] = "ONT";
|
||||
continue argloop;
|
||||
}
|
||||
}
|
||||
for (String s : eco) {
|
||||
if (args[i].toLowerCase().contains(s)) {
|
||||
returnArray[i] = "ECO";
|
||||
continue argloop;
|
||||
}
|
||||
}
|
||||
for (String s : tow) {
|
||||
if (args[i].toLowerCase().contains(s)) {
|
||||
returnArray[i] = "TOW";
|
||||
continue argloop;
|
||||
}
|
||||
}
|
||||
returnArray[i] = args[i];
|
||||
if (args[i].equals("-p")) {
|
||||
returnArray[0] = args[0] + "_(Playername)";
|
||||
returnArray[i] = "---";
|
||||
}
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
// Creates a new Date with Epoch second and returns Date and Time String
|
||||
public static String formatTimeStamp(String string) throws NumberFormatException {
|
||||
long ms = Long.parseLong(string);
|
||||
Date sfd = new Date(ms);
|
||||
return ("" + sfd).substring(4, 19);
|
||||
}
|
||||
|
||||
// Formats Time Since (0 -> string)
|
||||
public static String formatTimeAmount(String string) throws NumberFormatException {
|
||||
long ms = Long.parseLong(string);
|
||||
return turnMsLongToString(ms);
|
||||
}
|
||||
|
||||
// Formats Time Difference String before -> Date now
|
||||
public static String formatTimeAmountSinceString(String string, Date now) throws NumberFormatException {
|
||||
long ms = Math.abs((now.toInstant().getEpochSecond() * 1000) - Long.parseLong(string));
|
||||
return turnMsLongToString(ms);
|
||||
}
|
||||
|
||||
// Formats Time Difference Date before -> Date now
|
||||
public static String formatTimeAmountSinceDate(Date before, Date now) throws NumberFormatException {
|
||||
long ms = Math.abs((now.toInstant().getEpochSecond() * 1000) - (before.toInstant().getEpochSecond() * 1000));
|
||||
return turnMsLongToString(ms);
|
||||
}
|
||||
|
||||
// Formats long in milliseconds into d:h:m:s string
|
||||
private static String turnMsLongToString(long ms) {
|
||||
String returnValue = "";
|
||||
long x = ms / 1000;
|
||||
long seconds = x % 60;
|
||||
x /= 60;
|
||||
long minutes = x % 60;
|
||||
x /= 60;
|
||||
long hours = x % 24;
|
||||
x /= 24;
|
||||
long days = x;
|
||||
if (days != 0) {
|
||||
returnValue += days + "d ";
|
||||
}
|
||||
if (hours != 0) {
|
||||
returnValue += hours + "h ";
|
||||
}
|
||||
if (minutes != 0) {
|
||||
returnValue += minutes + "m ";
|
||||
}
|
||||
if (seconds != 0) {
|
||||
returnValue += seconds + "s";
|
||||
}
|
||||
if (returnValue.isEmpty()) {
|
||||
returnValue += "< 1s";
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
// Removes letters from a string leaving only numbers and dots.
|
||||
public static String removeLetters(String dataPoint) {
|
||||
String numbers = "0123456789.";
|
||||
List<Character> numList = new ArrayList<>();
|
||||
char[] numberArray = numbers.toCharArray();
|
||||
for (char c : numberArray) {
|
||||
numList.add(c);
|
||||
}
|
||||
String returnString = "";
|
||||
for (int i = 0; i < dataPoint.length(); i++) {
|
||||
if (numList.contains(dataPoint.charAt(i))) {
|
||||
returnString += dataPoint.charAt(i);
|
||||
}
|
||||
}
|
||||
return returnString;
|
||||
}
|
||||
|
||||
// Sorts HashMap into Sorted List of Arrays
|
||||
@Deprecated
|
||||
public static List<String[]> turnDataHashMapToSortedListOfArrays(HashMap<String, DataPoint> data) {
|
||||
List<String[]> dataList = new ArrayList<>();
|
||||
data.keySet().stream().forEach((key) -> {
|
||||
|
@ -1,88 +0,0 @@
|
||||
package com.djrapitops.plan.command.utils;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
public class DataUtils {
|
||||
|
||||
// allData defined by -a argument in InspectCommand
|
||||
// returns data given by each Hook
|
||||
public static HashMap<String, DataPoint> getData(boolean allData, String playerName) {
|
||||
HashMap<String, DataPoint> data = new HashMap<>();
|
||||
return data;
|
||||
}
|
||||
|
||||
// Returns data HashMaps for all pplayers in a HashMap.
|
||||
public static HashMap<UUID, HashMap<String, DataPoint>> getTotalData(Set<OfflinePlayer> ofPlayers) {
|
||||
HashMap<UUID, HashMap<String, DataPoint>> playerData = new HashMap<>();
|
||||
return playerData;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static HashMap<String, DataPoint> analyze(HashMap<UUID, HashMap<String, DataPoint>> playerData) {
|
||||
return Analysis.analyze(playerData);
|
||||
}
|
||||
|
||||
public static String getPlayerDisplayname(String[] args, CommandSender sender) {
|
||||
String playerName = "";
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
if (args.length > 0) {
|
||||
if ((args[0].equals("-a")) || (args[0].equals("-r"))) {
|
||||
playerName = "ArgumentGivenError";
|
||||
plugin.log("No username given, returned empty username.");
|
||||
|
||||
plugin.logToFile(Phrase.ERROR_NO_USERNAME + args[0]);
|
||||
|
||||
} else if (sender.hasPermission("plan.inspect.other") || !(sender instanceof Player)) {
|
||||
playerName = args[0];
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Player player = plugin.getServer().getPlayer(UUIDFetcher.getUUIDOf(sender.getName()));
|
||||
playerName = player.getName();
|
||||
} catch (Exception e) {
|
||||
playerName = "ConsoleNotPlayerErr";
|
||||
}
|
||||
}
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public static Set<OfflinePlayer> getMatchingDisplaynames(String[] args, CommandSender sender, boolean all) {
|
||||
List<OfflinePlayer> players = new ArrayList<>();
|
||||
players.addAll(Arrays.asList(Bukkit.getOfflinePlayers()));
|
||||
Set<OfflinePlayer> matches = new HashSet<>();
|
||||
if (all) {
|
||||
matches.addAll(players);
|
||||
} else {
|
||||
List<String> searchTerms = new ArrayList<>();
|
||||
searchTerms.addAll(Arrays.asList(args));
|
||||
|
||||
players.parallelStream().forEach((p) -> {
|
||||
searchTerms.stream().filter((searchTerm) -> (p.getName().toLowerCase().contains(searchTerm.toLowerCase()))).forEach((_item) -> {
|
||||
matches.add(p);
|
||||
});
|
||||
});
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
public static Set<OfflinePlayer> getMatchingDisplaynames(boolean b) {
|
||||
return getMatchingDisplaynames(new String[0], null, true);
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package com.djrapitops.plan.command.utils;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import java.net.URL;
|
||||
import java.util.Scanner;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class MiscUtils {
|
||||
|
||||
/**
|
||||
* Checks the version and returns response String.
|
||||
*
|
||||
* @return String informing about status of plugins version.
|
||||
*/
|
||||
public static String checkVersion() {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
String cVersion;
|
||||
String lineWithVersion;
|
||||
try {
|
||||
URL githubUrl = new URL("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/src/plugin.yml");
|
||||
lineWithVersion = "";
|
||||
Scanner websiteScanner = new Scanner(githubUrl.openStream());
|
||||
while (websiteScanner.hasNextLine()) {
|
||||
String line = websiteScanner.nextLine();
|
||||
if (line.toLowerCase().contains("version")) {
|
||||
lineWithVersion = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String versionString = lineWithVersion.split(": ")[1];
|
||||
double newestVersionNumber = parseVersionDouble(versionString);
|
||||
cVersion = plugin.getDescription().getVersion();
|
||||
double currentVersionNumber = parseVersionDouble(cVersion);
|
||||
if (newestVersionNumber > currentVersionNumber) {
|
||||
return "New Version (" + versionString + ") is availible at https://www.spigotmc.org/resources/plan-player-analytics.32536/";
|
||||
} else {
|
||||
return "You're running the latest version";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.logToFile("Failed to compare versions.\n" + e);
|
||||
}
|
||||
return "Failed to get newest version number.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns the version string into a double
|
||||
*
|
||||
* @param versionString String - number format 1.1.1
|
||||
* @return parsed double - for example 1,11
|
||||
* @throws NumberFormatException When wrong format
|
||||
*/
|
||||
public static double parseVersionDouble(String versionString) throws NumberFormatException {
|
||||
String[] versionArray = versionString.split("\\.");
|
||||
if (versionArray.length != 3) {
|
||||
throw new NumberFormatException("Wrong format used");
|
||||
}
|
||||
double versionDouble = Double.parseDouble(versionArray[0] + "." + versionArray[1] + versionArray[2]);
|
||||
return versionDouble;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges multiple arrays into one.
|
||||
*
|
||||
* @param arrays String arrays that need to be combined
|
||||
* @return One array with contents of the multiple
|
||||
*/
|
||||
public static String[] mergeArrays(String[]... arrays) {
|
||||
int arraySize = 0;
|
||||
for (String[] array : arrays) {
|
||||
arraySize += array.length;
|
||||
}
|
||||
String[] result = new String[arraySize];
|
||||
int j = 0;
|
||||
for (String[] array : arrays) {
|
||||
for (String string : array) {
|
||||
result[j++] = string;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -91,15 +91,18 @@ public class UserData {
|
||||
}
|
||||
|
||||
public void addLocation(Location loc) {
|
||||
locations.add(loc);
|
||||
// locations.add(loc);
|
||||
location = loc;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addLocations(Collection<Location> addLocs) {
|
||||
/*
|
||||
locations.addAll(addLocs);
|
||||
if (!locations.isEmpty()) {
|
||||
location = locations.get(locations.size() - 1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void addNickname(String nick) {
|
||||
@ -141,10 +144,12 @@ public class UserData {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<Location> getLocations() {
|
||||
return locations;
|
||||
}
|
||||
|
@ -5,9 +5,12 @@ import com.djrapitops.plan.database.Database;
|
||||
import com.djrapitops.plan.data.*;
|
||||
import com.djrapitops.plan.data.handlers.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import static org.bukkit.Bukkit.getPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -32,10 +35,10 @@ public class DataCacheHandler {
|
||||
private int timesSaved;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
* Class Constructor.
|
||||
*
|
||||
* Creates the set of Handlers that will be used to modify UserData gets the
|
||||
* Database from the plugin
|
||||
* Creates the set of Handlers that will be used to modify UserData. Gets
|
||||
* the Database from the plugin. Registers Asyncronous Periodic Save Task
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
@ -57,28 +60,21 @@ public class DataCacheHandler {
|
||||
timesSaved = 0;
|
||||
|
||||
int minutes = plugin.getConfig().getInt("saveEveryXMinutes");
|
||||
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
if (minutes <= 0) {
|
||||
minutes = 5;
|
||||
}
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
saveHandlerDataToCache();
|
||||
saveCachedData();
|
||||
DataCacheHandler handler = plugin.getHandler();
|
||||
handler.saveHandlerDataToCache();
|
||||
handler.saveCachedData();
|
||||
if (timesSaved % 5 == 0) {
|
||||
clearCache();
|
||||
handler.clearCache();
|
||||
}
|
||||
timesSaved++;
|
||||
}
|
||||
}, 60 * 20 * minutes, 60 * 20 * minutes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells wether or not user has been saved to the database before
|
||||
*
|
||||
* @param uuid Players UUID
|
||||
* @return User's data is not in the database: true
|
||||
* @deprecated Moved to ActivityHandler
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isFirstTimeJoin(UUID uuid) {
|
||||
return activityHandler.isFirstTimeJoin(uuid);
|
||||
}).runTaskTimerAsynchronously(plugin, 60 * 20 * minutes, 60 * 20 * minutes);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,6 +91,7 @@ public class DataCacheHandler {
|
||||
if (cache) {
|
||||
if (dataCache.get(uuid) == null) {
|
||||
dataCache.put(uuid, db.getUserData(uuid));
|
||||
plugin.log("Added " + uuid.toString() + " to Cache.");
|
||||
}
|
||||
return dataCache.get(uuid);
|
||||
} else {
|
||||
@ -117,7 +114,7 @@ public class DataCacheHandler {
|
||||
* Saves all data in the cache to Database with AsyncTasks
|
||||
*/
|
||||
public void saveCachedData() {
|
||||
dataCache.keySet().parallelStream().forEach((uuid) -> {
|
||||
dataCache.keySet().stream().forEach((uuid) -> {
|
||||
saveCachedData(uuid);
|
||||
});
|
||||
saveServerData();
|
||||
@ -125,8 +122,7 @@ public class DataCacheHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all data in the cache to Database without AsyncTask (Disabled
|
||||
* plugins can't register tasks)
|
||||
* Saves all data in the cache to Database and closes the database down.
|
||||
*/
|
||||
public void saveCacheOnDisable() {
|
||||
dataCache.keySet().stream().forEach((uuid) -> {
|
||||
@ -135,6 +131,7 @@ public class DataCacheHandler {
|
||||
}
|
||||
});
|
||||
db.saveServerData(serverData);
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,14 +140,16 @@ public class DataCacheHandler {
|
||||
* @param uuid Player's UUID
|
||||
*/
|
||||
public void saveCachedData(UUID uuid) {
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (dataCache.get(uuid) != null) {
|
||||
db.saveUserData(uuid, dataCache.get(uuid));
|
||||
}
|
||||
this.cancel();
|
||||
}
|
||||
});
|
||||
}).runTaskAsynchronously(plugin);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,27 +158,43 @@ public class DataCacheHandler {
|
||||
* Data is saved on a new line with a long value matching current Date
|
||||
*/
|
||||
public void saveServerData() {
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
db.saveServerData(serverData);
|
||||
}
|
||||
});
|
||||
}).runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
private void saveHandlerDataToCache() {
|
||||
Bukkit.getServer().getOnlinePlayers().parallelStream().forEach((p) -> {
|
||||
saveHandlerDataToCache(p);
|
||||
});
|
||||
}
|
||||
|
||||
public void saveHandlerDataToCache(UUID uuid) {
|
||||
Player p = getPlayer(uuid);
|
||||
if (p != null) {
|
||||
if (p.isOnline()) {
|
||||
saveHandlerDataToCache(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveHandlerDataToCache(Player p) {
|
||||
UserData data = getCurrentData(p.getUniqueId());
|
||||
activityHandler.saveToCache(p, data);
|
||||
gamemodeTimesHandler.saveToCache(p, data);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all UserData from the HashMap
|
||||
*/
|
||||
public void clearCache() {
|
||||
dataCache.clear();
|
||||
Set<UUID> uuidSet = dataCache.keySet();
|
||||
for (UUID uuid : uuidSet) {
|
||||
clearFromCache(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,7 +204,21 @@ public class DataCacheHandler {
|
||||
*/
|
||||
public void clearFromCache(UUID uuid) {
|
||||
if (dataCache.get(uuid) != null) {
|
||||
if (dataCache.get(uuid).isAccessed()) {
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!dataCache.get(uuid).isAccessed()) {
|
||||
dataCache.remove(uuid);
|
||||
plugin.log("Cleared " + uuid.toString() + " from Cache. (Delay task)");
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}).runTaskTimer(plugin, 30 * 20, 30 * 20);
|
||||
} else {
|
||||
dataCache.remove(uuid);
|
||||
plugin.log("Cleared " + uuid.toString() + " from Cache.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.UserData;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -37,12 +38,12 @@ public class InspectCacheHandler {
|
||||
return;
|
||||
}
|
||||
cache.put(uuid, handler.getCurrentData(uuid, false));
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
clearFomCache(uuid);
|
||||
}
|
||||
}, 60 * 20 * 3);
|
||||
}).runTaskLater(plugin, 60 * 20 * 3);
|
||||
}
|
||||
|
||||
private void clearFomCache(UUID uuid) {
|
||||
@ -59,4 +60,7 @@ public class InspectCacheHandler {
|
||||
return cache.get(uuid);
|
||||
}
|
||||
|
||||
public HashMap<UUID, UserData> getCache() {
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
|
@ -7,18 +7,15 @@ import com.djrapitops.plan.data.UserData;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DemographicsHandler {
|
||||
|
||||
|
@ -5,28 +5,64 @@ import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.UserData;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class LocationHandler {
|
||||
|
||||
private final DataCacheHandler handler;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
* @param plugin Current instance of Plan
|
||||
* @param h Current instance of DataCacheHandler
|
||||
*/
|
||||
public LocationHandler(Plan plugin, DataCacheHandler h) {
|
||||
this.handler = h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds location to the UserData if it is not being saved.
|
||||
* @param uuid UUID of the matching Player
|
||||
* @param loc Location from the MoveEvent listener.
|
||||
*/
|
||||
public void addLocation(UUID uuid, Location loc) {
|
||||
handler.getCurrentData(uuid).addLocation(loc);
|
||||
UserData data = handler.getCurrentData(uuid);
|
||||
if (!data.isAccessed()) {
|
||||
data.addLocation(loc);
|
||||
} else {
|
||||
// TODO: Location scheduler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple locaitons to the UserData.
|
||||
* @param uuid UUID of the matching Player
|
||||
* @param locs The Locations that are added.
|
||||
*/
|
||||
public void addLocations(UUID uuid, Collection<Location> locs) {
|
||||
handler.getCurrentData(uuid).addLocations(locs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles QuitEvent by updating BedLocation.
|
||||
*
|
||||
* Uses OfflinePlayer to prevent null bedlocation.
|
||||
* @param event QuitEvent from Listener.
|
||||
* @param data UserData matching Player.
|
||||
*/
|
||||
public void handleLogOut(PlayerQuitEvent event, UserData data) {
|
||||
Player p = event.getPlayer();
|
||||
handler.getCurrentData(p.getUniqueId()).setBedLocation(p.getBedSpawnLocation());
|
||||
OfflinePlayer p = getOfflinePlayer(event.getPlayer().getUniqueId());
|
||||
Location bedSpawnLocation = p.getBedSpawnLocation();
|
||||
if (bedSpawnLocation == null) {
|
||||
return;
|
||||
}
|
||||
handler.getCurrentData(p.getUniqueId()).setBedLocation(bedSpawnLocation);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ public class RuleBreakingHandler {
|
||||
* @param data UserData matching Player
|
||||
*/
|
||||
public void handleKick(PlayerKickEvent event, UserData data) {
|
||||
Player player = event.getPlayer();
|
||||
data.setTimesKicked(data.getTimesKicked() + 1);
|
||||
data.setPlayTime(data.getPlayTime() + (new Date().getTime() - data.getLastPlayed()));
|
||||
data.setLastPlayed(new Date().getTime());
|
||||
|
@ -10,18 +10,31 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlanChatListener implements Listener {
|
||||
|
||||
private final Plan plugin;
|
||||
private final DataCacheHandler handler;
|
||||
private final DemographicsHandler demographicsHandler;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public PlanChatListener(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
handler = plugin.getHandler();
|
||||
demographicsHandler = handler.getDemographicsHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatEvent listener.
|
||||
* @param event Fired Event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
|
@ -89,7 +89,6 @@ public class PlanPlayerListener implements Listener {
|
||||
gmTimesH.handleLogOut(event, data);
|
||||
serverHandler.handleLogout();
|
||||
handler.saveCachedData(uuid);
|
||||
handler.clearFromCache(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,18 +10,33 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlanPlayerMoveListener implements Listener {
|
||||
|
||||
private final Plan plugin;
|
||||
private final DataCacheHandler handler;
|
||||
private final LocationHandler locationH;
|
||||
|
||||
/**
|
||||
* Class Consturctor.
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public PlanPlayerMoveListener(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
handler = plugin.getHandler();
|
||||
locationH = handler.getLocationHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* MoveEventListener.
|
||||
*
|
||||
* Adds location to UserData if the player has moved a block.
|
||||
*
|
||||
* @param event Event that is fired
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
@ -30,9 +45,10 @@ public class PlanPlayerMoveListener implements Listener {
|
||||
Player p = event.getPlayer();
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
if (from.getX() == to.getX() && from.getZ() == to.getZ()) {
|
||||
if (from.getBlockX() == to.getBlockX() && from.getBlockZ()== to.getBlockZ()) {
|
||||
return;
|
||||
}
|
||||
locationH.addLocation(p.getUniqueId(), to);
|
||||
Location savedLocation = to.getBlock().getLocation();
|
||||
locationH.addLocation(p.getUniqueId(), savedLocation);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public abstract class SQLDB extends Database {
|
||||
|
||||
@ -123,7 +125,8 @@ public abstract class SQLDB extends Database {
|
||||
|
||||
versionName = "plan_version";
|
||||
|
||||
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
// Maintains Connection.
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@ -134,7 +137,7 @@ public abstract class SQLDB extends Database {
|
||||
connection = getNewConnection();
|
||||
}
|
||||
}
|
||||
}, 60 * 20, 60 * 20);
|
||||
}).runTaskTimerAsynchronously(plugin, 60 * 20, 60 * 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,29 +164,29 @@ public abstract class SQLDB extends Database {
|
||||
query("CREATE TABLE IF NOT EXISTS " + userName + " ("
|
||||
+ userColumnID + " integer PRIMARY KEY, "
|
||||
+ userColumnUUID + " varchar(36) NOT NULL, "
|
||||
+ userColumnDemAge + " int NOT NULL, "
|
||||
+ userColumnDemAge + " integer NOT NULL, "
|
||||
+ userColumnDemGender + " varchar(8) NOT NULL, "
|
||||
+ userColumnDemGeoLocation + " varchar(50) NOT NULL, "
|
||||
+ userColumnLastGM + " varchar(15) NOT NULL, "
|
||||
+ userColumnLastGMSwapTime + " bigint NOT NULL, "
|
||||
+ userColumnPlayTime + " bigint NOT NULL, "
|
||||
+ userColumnLoginTimes + " int NOT NULL, "
|
||||
+ userColumnLoginTimes + " integer NOT NULL, "
|
||||
+ userColumnLastPlayed + " bigint NOT NULL"
|
||||
+ ")"
|
||||
);
|
||||
|
||||
/* Locations Removed from Build 2.0.0 for performance reasons.
|
||||
query("CREATE TABLE IF NOT EXISTS " + locationName + " ("
|
||||
+ locationColumnID + " integer PRIMARY KEY, "
|
||||
+ locationColumnUserID + " int NOT NULL, "
|
||||
+ locationColumnCoordinatesX + " int NOT NULL, "
|
||||
+ locationColumnCoordinatesZ + " int NOT NULL, "
|
||||
+ locationColumnUserID + " integer NOT NULL, "
|
||||
+ locationColumnCoordinatesX + " integer NOT NULL, "
|
||||
+ locationColumnCoordinatesZ + " integer NOT NULL, "
|
||||
+ locationColumnWorld + " varchar(64) NOT NULL, "
|
||||
+ "FOREIGN KEY(" + locationColumnUserID + ") REFERENCES " + userName + "(" + userColumnID + ")"
|
||||
+ ")"
|
||||
);
|
||||
|
||||
*/
|
||||
query("CREATE TABLE IF NOT EXISTS " + gamemodetimesName + " ("
|
||||
+ gamemodetimesColumnUserID + " int NOT NULL, "
|
||||
+ gamemodetimesColumnUserID + " integer NOT NULL, "
|
||||
+ gamemodetimesColumnSurvivalTime + " bigint NOT NULL, "
|
||||
+ gamemodetimesColumnCreativeTime + " bigint NOT NULL, "
|
||||
+ gamemodetimesColumnAdventureTime + " bigint NOT NULL, "
|
||||
@ -193,14 +196,14 @@ public abstract class SQLDB extends Database {
|
||||
);
|
||||
|
||||
query("CREATE TABLE IF NOT EXISTS " + ipsName + " ("
|
||||
+ ipsColumnUserID + " int NOT NULL, "
|
||||
+ ipsColumnUserID + " integer NOT NULL, "
|
||||
+ ipsColumnIP + " varchar(20) NOT NULL, "
|
||||
+ "FOREIGN KEY(" + ipsColumnUserID + ") REFERENCES " + userName + "(" + userColumnID + ")"
|
||||
+ ")"
|
||||
);
|
||||
|
||||
query("CREATE TABLE IF NOT EXISTS " + nicknamesName + " ("
|
||||
+ nicknamesColumnUserID + " int NOT NULL, "
|
||||
+ nicknamesColumnUserID + " integer NOT NULL, "
|
||||
+ nicknamesColumnNick + " varchar(30) NOT NULL, "
|
||||
+ "FOREIGN KEY(" + nicknamesColumnUserID + ") REFERENCES " + userName + "(" + userColumnID + ")"
|
||||
+ ")"
|
||||
@ -208,19 +211,19 @@ public abstract class SQLDB extends Database {
|
||||
|
||||
query("CREATE TABLE IF NOT EXISTS " + commanduseName + " ("
|
||||
+ commanduseColumnCommand + " varchar(20) NOT NULL, "
|
||||
+ commanduseColumnTimesUsed + " int NOT NULL"
|
||||
+ commanduseColumnTimesUsed + " integer NOT NULL"
|
||||
+ ")"
|
||||
);
|
||||
|
||||
query("CREATE TABLE IF NOT EXISTS " + serverdataName + " ("
|
||||
+ serverdataColumnDate + " bigint NOT NULL, "
|
||||
+ serverdataColumnNewPlayers + " int NOT NULL, "
|
||||
+ serverdataColumnPlayersOnline + " int NOT NULL"
|
||||
+ serverdataColumnNewPlayers + " integer NOT NULL, "
|
||||
+ serverdataColumnPlayersOnline + " integer NOT NULL"
|
||||
+ ")"
|
||||
);
|
||||
|
||||
query("CREATE TABLE IF NOT EXISTS " + versionName + " ("
|
||||
+ "version int NOT NULL"
|
||||
+ "version integer NOT NULL"
|
||||
+ ")"
|
||||
);
|
||||
|
||||
@ -292,10 +295,9 @@ public abstract class SQLDB extends Database {
|
||||
return getUserId(uuid.toString()) != -1;
|
||||
}
|
||||
|
||||
private int getUserId(String uuid) {
|
||||
public int getUserId(String uuid) {
|
||||
int userId = -1;
|
||||
try {
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT " + userColumnID + " FROM " + userName + " WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)");
|
||||
statement.setString(1, uuid);
|
||||
ResultSet set = statement.executeQuery();
|
||||
@ -316,9 +318,15 @@ public abstract class SQLDB extends Database {
|
||||
if (!wasSeenBefore(uuid)) {
|
||||
return null;
|
||||
}
|
||||
List<World> worldList = Bukkit.getServer().getWorlds();
|
||||
World defaultWorld = worldList.get(0);
|
||||
HashMap<String, World> worlds = new HashMap<>();
|
||||
for (World w : worldList) {
|
||||
worlds.put(w.getName(), w);
|
||||
}
|
||||
// Get the data
|
||||
try {
|
||||
UserData data = new UserData(getOfflinePlayer(uuid), new DemographicsData(), this);
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + userName + " WHERE UPPER(" + userColumnUUID + ") LIKE UPPER(?)");
|
||||
statement.setString(1, uuid.toString());
|
||||
ResultSet set = statement.executeQuery();
|
||||
@ -341,18 +349,22 @@ public abstract class SQLDB extends Database {
|
||||
statement.setString(1, userId);
|
||||
set = statement.executeQuery();
|
||||
|
||||
/* Locations Removed from Build 2.0.0 for performance reasons.
|
||||
List<Location> locations = new ArrayList<>();
|
||||
while (set.next()) {
|
||||
locations.add(new Location(Bukkit.getWorld(set.getString(locationColumnWorld)), set.getInt(locationColumnCoordinatesX), 0, set.getInt(locationColumnCoordinatesZ)));
|
||||
locations.add(new Location(worlds.get(set.getString(locationColumnWorld)), set.getInt(locationColumnCoordinatesX), 0, set.getInt(locationColumnCoordinatesZ)));
|
||||
}
|
||||
set.close();
|
||||
statement.close();
|
||||
data.addLocations(locations);
|
||||
|
||||
if (locations.isEmpty()) {
|
||||
plugin.logToFile("DATABASE-SQLDB\nLocations list is empty");
|
||||
data.setLocation(new Location(defaultWorld, 0, 0, 0));
|
||||
} else {
|
||||
data.setLocation(locations.get(locations.size() - 1));
|
||||
}
|
||||
*/
|
||||
data.setLocation(new Location(defaultWorld, 0, 0, 0));
|
||||
|
||||
statement = connection.prepareStatement("SELECT * FROM " + nicknamesName + " WHERE UPPER(" + nicknamesColumnUserID + ") LIKE UPPER(?)");
|
||||
statement.setString(1, userId);
|
||||
@ -395,11 +407,11 @@ public abstract class SQLDB extends Database {
|
||||
set.close();
|
||||
statement.close();
|
||||
data.setGmTimes(times);
|
||||
return data;
|
||||
} catch (SQLException e) {
|
||||
plugin.logToFile("DATABASE-SQLDB\n" + e + "\n" + e.getCause());
|
||||
return null;
|
||||
data = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -504,10 +516,12 @@ public abstract class SQLDB extends Database {
|
||||
statement.setString(1, uuid);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
/* Locations Removed from Build 2.0.0 for performance reasons.
|
||||
statement = connection.prepareStatement("DELETE FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)");
|
||||
statement.setString(1, "" + userId);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
*/
|
||||
statement = connection.prepareStatement("DELETE FROM " + nicknamesName + " WHERE UPPER(" + nicknamesColumnUserID + ") LIKE UPPER(?)");
|
||||
statement.setString(1, "" + userId);
|
||||
statement.execute();
|
||||
@ -528,7 +542,7 @@ public abstract class SQLDB extends Database {
|
||||
@Override
|
||||
public void saveUserData(UUID uuid, UserData data) {
|
||||
checkConnection();
|
||||
|
||||
data.setAccessing(true);
|
||||
int userId = getUserId(uuid.toString());
|
||||
try {
|
||||
int update = 0;
|
||||
@ -593,7 +607,7 @@ public abstract class SQLDB extends Database {
|
||||
statement.close();
|
||||
userId = getUserId(uuid.toString());
|
||||
}
|
||||
saveLocationList(userId, data.getLocations());
|
||||
// saveLocationList(userId, data.getLocations());
|
||||
saveNickList(userId, data.getNicknames());
|
||||
saveIPList(userId, data.getIps());
|
||||
saveGMTimes(userId, data.getGmTimes());
|
||||
@ -606,9 +620,12 @@ public abstract class SQLDB extends Database {
|
||||
+ "\n" + wasSeenBefore(uuid)
|
||||
);
|
||||
}
|
||||
data.setAccessing(false);
|
||||
}
|
||||
|
||||
@Deprecated // Locations Removed from Build 2.0.0 for performance reasons.
|
||||
public void saveLocationList(int userId, List<Location> locations) {
|
||||
/*
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement(
|
||||
"DELETE FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)");
|
||||
@ -616,27 +633,27 @@ public abstract class SQLDB extends Database {
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
Location location = locations.get(i);
|
||||
statement = connection.prepareStatement("INSERT INTO " + locationName + " ("
|
||||
for (Location location : locations) {
|
||||
PreparedStatement saveStatement = connection.prepareStatement("INSERT INTO " + locationName + " ("
|
||||
+ locationColumnUserID + ", "
|
||||
+ locationColumnCoordinatesX + ", "
|
||||
+ locationColumnCoordinatesZ + ", "
|
||||
+ locationColumnWorld
|
||||
+ ") VALUES (?, ?, ?, ?)");
|
||||
|
||||
statement.setInt(1, userId);
|
||||
statement.setInt(2, location.getBlockX());
|
||||
statement.setInt(3, location.getBlockZ());
|
||||
statement.setString(4, location.getWorld().getName());
|
||||
saveStatement.setInt(1, userId);
|
||||
saveStatement.setInt(2, (int) location.getBlockX());
|
||||
saveStatement.setInt(3, (int) location.getBlockZ());
|
||||
saveStatement.setString(4, location.getWorld().getName());
|
||||
|
||||
statement.execute();
|
||||
statement.close();
|
||||
saveStatement.execute();
|
||||
saveStatement.close();
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void saveNickList(int userId, HashSet<String> names) {
|
||||
@ -858,4 +875,161 @@ public abstract class SQLDB extends Database {
|
||||
public void setIpsColumnIP(String ipsColumnIP) {
|
||||
this.ipsColumnIP = ipsColumnIP;
|
||||
}
|
||||
|
||||
// Getters
|
||||
public boolean supportsModification() {
|
||||
return supportsModification;
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getLocationName() {
|
||||
return locationName;
|
||||
}
|
||||
|
||||
public String getServerdataName() {
|
||||
return serverdataName;
|
||||
}
|
||||
|
||||
public String getCommanduseName() {
|
||||
return commanduseName;
|
||||
}
|
||||
|
||||
public String getGamemodetimesName() {
|
||||
return gamemodetimesName;
|
||||
}
|
||||
|
||||
public String getNicknamesName() {
|
||||
return nicknamesName;
|
||||
}
|
||||
|
||||
public String getIpsName() {
|
||||
return ipsName;
|
||||
}
|
||||
|
||||
public String getUserColumnUUID() {
|
||||
return userColumnUUID;
|
||||
}
|
||||
|
||||
public String getUserColumnID() {
|
||||
return userColumnID;
|
||||
}
|
||||
|
||||
public String getUserColumnPlayTime() {
|
||||
return userColumnPlayTime;
|
||||
}
|
||||
|
||||
public String getUserColumnDemGeoLocation() {
|
||||
return userColumnDemGeoLocation;
|
||||
}
|
||||
|
||||
public String getUserColumnDemAge() {
|
||||
return userColumnDemAge;
|
||||
}
|
||||
|
||||
public String getUserColumnDemGender() {
|
||||
return userColumnDemGender;
|
||||
}
|
||||
|
||||
public String getUserColumnLastGM() {
|
||||
return userColumnLastGM;
|
||||
}
|
||||
|
||||
public String getUserColumnLastGMSwapTime() {
|
||||
return userColumnLastGMSwapTime;
|
||||
}
|
||||
|
||||
public String getUserColumnLoginTimes() {
|
||||
return userColumnLoginTimes;
|
||||
}
|
||||
|
||||
public String getUserColumnLastPlayed() {
|
||||
return userColumnLastPlayed;
|
||||
}
|
||||
|
||||
public String getLocationColumnUserID() {
|
||||
return locationColumnUserID;
|
||||
}
|
||||
|
||||
public String getLocationColumnID() {
|
||||
return locationColumnID;
|
||||
}
|
||||
|
||||
public String getLocationColumnCoordinatesX() {
|
||||
return locationColumnCoordinatesX;
|
||||
}
|
||||
|
||||
public String getLocationColumnCoordinatesZ() {
|
||||
return locationColumnCoordinatesZ;
|
||||
}
|
||||
|
||||
public String getLocationColumnWorld() {
|
||||
return locationColumnWorld;
|
||||
}
|
||||
|
||||
public String getServerdataColumnDate() {
|
||||
return serverdataColumnDate;
|
||||
}
|
||||
|
||||
public String getServerdataColumnPlayersOnline() {
|
||||
return serverdataColumnPlayersOnline;
|
||||
}
|
||||
|
||||
public String getServerdataColumnNewPlayers() {
|
||||
return serverdataColumnNewPlayers;
|
||||
}
|
||||
|
||||
public String getCommanduseColumnCommand() {
|
||||
return commanduseColumnCommand;
|
||||
}
|
||||
|
||||
public String getCommanduseColumnTimesUsed() {
|
||||
return commanduseColumnTimesUsed;
|
||||
}
|
||||
|
||||
public String getGamemodetimesColumnUserID() {
|
||||
return gamemodetimesColumnUserID;
|
||||
}
|
||||
|
||||
public String getGamemodetimesColumnSurvivalTime() {
|
||||
return gamemodetimesColumnSurvivalTime;
|
||||
}
|
||||
|
||||
public String getGamemodetimesColumnCreativeTime() {
|
||||
return gamemodetimesColumnCreativeTime;
|
||||
}
|
||||
|
||||
public String getGamemodetimesColumnAdventureTime() {
|
||||
return gamemodetimesColumnAdventureTime;
|
||||
}
|
||||
|
||||
public String getGamemodetimesColumnSpectatorTime() {
|
||||
return gamemodetimesColumnSpectatorTime;
|
||||
}
|
||||
|
||||
public String getNicknamesColumnUserID() {
|
||||
return nicknamesColumnUserID;
|
||||
}
|
||||
|
||||
public String getNicknamesColumnNick() {
|
||||
return nicknamesColumnNick;
|
||||
}
|
||||
|
||||
public String getIpsColumnUserID() {
|
||||
return ipsColumnUserID;
|
||||
}
|
||||
|
||||
public String getIpsColumnIP() {
|
||||
return ipsColumnIP;
|
||||
}
|
||||
|
||||
public String getVersionName() {
|
||||
return versionName;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.djrapitops.plan.utilities;
|
||||
|
||||
public class Analysis {
|
||||
|
||||
}
|
122
Plan Advanced/src/com/djrapitops/plan/utilities/FormatUtils.java
Normal file
122
Plan Advanced/src/com/djrapitops/plan/utilities/FormatUtils.java
Normal file
@ -0,0 +1,122 @@
|
||||
|
||||
package com.djrapitops.plan.utilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class FormatUtils {
|
||||
|
||||
// Formats Time Since (0 -> string)
|
||||
public static String formatTimeAmount(String string) throws NumberFormatException {
|
||||
long ms = Long.parseLong(string);
|
||||
return turnMsLongToString(ms);
|
||||
}
|
||||
|
||||
// Formats Time Difference Date before -> Date now
|
||||
public static String formatTimeAmountSinceDate(Date before, Date now) throws NumberFormatException {
|
||||
long ms = Math.abs((now.toInstant().getEpochSecond() * 1000) - (before.toInstant().getEpochSecond() * 1000));
|
||||
return turnMsLongToString(ms);
|
||||
}
|
||||
|
||||
// Creates a new Date with Epoch second and returns Date and Time String
|
||||
public static String formatTimeStamp(String string) throws NumberFormatException {
|
||||
long ms = Long.parseLong(string);
|
||||
Date sfd = new Date(ms);
|
||||
return ("" + sfd).substring(4, 19);
|
||||
}
|
||||
|
||||
// Formats Time Difference String before -> Date now
|
||||
public static String formatTimeAmountSinceString(String string, Date now) throws NumberFormatException {
|
||||
long ms = Math.abs((now.toInstant().getEpochSecond() * 1000) - Long.parseLong(string));
|
||||
return turnMsLongToString(ms);
|
||||
}
|
||||
|
||||
// Removes letters from a string leaving only numbers and dots.
|
||||
public static String removeLetters(String dataPoint) {
|
||||
String numbers = "0123456789.";
|
||||
List<Character> numList = new ArrayList<>();
|
||||
char[] numberArray = numbers.toCharArray();
|
||||
for (char c : numberArray) {
|
||||
numList.add(c);
|
||||
}
|
||||
String returnString = "";
|
||||
for (int i = 0; i < dataPoint.length(); i++) {
|
||||
if (numList.contains(dataPoint.charAt(i))) {
|
||||
returnString += dataPoint.charAt(i);
|
||||
}
|
||||
}
|
||||
return returnString;
|
||||
}
|
||||
|
||||
// Formats long in milliseconds into d:h:m:s string
|
||||
private static String turnMsLongToString(long ms) {
|
||||
String returnValue = "";
|
||||
long x = ms / 1000;
|
||||
long seconds = x % 60;
|
||||
x /= 60;
|
||||
long minutes = x % 60;
|
||||
x /= 60;
|
||||
long hours = x % 24;
|
||||
x /= 24;
|
||||
long days = x;
|
||||
if (days != 0) {
|
||||
returnValue += days + "d ";
|
||||
}
|
||||
if (hours != 0) {
|
||||
returnValue += hours + "h ";
|
||||
}
|
||||
if (minutes != 0) {
|
||||
returnValue += minutes + "m ";
|
||||
}
|
||||
if (seconds != 0) {
|
||||
returnValue += seconds + "s";
|
||||
}
|
||||
if (returnValue.isEmpty()) {
|
||||
returnValue += "< 1s";
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns the version string into a double
|
||||
*
|
||||
* @param versionString String - number format 1.1.1
|
||||
* @return parsed double - for example 1,11
|
||||
* @throws NumberFormatException When wrong format
|
||||
*/
|
||||
public static double parseVersionDouble(String versionString) throws NumberFormatException {
|
||||
String[] versionArray = versionString.split("\\.");
|
||||
if (versionArray.length != 3) {
|
||||
throw new NumberFormatException("Wrong format used");
|
||||
}
|
||||
double versionDouble = Double.parseDouble(versionArray[0] + "." + versionArray[1] + versionArray[2]);
|
||||
return versionDouble;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges multiple arrays into one.
|
||||
*
|
||||
* @param arrays String arrays that need to be combined
|
||||
* @return One array with contents of the multiple
|
||||
*/
|
||||
public static String[] mergeArrays(String[]... arrays) {
|
||||
int arraySize = 0;
|
||||
for (String[] array : arrays) {
|
||||
arraySize += array.length;
|
||||
}
|
||||
String[] result = new String[arraySize];
|
||||
int j = 0;
|
||||
for (String[] array : arrays) {
|
||||
for (String string : array) {
|
||||
result[j++] = string;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class MiscUtils {
|
||||
|
||||
/**
|
||||
* Checks the version and returns response String.
|
||||
*
|
||||
* @return String informing about status of plugins version.
|
||||
*/
|
||||
public static String checkVersion() {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
String cVersion;
|
||||
String lineWithVersion;
|
||||
try {
|
||||
URL githubUrl = new URL("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/src/plugin.yml");
|
||||
lineWithVersion = "";
|
||||
Scanner websiteScanner = new Scanner(githubUrl.openStream());
|
||||
while (websiteScanner.hasNextLine()) {
|
||||
String line = websiteScanner.nextLine();
|
||||
if (line.toLowerCase().contains("version")) {
|
||||
lineWithVersion = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String versionString = lineWithVersion.split(": ")[1];
|
||||
double newestVersionNumber = FormatUtils.parseVersionDouble(versionString);
|
||||
cVersion = plugin.getDescription().getVersion();
|
||||
double currentVersionNumber = FormatUtils.parseVersionDouble(cVersion);
|
||||
if (newestVersionNumber > currentVersionNumber) {
|
||||
return "New Version (" + versionString + ") is availible at https://www.spigotmc.org/resources/plan-player-analytics.32536/";
|
||||
} else {
|
||||
return "You're running the latest version";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.logToFile("Failed to compare versions.\n" + e);
|
||||
}
|
||||
return "Failed to get newest version number.";
|
||||
}
|
||||
|
||||
public static String getPlayerDisplayname(String[] args, CommandSender sender) {
|
||||
String playerName = "";
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
if (args.length > 0) {
|
||||
if ((args[0].equals("-a")) || (args[0].equals("-r"))) {
|
||||
playerName = "ArgumentGivenError";
|
||||
plugin.log("No username given, returned empty username.");
|
||||
plugin.logToFile(Phrase.ERROR_NO_USERNAME + args[0]);
|
||||
} else if (sender.hasPermission("plan.inspect.other") || !(sender instanceof Player)) {
|
||||
playerName = args[0];
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Player player = plugin.getServer().getPlayer(UUIDFetcher.getUUIDOf(sender.getName()));
|
||||
playerName = player.getName();
|
||||
} catch (Exception e) {
|
||||
playerName = "ConsoleNotPlayerErr";
|
||||
}
|
||||
}
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public static Set<OfflinePlayer> getMatchingDisplaynames(String search) {
|
||||
List<OfflinePlayer> players = new ArrayList<>();
|
||||
players.addAll(Arrays.asList(Bukkit.getOfflinePlayers()));
|
||||
Set<OfflinePlayer> matches = new HashSet<>();
|
||||
players.parallelStream().filter((OfflinePlayer player) -> (player.getName().contains(search))).forEach((OfflinePlayer player) -> {
|
||||
matches.add(player);
|
||||
});
|
||||
return matches;
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
package com.djrapitops.plan.utilities;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.json.simple.JSONArray;
|
@ -1,4 +1,5 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: com.djrapitops.plan.Plan
|
||||
version: 2.0.0
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.HashMap;
|
||||
import me.clip.placeholderapi.external.EZPlaceholderHook;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlaceholderAPIHook extends EZPlaceholderHook {
|
||||
|
||||
private final PlanLite plan;
|
||||
|
||||
public PlaceholderAPIHook(PlanLite plan) {
|
||||
super(plan, "plan");
|
||||
this.plan = plan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, String identifier) {
|
||||
HashMap<String, DataPoint> data = DataFormatUtils.removeExtraDataPoints(DataUtils.getData(true, player.getDisplayName()));
|
||||
String key = identifier.toUpperCase();
|
||||
if (Optional.of(data.get(key)).isPresent()) {
|
||||
return data.get(key).data();
|
||||
} else {
|
||||
plan.logToFile("PlaceholderAPIHOOK\nFailed to get data\n" + player.getDisplayName() + "\n" + key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hook() {
|
||||
return super.hook();
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
package com.djrapitops.plan;
|
||||
package com.djrapitops.planlite;
|
||||
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.command.commands.AnalyzeCommand;
|
||||
import com.djrapitops.plan.command.commands.DebugCommand;
|
||||
import com.djrapitops.plan.command.commands.HelpCommand;
|
||||
import com.djrapitops.plan.command.commands.InfoCommand;
|
||||
import com.djrapitops.plan.command.commands.InspectCommand;
|
||||
import com.djrapitops.plan.command.commands.ReloadCommand;
|
||||
import com.djrapitops.plan.command.commands.SearchCommand;
|
||||
import com.djrapitops.plan.command.utils.MiscUtils;
|
||||
import com.djrapitops.planlite.command.CommandType;
|
||||
import com.djrapitops.planlite.command.SubCommand;
|
||||
import com.djrapitops.planlite.command.commands.AnalyzeCommand;
|
||||
import com.djrapitops.planlite.command.commands.DebugCommand;
|
||||
import com.djrapitops.planlite.command.commands.HelpCommand;
|
||||
import com.djrapitops.planlite.command.commands.InfoCommand;
|
||||
import com.djrapitops.planlite.command.commands.InspectCommand;
|
||||
import com.djrapitops.planlite.command.commands.ReloadCommand;
|
||||
import com.djrapitops.planlite.command.commands.SearchCommand;
|
||||
import com.djrapitops.planlite.command.utils.MiscUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
@ -79,20 +79,20 @@ public class PlanCommand implements CommandExecutor {
|
||||
|
||||
if (!sender.hasPermission(command.getPermission())) {
|
||||
// Phrase.NO_PERMISSION_FOR_COMMAND.sendWithPrefix( sender );
|
||||
sender.sendMessage(ChatColor.RED + "[PLAN] You do not have the required permmission.");
|
||||
sender.sendMessage(ChatColor.RED + "[PlanLite] You do not have the required permmission.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (console && args.length < 2 && command.getCommandType() == CommandType.CONSOLE_WITH_ARGUMENTS) {
|
||||
// Phrase.COMMAND_NEEDS_ARGUMENTS.sendWithPrefix( sender );
|
||||
sender.sendMessage(ChatColor.RED + "[PLAN] Command requires arguments.");
|
||||
sender.sendMessage(ChatColor.RED + "[PlanLite] Command requires arguments.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (console && command.getCommandType() == CommandType.PLAYER) {
|
||||
// Phrase.COMMAND_NOT_CONSOLE.sendWithPrefix( sender, commandLabel );
|
||||
sender.sendMessage(ChatColor.RED + "[PLAN] This command can be only used as a player.");
|
||||
sender.sendMessage(ChatColor.RED + "[PlanLite] This command can be only used as a player.");
|
||||
|
||||
return true;
|
||||
}
|
@ -1,19 +1,18 @@
|
||||
package com.djrapitops.plan;
|
||||
package com.djrapitops.planlite;
|
||||
|
||||
import com.djrapitops.plan.api.API;
|
||||
import com.djrapitops.plan.command.hooks.EssentialsHook;
|
||||
import com.djrapitops.plan.command.hooks.FactionsHook;
|
||||
import com.djrapitops.plan.command.hooks.OnTimeHook;
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.command.hooks.PlaceholderAPIHook;
|
||||
import com.djrapitops.plan.command.hooks.SuperbVoteHook;
|
||||
import com.djrapitops.plan.command.hooks.TownyHook;
|
||||
import com.djrapitops.plan.command.hooks.VaultHook;
|
||||
import com.djrapitops.plan.command.hooks.AdvancedAchievementsHook;
|
||||
import com.djrapitops.plan.command.hooks.BukkitDataHook;
|
||||
import com.djrapitops.plan.command.hooks.PlayerLoggerHook;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.plan.command.utils.MiscUtils;
|
||||
import com.djrapitops.planlite.api.API;
|
||||
import com.djrapitops.planlite.command.hooks.EssentialsHook;
|
||||
import com.djrapitops.planlite.command.hooks.FactionsHook;
|
||||
import com.djrapitops.planlite.command.hooks.OnTimeHook;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.command.hooks.SuperbVoteHook;
|
||||
import com.djrapitops.planlite.command.hooks.TownyHook;
|
||||
import com.djrapitops.planlite.command.hooks.VaultHook;
|
||||
import com.djrapitops.planlite.command.hooks.AdvancedAchievementsHook;
|
||||
import com.djrapitops.planlite.command.hooks.BukkitDataHook;
|
||||
import com.djrapitops.planlite.command.hooks.PlayerLoggerHook;
|
||||
import com.djrapitops.planlite.command.utils.DataUtils;
|
||||
import com.djrapitops.planlite.command.utils.MiscUtils;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -49,23 +48,12 @@ public class PlanLite extends JavaPlugin {
|
||||
|
||||
getConfig().options().copyDefaults(true);
|
||||
|
||||
getConfig().options().header("Plan Config\n"
|
||||
getConfig().options().header("PlanLite Config\n"
|
||||
+ "debug - Errors are saved in errorlog.txt when they occur\n"
|
||||
+ "visible - Plugin's data is accessable with /plan inspect command"
|
||||
);
|
||||
|
||||
saveConfig();
|
||||
|
||||
try {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
PlaceholderAPIHook phAHook = new PlaceholderAPIHook(this);
|
||||
phAHook.hook();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logError("Failed to create placeholders.yml");
|
||||
logToFile("Failed to create placeholders.yml\n" + e);
|
||||
}
|
||||
|
||||
List<String> hookFail = hookInit();
|
||||
if (this.hooks.isEmpty()) {
|
||||
logError("Found no plugins to get data (or config set to false). Disabling plugin..");
|
||||
@ -86,9 +74,9 @@ public class PlanLite extends JavaPlugin {
|
||||
for (String string : hookFail) {
|
||||
failedMsg += ChatColor.RED + string + " ";
|
||||
}
|
||||
Bukkit.getServer().getConsoleSender().sendMessage("[Plan] " + loadedMsg);
|
||||
Bukkit.getServer().getConsoleSender().sendMessage("[PlanLite] " + loadedMsg);
|
||||
if (!hookFail.isEmpty()) {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage("[Plan] " + failedMsg);
|
||||
Bukkit.getServer().getConsoleSender().sendMessage("[PlanLite] " + failedMsg);
|
||||
}
|
||||
|
||||
getCommand("plan").setExecutor(new PlanCommand(this));
|
||||
@ -108,7 +96,7 @@ public class PlanLite extends JavaPlugin {
|
||||
plugins.parallelStream().forEach((pluginName) -> {
|
||||
if (getConfig().getBoolean("visible." + pluginName.toLowerCase())) {
|
||||
try {
|
||||
String className = "com.djrapitops.plan.command.hooks." + pluginName + "Hook";
|
||||
String className = "com.djrapitops.planlite.command.hooks." + pluginName + "Hook";
|
||||
Class<Hook> clazz = (Class<Hook>) Hook.class.forName(className);
|
||||
this.hooks.put(pluginName, clazz.getConstructor(PlanLite.class).newInstance(this));
|
||||
} catch (Exception | NoClassDefFoundError e) {
|
@ -19,7 +19,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
package com.djrapitops.planlite;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.json.simple.JSONArray;
|
@ -1,8 +1,8 @@
|
||||
package com.djrapitops.plan.api;
|
||||
package com.djrapitops.planlite.api;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.planlite.command.utils.DataUtils;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
package com.djrapitops.plan.api;
|
||||
package com.djrapitops.planlite.api;
|
||||
|
||||
public class DataPoint {
|
||||
private String data;
|
@ -1,5 +1,5 @@
|
||||
|
||||
package com.djrapitops.plan.api;
|
||||
package com.djrapitops.planlite.api;
|
||||
|
||||
public enum DataType {
|
||||
STRING, // Any preformatted data & words
|
@ -1,7 +1,7 @@
|
||||
|
||||
package com.djrapitops.plan.api;
|
||||
package com.djrapitops.planlite.api;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface Hook {
|
@ -1,4 +1,4 @@
|
||||
package com.djrapitops.plan.command;
|
||||
package com.djrapitops.planlite.command;
|
||||
|
||||
public enum CommandType
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package com.djrapitops.plan.command;
|
||||
package com.djrapitops.planlite.command;
|
||||
|
||||
//import com.djrapitops.plan.Phrase;
|
||||
import org.bukkit.command.Command;
|
@ -1,12 +1,12 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
package com.djrapitops.planlite.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.plan.command.utils.Analysis;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.command.CommandType;
|
||||
import com.djrapitops.planlite.command.SubCommand;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.planlite.command.utils.DataUtils;
|
||||
import com.djrapitops.planlite.command.utils.Analysis;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
@ -1,9 +1,9 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
package com.djrapitops.planlite.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.command.CommandType;
|
||||
import com.djrapitops.planlite.command.SubCommand;
|
||||
import com.djrapitops.planlite.command.utils.DataUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -21,7 +21,7 @@ public class DebugCommand extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
if (!plugin.getConfig().getBoolean("debug")) {
|
||||
sender.sendMessage(ChatColor.RED+"[Plan] Debug disabled in config");
|
||||
sender.sendMessage(ChatColor.RED+"[PlanLite] Debug disabled in config");
|
||||
return true;
|
||||
}
|
||||
String[] commands = {"plan", "plan info", "plan reload", "plan inspect",
|
||||
@ -30,7 +30,7 @@ public class DebugCommand extends SubCommand {
|
||||
for (String command : commands) {
|
||||
Bukkit.dispatchCommand(sender, command);
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN+"[Plan] Debug successful, possible errors written in file.");
|
||||
sender.sendMessage(ChatColor.GREEN+"[PlanLite] Debug successful, possible errors written in file.");
|
||||
return true;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
package com.djrapitops.planlite.command.commands;
|
||||
|
||||
//import com.djrapitops.plan.Phrase;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.PlanCommand;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.PlanCommand;
|
||||
import com.djrapitops.planlite.command.CommandType;
|
||||
import com.djrapitops.planlite.command.SubCommand;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
@ -1,9 +1,9 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
package com.djrapitops.planlite.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.command.utils.MiscUtils;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.command.CommandType;
|
||||
import com.djrapitops.planlite.command.SubCommand;
|
||||
import com.djrapitops.planlite.command.utils.MiscUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
@ -1,16 +1,16 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
package com.djrapitops.planlite.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.command.CommandType;
|
||||
import com.djrapitops.planlite.command.SubCommand;
|
||||
import com.djrapitops.planlite.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.planlite.command.utils.DataUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
@ -1,10 +1,9 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
package com.djrapitops.planlite.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.command.hooks.PlaceholderAPIHook;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.command.CommandType;
|
||||
import com.djrapitops.planlite.command.SubCommand;
|
||||
import com.djrapitops.planlite.command.utils.DataUtils;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
@ -1,12 +1,12 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
package com.djrapitops.planlite.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.command.CommandType;
|
||||
import com.djrapitops.plan.command.SubCommand;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.plan.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.plan.command.utils.DataUtils;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.command.CommandType;
|
||||
import com.djrapitops.planlite.command.SubCommand;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import com.djrapitops.planlite.command.utils.DataFormatUtils;
|
||||
import com.djrapitops.planlite.command.utils.DataUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
@ -1,10 +1,10 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
package com.djrapitops.planlite.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import com.hm.achievement.AdvancedAchievements;
|
||||
import com.hm.achievement.category.MultipleAchievements;
|
||||
import com.hm.achievement.category.NormalAchievements;
|
@ -1,13 +1,12 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
package com.djrapitops.planlite.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.HashMap;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
@ -1,10 +1,10 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
package com.djrapitops.planlite.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
@ -1,10 +1,10 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
package com.djrapitops.planlite.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import java.util.HashMap;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
package com.djrapitops.planlite.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import java.util.HashMap;
|
||||
import me.edge209.OnTime.OnTimeAPI;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
@ -1,10 +1,10 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
package com.djrapitops.planlite.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
package com.djrapitops.planlite.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import io.minimum.minecraft.superbvote.SuperbVote;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
@ -1,10 +1,10 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
package com.djrapitops.planlite.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import static com.palmergames.bukkit.towny.TownyFormatter.getFormattedName;
|
||||
import static com.palmergames.bukkit.towny.TownyFormatter.lastOnlineFormat;
|
@ -1,10 +1,10 @@
|
||||
package com.djrapitops.plan.command.hooks;
|
||||
package com.djrapitops.planlite.command.hooks;
|
||||
|
||||
import com.djrapitops.plan.api.Hook;
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.api.Hook;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.OfflinePlayer;
|
@ -1,9 +1,9 @@
|
||||
package com.djrapitops.plan.command.utils;
|
||||
package com.djrapitops.planlite.command.utils;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.command.hooks.AdvancedAchievementsHook;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.command.hooks.AdvancedAchievementsHook;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
@ -1,4 +1,4 @@
|
||||
package com.djrapitops.plan.command.utils;
|
||||
package com.djrapitops.planlite.command.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -1,8 +1,8 @@
|
||||
package com.djrapitops.plan.command.utils;
|
||||
package com.djrapitops.planlite.command.utils;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.plan.api.DataType;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import com.djrapitops.planlite.api.DataType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
@ -1,8 +1,8 @@
|
||||
package com.djrapitops.plan.command.utils;
|
||||
package com.djrapitops.planlite.command.utils;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.plan.UUIDFetcher;
|
||||
import com.djrapitops.plan.api.DataPoint;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import com.djrapitops.planlite.UUIDFetcher;
|
||||
import com.djrapitops.planlite.api.DataPoint;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
@ -1,6 +1,6 @@
|
||||
package com.djrapitops.plan.command.utils;
|
||||
package com.djrapitops.planlite.command.utils;
|
||||
|
||||
import com.djrapitops.plan.PlanLite;
|
||||
import com.djrapitops.planlite.PlanLite;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
@ -1,5 +1,5 @@
|
||||
name: PlanLite
|
||||
main: com.djrapitops.plan.PlanLite
|
||||
main: com.djrapitops.planlite.PlanLite
|
||||
version: 1.6.3
|
||||
|
||||
commands:
|
||||
|
Loading…
Reference in New Issue
Block a user