mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-07 17:28:03 +08:00
Fixed InternalStateException Player profile was null when a new player registers #446
This commit is contained in:
parent
7f580bffe9
commit
65db632874
@ -2,6 +2,7 @@ package main.java.com.djrapitops.plan.api;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.data.plugin.PluginData;
|
||||
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||
@ -142,7 +143,7 @@ public class API {
|
||||
* @param uuid UUID of the player.
|
||||
* @return player.html with all placeholders replaced.
|
||||
*/
|
||||
public String getPlayerHtmlAsString(UUID uuid) {
|
||||
public String getPlayerHtmlAsString(UUID uuid) throws ParseException {
|
||||
return plugin.getInfoManager().getPlayerHtml(uuid);
|
||||
}
|
||||
|
||||
|
@ -108,9 +108,25 @@ public class BukkitInformationManager extends InformationManager {
|
||||
} catch (WebAPIException e) {
|
||||
attemptConnection();
|
||||
cachePlayer(uuid);
|
||||
} catch (ParseException e) {
|
||||
if (!(e.getCause() instanceof IllegalStateException)) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PageCache.cachePage("inspectPage: " + uuid, () -> new InspectPageResponse(this, uuid));
|
||||
PageCache.cachePage("inspectPage: " + uuid, () -> {
|
||||
try {
|
||||
return new InspectPageResponse(this, uuid);
|
||||
} catch (ParseException e) {
|
||||
if (e.getCause() instanceof IllegalStateException) {
|
||||
return new NotFoundResponse(
|
||||
"Player just registered, so the data was not yet in the database. " +
|
||||
"Please wait until they log off or use /plan inspect <player>"
|
||||
);
|
||||
}
|
||||
return new InternalErrorResponse(e, this.getClass().getName());
|
||||
}
|
||||
});
|
||||
if (Settings.ANALYSIS_EXPORT.isTrue()) {
|
||||
HtmlExport.exportPlayer(plugin, uuid);
|
||||
}
|
||||
@ -246,12 +262,8 @@ public class BukkitInformationManager extends InformationManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerHtml(UUID uuid) {
|
||||
try {
|
||||
return Theme.replaceColors(new InspectPageParser(uuid, plugin).parse());
|
||||
} catch (ParseException e) {
|
||||
return new InternalErrorResponse(e, this.getClass().getSimpleName()).getContent();
|
||||
}
|
||||
public String getPlayerHtml(UUID uuid) throws ParseException {
|
||||
return Theme.replaceColors(new InspectPageParser(uuid, plugin).parse());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,7 @@
|
||||
package main.java.com.djrapitops.plan.systems.info;
|
||||
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.ParseException;
|
||||
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.webserver.PageCache;
|
||||
@ -48,7 +49,7 @@ public abstract class InformationManager {
|
||||
return PageCache.isCached("inspectPage: " + uuid);
|
||||
}
|
||||
|
||||
public abstract String getPlayerHtml(UUID uuid);
|
||||
public abstract String getPlayerHtml(UUID uuid) throws ParseException;
|
||||
|
||||
/**
|
||||
* Used for /server on Bukkit and /network on Bungee
|
||||
|
@ -1,5 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.systems.webserver.response;
|
||||
|
||||
import main.java.com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
@ -16,7 +17,7 @@ public class InspectPageResponse extends Response {
|
||||
|
||||
private final UUID uuid;
|
||||
|
||||
public InspectPageResponse(InformationManager infoManager, UUID uuid) {
|
||||
public InspectPageResponse(InformationManager infoManager, UUID uuid) throws ParseException {
|
||||
this.uuid = uuid;
|
||||
super.setHeader("HTTP/1.1 200 OK");
|
||||
super.setContent(infoManager.getPlayerHtml(uuid));
|
||||
|
Loading…
Reference in New Issue
Block a user