mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-26 02:57:52 +01:00
MiscUtils.getIPlan
This commit is contained in:
parent
21503c953d
commit
6626875239
@ -1,9 +1,7 @@
|
||||
package main.java.com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Compatibility;
|
||||
import com.djrapitops.plugin.utilities.log.DebugInfo;
|
||||
import com.djrapitops.plugin.utilities.log.PluginLog;
|
||||
import main.java.com.djrapitops.plan.bungee.PlanBungee;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -139,11 +137,7 @@ public class Log {
|
||||
}
|
||||
|
||||
private static PluginLog getPluginLogger() {
|
||||
if (Compatibility.isBukkitAvailable()) {
|
||||
return Plan.getInstance().getPluginLogger();
|
||||
} else {
|
||||
return PlanBungee.getInstance().getPluginLogger();
|
||||
}
|
||||
return MiscUtils.getIPlan().getPluginLogger();
|
||||
}
|
||||
|
||||
public static void logStackTrace(Throwable e) {
|
||||
|
@ -12,9 +12,7 @@ import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.command.ConditionUtils;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.InspectPageResponse;
|
||||
import main.java.com.djrapitops.plan.systems.processing.info.InspectCacheRequestProcessor;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
@ -90,13 +88,7 @@ public class InspectCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
plugin.addToProcessQueue(new Processor<UUID>(uuid) {
|
||||
@Override
|
||||
public void process() {
|
||||
PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(plugin.getInfoManager(), uuid));
|
||||
sendInspectMsg(sender, playerName);
|
||||
}
|
||||
});
|
||||
plugin.addToProcessQueue(new InspectCacheRequestProcessor(uuid, sender, playerName));
|
||||
} catch (SQLException ex) {
|
||||
Log.toLog(this.getClass().getName(), ex);
|
||||
} finally {
|
||||
|
@ -14,7 +14,6 @@ import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Command for registering web users.
|
||||
@ -50,8 +49,8 @@ public class RegisterCommand extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
String notEnoughArgsMsg = Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse("(3) " + super.getArguments());
|
||||
String hashErrorMsg = ChatColor.RED + "Password hash error.";
|
||||
String permLvlErrorMsg = ChatColor.RED + "Incorrect perm level, not a number: ";
|
||||
String hashErrorMsg = "§cPassword hash error.";
|
||||
String permLvlErrorMsg = "§cIncorrect perm level, not a number: ";
|
||||
try {
|
||||
if (CommandUtils.isPlayer(sender)) {
|
||||
Log.info(sender.getName() + " issued WebUser register command.");
|
||||
@ -114,9 +113,9 @@ public class RegisterCommand extends SubCommand {
|
||||
plugin.getRunnableFactory().createNew(new AbsRunnable("Register WebUser Task") {
|
||||
@Override
|
||||
public void run() {
|
||||
final String existsMsg = ChatColor.RED + "User Already Exists!";
|
||||
final String existsMsg = "§cUser Already Exists!";
|
||||
final String userName = webUser.getName();
|
||||
final String successMsg = ChatColor.GREEN + "Added a new user (" + userName + ") successfully!";
|
||||
final String successMsg = "§aAdded a new user (" + userName + ") successfully!";
|
||||
try {
|
||||
SecurityTable securityTable = plugin.getDB().getSecurityTable();
|
||||
boolean userExists = securityTable.userExists(userName);
|
||||
|
@ -18,6 +18,7 @@ import main.java.com.djrapitops.plan.systems.info.parsing.AnalysisPageParser;
|
||||
import main.java.com.djrapitops.plan.systems.info.parsing.InspectPageParser;
|
||||
import main.java.com.djrapitops.plan.systems.info.parsing.UrlParser;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.InspectPageResponse;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
|
||||
@ -72,7 +73,7 @@ public class InformationManager {
|
||||
}
|
||||
|
||||
public void cachePlayer(UUID uuid) {
|
||||
plugin.addToProcessQueue(); // TODO Player page information parser
|
||||
PageCache.loadPage("inspectPage: "+uuid, () -> new InspectPageResponse(this, uuid));
|
||||
// TODO Player page plugin tab request
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 main.java.com.djrapitops.plan.systems.processing.info;
|
||||
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
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;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class InspectCacheRequestProcessor extends PlayerProcessor {
|
||||
|
||||
private final ISender sender;
|
||||
private final String playerName;
|
||||
|
||||
public InspectCacheRequestProcessor(UUID uuid, ISender sender, String playerName) {
|
||||
super(uuid);
|
||||
this.playerName = playerName;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
MiscUtils.getIPlan().getInfoManager().cachePlayer(getUUID());
|
||||
sendInspectMsg(sender, playerName);
|
||||
}
|
||||
|
||||
private void sendInspectMsg(ISender sender, String playerName) {
|
||||
sender.sendMessage(Locale.get(Msg.CMD_HEADER_INSPECT) + " " + playerName);
|
||||
// Link
|
||||
String url = HtmlUtils.getInspectUrlWithProtocol(playerName);
|
||||
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
sender.sendMessage(message + url);
|
||||
} else {
|
||||
sender.sendMessage(message);
|
||||
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
|
||||
}
|
||||
|
||||
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
|
||||
}
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plugin.utilities.BenchUtil;
|
||||
import com.djrapitops.plugin.utilities.Compatibility;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.bungee.PlanBungee;
|
||||
|
||||
/**
|
||||
* @author Rsl1122
|
||||
@ -49,10 +46,6 @@ public class Benchmark {
|
||||
}
|
||||
|
||||
private static BenchUtil getBenchUtil() {
|
||||
if (Compatibility.isBukkitAvailable()) {
|
||||
return Plan.getInstance().benchmark();
|
||||
} else {
|
||||
return PlanBungee.getInstance().benchmark();
|
||||
}
|
||||
return MiscUtils.getIPlan().benchmark();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.utilities.Compatibility;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.bungee.PlanBungee;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
@ -134,4 +135,12 @@ public class MiscUtils {
|
||||
return PlanBungee.getInstance().getDescription().getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
public static IPlan getIPlan() {
|
||||
if (Compatibility.isBukkitAvailable()) {
|
||||
return Plan.getInstance();
|
||||
} else {
|
||||
return PlanBungee.getInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user