mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-21 23:51:29 +01:00
Bugfix attempts & Error message change
- Changed "Plan has run into error..." to include error type - More attempts to fix #26 - Null checks for uuid - Now not saving userdata when uuid = null - If uuid = null, data will not be fetched.
This commit is contained in:
parent
75e1cf3e85
commit
549cefd098
@ -74,7 +74,7 @@ public enum Phrase {
|
||||
ERROR_NO_DATA_VIEW(ChatColor.YELLOW + "Webserver disabled but Alternative IP/PlanLite not used, no way to view data!"),
|
||||
ERROR_WEBSERVER_OFF_ANALYSIS(ChatColor.YELLOW + "" + PREFIX + "This command can be only used if the webserver is running on this server."),
|
||||
ERROR_WEBSERVER_OFF_INSPECT(ChatColor.YELLOW + "" + PREFIX + "This command can be only used if webserver/planlite is enabled on this server."),
|
||||
ERROR_LOGGED("Ran into an error. It has been logged to the Errors.txt"),
|
||||
ERROR_LOGGED("Caugth "+REPLACE0+". It has been logged to the Errors.txt"),
|
||||
ERROR_SESSIONDATA_INITIALIZATION("Player's session was initialized in a wrong way! (" + REPLACE0 + ")"),
|
||||
//
|
||||
CMD_FOOTER(COLOR_TER.color() + "" + ARROWS_RIGHT),
|
||||
|
@ -51,18 +51,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/* TODO
|
||||
Placeholder API
|
||||
Play session length
|
||||
- Playtime month
|
||||
- Playtime week
|
||||
Location Analysis to view meaningful locations on Dynmap (Investigate dynmap api)
|
||||
Text interface
|
||||
Database Cleaning of useless data
|
||||
Add -n argument for nickname search.
|
||||
Fix any bugs that come up
|
||||
Random security code generation
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
@ -189,7 +177,7 @@ public class Plan extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void toLog(String source, Exception e) {
|
||||
logError(Phrase.ERROR_LOGGED + "");
|
||||
logError(Phrase.ERROR_LOGGED.parse(e.toString()));
|
||||
toLog(source + " Caught " + e);
|
||||
for (StackTraceElement x : e.getStackTrace()) {
|
||||
toLog(" " + x);
|
||||
@ -220,7 +208,7 @@ public class Plan extends JavaPlugin {
|
||||
pw.flush();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
getLogger().severe("Failed to create DBerrors.txt file");
|
||||
getLogger().severe("Failed to create Errors.txt file");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,9 @@ class GetConsumer implements Runnable {
|
||||
void consume(HashMap<UUID, List<DBCallableProcessor>> processors) {
|
||||
try {
|
||||
for (UUID uuid : processors.keySet()) {
|
||||
if (uuid == null) {
|
||||
continue;
|
||||
}
|
||||
List<DBCallableProcessor> processorsList = processors.get(uuid);
|
||||
if (processorsList != null) {
|
||||
try {
|
||||
|
@ -333,7 +333,7 @@ public abstract class SQLDB extends Database {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVersion(int version) throws SQLException {
|
||||
public void setVersion(int version) throws SQLException {
|
||||
connection.prepareStatement("DELETE FROM " + versionName).executeUpdate();
|
||||
connection.prepareStatement("INSERT INTO " + versionName + " (version) VALUES (" + version + ")").executeUpdate();
|
||||
|
||||
@ -390,7 +390,11 @@ public abstract class SQLDB extends Database {
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT " + userColumnUUID + " FROM " + userName);
|
||||
ResultSet set = statement.executeQuery();
|
||||
while (set.next()) {
|
||||
uuids.add(UUID.fromString(set.getString(userColumnUUID)));
|
||||
UUID uuid = UUID.fromString(set.getString(userColumnUUID));
|
||||
if (uuid == null) {
|
||||
continue;
|
||||
}
|
||||
uuids.add(uuid);
|
||||
}
|
||||
set.close();
|
||||
return uuids;
|
||||
@ -413,6 +417,9 @@ public abstract class SQLDB extends Database {
|
||||
boolean commitRequired = false;
|
||||
if (!data.isEmpty()) {
|
||||
for (String key : data.keySet()) {
|
||||
if (key.length() > 20) {
|
||||
continue;
|
||||
}
|
||||
statement.setString(1, key);
|
||||
statement.setInt(2, data.get(key));
|
||||
statement.addBatch();
|
||||
@ -687,8 +694,13 @@ public abstract class SQLDB extends Database {
|
||||
if (uData == null) {
|
||||
continue;
|
||||
}
|
||||
UUID uuid = uData.getUuid();
|
||||
if (uuid == null) {
|
||||
continue;
|
||||
}
|
||||
uData.access();
|
||||
int userId = getUserId(uData.getUuid().toString());
|
||||
|
||||
int userId = getUserId(uuid.toString());
|
||||
if (userId == -1) {
|
||||
saveLast.add(uData);
|
||||
continue;
|
||||
@ -749,8 +761,12 @@ public abstract class SQLDB extends Database {
|
||||
uData.stopAccessing();
|
||||
}
|
||||
for (UserData userData : saveLast) {
|
||||
UUID uuid = userData.getUuid();
|
||||
if (uuid == null) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
saveUserData(userData.getUuid(), userData);
|
||||
saveUserData(uuid, userData);
|
||||
} catch (SQLException e) {
|
||||
exceptions.add(e);
|
||||
} catch (NullPointerException e) {
|
||||
@ -764,6 +780,9 @@ public abstract class SQLDB extends Database {
|
||||
|
||||
@Override
|
||||
public void saveUserData(UUID uuid, UserData data) throws SQLException {
|
||||
if (uuid == null) {
|
||||
return;
|
||||
}
|
||||
checkConnection();
|
||||
data.access();
|
||||
int userId = getUserId(uuid.toString());
|
||||
|
@ -3,8 +3,10 @@ package main.java.com.djrapitops.plan.ui.tables;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.MapComparator;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -20,8 +22,14 @@ public class SortableCommandUseTableCreator {
|
||||
return html;
|
||||
}
|
||||
Collections.reverse(sorted);
|
||||
for (String[] values : sorted) {
|
||||
html += Html.TABLELINE_2.parse(values[1], values[0]);
|
||||
for (String[] values : sorted) {
|
||||
try {
|
||||
html += Html.TABLELINE_2.parse(values[1], values[0]);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
plugin.toLog("SortableCommandUseTableCreator", e);
|
||||
plugin.toLog("Cause: "+values[1]+" "+values[2]);
|
||||
}
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class Analysis {
|
||||
BukkitTask asyncAnalysisTask = (new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
uuids.stream().forEach((uuid) -> {
|
||||
uuids.stream().filter(uuid -> uuid != null).forEach((uuid) -> {
|
||||
inspectCache.cache(uuid, 15);
|
||||
});
|
||||
log(Phrase.ANALYSIS_FETCH_DATA + "");
|
||||
|
@ -64,10 +64,13 @@ public class AnalysisUtils {
|
||||
|
||||
static int getNewPlayers(List<Long> registered, long scale, long now) {
|
||||
int newPlayers = 0;
|
||||
// Filters out register dates before scale
|
||||
newPlayers = registered.stream()
|
||||
if (!registered.isEmpty()) {
|
||||
newPlayers = registered.stream()
|
||||
.filter((reg) -> (reg > now - scale))
|
||||
.map((_item) -> 1).reduce(newPlayers, Integer::sum);
|
||||
}
|
||||
// Filters out register dates before scale
|
||||
|
||||
return newPlayers;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.Scanner;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
|
Loading…
Reference in New Issue
Block a user