MiscUtils.getIPlan

This commit is contained in:
Rsl1122 2017-08-30 18:59:23 +03:00
parent 21503c953d
commit 6626875239
7 changed files with 73 additions and 31 deletions

View File

@ -1,9 +1,7 @@
package main.java.com.djrapitops.plan; 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.DebugInfo;
import com.djrapitops.plugin.utilities.log.PluginLog; import com.djrapitops.plugin.utilities.log.PluginLog;
import main.java.com.djrapitops.plan.bungee.PlanBungee;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.util.Collection; import java.util.Collection;
@ -139,11 +137,7 @@ public class Log {
} }
private static PluginLog getPluginLogger() { private static PluginLog getPluginLogger() {
if (Compatibility.isBukkitAvailable()) { return MiscUtils.getIPlan().getPluginLogger();
return Plan.getInstance().getPluginLogger();
} else {
return PlanBungee.getInstance().getPluginLogger();
}
} }
public static void logStackTrace(Throwable e) { public static void logStackTrace(Throwable e) {

View File

@ -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.command.ConditionUtils;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.processing.Processor; import main.java.com.djrapitops.plan.systems.processing.info.InspectCacheRequestProcessor;
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.Check; import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils; import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
@ -90,13 +88,7 @@ public class InspectCommand extends SubCommand {
} }
} }
plugin.addToProcessQueue(new Processor<UUID>(uuid) { plugin.addToProcessQueue(new InspectCacheRequestProcessor(uuid, sender, playerName));
@Override
public void process() {
PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(plugin.getInfoManager(), uuid));
sendInspectMsg(sender, playerName);
}
});
} catch (SQLException ex) { } catch (SQLException ex) {
Log.toLog(this.getClass().getName(), ex); Log.toLog(this.getClass().getName(), ex);
} finally { } finally {

View File

@ -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.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil; import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
import org.bukkit.ChatColor;
/** /**
* Command for registering web users. * Command for registering web users.
@ -50,8 +49,8 @@ public class RegisterCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
String notEnoughArgsMsg = Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse("(3) " + super.getArguments()); String notEnoughArgsMsg = Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse("(3) " + super.getArguments());
String hashErrorMsg = ChatColor.RED + "Password hash error."; String hashErrorMsg = "§cPassword hash error.";
String permLvlErrorMsg = ChatColor.RED + "Incorrect perm level, not a number: "; String permLvlErrorMsg = "§cIncorrect perm level, not a number: ";
try { try {
if (CommandUtils.isPlayer(sender)) { if (CommandUtils.isPlayer(sender)) {
Log.info(sender.getName() + " issued WebUser register command."); 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") { plugin.getRunnableFactory().createNew(new AbsRunnable("Register WebUser Task") {
@Override @Override
public void run() { public void run() {
final String existsMsg = ChatColor.RED + "User Already Exists!"; final String existsMsg = "§cUser Already Exists!";
final String userName = webUser.getName(); 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 { try {
SecurityTable securityTable = plugin.getDB().getSecurityTable(); SecurityTable securityTable = plugin.getDB().getSecurityTable();
boolean userExists = securityTable.userExists(userName); boolean userExists = securityTable.userExists(userName);

View File

@ -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.InspectPageParser;
import main.java.com.djrapitops.plan.systems.info.parsing.UrlParser; 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.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.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.Analysis; import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
@ -72,7 +73,7 @@ public class InformationManager {
} }
public void cachePlayer(UUID uuid) { 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 // TODO Player page plugin tab request
} }

View File

@ -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());
}
}

View File

@ -1,10 +1,7 @@
package main.java.com.djrapitops.plan.utilities; package main.java.com.djrapitops.plan.utilities;
import com.djrapitops.plugin.utilities.BenchUtil; 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.Log;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.bungee.PlanBungee;
/** /**
* @author Rsl1122 * @author Rsl1122
@ -49,10 +46,6 @@ public class Benchmark {
} }
private static BenchUtil getBenchUtil() { private static BenchUtil getBenchUtil() {
if (Compatibility.isBukkitAvailable()) { return MiscUtils.getIPlan().benchmark();
return Plan.getInstance().benchmark();
} else {
return PlanBungee.getInstance().benchmark();
}
} }
} }

View File

@ -6,6 +6,7 @@ import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.utilities.Compatibility; import com.djrapitops.plugin.utilities.Compatibility;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; 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.bungee.PlanBungee;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
@ -134,4 +135,12 @@ public class MiscUtils {
return PlanBungee.getInstance().getDescription().getVersion(); return PlanBungee.getInstance().getDescription().getVersion();
} }
} }
public static IPlan getIPlan() {
if (Compatibility.isBukkitAvailable()) {
return Plan.getInstance();
} else {
return PlanBungee.getInstance();
}
}
} }