Skip to content

Commit

Permalink
Fixed many url issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraLS3 committed Sep 26, 2017
1 parent 7dcbac3 commit 3c58681
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 55 deletions.
2 changes: 1 addition & 1 deletion Plan/src/main/java/com/djrapitops/plan/api/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void addPluginDataSource(PluginData dataSource) {
* @return ./player/PlayerName
*/
public String getPlayerInspectPageLink(String name) {
return plugin.getInfoManager().getLinkTo("/player/" + name).relative().toString();
return "../player/" + name;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void sendAnalysisMessage(Collection<ISender> senders, UUID serverU
Optional<String> serverName = plugin.getDB().getServerTable().getServerName(serverUUID);
if (serverName.isPresent()) {
String target = "/server/" + serverName.get();
String url = plugin.getInfoManager().getLinkTo(target).toString();
String url = plugin.getInfoManager().getLinkTo(target);
String message = Locale.get(Msg.CMD_INFO_LINK).toString();

for (ISender sender : senders) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;

/**
* Command used to display link to the player list webpage.
Expand Down Expand Up @@ -43,7 +43,7 @@ private void sendListMsg(ISender sender) {
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse());

// Link
String url = HtmlUtils.getServerAnalysisUrlWithProtocol().replace("server", "players");
String url = Plan.getInstance().getInfoManager().getLinkTo("/players");
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
boolean console = !CommandUtils.isPlayer(sender);
if (console) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.djrapitops.plugin.command.ISender;
import main.java.com.djrapitops.plan.systems.cache.DataCache;
import main.java.com.djrapitops.plan.systems.cache.SessionCache;
import main.java.com.djrapitops.plan.systems.info.parsing.UrlParser;
import main.java.com.djrapitops.plan.systems.webserver.PageCache;

import java.util.*;
Expand All @@ -32,12 +31,8 @@ public InformationManager() {

public abstract void cachePlayer(UUID uuid);

public UrlParser getLinkTo(String target) {
if (webServerAddress != null) {
return new UrlParser(webServerAddress).target(target);
} else {
return new UrlParser("");
}
public String getLinkTo(String target) {
return getWebServerAddress() + target;
}

public abstract void refreshAnalysis(UUID serverUUID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.cache.DataCache;
import main.java.com.djrapitops.plan.systems.processing.player.PlayerProcessor;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;

import java.util.UUID;

Expand Down Expand Up @@ -46,7 +46,7 @@ public void process() {
private void sendInspectMsg(ISender sender, String playerName) {
sender.sendMessage(Locale.get(Msg.CMD_HEADER_INSPECT) + " " + playerName);
// Link
String url = HtmlUtils.getInspectUrlWithProtocol(playerName);
String url = Plan.getInstance().getInfoManager().getLinkTo("/player/" + playerName);
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
boolean console = !CommandUtils.isPlayer(sender);
if (console) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import main.java.com.djrapitops.plan.systems.webserver.response.*;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;

import java.sql.SQLException;
Expand Down Expand Up @@ -217,10 +216,12 @@ private Response playerResponse(String[] args) {

private Response notFoundResponse() {
String error = "404 Not Found";
return PageCache.loadPage("notFound: " + error, () ->
new NotFoundResponse("Make sure you're accessing a link given by a command, Examples:</p>"
+ "<p>" + webServer.getProtocol() + ":" + HtmlUtils.getInspectUrl("<player>") + " or<br>"
+ webServer.getProtocol() + ":" + HtmlUtils.getServerAnalysisUrl())
return PageCache.loadPage("notFound: " + error, () -> {
String url = plugin.getInfoManager().getWebServerAddress();
return new NotFoundResponse("Make sure you're accessing a link given by a command, Examples:</p>"
+ "<p>" + url + "/player/Playername<br>" +
url + "/server</p>");
}
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedComparator;
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
import main.java.com.djrapitops.plan.utilities.html.tables.PlayersTableCreator;
import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -122,7 +121,7 @@ public boolean analyzeData(InformationManager infoManager, Database db) {

Log.logDebug("Analysis", time);

Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(String.valueOf(time), HtmlUtils.getServerAnalysisUrlWithProtocol()));
Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(String.valueOf(time), ""));

// TODO Export
// ExportUtility.export(analysisData, rawData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public static String createServerContainer(Plan plugin) {
boolean analysisIsAvailable = analysisRefreshDate.isPresent();

String serverName = plugin.getServerInfoManager().getServerName();
String address = plugin.getInfoManager().getLinkTo("/server/" + serverName).relative().toString();
String address = "../server/" + serverName;

StringBuilder b = new StringBuilder("<div class=\"column\">");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ public static String replacePlaceholders(String html, Map<String, Serializable>
return sub.replace(html);
}

/**
* @return
*/
public static String getServerAnalysisUrlWithProtocol() {
return getProtocol() + ":" + getServerAnalysisUrl();
}

/**
* @return
*/
public static String getServerAnalysisUrl() {
String ip = getIP();
return "//" + ip + "/server";
}

/**
* Used to get the WebServer's IP with Port.
*
Expand All @@ -70,25 +55,6 @@ public static String getProtocol() {
return uiServer.isEnabled() ? uiServer.getProtocol() : Settings.EXTERNAL_WEBSERVER_LINK_PROTOCOL.toString();
}

/**
* @param playerName
* @return
*/
public static String getInspectUrlWithProtocol(String playerName) {
return getProtocol() + ":" + getInspectUrl(playerName);
}

/**
* @param playerName
* @return
* @deprecated Use getRelativeInspectUrl instead.
*/
@Deprecated
public static String getInspectUrl(String playerName) {
String ip = getIP();
return "//" + ip + "/player/" + playerName.replace(" ", "%20").replace(".", "%2E");
}

public static String getRelativeInspectUrl(String playerName) {
return "../player/" + playerName.replace(" ", "%20").replace(".", "%2E");
}
Expand Down

0 comments on commit 3c58681

Please sign in to comment.