mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-01 00:10:12 +01:00
Critical bugfix & Changed version check handler to use Integers to prevent possible double digit issue.
This commit is contained in:
parent
0dfb2570e8
commit
7803e5dc18
@ -22,29 +22,24 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/* TODO 2.1.0
|
||||
Placeholder API
|
||||
Html getter without webserver
|
||||
Webserver off setting
|
||||
Immutable InspectCache ?
|
||||
Join-leavers to activity pie.
|
||||
Recent players
|
||||
Customizability
|
||||
Colors, chat, analysis
|
||||
Demographics triggers
|
||||
Optimize db with batch processing (commanduse, ips, nicks)
|
||||
Manage command
|
||||
Database cleaning
|
||||
Server & user data saved seperately with different times
|
||||
Alternative ip & webserver off check warning, check for PlanLite too.
|
||||
Fix PlanLite balance.
|
||||
PlanLite Top 20 richest
|
||||
PlanLite Top 20 most votes
|
||||
Top 20 most active
|
||||
Clear setting multiper (InspectCache)
|
||||
Clear check for existing clear task. (InspectCache)
|
||||
ErrorManager
|
||||
(Alternative ui) ? Push data to PlanLite (setting)
|
||||
DataBase init message
|
||||
Update Version checker so it doesn't fail
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
||||
public class Plan extends JavaPlugin {
|
||||
|
||||
private API api;
|
||||
@ -56,6 +51,11 @@ public class Plan extends JavaPlugin {
|
||||
private HashSet<Database> databases;
|
||||
private WebSocketServer uiServer;
|
||||
|
||||
/**
|
||||
* OnEnable method.
|
||||
*
|
||||
* Initiates the plugin with database, webserver, commands & listeners.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getDataFolder().mkdirs();
|
||||
@ -126,6 +126,9 @@ public class Plan extends JavaPlugin {
|
||||
log("Player Analytics Enabled.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks PlanLite for UI and/or additional data.
|
||||
*/
|
||||
public void hookPlanLite() {
|
||||
try {
|
||||
planLiteHook = new PlanLiteHook(this);
|
||||
@ -134,9 +137,16 @@ public class Plan extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the plugin.
|
||||
*
|
||||
* Stops the webserver, cancels all tasks and saves cache to the database. *
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
uiServer.stop();
|
||||
if (uiServer != null) {
|
||||
uiServer.stop();
|
||||
}
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
if (handler != null) {
|
||||
log("Saving cached data..");
|
||||
@ -150,14 +160,25 @@ public class Plan extends JavaPlugin {
|
||||
log("Player Analytics Disabled.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the message to the console.
|
||||
* @param message
|
||||
*/
|
||||
public void log(String message) {
|
||||
getLogger().info(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an error message to the console.
|
||||
* @param message
|
||||
*/
|
||||
public void logError(String message) {
|
||||
getLogger().severe(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Plan API
|
||||
*/
|
||||
public API getAPI() {
|
||||
return api;
|
||||
}
|
||||
@ -200,26 +221,44 @@ public class Plan extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Currnet instance of the AnalysisCacheHandler
|
||||
*/
|
||||
public AnalysisCacheHandler getAnalysisCache() {
|
||||
return analysisCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Currnet instance of the InspectCacheHandler
|
||||
*/
|
||||
public InspectCacheHandler getInspectCache() {
|
||||
return inspectCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Currnet instance of the DataCacheHandler
|
||||
*/
|
||||
public DataCacheHandler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PlanLiteHook
|
||||
*/
|
||||
public PlanLiteHook getPlanLiteHook() {
|
||||
return planLiteHook;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Database
|
||||
*/
|
||||
public Database getDB() {
|
||||
return db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Webserver
|
||||
*/
|
||||
public WebSocketServer getUiServer() {
|
||||
return uiServer;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -78,13 +78,16 @@ public class FormatUtils {
|
||||
* @return parsed double - for example 1,11
|
||||
* @throws NumberFormatException When wrong format
|
||||
*/
|
||||
public static double parseVersionDouble(String versionString) throws NumberFormatException {
|
||||
public static int parseVersionNumber(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;
|
||||
int main = Integer.parseInt(versionArray[0]) * 100;
|
||||
int major = Integer.parseInt(versionArray[1]) * 10;
|
||||
int minor = Integer.parseInt(versionArray[2]);
|
||||
int versionNumber = main + major + minor;
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,9 +42,9 @@ public class MiscUtils {
|
||||
}
|
||||
}
|
||||
String versionString = lineWithVersion.split(": ")[1];
|
||||
double newestVersionNumber = FormatUtils.parseVersionDouble(versionString);
|
||||
int newestVersionNumber = FormatUtils.parseVersionNumber(versionString);
|
||||
cVersion = plugin.getDescription().getVersion();
|
||||
double currentVersionNumber = FormatUtils.parseVersionDouble(cVersion);
|
||||
int currentVersionNumber = FormatUtils.parseVersionNumber(cVersion);
|
||||
if (newestVersionNumber > currentVersionNumber) {
|
||||
return "New Version (" + versionString + ") is availible at https://www.spigotmc.org/resources/plan-player-analytics.32536/";
|
||||
} else {
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: com.djrapitops.plan.Plan
|
||||
version: 2.1.0
|
||||
version: 2.1.1
|
||||
|
||||
commands:
|
||||
plan:
|
||||
|
Loading…
Reference in New Issue
Block a user