mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-10 13:49:17 +01:00
Reduced TODO items allover the code
This commit is contained in:
parent
0320b2cea8
commit
1c488d50f8
@ -11,7 +11,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Interface for PlanAPI methods.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -5,15 +5,12 @@
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Thrown when ConnectionSystem can not find any servers to send request to.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class NoServersException extends WebException {
|
||||
|
||||
public NoServersException() {
|
||||
}
|
||||
|
||||
public NoServersException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ package com.djrapitops.plan.api.exceptions.connection;
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class NotFoundException extends WebFailException {
|
||||
public NotFoundException() {
|
||||
super("Not Found");
|
||||
public NotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.api.exceptions.connection;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Thrown when DBException occurs during InfoRequest#placeIntoDatabase.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -11,9 +11,6 @@ package com.djrapitops.plan.api.exceptions.connection;
|
||||
*/
|
||||
public class UnauthorizedServerException extends WebFailException {
|
||||
|
||||
public UnauthorizedServerException() {
|
||||
}
|
||||
|
||||
public UnauthorizedServerException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.api.exceptions.connection;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Exception thrown when calling Database#transfer and Database implementation doesn't support it.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -4,9 +4,9 @@ import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.systems.info.InformationManager;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
@ -83,8 +83,6 @@ public class AnalyzeCommand extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
|
||||
// TODO Write a command for listing servers.
|
||||
|
||||
UUID serverUUID = Plan.getServerUUID();
|
||||
if (args.length >= 1 && plugin.getInfoManager().isUsingAnotherWebServer()) {
|
||||
try {
|
||||
|
@ -11,7 +11,9 @@ import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Command for Toggling whether or not BungeeCord accepts set up requests.
|
||||
*
|
||||
* This was added as a security measure against unwanted MySQL snooping.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.data;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public interface HasDate {
|
||||
|
||||
long getDate();
|
||||
|
||||
}
|
@ -5,7 +5,6 @@
|
||||
package com.djrapitops.plan.data.container;
|
||||
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.HasDate;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
|
||||
@ -16,7 +15,7 @@ import java.util.Objects;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Action implements HasDate {
|
||||
public class Action {
|
||||
private final long date;
|
||||
private final Actions doneAction;
|
||||
private final String additionalInfo;
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.data.container;
|
||||
|
||||
import com.djrapitops.plan.data.HasDate;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
@ -12,7 +11,7 @@ import com.google.common.base.Objects;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class GeoInfo implements HasDate {
|
||||
public class GeoInfo {
|
||||
|
||||
private final String ip;
|
||||
private final String geolocation;
|
||||
@ -36,11 +35,6 @@ public class GeoInfo implements HasDate {
|
||||
return lastUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDate() {
|
||||
return getLastUsed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -2,7 +2,6 @@ package com.djrapitops.plan.data.container;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.HasDate;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -14,7 +13,7 @@ import java.util.UUID;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlayerKill implements HasDate {
|
||||
public class PlayerKill {
|
||||
|
||||
private final UUID victim;
|
||||
private final long time;
|
||||
@ -51,11 +50,6 @@ public class PlayerKill implements HasDate {
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDate() {
|
||||
return getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Weapon used as string.
|
||||
*
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.data.container;
|
||||
|
||||
import com.djrapitops.plan.data.HasDate;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
@ -28,7 +27,7 @@ import java.util.Objects;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Session implements HasDate {
|
||||
public class Session {
|
||||
|
||||
private final long sessionStart;
|
||||
private Integer sessionID;
|
||||
@ -217,9 +216,4 @@ public class Session implements HasDate {
|
||||
.append("deaths", deaths)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDate() {
|
||||
return getSessionStart();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.data.container;
|
||||
|
||||
import com.djrapitops.plan.data.HasDate;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -16,7 +15,7 @@ import java.util.Objects;
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class TPS implements HasDate {
|
||||
public class TPS {
|
||||
|
||||
private final long date;
|
||||
private final double ticksPerSecond;
|
||||
|
@ -14,7 +14,7 @@ import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* System that holds data caches of the plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Bukkit Database system that initializes SQLite and MySQL database objects.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.system.database.databases.sql.MySQLDB;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Bungee Database system that initializes MySQL object.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* System that holds the active databases.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -12,7 +12,9 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Operation methods for saving data.
|
||||
*
|
||||
* Note: Method names subject to change (TODO remove insert update and such)
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -10,7 +10,9 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Operations for transferring data via Database to another server.
|
||||
*
|
||||
* Receiving server has to be using the same database.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* SaveOperations implementation for SQL databases.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@ -196,4 +196,13 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
||||
throw ErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void session(UUID uuid, Session session) throws DBException {
|
||||
try {
|
||||
sessionsTable.saveSession(uuid, session);
|
||||
} catch (SQLException e) {
|
||||
throw ErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* SQL executing statement that closes appropriate elements.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -9,7 +9,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* SQL query that doesn't require preparing that closes proper elements.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* SQL query that closes proper elements.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Abstracts File methods of Plugin classes so that they can be tested without Mocks.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.system.info;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
@ -14,12 +14,19 @@ import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest;
|
||||
import com.djrapitops.plan.system.info.request.GenerateInspectPageRequest;
|
||||
import com.djrapitops.plan.system.info.request.InfoRequest;
|
||||
import com.djrapitops.plan.utilities.NullCheck;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
interface ExceptionLoggingAction {
|
||||
|
||||
void performAction() throws WebException;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Information management system.
|
||||
*
|
||||
* <p>
|
||||
* Subclasses should decide how InfoRequests are run locally if necessary.
|
||||
*
|
||||
* @author Rsl1122
|
||||
@ -38,7 +45,7 @@ public abstract class InfoSystem implements SubSystem {
|
||||
return infoSystem;
|
||||
}
|
||||
|
||||
public void generatePlayerPage(UUID player) throws WebException {
|
||||
public void generateAndCachePlayerPage(UUID player) throws WebException {
|
||||
sendRequest(new GenerateInspectPageRequest(player));
|
||||
}
|
||||
|
||||
@ -77,4 +84,17 @@ public abstract class InfoSystem implements SubSystem {
|
||||
public ConnectionSystem getConnectionSystem() {
|
||||
return connectionSystem;
|
||||
}
|
||||
|
||||
public abstract void updateNetworkPage();
|
||||
|
||||
public void handlePossibleException(ExceptionLoggingAction action) {
|
||||
try {
|
||||
action.performAction();
|
||||
} catch (ConnectionFailException | UnsupportedTransferDatabaseException | UnauthorizedServerException
|
||||
| NotFoundException | NoServersException e) {
|
||||
Log.warn(e.getMessage());
|
||||
} catch (WebException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
@ -117,13 +117,13 @@ public class ConnectionOut {
|
||||
case 200:
|
||||
return;
|
||||
case 400:
|
||||
throw new WebFailException("Bad Request: " + url.toString() + "|" + parameters);
|
||||
throw new WebFailException("Bad Request: " + url.toString() + " | " + parameters);
|
||||
case 403:
|
||||
throw new ForbiddenException(url.toString());
|
||||
throw new ForbiddenException(url.toString() + " returned 403, this is not supposed to happen.");
|
||||
case 404:
|
||||
throw new NotFoundException();
|
||||
throw new NotFoundException(url.toString() + " returned a 404, ensure that your server is connected to an up to date Plan server.");
|
||||
case 412:
|
||||
throw new UnauthorizedServerException();
|
||||
throw new UnauthorizedServerException(url.toString() + " reported that it does not recognize this server. Make sure '/plan m setup' was successful.");
|
||||
case 500:
|
||||
throw new InternalErrorException();
|
||||
default:
|
||||
@ -135,7 +135,7 @@ public class ConnectionOut {
|
||||
if (Settings.DEV_MODE.isTrue()) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
throw new ConnectionFailException("Connection failed. address: " + address, e);
|
||||
throw new ConnectionFailException("Connection failed to address: " + address, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.system.info.request;
|
||||
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* InfoRequest for caching Network page parts to ResponseCache of receiving server.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class CacheNetworkPageContentRequest implements InfoRequest {
|
||||
|
||||
@Override
|
||||
public void placeDataToDatabase() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response handleRequest(Map<String, String> variables) {
|
||||
return null; // TODO
|
||||
}
|
||||
}
|
@ -4,22 +4,22 @@
|
||||
*/
|
||||
package com.djrapitops.plan.system.processing.processors.info;
|
||||
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.processing.processors.Processor;
|
||||
import com.djrapitops.plan.systems.info.InformationManager;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Processor for updating the network page.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class NetworkPageUpdateProcessor extends Processor<InformationManager> {
|
||||
public class NetworkPageUpdateProcessor extends Processor<InfoSystem> {
|
||||
|
||||
public NetworkPageUpdateProcessor(InformationManager object) {
|
||||
super(object);
|
||||
public NetworkPageUpdateProcessor() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
object.updateNetworkPageContent();
|
||||
InfoSystem.getInstance().updateNetworkPage();
|
||||
}
|
||||
}
|
@ -9,7 +9,9 @@ import com.djrapitops.plan.system.file.FileSystem;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* ConfigSystem for Bukkit.
|
||||
* <p>
|
||||
* Bukkit and Bungee have different default config file inside the jar.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -9,7 +9,9 @@ import com.djrapitops.plan.system.file.FileSystem;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* ConfigSystem for Bungee.
|
||||
* <p>
|
||||
* Bukkit and Bungee have different default config file inside the jar.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* System for Config and other user customizable options.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@ -59,6 +59,11 @@ public abstract class ConfigSystem implements SubSystem {
|
||||
theme.enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies default values from file in jar to Config.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected abstract void copyDefaults() throws IOException;
|
||||
|
||||
@Override
|
||||
|
@ -13,7 +13,9 @@ import com.djrapitops.plugin.task.IRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* TaskSystem that registers tasks that were previously registered inside Plugin classes.
|
||||
*
|
||||
* Subclasses register actual tasks.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* System for checking if new Version is available when the System initializes.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Interface for different WebUser authentication methods used by Requests.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -13,7 +13,10 @@ import com.djrapitops.plan.utilities.Base64Util;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Authentication handling for Basic Auth.
|
||||
*
|
||||
* Basic access authentication (Wikipedia):
|
||||
* https://en.wikipedia.org/wiki/Basic_access_authentication
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -5,9 +5,10 @@
|
||||
package com.djrapitops.plan.system.webserver.auth;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Reason for WebUserAuthException.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @see com.djrapitops.plan.api.exceptions.WebUserAuthException
|
||||
*/
|
||||
public enum FailReason {
|
||||
USER_AND_PASS_NOT_SPECIFIED("User and Password not specified"),
|
||||
|
@ -14,7 +14,7 @@ import com.djrapitops.plan.system.webserver.response.pages.DebugPageResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* PageHandler for /debug page.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@ import com.djrapitops.plan.system.webserver.response.api.SuccessResponse;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Enum containing default responses that don't need to be cached because they're always the same.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -5,6 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.pages;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.webserver.Request;
|
||||
import com.djrapitops.plan.system.webserver.auth.Authentication;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
@ -12,7 +13,7 @@ import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* PageHandlers are used for easier Response management and authorization checking.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@ -25,7 +26,7 @@ public abstract class PageHandler {
|
||||
* @param target Rest of the target coordinates after this page has been solved.
|
||||
* @return Response appropriate to the PageHandler.
|
||||
*/
|
||||
public abstract Response getResponse(Request request, List<String> target);
|
||||
public abstract Response getResponse(Request request, List<String> target) throws WebException;
|
||||
|
||||
public boolean isAuthorized(Authentication auth, List<String> target) throws WebUserAuthException {
|
||||
return true;
|
||||
|
@ -4,18 +4,17 @@
|
||||
*/
|
||||
package com.djrapitops.plan.system.webserver.pages;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.webserver.Request;
|
||||
import com.djrapitops.plan.system.webserver.auth.Authentication;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.response.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.response.cache.ResponseCache;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse;
|
||||
import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
@ -25,14 +24,14 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* PageHandler for /player/PlayerName pages.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlayerPageHandler extends PageHandler {
|
||||
|
||||
@Override
|
||||
public Response getResponse(Request request, List<String> target) {
|
||||
public Response getResponse(Request request, List<String> target) throws WebException {
|
||||
if (target.isEmpty()) {
|
||||
return DefaultResponses.NOT_FOUND.get();
|
||||
}
|
||||
@ -46,17 +45,9 @@ public class PlayerPageHandler extends PageHandler {
|
||||
|
||||
try {
|
||||
if (Database.getActive().check().isPlayerRegistered(uuid)) {
|
||||
PlanPlugin.getInstance().getInfoManager().cachePlayer(uuid);
|
||||
Response response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid));
|
||||
// TODO Create a new method that places NotFoundResponse to ResponseCache instead.
|
||||
if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) {
|
||||
ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> {
|
||||
try {
|
||||
return new InspectPageResponse(PlanPlugin.getInstance().getInfoManager(), uuid);
|
||||
} catch (ParseException e) {
|
||||
return new InternalErrorResponse(e, this.getClass().getName());
|
||||
}
|
||||
});
|
||||
if (response == null || !(response instanceof InspectPageResponse)) {
|
||||
InfoSystem.getInstance().generateAndCachePlayerPage(uuid);
|
||||
response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid));
|
||||
}
|
||||
return response;
|
||||
|
@ -15,7 +15,7 @@ import com.djrapitops.plan.system.webserver.response.pages.PlayersPageResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* PageHandler for /players page.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -5,6 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.pages;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.webserver.Request;
|
||||
import com.djrapitops.plan.system.webserver.ResponseHandler;
|
||||
@ -18,7 +19,9 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* PageHandler for / page (Address root).
|
||||
*
|
||||
* Not Available if Authentication is not enabled.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@ -31,7 +34,7 @@ public class RootPageHandler extends PageHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getResponse(Request request, List<String> target) {
|
||||
public Response getResponse(Request request, List<String> target) throws WebException {
|
||||
Optional<Authentication> auth = request.getAuth();
|
||||
if (!auth.isPresent()) {
|
||||
return DefaultResponses.BASIC_AUTH.get();
|
||||
|
@ -5,6 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.pages;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.webserver.Request;
|
||||
import com.djrapitops.plan.system.webserver.auth.Authentication;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
@ -14,7 +15,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Abstract PageHandler that allows Tree-like target deduction.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@ -45,7 +46,7 @@ public abstract class TreePageHandler extends PageHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getResponse(Request request, List<String> target) {
|
||||
public Response getResponse(Request request, List<String> target) throws WebException {
|
||||
PageHandler pageHandler = getPageHandler(target);
|
||||
return pageHandler != null
|
||||
? pageHandler.getResponse(request, target)
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.response;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Enum for HTTP content-type response header Strings.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -33,6 +33,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class WebAPI {
|
||||
|
||||
private static TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
|
@ -11,6 +11,8 @@ import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.NotFoundException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.info.server.BungeeServerInfoManager;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.response.cache.PageId;
|
||||
@ -26,8 +28,6 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.InspectWebAPI;
|
||||
import com.djrapitops.plan.system.webserver.webapi.bukkit.IsOnlineWebAPI;
|
||||
import com.djrapitops.plan.system.webserver.webapi.bungee.RequestPluginsTabWebAPI;
|
||||
import com.djrapitops.plan.systems.info.parsing.NetworkPage;
|
||||
import com.djrapitops.plan.system.info.server.BungeeServerInfoManager;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||
import com.djrapitops.plan.utilities.html.HtmlStructure;
|
||||
import com.djrapitops.plugin.api.utility.log.ErrorLogger;
|
||||
@ -387,7 +387,6 @@ public class BungeeInformationManager extends InformationManager {
|
||||
|
||||
@Override
|
||||
public TreeMap<String, List<String>> getErrors() throws IOException {
|
||||
// TODO Request Bukkit servers for errors
|
||||
return ErrorLogger.getLoggedErrors(plugin);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import com.djrapitops.plan.utilities.html.graphs.line.ServerPreferencePie;
|
||||
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plan.utilities.html.structure.ServerAccordionCreator;
|
||||
import com.djrapitops.plan.utilities.html.tables.ActionsTableCreator;
|
||||
import com.djrapitops.plan.utilities.html.tables.IpTableCreator;
|
||||
import com.djrapitops.plan.utilities.html.tables.GeoInfoTableCreator;
|
||||
import com.djrapitops.plan.utilities.html.tables.NicknameTableCreator;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
@ -117,7 +117,7 @@ public class InspectPage extends Page {
|
||||
addValue("favoriteServer", favoriteServer != null ? favoriteServer : "Unknown");
|
||||
|
||||
addValue("tableBodyNicknames", NicknameTableCreator.createTable(profile.getNicknames(), serverNames));
|
||||
addValue("tableBodyIPs", IpTableCreator.createTable(profile.getGeoInformation()));
|
||||
addValue("tableBodyIPs", GeoInfoTableCreator.createTable(profile.getGeoInformation()));
|
||||
|
||||
Map<UUID, List<Session>> sessions = profile.getSessions();
|
||||
Map<String, List<Session>> sessionsByServerName = sessions.entrySet().stream()
|
||||
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.utilities;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Utility for performing Base64 operations.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.utilities;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Utility class for performing actions if something is null.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.utilities.comparators;
|
||||
|
||||
import com.djrapitops.plan.data.HasDate;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Comparator for HasDate interface Objects.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class HasDateComparator implements Comparator<HasDate> {
|
||||
|
||||
private final boolean reversed;
|
||||
|
||||
public HasDateComparator() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public HasDateComparator(boolean reversed) {
|
||||
this.reversed = reversed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(HasDate o1, HasDate o2) {
|
||||
return (reversed ? -1 : 1) * Long.compare(o1.getDate(), o2.getDate());
|
||||
}
|
||||
}
|
@ -15,7 +15,9 @@ import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Graph creation utility for Activity Stack graph.
|
||||
*
|
||||
* This graph represents evolution of the playerbase.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@ import com.djrapitops.plan.settings.theme.ThemeVal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Utility class for creating Activity Pie data.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* HTML utility class for parsing HTML for Inspect page plugins tabs.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -20,7 +20,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* HTML utility class for creating a Session Accordion.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* HTML utility class used for creating main element on Sessions tabs.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -16,10 +16,9 @@ import java.util.List;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class IpTableCreator {
|
||||
public class GeoInfoTableCreator {
|
||||
|
||||
|
||||
public IpTableCreator() {
|
||||
public GeoInfoTableCreator() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
@ -30,7 +29,7 @@ public class IpTableCreator {
|
||||
html.append(Html.TABLELINE_3.parse("No Connections", "-", "-"));
|
||||
} else {
|
||||
for (GeoInfo info : geoInfo) {
|
||||
long date = info.getDate();
|
||||
long date = info.getLastUsed();
|
||||
html.append(Html.TABLELINE_3.parse(
|
||||
FormatUtils.formatIP(info.getIp()),
|
||||
info.getGeolocation(),
|
@ -21,7 +21,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Utility for creating HTML {@code <table>}-element with Sessions inside it.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -27,8 +27,6 @@ public class BStats {
|
||||
}
|
||||
|
||||
private void registerConfigSettingGraphs() {
|
||||
// TODO Write a Module bar graph
|
||||
|
||||
String serverType = plugin.getServer().getName();
|
||||
if ("CraftBukkit".equals(serverType) && Check.isSpigotAvailable()) {
|
||||
serverType = "Spigot";
|
||||
|
@ -18,11 +18,6 @@ import java.util.List;
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(JavaPlugin.class)
|
||||
public class PlayerProfileTest {
|
||||
|
@ -7,10 +7,12 @@ package com.djrapitops.plan.data;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Ignore
|
||||
public class SessionTest {
|
||||
|
||||
private Session session;
|
||||
|
@ -29,6 +29,7 @@ public class UserInfoTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
// TODO Rewrite
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ package com.djrapitops.plan.data.cache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
@ -29,6 +30,7 @@ public class SessionCacheTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
// TODO Rewrite
|
||||
}
|
||||
|
@ -14,11 +14,6 @@ import test.utilities.TestInit;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({JavaPlugin.class})
|
||||
public class WebServerTest {
|
||||
|
Loading…
Reference in New Issue
Block a user