[2.6.0-DEV] Moved Tester to new Project, Removed PlanLite features, Bugfixes

- Fixed many cases where database might try to save empty data.
(Possible fixes to causes of #13 #8)
- Fixed partially ConcurrentModificationException causes by adding
uData.setAccessing to SaveMultipleUserData
- Sped up Graph creation with functional operations
This commit is contained in:
Rsl1122 2017-02-15 22:20:18 +02:00
parent 249724c162
commit 595adfa740
40 changed files with 104 additions and 2860 deletions

View File

@ -16,8 +16,7 @@
* If not it should be visible on the distribution page.
* Or here
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/licence.yml
*/
*/
package main.java.com.djrapitops.plan;
import java.io.File;
@ -65,7 +64,6 @@ Add -n argument for nickname search.
public class Plan extends JavaPlugin {
private API api;
private PlanLiteHook planLiteHook;
private DataCacheHandler handler;
private InspectCacheHandler inspectCache;
private AnalysisCacheHandler analysisCache;
@ -108,7 +106,6 @@ public class Plan extends JavaPlugin {
return;
}
hookPlanLite();
this.handler = new DataCacheHandler(this);
this.inspectCache = new InspectCacheHandler(this);
this.analysisCache = new AnalysisCacheHandler(this);
@ -132,8 +129,7 @@ public class Plan extends JavaPlugin {
startAnalysisRefreshTask(analysisRefreshMinutes);
}
} else if (!(Settings.SHOW_ALTERNATIVE_IP.isTrue())
|| (Settings.USE_ALTERNATIVE_UI.isTrue()
&& planLiteHook.isEnabled())) {
|| (Settings.USE_ALTERNATIVE_UI.isTrue())) {
consoleSender.sendMessage(Phrase.PREFIX + "" + Phrase.ERROR_NO_DATA_VIEW);
}
if (!Settings.SHOW_ALTERNATIVE_IP.isTrue() && getServer().getIp().isEmpty()) {
@ -143,17 +139,6 @@ public class Plan extends JavaPlugin {
log(Phrase.ENABLED + "");
}
/**
* Hooks PlanLite for UI and/or additional data.
*/
public void hookPlanLite() {
try {
planLiteHook = new PlanLiteHook(this);
} catch (NoClassDefFoundError | Exception e) {
}
}
/**
* Disables the plugin.
*
@ -295,13 +280,6 @@ public class Plan extends JavaPlugin {
return handler;
}
/**
* @return PlanLiteHook
*/
public PlanLiteHook getPlanLiteHook() {
return planLiteHook;
}
/**
* @return the Database
*/

View File

@ -1,134 +0,0 @@
package main.java.com.djrapitops.plan;
import com.djrapitops.planlite.PlanLite;
import com.djrapitops.planlite.api.API;
import com.djrapitops.planlite.api.DataPoint;
import java.util.HashMap;
import java.util.Set;
import main.java.com.djrapitops.plan.data.handlers.PlanLiteDataPushHook;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/**
*
* @author Rsl1122
*/
public class PlanLiteHook {
private PlanLite planLite;
private Plan plugin;
private API planLiteApi;
private boolean enabled;
/**
* Class Constructor.
*
* Attempts to hook to PlanLite, if not present sets enabled to false
*
* @param plugin
*/
public PlanLiteHook(Plan plugin) {
this.plugin = plugin;
if (Settings.PLANLITE_ENABLED.isTrue()) {
if (Bukkit.getPluginManager().isPluginEnabled("PlanLite")) {
try {
this.planLite = getPlugin(PlanLite.class);
if (planLite == null) {
throw new Exception(Phrase.ERROR_PLANLITE.toString());
}
enabled = true;
planLiteApi = planLite.getAPI();
if (Settings.USE_ALTERNATIVE_UI.isTrue()) {
planLite.addExtraHook("Plan", new PlanLiteDataPushHook(plugin));
}
} catch (Exception e) {
}
} else {
enabled = false;
}
} else {
enabled = false;
}
}
/**
* @return Set of the Enabled hooks names.
*/
public Set<String> getEnabledHooksNames() {
return planLite.getHooks().keySet();
}
/**
* Used to get data from PlanLite for the Analysis & Inspect.
*
* @param playerName Name of the player.
* @param dataPoint true (use datapoint system)
* @return The data about the player.
*/
public HashMap<String, DataPoint> getData(String playerName, boolean dataPoint) {
return planLiteApi.getData(playerName, dataPoint);
}
/**
* Used to get data from PlanLite for the Analysis & Inspect.
*
* @param playerName Name of the player.
* @param dataPoint true (use datapoint system)
* @return The data about the player.
*/
public HashMap<String, DataPoint> getAllData(String playerName, boolean dataPoint) {
return planLiteApi.getAllData(playerName, dataPoint);
}
/**
* @return true if the config setting is true & PlanLite is installed.
*/
public boolean isEnabled() {
return enabled;
}
/**
* Passes commands to PlanLite.
*
* Used by /plan lite
* @param sender
* @param cmd
* @param commandLabel
* @param args
* @return
*/
public boolean passCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
return planLite.getPlanCommand().onCommand(sender, cmd, commandLabel, args);
}
/**
* @return true if server has towny
*/
public boolean hasTowny() {
return getEnabledHooksNames().contains("Towny");
}
/**
* @return true if server has factions
*/
public boolean hasFactions() {
return getEnabledHooksNames().contains("Factions");
}
/**
* @return true if server has superbvote
*/
public boolean hasSuperbVote() {
return getEnabledHooksNames().contains("SuperbVote");
}
/**
* @return true if server has vault
*/
public boolean hasVault() {
return getEnabledHooksNames().contains("Vault");
}
}

View File

@ -12,8 +12,7 @@ public enum Settings {
ANALYSIS_REFRESH_ON_ENABLE("Settings.Cache.AnalysisCache.RefreshAnalysisCacheOnEnable"),
ANALYSIS_LOG_TO_CONSOLE("Settings.Analysis.LogProgressOnConsole"),
SHOW_ALTERNATIVE_IP("Settings.WebServer.ShowAlternativeServerIP"),
USE_ALTERNATIVE_UI("Settings.PlanLite.UseAsAlternativeUI"),
PLANLITE_ENABLED("Settings.PlanLite.Enabled"),
USE_ALTERNATIVE_UI("Settings.UseTextUI"),
GATHERLOCATIONS("Settings.Data.GatherLocations"),
SECURITY_IP_UUID("Settings.WebServer.Security.DisplayIPsAndUUIDs"),
// Integer

View File

@ -4,7 +4,6 @@ import com.djrapitops.planlite.UUIDFetcher;
import java.util.Date;
import java.util.UUID;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanLiteHook;
import main.java.com.djrapitops.plan.data.AnalysisData;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.ui.DataRequestHandler;
@ -18,7 +17,6 @@ import main.java.com.djrapitops.plan.utilities.FormatUtils;
public class API {
private Plan plugin;
private PlanLiteHook hook;
/**
* Class Construcor.
@ -27,7 +25,6 @@ public class API {
*/
public API(Plan plugin) {
this.plugin = plugin;
hook = plugin.getPlanLiteHook();
}
/**

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanLiteHook;
import main.java.com.djrapitops.plan.command.commands.*;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import org.bukkit.command.Command;
@ -37,12 +36,6 @@ public class PlanCommand implements CommandExecutor {
commands.add(new InfoCommand(plugin));
commands.add(new ReloadCommand(plugin));
commands.add(new ManageCommand(plugin));
PlanLiteHook planLiteHook = plugin.getPlanLiteHook();
if (planLiteHook != null) {
if (planLiteHook.isEnabled()) {
commands.add(new LiteCommand(plugin));
}
}
}
/**

View File

@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.command.commands;
import java.util.UUID;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanLiteHook;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.command.CommandType;
import main.java.com.djrapitops.plan.command.SubCommand;
@ -59,10 +58,9 @@ public class InspectCommand extends SubCommand {
final boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
if (!useAlternativeIP) {
PlanLiteHook planLiteHook = plugin.getPlanLiteHook();
if (Settings.USE_ALTERNATIVE_UI.isTrue() && planLiteHook.isEnabled()) {
if (Settings.USE_ALTERNATIVE_UI.isTrue()) {
sender.sendMessage(Phrase.CMD_PASS_PLANLITE + "");
planLiteHook.passCommand(sender, cmd, commandLabel, args);
//TODO CREATE TEXT UI
} else {
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_INSPECT + "");
}

View File

@ -1,38 +0,0 @@
package main.java.com.djrapitops.plan.command.commands;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanLiteHook;
import main.java.com.djrapitops.plan.command.CommandType;
import main.java.com.djrapitops.plan.command.SubCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
/**
*
* @author Rsl1122
*/
public class LiteCommand extends SubCommand {
private Plan plugin;
private PlanLiteHook hook;
/**
* Subcommand Constructor.
*
* @param plugin Current instance of Plan
*/
public LiteCommand(Plan plugin) {
super("lite", "plan.?", "Use PlanLite Commands", CommandType.CONSOLE, "<planlite command>");
this.plugin = plugin;
this.hook = plugin.getPlanLiteHook();
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (hook.isEnabled()) {
return hook.passCommand(sender, cmd, commandLabel, args);
}
return false;
}
}

View File

@ -43,9 +43,6 @@ public class AnalysisData {
private long totalmobkills;
private long totaldeaths;
private boolean planLiteEnabled;
private PlanLiteAnalyzedData planLiteData;
/**
* Class constructor.
*
@ -69,41 +66,6 @@ public class AnalysisData {
this.joinleaver = joinleaver;
}
/**
* @return true if PlanLite was enabled at the time of Analysis
*/
public boolean isPlanLiteEnabled() {
return planLiteEnabled;
}
/**
* @param planLiteEnabled true if PlanLite was enabled at the time of
* Analysis
*/
public void setPlanLiteEnabled(boolean planLiteEnabled) {
this.planLiteEnabled = planLiteEnabled;
}
/**
* Retrieve the PlanLiteAnalyzedData.
*
* null if planLiteEnabled = false
*
* @return Seperate object used to save PlanLiteData
*/
public PlanLiteAnalyzedData getPlanLiteData() {
return planLiteData;
}
/**
* Set the PlanLiteAnalyzedData.
*
* @param planLiteData Seperate object used to save PlanLiteData
*/
public void setPlanLiteData(PlanLiteAnalyzedData planLiteData) {
this.planLiteData = planLiteData;
}
/**
* @return HTML String of the Month Activity graph
*/

View File

@ -1,80 +0,0 @@
package main.java.com.djrapitops.plan.data;
import java.util.HashMap;
/**
*
* @author Rsl1122
*/
public class PlanLiteAnalyzedData {
private HashMap<String, Integer> townMap;
private HashMap<String, Integer> factionMap;
private int totalVotes;
private int totalMoney;
/**
* Class Constructor.
*
* All data has to be set to avoid NPE.
*/
public PlanLiteAnalyzedData() {
}
/**
* @return Map of Town names with residents inside them.
*/
public HashMap<String, Integer> getTownMap() {
return townMap;
}
/**
* @param townMap Map of Town names with residents inside them.
*/
public void setTownMap(HashMap<String, Integer> townMap) {
this.townMap = townMap;
}
/**
* @return Map of Faction names with players inside them.
*/
public HashMap<String, Integer> getFactionMap() {
return factionMap;
}
/**
* @param factionMap Map of Faction names with players inside them.
*/
public void setFactionMap(HashMap<String, Integer> factionMap) {
this.factionMap = factionMap;
}
/**
* @return Amount of votes the server has recieved.
*/
public int getTotalVotes() {
return totalVotes;
}
/**
* @param totalVotes Amount of votes the server has recieved.
*/
public void setTotalVotes(int totalVotes) {
this.totalVotes = totalVotes;
}
/**
* @return Amount of money that is in the economy.
*/
public int getTotalMoney() {
return totalMoney;
}
/**
* @param totalMoney Amount of money that is in the economy.
*/
public void setTotalMoney(int totalMoney) {
this.totalMoney = totalMoney;
}
}

View File

@ -1,208 +0,0 @@
package main.java.com.djrapitops.plan.data;
/**
*
* @author Rsl1122
*/
public class PlanLitePlayerData {
private boolean towny;
private boolean factions;
private boolean superbVote;
private boolean vault;
private String town;
private String friends;
private String plotPerms;
private String plotOptions;
private String faction;
private int votes;
private double money;
/**
* Class Constructor.
*
* All data has to be set to avoid NPE
*/
public PlanLitePlayerData() {
}
/**
* @param towny Is Towny installed?
*/
public void setTowny(boolean towny) {
this.towny = towny;
}
/**
* @param factions Is Factions installed?
*/
public void setFactions(boolean factions) {
this.factions = factions;
}
/**
* @param superbVote Is SuperbVote installed?
*/
public void setSuperbVote(boolean superbVote) {
this.superbVote = superbVote;
}
/**
* @param vault Is Vault installed?
*/
public void setVault(boolean vault) {
this.vault = vault;
}
/**
* @param town Name of town player is resident in (Towny)
*/
public void setTown(String town) {
this.town = town;
}
/**
* @param friends Friends of player (Towny)
*/
public void setFriends(String friends) {
this.friends = friends;
}
/**
* @param plotPerms Perms of player (Towny)
*/
public void setPlotPerms(String plotPerms) {
this.plotPerms = plotPerms;
}
/**
* @param plotOptions Options of player (Towny)
*/
public void setPlotOptions(String plotOptions) {
this.plotOptions = plotOptions;
}
/**
* @param faction Faction the player is in
*/
public void setFaction(String faction) {
this.faction = faction;
}
/**
* @param votes How many votes the player has
*/
public void setVotes(int votes) {
this.votes = votes;
}
/**
* @param money How much money the player has
*/
public void setMoney(double money) {
this.money = money;
}
/**
* @return Is Towny installed?
*/
public boolean hasTowny() {
return towny;
}
/**
* @return Is Factions installed?
*/
public boolean hasFactions() {
return factions;
}
/**
* @return Is Superbvote installed?
*/
public boolean hasSuperbVote() {
return superbVote;
}
/**
* @return Is Vault installed?
*/
public boolean hasVault() {
return vault;
}
/**
* @return Town player is resident in
*/
public String getTown() {
if (towny) {
return town;
}
return "";
}
/**
* @return Friends of player (towny)
*/
public String getFriends() {
if (towny) {
return friends;
}
return "";
}
/**
* @return Perms of player (towny)
*/
public String getPlotPerms() {
if (towny) {
return plotPerms;
}
return "";
}
/**
* @return Options of player (towny)
*/
public String getPlotOptions() {
if (towny) {
return plotOptions;
}
return "";
}
/**
* @return Faction of player
*/
public String getFaction() {
if (factions) {
return faction;
}
return "";
}
/**
* @return How many times player has voted, -1 if superbvote not installed
*/
public int getVotes() {
if (superbVote) {
return votes;
}
return -1;
}
/**
* @return How much money player has. -1 if vault not installed
*/
public double getMoney() {
if (vault) {
return money;
}
return -1;
}
}

View File

@ -39,9 +39,6 @@ public class UserData {
private List<KillData> playerKills;
private int deaths;
private boolean planLiteFound;
private PlanLitePlayerData planLiteData;
private String name;
private boolean isOnline;
@ -176,21 +173,6 @@ public class UserData {
}
// Getters -------------------------------------------------------------
public boolean isPlanLiteFound() {
return planLiteFound;
}
public void setPlanLiteFound(boolean planLiteFound) {
this.planLiteFound = planLiteFound;
}
public PlanLitePlayerData getPlanLiteData() {
return planLiteData;
}
public void setPlanLiteData(PlanLitePlayerData planLiteData) {
this.planLiteData = planLiteData;
}
public UUID getUuid() {
return uuid;

View File

@ -35,7 +35,6 @@ public class DataCacheHandler {
private final RuleBreakingHandler ruleBreakingHandler;
private final HashMap<String, Integer> commandUse;
private final CommandUseHandler commandUseHandler;
private final PlanLiteHandler planLiteHandler;
private final KillHandler killHandler;
private final SessionHandler sessionHandler;
private final Database db;
@ -64,7 +63,6 @@ public class DataCacheHandler {
ruleBreakingHandler = new RuleBreakingHandler(plugin, this);
commandUse = db.getCommandUse();
commandUseHandler = new CommandUseHandler(commandUse);
planLiteHandler = new PlanLiteHandler(plugin);
newPlayerCreator = new NewPlayerCreator(plugin, this);
killHandler = new KillHandler(plugin);
sessionHandler = new SessionHandler(plugin);
@ -120,9 +118,6 @@ public class DataCacheHandler {
if (dataCache.get(uuid) == null) {
UserData uData = db.getUserData(uuid);
if (uData != null) {
if (uData.getPlanLiteData() == null) {
getPlanLiteHandler().handleEvents(uData.getName(), uData);
}
dataCache.put(uuid, uData);
plugin.log(Phrase.ADD_TO_CACHE.parse(uuid.toString()));
}
@ -133,11 +128,6 @@ public class DataCacheHandler {
return dataCache.get(uuid);
}
UserData uData = db.getUserData(uuid);
if (uData != null) {
if (uData.getPlanLiteData() == null) {
getPlanLiteHandler().handleEvents(uData.getName(), uData);
}
}
return uData;
}
}
@ -369,13 +359,6 @@ public class DataCacheHandler {
return gamemodeTimesHandler;
}
/**
* @return Current instance of PlanLiteHandler
*/
public PlanLiteHandler getPlanLiteHandler() {
return planLiteHandler;
}
public KillHandler getKillHandler() {
return killHandler;
}

View File

@ -1,127 +0,0 @@
package main.java.com.djrapitops.plan.data.handlers;
import com.djrapitops.planlite.api.DataPoint;
import java.util.HashMap;
import java.util.Set;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanLiteHook;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.PlanLitePlayerData;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent;
/**
*
* @author Rsl1122
*/
public class PlanLiteHandler {
private Plan plugin;
private PlanLiteHook hook;
private DataCacheHandler handler;
private boolean enabled;
/**
* Class Constructor.
*
* @param plugin Current instance of Plan
*/
public PlanLiteHandler(Plan plugin) {
this.plugin = plugin;
PlanLiteHook planLiteHook = plugin.getPlanLiteHook();
if (planLiteHook != null) {
enabled = planLiteHook.isEnabled();
} else {
enabled = false;
}
if (enabled) {
hook = planLiteHook;
}
}
/**
* Handles the player login by getting the data of the player from planlite.
*
* @param event LoginEvent
* @param data UserData for the player.
*/
public void handleLogin(PlayerJoinEvent event, UserData data) {
if (!enabled) {
data.setPlanLiteFound(false);
return;
}
Player p = event.getPlayer();
String playerName = p.getName();
handleEvents(playerName, data);
}
/**
* Places the data to the PlanLitePlayerData and saves that to UserData.
*
* If PlanLite is used as UI the additional data of PlanLite has to be
* disabled to avoid stackoverflow.
*
* @param playerName Name of the Player
* @param data UserData for the player.
*/
public void handleEvents(String playerName, UserData data) {
if (!enabled) {
return;
}
Set<String> enabledHooks = hook.getEnabledHooksNames();
PlanLitePlayerData plData = new PlanLitePlayerData();
// Avoiding StackOverFlow
if (Settings.USE_ALTERNATIVE_UI.isTrue()
&& plugin.getPlanLiteHook().isEnabled()) {
data.setPlanLiteFound(false);
plData.setTowny(false);
plData.setFactions(false);
plData.setSuperbVote(false);
plData.setVault(false);
data.setPlanLiteData(plData);
} else {
HashMap<String, DataPoint> liteData = hook.getAllData(playerName, true);
plData.setTowny(enabledHooks.contains("Towny"));
plData.setFactions(enabledHooks.contains("Factions"));
plData.setSuperbVote(enabledHooks.contains("SuperbVote"));
plData.setVault(enabledHooks.contains("Vault"));
if (plData.hasTowny()) {
DataPoint town = liteData.get("TOW-TOWN");
plData.setTown((town != null) ? town.data() : Phrase.NOT_IN_TOWN+"");
DataPoint friends = liteData.get("TOW-FRIENDS");
plData.setFriends((town != null) ? friends.data() : "");
DataPoint perms = liteData.get("TOW-PLOT PERMS");
plData.setPlotPerms((perms != null) ? perms.data() : "");
DataPoint options = liteData.get("TOW-PLOT OPTIONS");
plData.setPlotOptions((options != null) ? options.data() : "");
}
if (plData.hasFactions()) {
DataPoint faction = liteData.get("FAC-FACTION");
plData.setFaction((faction != null) ? faction.data() : Phrase.NOT_IN_FAC+"");
}
if (plData.hasSuperbVote()) {
try {
plData.setVotes(Integer.parseInt(liteData.get("SVO-VOTES").data()));
} catch (Exception e) {
plData.setVotes(0);
}
}
if (plData.hasVault()) {
try {
plData.setMoney(Double.parseDouble(FormatUtils.removeLetters(liteData.get("ECO-BALANCE").data())));
} catch (Exception e) {
plData.setMoney(0);
}
}
data.setPlanLiteFound(true);
data.setPlanLiteData(plData);
}
}
}

View File

@ -28,7 +28,6 @@ public class PlanPlayerListener implements Listener {
private final LocationHandler locationH;
private final DemographicsHandler demographicH;
private final RuleBreakingHandler rulebreakH;
private final PlanLiteHandler planLiteH;
private final CommandUseHandler serverHandler;
/**
@ -48,7 +47,6 @@ public class PlanPlayerListener implements Listener {
demographicH = handler.getDemographicsHandler();
locationH = handler.getLocationHandler();
rulebreakH = handler.getRuleBreakingHandler();
planLiteH = handler.getPlanLiteHandler();
serverHandler = handler.getServerDataHandler();
}
@ -73,7 +71,6 @@ public class PlanPlayerListener implements Listener {
basicInfoH.handleLogin(event, data);
gmTimesH.handleLogin(event, data);
demographicH.handleLogin(event, data);
planLiteH.handleLogin(event, data);
(new BukkitRunnable() {
@Override
public void run() {

View File

@ -415,6 +415,9 @@ public abstract class SQLDB extends Database {
@Override
public void saveCommandUse(HashMap<String, Integer> data) {
if (data.isEmpty()) {
return;
}
try {
PreparedStatement statement = connection.prepareStatement(
"DELETE FROM " + commanduseName);
@ -695,6 +698,9 @@ public abstract class SQLDB extends Database {
@Override
public void saveMultipleUserData(List<UserData> data) {
if (data.isEmpty()) {
return;
}
List<UserData> saveLast = new ArrayList<>();
String uSQL = "UPDATE " + userName + " SET "
+ userColumnDemAge + "=?, "
@ -713,6 +719,7 @@ public abstract class SQLDB extends Database {
PreparedStatement uStatement = connection.prepareStatement(uSQL);
boolean commitRequired = false;
for (UserData uData : data) {
uData.setAccessing(true);
int userId = getUserId(uData.getUuid().toString());
if (userId == -1) {
saveLast.add(uData);
@ -738,8 +745,10 @@ public abstract class SQLDB extends Database {
uStatement.addBatch();
} catch (SQLException | NullPointerException e) {
saveLast.add(uData);
uData.setAccessing(false);
continue;
}
uData.setAccessing(false);
commitRequired = true;
}
uStatement.executeBatch();
@ -750,6 +759,7 @@ public abstract class SQLDB extends Database {
connection.setAutoCommit(true);
data.removeAll(saveLast);
for (UserData uData : data) {
uData.setAccessing(true);
int userId = getUserId(uData.getUuid().toString());
saveLocationList(userId, uData.getLocations());
saveNickList(userId, uData.getNicknames(), uData.getLastNick());
@ -758,6 +768,7 @@ public abstract class SQLDB extends Database {
savePlayerKills(userId, uData.getPlayerKills());
connection.setAutoCommit(true);
saveGMTimes(userId, uData.getGmTimes());
uData.setAccessing(false);
}
for (UserData userData : saveLast) {
saveUserData(userData.getUuid(), userData);
@ -857,6 +868,9 @@ public abstract class SQLDB extends Database {
}
public void saveLocationList(int userId, List<Location> locations) {
if (locations.isEmpty()) {
return;
}
try {
PreparedStatement deleteStatement = connection.prepareStatement(
"DELETE FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)");
@ -897,6 +911,9 @@ public abstract class SQLDB extends Database {
}
public void saveNickList(int userId, HashSet<String> names, String lastNick) {
if (names.isEmpty()) {
return;
}
try {
PreparedStatement statement = connection.prepareStatement(
"DELETE FROM " + nicknamesName + " WHERE UPPER(" + nicknamesColumnUserID + ") LIKE UPPER(?)");
@ -929,6 +946,9 @@ public abstract class SQLDB extends Database {
}
public void saveSessionList(int userId, List<SessionData> sessions) {
if (sessions.isEmpty()) {
return;
}
try {
PreparedStatement statement = connection.prepareStatement(
"DELETE FROM " + sessionName + " WHERE UPPER(" + sessionColumnUserID + ") LIKE UPPER(?)");
@ -961,6 +981,9 @@ public abstract class SQLDB extends Database {
}
public void savePlayerKills(int userId, List<KillData> kills) {
if (kills.isEmpty()) {
return;
}
try {
PreparedStatement statement = connection.prepareStatement(
"DELETE FROM " + killsName + " WHERE UPPER(" + killsColumnKillerUserID + ") LIKE UPPER(?)");
@ -995,6 +1018,9 @@ public abstract class SQLDB extends Database {
}
public void saveIPList(int userId, HashSet<InetAddress> ips) {
if (ips.isEmpty()) {
return;
}
try {
PreparedStatement statement = connection.prepareStatement(
"DELETE FROM " + ipsName + " WHERE UPPER(" + ipsColumnUserID + ") LIKE UPPER(?)");
@ -1026,6 +1052,9 @@ public abstract class SQLDB extends Database {
}
public void saveGMTimes(int userId, HashMap<GameMode, Long> gamemodeTimes) {
if (gamemodeTimes.isEmpty()) {
return;
}
try {
PreparedStatement statement = connection.prepareStatement(
"DELETE FROM " + gamemodetimesName + " WHERE UPPER(" + gamemodetimesColumnUserID + ") LIKE UPPER(?)");

View File

@ -1,5 +1,6 @@
package main.java.com.djrapitops.plan.ui;
import java.io.FileNotFoundException;
import java.util.UUID;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.UserData;
@ -47,14 +48,18 @@ public class DataRequestHandler {
* @return The html
*/
public String getDataHtml(UUID uuid) {
UserData data = inspectCache.getFromCache(uuid);
if (data == null) {
return "<h1>404 Data was not found in cache</h1>";
try {
UserData data = inspectCache.getFromCache(uuid);
if (data == null) {
return "<h1>404 Data was not found in cache</h1>";
}
return HtmlUtils.replacePlaceholders(
HtmlUtils.getHtmlStringFromResource("player.html"),
PlaceholderUtils.getInspectReplaceRules(data)
);
} catch (FileNotFoundException ex) {
return "<h1>404 player.html was not found. </h1>";
}
return HtmlUtils.replacePlaceholders(
HtmlUtils.getHtmlStringFromResource("player.html"),
PlaceholderUtils.getInspectReplaceRules(data)
);
}
/**
@ -63,13 +68,17 @@ public class DataRequestHandler {
* @return the html
*/
public String getAnalysisHtml() {
if (!analysisCache.isCached()) {
return "<h1>404 Data was not found in cache</h1>";
try {
if (!analysisCache.isCached()) {
return "<h1>404 Data was not found in cache</h1>";
}
return HtmlUtils.replacePlaceholders(
HtmlUtils.getHtmlStringFromResource("analysis.html"),
PlaceholderUtils.getAnalysisReplaceRules(analysisCache.getData())
);
} catch (FileNotFoundException ex) {
return "<h1>404 analysis.html was not found</h1>";
}
return HtmlUtils.replacePlaceholders(
HtmlUtils.getHtmlStringFromResource("analysis.html"),
PlaceholderUtils.getAnalysisReplaceRules(analysisCache.getData())
);
}
/**

View File

@ -11,6 +11,8 @@ import com.googlecode.charts4j.XYLine;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.SessionData;
@ -32,10 +34,22 @@ public class PlayerActivityGraphCreator {
*/
public static String createChart(List<SessionData> sessionData, long scale) {
List<Long> sessionStarts = new ArrayList<>();
List<Long> sessionEnds = new ArrayList<>();
sessionData.parallelStream().forEach(
(session) -> {
long now = new Date().toInstant().getEpochSecond() * (long) 1000;
long nowMinusScale = now - scale;
CopyOnWriteArrayList<Long> sessionStarts = new CopyOnWriteArrayList<>();
CopyOnWriteArrayList<Long> sessionEnds = new CopyOnWriteArrayList<>();
CopyOnWriteArrayList<SessionData> s = new CopyOnWriteArrayList(sessionData);
// List<Long> sessionStarts = sessionData.parallelStream()
// .filter((session) -> (session.getSessionStart() > nowMinusScale))
// .map(SessionData::getSessionStart)
// .collect(Collectors.toList());
// List<Long> sessionEnds = sessionData.parallelStream()
// .filter((session) -> (session.getSessionStart() > nowMinusScale))
// .map(SessionData::getSessionEnd)
// .collect(Collectors.toList());
s.parallelStream()
.filter((session) -> (session.getSessionStart() > nowMinusScale))
.forEach((session) -> {
sessionEnds.add(session.getSessionEnd());
sessionStarts.add(session.getSessionStart());
});
@ -47,29 +61,26 @@ public class PlayerActivityGraphCreator {
Plan plugin = getPlugin(Plan.class);
int maxPlayers = plugin.getHandler().getMaxPlayers();
long now = new Date().toInstant().getEpochSecond() * (long) 1000;
long nowMinusScale = now - scale;
int lastPValue = 0;
int lastSavedPValue = -1;
long lastSaveI = 0;
for (long i = nowMinusScale; i <= now; i += 1000) {
final long j = i;
if (sessionStarts.contains(i)) {
int amount = 0;
for (long start : sessionStarts) {
if (start == i) {
amount++;
}
}
amount = sessionStarts.parallelStream()
.filter((start) -> (start == j))
.map((_item) -> 1)
.reduce(amount, Integer::sum);
lastPValue += amount;
}
if (sessionEnds.contains(i)) {
int amount = 0;
for (long end : sessionEnds) {
if (end == i) {
amount++;
}
}
amount = sessionEnds.parallelStream()
.filter((end) -> (end == j))
.map((_item) -> 1)
.reduce(amount, Integer::sum);
lastPValue -= amount;
}
Double scaledDateValue = ((i - nowMinusScale) * 1.0 / scale) * 100;

View File

@ -12,6 +12,10 @@ import main.java.com.djrapitops.plan.utilities.comparators.MapComparator;
* @author Rsl1122
*/
public class SortedTableCreator {
public static String createCommandUseTable(HashMap<String, Integer> commandUse) {
return "Not Implemented yet";
}
public static String createTableOutOfHashMap(HashMap<String, Integer> commandUse) {
return createTableOutOfHashMap(commandUse, 50);

View File

@ -8,10 +8,8 @@ import java.util.Set;
import java.util.UUID;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanLiteHook;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.AnalysisData;
import main.java.com.djrapitops.plan.data.PlanLiteAnalyzedData;
import main.java.com.djrapitops.plan.data.RawAnalysisData;
import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.data.UserData;
@ -90,13 +88,6 @@ public class Analysis {
log(Phrase.ANALYSIS_BEGIN_ANALYSIS + "");
AnalysisData analysisData = new AnalysisData();
// DEPRECATED - WILL BE REMOVED
boolean planLiteEnabled = isPlanLiteEnabled();
PlanLiteAnalyzedData plData = new PlanLiteAnalyzedData();
HashMap<String, Integer> townMap = new HashMap<>();
HashMap<String, Integer> factionMap = new HashMap<>();
int totalVotes = 0;
int totalMoney = 0;
// Fill Dataset with userdata.
rawData.parallelStream().forEach((uData) -> {
try {
@ -152,8 +143,6 @@ public class Analysis {
analysisData.setTop20ActivePlayers(AnalysisUtils.createActivePlayersTable(sorted.getPlaytimes(), 20));
analysisData.setRecentPlayers(AnalysisUtils.createListStringOutOfHashMapLong(sorted.getLatestLogins(), 20));
addPlanLiteToData(planLiteEnabled, plData, factionMap, townMap, totalVotes, totalMoney, analysisData);
long totalPlaytime = sorted.getTotalPlaytime();
analysisData.setTotalPlayTime(totalPlaytime);
analysisData.setAveragePlayTime(totalPlaytime / rawData.size());
@ -185,30 +174,6 @@ public class Analysis {
}
}
private boolean isPlanLiteEnabled() {
boolean planLiteEnabled;
PlanLiteHook planLiteHook = plugin.getPlanLiteHook();
if (planLiteHook != null) {
planLiteEnabled = planLiteHook.isEnabled();
} else {
planLiteEnabled = false;
}
return planLiteEnabled;
}
private void addPlanLiteToData(boolean planLiteEnabled, PlanLiteAnalyzedData plData, HashMap<String, Integer> factionMap, HashMap<String, Integer> townMap, int totalVotes, int totalMoney, AnalysisData data) {
if (planLiteEnabled) {
plData.setFactionMap(factionMap);
plData.setTownMap(townMap);
plData.setTotalVotes(totalVotes);
plData.setTotalMoney(totalMoney);
data.setPlanLiteEnabled(true);
data.setPlanLiteData(plData);
} else {
data.setPlanLiteEnabled(false);
}
}
private void createActivityVisalization(int totalBanned, int active, int inactive, int joinleaver, AnalysisData data) {
String activityPieChartHtml = AnalysisUtils.createActivityPieChart(totalBanned, active, inactive, joinleaver);
data.setActivityChartImgHtml(activityPieChartHtml);

View File

@ -14,16 +14,12 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
*/
public class HtmlUtils {
public static String getHtmlStringFromResource(String fileName) {
public static String getHtmlStringFromResource(String fileName) throws FileNotFoundException {
Plan plugin = getPlugin(Plan.class);
File localFile = new File(plugin.getDataFolder(), fileName);
File localFile = new File(plugin.getDataFolder(), fileName);
Scanner scanner = new Scanner(plugin.getResource(fileName));
if (localFile.exists()) {
try {
scanner = new Scanner(localFile, "UTF-8");
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
scanner = new Scanner(localFile, "UTF-8");
}
String html = "";
while (scanner.hasNextLine()) {

View File

@ -4,7 +4,6 @@ import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
@ -107,15 +106,4 @@ public class MiscUtils {
});
return matches;
}
public static boolean isOnSameDay(Date first, Date second) {
Date startOfFirst = getStartOfDate(first);
Date startOfSecond = getStartOfDate(second);
return (startOfFirst != startOfSecond);
}
public static Date getStartOfDate(Date date) {
Date startOfDate = new Date(date.getTime() - (date.getTime() % 86400000));
return startOfDate;
}
}

View File

@ -1,14 +1,12 @@
package main.java.com.djrapitops.plan.utilities;
import java.io.FileNotFoundException;
import java.util.Date;
import java.util.HashMap;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanLiteHook;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.AnalysisData;
import main.java.com.djrapitops.plan.data.PlanLiteAnalyzedData;
import main.java.com.djrapitops.plan.data.PlanLitePlayerData;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.ui.Html;
import org.bukkit.GameMode;
@ -54,30 +52,12 @@ public class PlaceholderUtils {
replaceMap.put("%totallogins%", "" + data.getTotalLoginTimes());
replaceMap.put("%top20mostactive%", data.getTop20ActivePlayers());
replaceMap.put("%recentlogins%", data.getRecentPlayers());
replaceMap.put("%deaths%", data.getTotaldeaths()+"");
replaceMap.put("%playerkills%", data.getTotalkills()+"");
replaceMap.put("%mobkills%", data.getTotalmobkills()+"");
replaceMap.put("%deaths%", data.getTotaldeaths() + "");
replaceMap.put("%playerkills%", data.getTotalkills() + "");
replaceMap.put("%mobkills%", data.getTotalmobkills() + "");
Plan plugin = getPlugin(Plan.class);
PlanLiteHook hook = plugin.getPlanLiteHook();
replaceMap.put("%version%", plugin.getDescription().getVersion());
if (hook != null) {
replaceMap.put("%planlite%", hook.isEnabled() ? getPlanLiteAnalysisHtml(data.getPlanLiteData()) : "");
} else {
replaceMap.put("%planlite%", "");
}
return replaceMap;
}
public static HashMap<String, String> getPlanLitePlayerReplaceRules(PlanLitePlayerData planLiteData) {
HashMap<String, String> replaceMap = new HashMap<>();
PlanLiteHook hook = getPlugin(Plan.class).getPlanLiteHook();
replaceMap.put("%townylinetown%", hook.hasTowny() ? Html.TOWN.parse(planLiteData.getTown()) : "");
replaceMap.put("%townylineplotperms%", "");
replaceMap.put("%townylineplotoptions%", hook.hasTowny() ? Html.PLOT_OPTIONS.parse(planLiteData.getPlotOptions()) : "");
replaceMap.put("%townylinefriends%", hook.hasTowny() ? Html.FRIENDS.parse(planLiteData.getFriends()) : "");
replaceMap.put("%factionsline%", hook.hasFactions() ? Html.FACTION.parse(planLiteData.getFaction()) : "");
replaceMap.put("%totalmoneyline%", hook.hasVault() ? Html.BALANCE.parse(planLiteData.getMoney() + "") : "");
replaceMap.put("%totalvotesline%", hook.hasSuperbVote() ? Html.VOTES.parse(planLiteData.getVotes() + "") : "");
replaceMap.put("%planlite%", "");
return replaceMap;
}
@ -86,8 +66,9 @@ public class PlaceholderUtils {
*
* @param data UserData used to replace the placeholders with
* @return HashMap that contains string for each placeholder.
* @throws java.io.FileNotFoundException if planliteplayer.html is not found
*/
public static HashMap<String, String> getInspectReplaceRules(UserData data) {
public static HashMap<String, String> getInspectReplaceRules(UserData data) throws FileNotFoundException {
HashMap<String, String> replaceMap = new HashMap<>();
boolean showIPandUUID = Settings.SECURITY_IP_UUID.isTrue();
replaceMap.put("%uuid%", (showIPandUUID ? "" + data.getUuid() : Html.HIDDEN.parse()));
@ -130,44 +111,13 @@ public class PlaceholderUtils {
replaceMap.put("%op%", data.isOp() ? Html.OPERATOR.parse() : "");
replaceMap.put("%isonline%", (data.isOnline()) ? Html.ONLINE.parse() : Html.OFFLINE.parse());
int deaths = data.getDeaths();
replaceMap.put("%deaths%", deaths+"");
replaceMap.put("%playerkills%", data.getPlayerKills()+"");
replaceMap.put("%mobkills%", data.getMobKills()+"");
replaceMap.put("%deaths%", deaths + "");
replaceMap.put("%playerkills%", data.getPlayerKills() + "");
replaceMap.put("%mobkills%", data.getMobKills() + "");
Plan plugin = getPlugin(Plan.class);
replaceMap.put("%version%", plugin.getDescription().getVersion());
PlanLiteHook hook = plugin.getPlanLiteHook();
if (hook != null) {
replaceMap.put("%planlite%", hook.isEnabled() ? getPlanLitePlayerHtml(data.getPlanLiteData()) : "");
} else {
replaceMap.put("%planlite%", "");
}
replaceMap.put("%planlite%", "");
replaceMap.put("%inaccuratedatawarning%", (new Date().getTime() - data.getRegistered() < 180000) ? Html.WARN_INACCURATE.parse() : "");
return replaceMap;
}
public static HashMap<String, String> getPlanLiteAnalysisReplaceRules(PlanLiteAnalyzedData planLiteData) {
HashMap<String, String> replaceMap = new HashMap<>();
PlanLiteHook hook = getPlugin(Plan.class).getPlanLiteHook();
replaceMap.put("%townyheader%", hook.hasTowny() ? Html.TOP_TOWNS.parse() : "");
replaceMap.put("%townylist%", hook.hasTowny() ? AnalysisUtils.createTableOutOfHashMap(planLiteData.getTownMap(), 20) : "");
replaceMap.put("%factionheader%", hook.hasFactions() ? Html.TOP_FACTIONS.parse() : "");
replaceMap.put("%factionlist%", hook.hasFactions() ? AnalysisUtils.createTableOutOfHashMap(planLiteData.getFactionMap(), 20) : "");
replaceMap.put("%totalmoneyline%", hook.hasVault() ? Html.TOTAL_BALANCE.parse(planLiteData.getTotalMoney() + "") : "");
replaceMap.put("%totalvotesline%", hook.hasSuperbVote() ? Html.TOTAL_VOTES.parse(planLiteData.getTotalVotes() + "") : "");
return replaceMap;
}
private static String getPlanLitePlayerHtml(PlanLitePlayerData planLiteData) {
return HtmlUtils.replacePlaceholders(
HtmlUtils.getHtmlStringFromResource("planliteplayer.html"),
PlaceholderUtils.getPlanLitePlayerReplaceRules(planLiteData)
);
}
private static String getPlanLiteAnalysisHtml(PlanLiteAnalyzedData planLiteData) {
return HtmlUtils.replacePlaceholders(
HtmlUtils.getHtmlStringFromResource("planlite.html"),
PlaceholderUtils.getPlanLiteAnalysisReplaceRules(planLiteData)
);
}
}

View File

@ -1,5 +1,6 @@
Settings:
Locale: default
UseTextUI: false
Data:
GatherLocations: true
Analysis:
@ -21,10 +22,7 @@ Settings:
AlternativeIP: your.ip.here:%port%
Security:
DisplayIPsAndUUIDs: true
AddressSecurityCode: bAkEd
PlanLite:
Enabled: true
UseAsAlternativeUI: false
AddressSecurityCode: bAkEd
Customization:
Colors:

View File

@ -1,20 +0,0 @@
<tr>
<td style="margin-left: 3px; margin-right: auto;border-style: groove; border-width: 3px;
border-radius: 12px; padding: 2px 4px 2px 3px; box-shadow: 5px 5px 4px 0px #888888;">
<h4>Information from PlanLite</h4>
%totalmoneyline%
%totalvotesline%
<!-- <br/><h4>Richest Players</h4>
%top10richest%
<br/><h4>Top Voters</h4>
%top10votes%-->
</td>
<td style="margin-left: 3px; margin-right: auto;border-style: groove; border-width: 3px;
border-radius: 12px; padding: 2px 4px 2px 3px; box-shadow: 5px 5px 4px 0px #888888;">
%townyheader%
%townylist%
<br/>
%factionheader%
%factionlist%
</td>
</tr>

View File

@ -1,13 +0,0 @@
<tr>
<td style="margin-left: 3px; margin-right: auto;border-style: groove; border-width: 3px;
border-radius: 12px; padding: 2px 4px 2px 3px; box-shadow: 5px 5px 4px 0px #888888;">
<h4>Information from PlanLite</h4>
%totalmoneyline%
%totalvotesline%
%factionsline%
%townylinetown%
%townylineplotperms%
%townylineplotoptions%
%townylinefriends%
</td>
</tr>

View File

@ -1,6 +1,6 @@
name: Plan
author: Rsl1122
main: com.djrapitops.plan.Plan
main: main.java.com.djrapitops.plan.Plan
version: 2.5.2
commands:
@ -23,9 +23,6 @@ commands:
usage: /plan manage <manage subcommand>
description: manage the database
softdepend:
- PlanLite
permissions:
plan.?:
description: Help command

View File

@ -1,73 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="PlanDebugger" default="default" basedir=".">
<description>Builds, tests, and runs the project PlanDebugger.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="PlanDebugger-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

View File

@ -1,3 +0,0 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
build.xml.data.CRC32=a317dbfb
build.xml.script.CRC32=e58faa21
build.xml.stylesheet.CRC32=8064a381@1.80.1.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=a317dbfb
nbproject/build-impl.xml.script.CRC32=47a3e003
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48

View File

@ -1,78 +0,0 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/PlanDebugger.jar
dist.javadoc.dir=${dist.dir}/javadoc
excludes=
file.reference.craftbukkit-1.11.2.jar=D:\\Minecraft Servers\\Buildtools\\craftbukkit-1.11.2.jar
file.reference.Plan-jar-with-dependencies.jar=..\\Plan\\target\\Plan-jar-with-dependencies.jar
includes=**
jar.compress=false
javac.classpath=\
${file.reference.Plan-jar-with-dependencies.jar}:\
${file.reference.craftbukkit-1.11.2.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=com.djrapitops.plandebugger.PlanDebugger
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>PlanDebugger</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

View File

@ -1,117 +0,0 @@
/*
* Player Analytics Bukkit plugin for monitoring server activity.
* Copyright (C) 2016 Risto Lahtela / Rsl1122
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Plan License. (licence.yml)
* Modified software can only be redistributed if allowed in the licence.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License for more details.
*
* You should have received a copy of the License
* along with this program.
* If not it should be visible on the distribution page.
* Or here
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/licence.yml
*/
package com.djrapitops.plandebugger;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.utilities.FormatUtils;
import com.djrapitops.plandebugger.config.ConfigSetter;
import com.djrapitops.plandebugger.config.SettingsList;
import com.djrapitops.plandebugger.tests.IndependentTestRunner;
import com.djrapitops.plandebugger.tests.PluginTestRunner;
import com.djrapitops.plandebugger.tests.TestRunner;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.List;
import main.java.com.djrapitops.plan.Settings;
import org.bukkit.plugin.java.JavaPlugin;
/**
*
* @author Rsl1122
*/
public class PlanDebugger extends JavaPlugin {
private Plan plan;
private ConfigSetter configSetter;
private String originalDB;
private String debugTime;
@Override
public void onEnable() {
plan = getPlugin(Plan.class);
runConsoleCommand("plan manage backup mysql");
runConsoleCommand("plan manage backup sqlite");
originalDB = plan.getConfig().getString(Settings.DB_TYPE.getPath());
configSetter = new ConfigSetter(this, plan);
debugTime = FormatUtils.formatTimeStamp(new Date().getTime()+"").replaceAll(" ", "");
int[] r = new int[]{0, 0, 0};
TestRunner iTestRunner = new IndependentTestRunner(this, plan);
List<String> errors = iTestRunner.runAllTests();
r[0] = iTestRunner.getTestsRun();
r[1] = iTestRunner.getTestsFailed();
r[2] = iTestRunner.getTestsError();
TestRunner testRunner = new PluginTestRunner(this, plan);
for (SettingsList s : SettingsList.values()) {
configSetter.setSettings(s);
errors.addAll(testRunner.runAllTests());
}
log("\nTEST RESULTS - Run: "+r[0]+" Success: "+(r[0]-r[1]-r[2])+" Failed: "+r[1]+" Errors: "+r[2]+"\n");
log("ERRORS:");
for (String error : errors) {
logError("Error: "+error);
}
}
@Override
public void onDisable() {
plan.getConfig().set(Settings.DB_TYPE.getPath(), originalDB);
configSetter.resetSettings();
log("Tests Complete!");
log("Restore the old database by using the restore command.");
}
public void log(String message) {
getLogger().info(message);
toLog(message);
}
public void logError(String message) {
getLogger().severe(message);
toLog(message);
}
public void toLog(String message) {
File folder = getDataFolder();
if (!folder.exists()) {
folder.mkdir();
}
File log = new File(getDataFolder(), "DebugLog-" + debugTime + ".txt");
try {
if (!log.exists()) {
log.createNewFile();
}
FileWriter fw = new FileWriter(log, true);
try (PrintWriter pw = new PrintWriter(fw)) {
String timestamp = FormatUtils.formatTimeStamp(new Date().getTime()+"");
pw.println("["+timestamp+"] "+message + "\n");
pw.flush();
}
} catch (IOException e) {
logError("Failed to create log.txt file");
}
}
public void runConsoleCommand(String command) {
getServer().dispatchCommand(getServer().getConsoleSender(), command);
}
}

View File

@ -1,82 +0,0 @@
package com.djrapitops.plandebugger.config;
import com.djrapitops.plan.Plan;
import com.djrapitops.plandebugger.PlanDebugger;
import main.java.com.djrapitops.plan.Settings;
import org.bukkit.configuration.file.FileConfiguration;
/**
*
* @author Rsl1122
*/
public class ConfigSetter {
private Plan plan;
private PlanDebugger debug;
private String[] originalSettings;
public ConfigSetter(PlanDebugger debug, Plan plan) {
this.plan = plan;
this.debug = debug;
originalSettings = getDefaultSettings();
}
public void setSettings(SettingsList list) {
setSettings(list.getValues());
debug.log("SETTINGS Set settings to "+list.name());
}
public void setSettings(String[] s) {
FileConfiguration c = plan.getConfig();
c.set(Settings.LOCALE.getPath(), s[0]);
c.set(Settings.GATHERLOCATIONS.getPath(), s[1]);
c.set(Settings.ANALYSIS_LOG_TO_CONSOLE.getPath(), s[2]);
c.set(Settings.ANALYSIS_MINUTES_FOR_ACTIVE.getPath(), s[3]);
c.set(Settings.ANALYSIS_REFRESH_ON_ENABLE.getPath(), s[4]);
c.set(Settings.ANALYSIS_AUTO_REFRESH.getPath(), s[5]);
c.set(Settings.CLEAR_INSPECT_CACHE.getPath(), s[6]);
c.set(Settings.SAVE_CACHE_MIN.getPath(), s[7]);
c.set(Settings.SAVE_SERVER_MIN.getPath(), s[8]);
c.set(Settings.CLEAR_CACHE_X_SAVES.getPath(), s[9]);
c.set(Settings.WEBSERVER_ENABLED.getPath(), s[10]);
c.set(Settings.WEBSERVER_PORT.getPath(), s[11]);
c.set(Settings.SHOW_ALTERNATIVE_IP.getPath(), s[12]);
c.set(Settings.ALTERNATIVE_IP.getPath(), s[13]);
c.set(Settings.SECURITY_IP_UUID.getPath(), s[14]);
c.set(Settings.SECURITY_CODE.getPath(), s[15]);
c.set(Settings.PLANLITE_ENABLED.getPath(), s[16]);
c.set(Settings.USE_ALTERNATIVE_UI.getPath(), s[17]);
plan.saveConfig();
plan.reloadConfig();
plan.onDisable();
plan.onEnable();
}
public void resetSettings() {
setSettings(originalSettings);
}
private String[] getDefaultSettings() {
FileConfiguration c = plan.getConfig();
return new String[]{
c.get(Settings.LOCALE.getPath()) + "",
c.get(Settings.GATHERLOCATIONS.getPath()) + "",
c.get(Settings.ANALYSIS_LOG_TO_CONSOLE.getPath()) + "",
c.get(Settings.ANALYSIS_MINUTES_FOR_ACTIVE.getPath()) + "",
c.get(Settings.ANALYSIS_REFRESH_ON_ENABLE.getPath()) + "",
c.get(Settings.ANALYSIS_AUTO_REFRESH.getPath()) + "",
c.get(Settings.CLEAR_INSPECT_CACHE.getPath()) + "",
c.get(Settings.SAVE_CACHE_MIN.getPath()) + "",
c.get(Settings.SAVE_SERVER_MIN.getPath()) + "",
c.get(Settings.CLEAR_CACHE_X_SAVES.getPath()) + "",
c.get(Settings.WEBSERVER_ENABLED.getPath()) + "",
c.get(Settings.WEBSERVER_PORT.getPath()) + "",
c.get(Settings.SHOW_ALTERNATIVE_IP.getPath()) + "",
c.get(Settings.ALTERNATIVE_IP.getPath()) + "",
c.get(Settings.SECURITY_IP_UUID.getPath()) + "",
c.get(Settings.SECURITY_CODE.getPath()) + "",
c.get(Settings.PLANLITE_ENABLED.getPath()) + "",
c.get(Settings.USE_ALTERNATIVE_UI.getPath()) + ""
};
}
}

View File

@ -1,19 +0,0 @@
package com.djrapitops.plandebugger.config;
/**
*
* @author Rsl1122
*/
public enum SettingsList {
DEFAULT(new String[]{"default", "true", "false", "10", "true", "-1", "5", "2", "1", "5", "true", "8804", "false", "your.ip.here:%port%", "true", "bAkEd", "true", "false"});
private String[] values;
private SettingsList(String[] values) {
this.values = values;
}
public String[] getValues() {
return values;
}
}

View File

@ -1,36 +0,0 @@
package com.djrapitops.plandebugger.tests;
import com.djrapitops.plan.Plan;
import com.djrapitops.plandebugger.PlanDebugger;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Rsl1122
*/
public class IndependentTestRunner extends TestRunner {
private List<Test> tests;
public IndependentTestRunner(PlanDebugger debug, Plan plan) {
super(debug, plan);
}
@Override
public List<String> runAllTests() {
List<String> errors = new ArrayList<>();
for (Test test : tests) {
try {
test.runTest();
} catch (Exception e) {
String msg = "Test "+test.getTestName()+" ran into ERROR: "+e.getMessage();
debug.logError(msg);
for (StackTraceElement x : e.getStackTrace()) {
debug.toLog(x+"");
}
errors.add(msg);
}
}
return errors;
}
}

View File

@ -1,38 +0,0 @@
package com.djrapitops.plandebugger.tests;
import com.djrapitops.plan.Plan;
import com.djrapitops.plandebugger.PlanDebugger;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Rsl1122
*/
public class PluginTestRunner extends TestRunner {
private List<Test> tests;
public PluginTestRunner(PlanDebugger debug, Plan plan) {
super(debug, plan);
}
@Override
public List<String> runAllTests() {
List<String> errors = new ArrayList<>();
for (Test test : tests) {
try {
test.runTest();
} catch (Exception e) {
String msg = "Test "+test.getTestName()+" ran into ERROR: "+e.getMessage();
debug.logError(msg);
for (StackTraceElement x : e.getStackTrace()) {
debug.toLog(x+"");
}
errors.add(msg);
}
}
return errors;
}
}

View File

@ -1,35 +0,0 @@
package com.djrapitops.plandebugger.tests;
import com.djrapitops.plan.Plan;
import com.djrapitops.plandebugger.PlanDebugger;
/**
*
* @author Rsl1122
*/
public abstract class Test {
Plan plan;
PlanDebugger debug;
private String testName;
public Test(Plan plan, PlanDebugger debug, String testName) {
this.plan = plan;
this.debug = debug;
}
public abstract boolean runTest() throws Exception;
public void pass() {
debug.log("Test "+testName+": PASSED");
}
public void fail() {
debug.logError("Test "+testName+": FAILED");
}
public String getTestName() {
return testName;
}
}

View File

@ -1,41 +0,0 @@
package com.djrapitops.plandebugger.tests;
import com.djrapitops.plan.Plan;
import com.djrapitops.plandebugger.PlanDebugger;
import java.util.List;
/**
*
* @author Rsl1122
*/
public abstract class TestRunner {
Plan plan;
PlanDebugger debug;
private int testsRun;
private int testsFailed;
private int testsError;
public TestRunner(PlanDebugger debug, Plan plan) {
this.plan = plan;
this.debug = debug;
testsRun = 0;
testsFailed = 0;
testsError = 0;
}
public abstract List<String> runAllTests();
public int getTestsRun() {
return testsRun;
}
public int getTestsFailed() {
return testsFailed;
}
public int getTestsError() {
return testsError;
}
}

View File

@ -1,7 +0,0 @@
name: PlanDebugger
main: com.djrapitops.plandebugger.PlanDebugger
author: Rsl1122
version: 2.5.1
depend:
- Plan