Added some unit tests & Pit and Checkstyle tools
This commit is contained in:
parent
aaae83cb0a
commit
0feef90973
|
@ -4,9 +4,6 @@
|
|||
/Plan Lite/build/
|
||||
/Plan Lite/dist/
|
||||
/Plan Lite/nbproject/private/
|
||||
/Plan Advanced/build/
|
||||
/Plan Advanced/dist/
|
||||
/Plan Advanced/nbproject/private/
|
||||
/Plan/target/
|
||||
/Plan/nbproject/
|
||||
/Debugger/nbproject/private/
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<module name='Checker'>
|
||||
|
||||
<!-- asetetaan kieliasetukset englanniksi. -->
|
||||
<property name="localeCountry" value="EN"/>
|
||||
<property name="localeLanguage" value="en"/>
|
||||
|
||||
<module name='TreeWalker'>
|
||||
|
||||
<property name='tabWidth' value='4' />
|
||||
|
||||
<!-- Block Checks -->
|
||||
|
||||
<module name='EmptyBlock' />
|
||||
<module name='LeftCurly' />
|
||||
<module name='NeedBraces' />
|
||||
<module name='RightCurly' />
|
||||
<module name='AvoidNestedBlocks' />
|
||||
<module name="NestedIfDepth">
|
||||
<property name="max" value="2"/>
|
||||
</module>
|
||||
<module name="NestedForDepth">
|
||||
<property name="max" value="2"/>
|
||||
</module>
|
||||
<module name="NestedTryDepth"/>
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<module name='Indentation' />
|
||||
<module name="OneStatementPerLine"/>
|
||||
|
||||
<!--- Naming Conventions -->
|
||||
|
||||
<module name='ClassTypeParameterName' />
|
||||
<module name='ConstantName' />
|
||||
<module name='LocalFinalVariableName' />
|
||||
<module name='LocalVariableName' />
|
||||
<module name='MemberName' />
|
||||
<module name='MethodName' />
|
||||
<module name='MethodTypeParameterName' />
|
||||
|
||||
<module name='PackageName'>
|
||||
<property name='format' value='^[a-z]+(\.[a-z][a-z0-9]*)*$' />
|
||||
</module>
|
||||
|
||||
<module name='ParameterName' />
|
||||
<module name='StaticVariableName' />
|
||||
<module name='TypeName' />
|
||||
|
||||
<!-- Whitespace -->
|
||||
|
||||
<module name='GenericWhitespace' />
|
||||
<module name='EmptyForInitializerPad' />
|
||||
<module name='EmptyForIteratorPad' />
|
||||
<module name='MethodParamPad' />
|
||||
|
||||
<module name='NoWhitespaceAfter'>
|
||||
<property name='tokens' value='BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS' />
|
||||
</module>
|
||||
|
||||
<module name='NoWhitespaceBefore'>
|
||||
<property name='tokens' value='SEMI, DOT, POST_DEC, POST_INC' />
|
||||
<property name='allowLineBreaks' value='true' />
|
||||
</module>
|
||||
|
||||
<module name='ParenPad' />
|
||||
<module name='TypecastParenPad' />
|
||||
<module name='WhitespaceAfter' />
|
||||
|
||||
<module name='WhitespaceAround'>
|
||||
<property name='allowEmptyConstructors' value='true' />
|
||||
<property name='allowEmptyMethods' value='true' />
|
||||
</module>
|
||||
|
||||
</module>
|
||||
|
||||
<!-- File Length -->
|
||||
|
||||
<module name='FileLength'>
|
||||
<property name='max' value='2000' />
|
||||
</module>
|
||||
|
||||
</module>
|
|
@ -1,47 +1,62 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<actions>
|
||||
<action>
|
||||
<actionName>run</actionName>
|
||||
<preAction>build-with-dependencies</preAction>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath D:\Minecraft Servers\Buildtools\craftbukkit-1.11.2 -classpath %classpath org.bukkit.craftbukkit.Main -classpath D:\Minecraft Servers\Buildtools\craftbukkit-1.11.2</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>debug</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath D:\Minecraft Servers\Buildtools\craftbukkit-1.11.2 -classpath %classpath org.bukkit.craftbukkit.Main -classpath D:\Minecraft Servers\Buildtools\craftbukkit-1.11.2</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<jpda.listen>true</jpda.listen>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>profile</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath D:\Minecraft Servers\Buildtools\craftbukkit-1.11.2 -classpath %classpath org.bukkit.craftbukkit.Main -classpath D:\Minecraft Servers\Buildtools\craftbukkit-1.11.2</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
</properties>
|
||||
</action>
|
||||
</actions>
|
||||
<action>
|
||||
<actionName>CUSTOM-checkstyle</actionName>
|
||||
<displayName>Checkstyle</displayName>
|
||||
<goals>
|
||||
<goal>jxr:jxr</goal>
|
||||
<goal>checkstyle:checkstyle</goal>
|
||||
</goals>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>CUSTOM-pit</actionName>
|
||||
<displayName>pit</displayName>
|
||||
<goals>
|
||||
<goal>org.pitest:pitest-maven:mutationCoverage</goal>
|
||||
</goals>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>run</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath %classpath com.djrapitops.nmplayer.NMPlayer</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>debug</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.djrapitops.nmplayer.NMPlayer</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<jpda.listen>true</jpda.listen>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>profile</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath %classpath com.djrapitops.nmplayer.NMPlayer</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
</properties>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
|
|
92
Plan/pom.xml
92
Plan/pom.xml
|
@ -55,7 +55,62 @@
|
|||
<version>0.91.4.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- -->
|
||||
<!-- -->
|
||||
<!-- <dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito</artifactId>
|
||||
<version>1.6.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>1.6.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4-rule</artifactId>
|
||||
<version>1.6.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-classloading-xstream</artifactId>
|
||||
<version>1.6.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>1.10.19</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-easymock</artifactId>
|
||||
<version>1.6.6</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>clean package install</defaultGoal>
|
||||
|
@ -81,13 +136,7 @@
|
|||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!-- <plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -102,8 +151,33 @@
|
|||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-maven</artifactId>
|
||||
<version>1.1.8</version>
|
||||
<configuration>
|
||||
<targetClasses>
|
||||
<param>main.java.com.djrapitops.*</param>
|
||||
</targetClasses>
|
||||
<targetTests>
|
||||
<param>test.java.main.java.com.djrapitops.*</param>
|
||||
</targetTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<configuration>
|
||||
<configLocation>checkstyle.xml</configLocation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- <plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
|
|
|
@ -32,9 +32,9 @@ public enum Phrase {
|
|||
DB_FAILURE_DISABLE("Database initialization has failed, disabling Plan."),
|
||||
NOTIFY_EMPTY_IP(ChatColor.YELLOW + "" + PREFIX + "IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!"),
|
||||
//
|
||||
CACHE_SAVETASK_DISABLED("Attempted to schedule data for save after task was shut down."),
|
||||
CACHE_GETTASK_DISABLED("Attempted to schedule data grab after task was shut down."),
|
||||
CACHE_CLEARTASK_DISABLED("Attempted to schedule data for clear after task was shut down."),
|
||||
CACHE_SAVETASK_DISABLED("Attempted to schedule data for save after task was shut down."),
|
||||
CACHE_GETTASK_DISABLED("Attempted to schedule data grab after task was shut down."),
|
||||
CACHE_CLEARTASK_DISABLED("Attempted to schedule data for clear after task was shut down."),
|
||||
//
|
||||
VERSION_NEW_AVAILABLE("New Version (" + REPLACE0 + ") is availible at https://www.spigotmc.org/resources/plan-player-analytics.32536/"),
|
||||
VERSION_LATEST("You're running the latest version"),
|
||||
|
@ -45,9 +45,9 @@ public enum Phrase {
|
|||
USERNAME_NOT_SEEN(ChatColor.RED + "" + PREFIX + "This Player has not played on this server."),
|
||||
USERNAME_NOT_KNOWN(ChatColor.RED + "" + PREFIX + "Player not found from the database."),
|
||||
//
|
||||
COLOR_MAIN(ChatColor.getByChar(getPlugin(Plan.class).getConfig().getString("Customization.Colors.Commands.Main").charAt(1))),
|
||||
COLOR_SEC(ChatColor.getByChar(getPlugin(Plan.class).getConfig().getString("Customization.Colors.Commands.Secondary").charAt(1))),
|
||||
COLOR_TER(ChatColor.getByChar(getPlugin(Plan.class).getConfig().getString("Customization.Colors.Commands.Highlight").charAt(1))),
|
||||
COLOR_MAIN(""),
|
||||
COLOR_SEC(""),
|
||||
COLOR_TER(""),
|
||||
//
|
||||
ARROWS_RIGHT("»"),
|
||||
BALL("•"),
|
||||
|
@ -74,7 +74,7 @@ public enum Phrase {
|
|||
ERROR_NO_DATA_VIEW(ChatColor.YELLOW + "Webserver disabled but Alternative IP/PlanLite not used, no way to view data!"),
|
||||
ERROR_WEBSERVER_OFF_ANALYSIS(ChatColor.YELLOW + "" + PREFIX + "This command can be only used if the webserver is running on this server."),
|
||||
ERROR_WEBSERVER_OFF_INSPECT(ChatColor.YELLOW + "" + PREFIX + "This command can be only used if webserver/planlite is enabled on this server."),
|
||||
ERROR_LOGGED("Caught "+REPLACE0+". It has been logged to the Errors.txt"),
|
||||
ERROR_LOGGED("Caught " + REPLACE0 + ". It has been logged to the Errors.txt"),
|
||||
ERROR_SESSIONDATA_INITIALIZATION("Player's session was initialized in a wrong way! (" + REPLACE0 + ")"),
|
||||
//
|
||||
CMD_FOOTER(COLOR_TER.color() + "" + ARROWS_RIGHT),
|
||||
|
@ -152,7 +152,7 @@ public enum Phrase {
|
|||
COMMAND_REQUIRES_ARGUMENTS(ChatColor.RED + "" + PREFIX + "Command requires arguments. REPLACE0"),
|
||||
COMMAND_ADD_CONFIRMATION_ARGUMENT(ChatColor.RED + "" + PREFIX + "Add -a to confirm execution! REPLACE0"),
|
||||
COMMAND_REQUIRES_ARGUMENTS_ONE(ChatColor.RED + "" + PREFIX + "Command requires one argument."),
|
||||
COMMAND_NO_PERMISSION(ChatColor.RED + "" + PREFIX + "You do not have the required permmission."),
|
||||
COMMAND_NO_PERMISSION(ChatColor.RED + "" + PREFIX + "You do not have the required permmission."),
|
||||
ERROR_TOO_SMALL_QUEUE("Queue size is too small! (REPLACE0), change the setting to a higher number! (Currently REPLACE1)");
|
||||
|
||||
private String text;
|
||||
|
|
|
@ -132,6 +132,10 @@ public class Plan extends JavaPlugin {
|
|||
}
|
||||
|
||||
hookHandler = new HookHandler(this);
|
||||
Phrase.COLOR_MAIN.setColor(Settings.COLOR_MAIN.toString().charAt(1)+"");
|
||||
Phrase.COLOR_SEC.setColor(Settings.COLOR_SEC.toString().charAt(1)+"");
|
||||
Phrase.COLOR_TER.setColor(Settings.COLOR_TER.toString().charAt(1)+"");
|
||||
|
||||
log(Phrase.ENABLED + "");
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,10 @@ public enum Settings {
|
|||
LOCALE("Settings.Locale"),
|
||||
SECURITY_CODE("Settings.WebServer.Security.AddressSecurityCode"),
|
||||
//
|
||||
COLOR_MAIN("Customization.Colors.Commands.Main"),
|
||||
COLOR_SEC("Customization.Colors.Commands.Secondary"),
|
||||
COLOR_TER("Customization.Colors.Commands.Highlight"),
|
||||
//
|
||||
HCOLOR_ACT_ONL("Customization.Colors.HTML.ActivityGraph.OnlinePlayers"),
|
||||
HCOLOR_ACT_ONL_FILL("Customization.Colors.HTML.ActivityGraph.OnlinePlayersFill"),
|
||||
HCOLOR_ACTP_ACT("Customization.Colors.HTML.ActivityPie.Active"),
|
||||
|
@ -43,7 +47,7 @@ public enum Settings {
|
|||
HCOLOR_ACTP_JON("Customization.Colors.HTML.ActivityPie.JoinedOnce"),
|
||||
HCOLOR_GMP_0("Customization.Colors.HTML.GamemodePie.Survival"),
|
||||
HCOLOR_GMP_1("Customization.Colors.HTML.GamemodePie.Creative"),
|
||||
HCOLOR_GMP_2("Customization.Colors.HTML.GamemodePie.Adventure"),
|
||||
HCOLOR_GMP_2("Customization.Colors.HTML.GamemodePie.Adventure"),
|
||||
HCOLOR_GMP_3("Customization.Colors.HTML.GamemodePie.Spectator"),
|
||||
HCOLOR_GENP_M("Customization.Colors.HTML.GenderPie.Male"),
|
||||
HCOLOR_GENP_F("Customization.Colors.HTML.GenderPie.Female"),
|
||||
|
|
|
@ -104,7 +104,7 @@ public class PlanCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
if (console && args.length < 2 && command.getCommandType() == CommandType.CONSOLE_WITH_ARGUMENTS) {
|
||||
sender.sendMessage("" + Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_PLAN+""));
|
||||
sender.sendMessage("" + Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_PLAN + ""));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AnalyzeCommand extends SubCommand {
|
|||
* @return true in all cases.
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||
if (!Settings.SHOW_ALTERNATIVE_IP.isTrue()) {
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_ANALYSIS.toString());
|
||||
|
@ -59,7 +59,7 @@ public class AnalyzeCommand extends SubCommand {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE+"");
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||
if (!analysisCache.isCached()) {
|
||||
int bootAnID = plugin.getBootAnalysisTaskID();
|
||||
if (bootAnID != -1) {
|
||||
|
@ -70,9 +70,9 @@ public class AnalyzeCommand extends SubCommand {
|
|||
analysisCache.updateCache();
|
||||
}
|
||||
|
||||
BukkitTask analysisMessageSenderTask = (new BukkitRunnable() {
|
||||
BukkitTask analysisMessageSenderTask = (new BukkitRunnable() {
|
||||
private int timesrun = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
timesrun++;
|
||||
|
@ -91,16 +91,16 @@ public class AnalyzeCommand extends SubCommand {
|
|||
|
||||
/**
|
||||
* Used to send the message after /plan analysis.
|
||||
*
|
||||
* @param sender Command sender.
|
||||
* @throws CommandException
|
||||
*/
|
||||
public void sendAnalysisMessage(CommandSender sender) throws CommandException {
|
||||
|
||||
|
||||
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER+"");
|
||||
|
||||
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
|
||||
// Link
|
||||
String url = HtmlUtils.getServerAnalysisUrl();
|
||||
String message = Phrase.CMD_LINK+"";
|
||||
String message = Phrase.CMD_LINK + "";
|
||||
boolean console = !(sender instanceof Player);
|
||||
if (console) {
|
||||
sender.sendMessage(message + url);
|
||||
|
@ -109,9 +109,9 @@ public class AnalyzeCommand extends SubCommand {
|
|||
Player player = (Player) sender;
|
||||
Bukkit.getServer().dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw " + player.getName() + " [\"\",{\"text\":\""+Phrase.CMD_CLICK_ME+"\",\"underlined\":true,"
|
||||
"tellraw " + player.getName() + " [\"\",{\"text\":\"" + Phrase.CMD_CLICK_ME + "\",\"underlined\":true,"
|
||||
+ "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]");
|
||||
}
|
||||
sender.sendMessage(Phrase.CMD_FOOTER+"");
|
||||
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class HelpCommand extends SubCommand {
|
|||
* @param command Current instance of PlanCommand
|
||||
*/
|
||||
public HelpCommand(Plan plugin, PlanCommand command) {
|
||||
super("help,?", "plan.?", Phrase.CMD_USG_HELP+"", CommandType.CONSOLE, "");
|
||||
super("help,?", "plan.?", Phrase.CMD_USG_HELP + "", CommandType.CONSOLE, "");
|
||||
|
||||
this.plugin = plugin;
|
||||
this.command = command;
|
||||
|
@ -39,7 +39,7 @@ public class HelpCommand extends SubCommand {
|
|||
ChatColor tColor = Phrase.COLOR_SEC.color();
|
||||
|
||||
// Header
|
||||
sender.sendMessage(Phrase.CMD_HELP_HEADER+"");
|
||||
sender.sendMessage(Phrase.CMD_HELP_HEADER + "");
|
||||
// Help results
|
||||
for (SubCommand command : this.command.getCommands()) {
|
||||
if (command.getName().equalsIgnoreCase(getName())) {
|
||||
|
@ -58,7 +58,7 @@ public class HelpCommand extends SubCommand {
|
|||
+ " /plan " + command.getFirstName() + " " + command.getArguments() + tColor + " - " + command.getUsage());
|
||||
}
|
||||
// Footer
|
||||
sender.sendMessage(Phrase.CMD_FOOTER+"");
|
||||
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class InfoCommand extends SubCommand {
|
|||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public InfoCommand(Plan plugin) {
|
||||
super("info", "plan.info", Phrase.CMD_USG_INFO+"", CommandType.CONSOLE, "");
|
||||
super("info", "plan.info", Phrase.CMD_USG_INFO + "", CommandType.CONSOLE, "");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ public class InfoCommand extends SubCommand {
|
|||
ChatColor tColor = Phrase.COLOR_SEC.color();
|
||||
|
||||
String[] messages = {
|
||||
Phrase.CMD_INFO_HEADER+"",
|
||||
Phrase.CMD_INFO_HEADER + "",
|
||||
Phrase.CMD_INFO_VERSION.parse(plugin.getDescription().getVersion()),
|
||||
Phrase.CMD_BALL.toString() + tColor + " " + MiscUtils.checkVersion(),
|
||||
Phrase.CMD_MANAGE_STATUS_ACTIVE_DB.parse(plugin.getDB().getConfigName()),
|
||||
Phrase.CMD_FOOTER+""
|
||||
Phrase.CMD_FOOTER + ""
|
||||
};
|
||||
sender.sendMessage(messages);
|
||||
return true;
|
||||
|
|
|
@ -21,7 +21,7 @@ public class ReloadCommand extends SubCommand {
|
|||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ReloadCommand(Plan plugin) {
|
||||
super("reload", "plan.reload", Phrase.CMD_USG_RELOAD+"", CommandType.CONSOLE, "");
|
||||
super("reload", "plan.reload", Phrase.CMD_USG_RELOAD + "", CommandType.CONSOLE, "");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class ReloadCommand extends SubCommand {
|
|||
plugin.reloadConfig();
|
||||
plugin.onDisable();
|
||||
plugin.onEnable();
|
||||
sender.sendMessage(Phrase.RELOAD_COMPLETE+"");
|
||||
sender.sendMessage(Phrase.RELOAD_COMPLETE + "");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ManageHelpCommand extends SubCommand {
|
|||
* @param command Current instance of PlanCommand
|
||||
*/
|
||||
public ManageHelpCommand(Plan plugin, ManageCommand command) {
|
||||
super("help,?", "plan.manage", Phrase.CMD_USG_MANAGE_HELP+"", CommandType.CONSOLE, "");
|
||||
super("help,?", "plan.manage", Phrase.CMD_USG_MANAGE_HELP + "", CommandType.CONSOLE, "");
|
||||
|
||||
this.plugin = plugin;
|
||||
this.command = command;
|
||||
|
@ -40,7 +40,7 @@ public class ManageHelpCommand extends SubCommand {
|
|||
ChatColor hColor = Phrase.COLOR_TER.color();
|
||||
|
||||
// Header
|
||||
sender.sendMessage(Phrase.CMD_MANAGE_HELP_HEADER+"");
|
||||
sender.sendMessage(Phrase.CMD_MANAGE_HELP_HEADER + "");
|
||||
// Help results
|
||||
for (SubCommand command : this.command.getCommands()) {
|
||||
if (command.getName().equalsIgnoreCase(getName())) {
|
||||
|
|
|
@ -23,15 +23,15 @@ public class ManageHotswapCommand extends SubCommand {
|
|||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageHotswapCommand(Plan plugin) {
|
||||
super("hotswap", "plan.manage", Phrase.CMD_USG_MANAGE_HOTSWAP+"", CommandType.CONSOLE_WITH_ARGUMENTS, "<DB>");
|
||||
super("hotswap", "plan.manage", Phrase.CMD_USG_MANAGE_HOTSWAP + "", CommandType.CONSOLE_WITH_ARGUMENTS, "<DB>");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subcommand hotswap.
|
||||
* Swaps db type and reloads plugin if the connection works.
|
||||
*
|
||||
* Subcommand hotswap. Swaps db type and reloads plugin if the connection
|
||||
* works.
|
||||
*
|
||||
* @param sender
|
||||
* @param cmd
|
||||
* @param commandLabel
|
||||
|
|
|
@ -22,7 +22,7 @@ public class ManageStatusCommand extends SubCommand {
|
|||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageStatusCommand(Plan plugin) {
|
||||
super("status", "plan.manage", Phrase.CMD_USG_MANAGE_STATUS+"", CommandType.CONSOLE, "");
|
||||
super("status", "plan.manage", Phrase.CMD_USG_MANAGE_STATUS + "", CommandType.CONSOLE, "");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ public class ManageStatusCommand extends SubCommand {
|
|||
ChatColor hColor = Phrase.COLOR_TER.color();
|
||||
|
||||
// Header
|
||||
sender.sendMessage(Phrase.CMD_MANAGE_STATUS_HEADER+"");
|
||||
|
||||
sender.sendMessage(Phrase.CMD_MANAGE_STATUS_HEADER + "");
|
||||
|
||||
sender.sendMessage(Phrase.CMD_MANAGE_STATUS_ACTIVE_DB.parse(plugin.getDB().getConfigName()));
|
||||
|
||||
|
||||
// Footer
|
||||
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString());
|
||||
return true;
|
||||
|
|
|
@ -44,13 +44,13 @@ public class AnalysisData {
|
|||
private long totalkills;
|
||||
private long totalmobkills;
|
||||
private long totaldeaths;
|
||||
|
||||
|
||||
private long sessionAverage;
|
||||
|
||||
|
||||
private String geomapCountries;
|
||||
private String geomapZ;
|
||||
private String geomapCodes;
|
||||
|
||||
|
||||
private int[] genderData;
|
||||
|
||||
/**
|
||||
|
@ -59,19 +59,19 @@ public class AnalysisData {
|
|||
* All data has to be set with setters to avoid NPE.
|
||||
*/
|
||||
public AnalysisData() {
|
||||
sortablePlayersTable = Html.ERROR_NOT_SET+"";
|
||||
commandUseTableHtml = Html.ERROR_NOT_SET+"";
|
||||
top20ActivePlayers = Html.ERROR_NOT_SET+"";
|
||||
recentPlayers = Html.ERROR_NOT_SET+"";
|
||||
geomapCountries = Html.ERROR_NOT_SET+"";
|
||||
geomapZ = Html.ERROR_NOT_SET+"";
|
||||
geomapCodes = Html.ERROR_NOT_SET+"";
|
||||
playersDataArray = new String[]{"[0]","[\"No data\"]","[0]","[\"No data\"]","[0]","[\"No data\"]"};
|
||||
genderData = new int[]{0,0,0};
|
||||
sortablePlayersTable = Html.ERROR_NOT_SET + "";
|
||||
commandUseTableHtml = Html.ERROR_NOT_SET + "";
|
||||
top20ActivePlayers = Html.ERROR_NOT_SET + "";
|
||||
recentPlayers = Html.ERROR_NOT_SET + "";
|
||||
geomapCountries = Html.ERROR_NOT_SET + "";
|
||||
geomapZ = Html.ERROR_NOT_SET + "";
|
||||
geomapCodes = Html.ERROR_NOT_SET + "";
|
||||
playersDataArray = new String[]{"[0]", "[\"No data\"]", "[0]", "[\"No data\"]", "[0]", "[\"No data\"]"};
|
||||
genderData = new int[]{0, 0, 0};
|
||||
}
|
||||
|
||||
|
||||
// Getters and setters v---------------------------------v
|
||||
@Override
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
|
@ -205,7 +205,7 @@ public class AnalysisData {
|
|||
public void setGeomapCodes(String geomapCodes) {
|
||||
this.geomapCodes = geomapCodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
|
@ -235,7 +235,7 @@ public class AnalysisData {
|
|||
public void setJoinleaver(int joinleaver) {
|
||||
this.joinleaver = joinleaver;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return HTML String of the Top50CommandsList
|
||||
*/
|
||||
|
|
|
@ -8,10 +8,10 @@ import java.util.UUID;
|
|||
*/
|
||||
public class KillData {
|
||||
|
||||
private UUID victim;
|
||||
private int victimUserID;
|
||||
private long date;
|
||||
private String weapon;
|
||||
private final UUID victim;
|
||||
private final int victimUserID;
|
||||
private final long date;
|
||||
private final String weapon;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -72,8 +72,8 @@ public class RawAnalysisData {
|
|||
|
||||
public void fillGeolocations() {
|
||||
String[] countries = new String[]{"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Democratic Republic of the", "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Polynesia", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guernsey", "Guinea-Bissau", "Guinea", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia, Federated States of", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Namibia", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Nigeria", "Niger", "Niue", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "West Bank", "Yemen", "Zambia", "Zimbabwe"};
|
||||
String[] codes = new String[]{"AFG","ALB","DZA","ASM","AND","AGO","AIA","ATG","ARG","ARM","ABW","AUS","AUT","AZE","BHM","BHR","BGD","BRB","BLR","BEL","BLZ","BEN","BMU","BTN","BOL","BIH","BWA","BRA","VGB","BRN","BGR","BFA","MMR","BDI","CPV","KHM","CMR","CAN","CYM","CAF","TCD","CHL","CHN","COL","COM","COD","COG","COK","CRI","CIV","HRV","CUB","CUW","CYP","CZE","DNK","DJI","DMA","DOM","ECU","EGY","SLV","GNQ","ERI","EST","ETH","FLK","FRO","FJI","FIN","FRA","PYF","GAB","GMB","GEO","DEU","GHA","GIB","GRC","GRL","GRD","GUM","GTM","GGY","GNB","GIN","GUY","HTI","HND","HKG","HUN","ISL","IND","IDN","IRN","IRQ","IRL","IMN","ISR","ITA","JAM","JPN","JEY","JOR","KAZ","KEN","KIR","KOR","PRK","KSV","KWT","KGZ","LAO","LVA","LBN","LSO","LBR","LBY","LIE","LTU","LUX","MAC","MKD","MDG","MWI","MYS","MDV","MLI","MLT","MHL","MRT","MUS","MEX","FSM","MDA","MCO","MNG","MNE","MAR","MOZ","NAM","NPL","NLD","NCL","NZL","NIC","NGA","NER","NIU","MNP","NOR","OMN","PAK","PLW","PAN","PNG","PRY","PER","PHL","POL","PRT","PRI","QAT","ROU","RUS","RWA","KNA","LCA","MAF","SPM","VCT","WSM","SMR","STP","SAU","SEN","SRB","SYC","SLE","SGP","SXM","SVK","SVN","SLB","SOM","ZAF","SSD","ESP","LKA","SDN","SUR","SWZ","SWE","CHE","SYR","TWN","TJK","TZA","THA","TLS","TGO","TON","TTO","TUN","TUR","TKM","TUV","UGA","UKR","ARE","GBR","USA","URY","UZB","VUT","VEN","VNM","VGB","WBG","YEM","ZMB","ZWE"};
|
||||
for (int i = 0; i < countries.length; i++) {
|
||||
String[] codes = new String[]{"AFG", "ALB", "DZA", "ASM", "AND", "AGO", "AIA", "ATG", "ARG", "ARM", "ABW", "AUS", "AUT", "AZE", "BHM", "BHR", "BGD", "BRB", "BLR", "BEL", "BLZ", "BEN", "BMU", "BTN", "BOL", "BIH", "BWA", "BRA", "VGB", "BRN", "BGR", "BFA", "MMR", "BDI", "CPV", "KHM", "CMR", "CAN", "CYM", "CAF", "TCD", "CHL", "CHN", "COL", "COM", "COD", "COG", "COK", "CRI", "CIV", "HRV", "CUB", "CUW", "CYP", "CZE", "DNK", "DJI", "DMA", "DOM", "ECU", "EGY", "SLV", "GNQ", "ERI", "EST", "ETH", "FLK", "FRO", "FJI", "FIN", "FRA", "PYF", "GAB", "GMB", "GEO", "DEU", "GHA", "GIB", "GRC", "GRL", "GRD", "GUM", "GTM", "GGY", "GNB", "GIN", "GUY", "HTI", "HND", "HKG", "HUN", "ISL", "IND", "IDN", "IRN", "IRQ", "IRL", "IMN", "ISR", "ITA", "JAM", "JPN", "JEY", "JOR", "KAZ", "KEN", "KIR", "KOR", "PRK", "KSV", "KWT", "KGZ", "LAO", "LVA", "LBN", "LSO", "LBR", "LBY", "LIE", "LTU", "LUX", "MAC", "MKD", "MDG", "MWI", "MYS", "MDV", "MLI", "MLT", "MHL", "MRT", "MUS", "MEX", "FSM", "MDA", "MCO", "MNG", "MNE", "MAR", "MOZ", "NAM", "NPL", "NLD", "NCL", "NZL", "NIC", "NGA", "NER", "NIU", "MNP", "NOR", "OMN", "PAK", "PLW", "PAN", "PNG", "PRY", "PER", "PHL", "POL", "PRT", "PRI", "QAT", "ROU", "RUS", "RWA", "KNA", "LCA", "MAF", "SPM", "VCT", "WSM", "SMR", "STP", "SAU", "SEN", "SRB", "SYC", "SLE", "SGP", "SXM", "SVK", "SVN", "SLB", "SOM", "ZAF", "SSD", "ESP", "LKA", "SDN", "SUR", "SWZ", "SWE", "CHE", "SYR", "TWN", "TJK", "TZA", "THA", "TLS", "TGO", "TON", "TTO", "TUN", "TUR", "TKM", "TUV", "UGA", "UKR", "ARE", "GBR", "USA", "URY", "UZB", "VUT", "VEN", "VNM", "VGB", "WBG", "YEM", "ZMB", "ZWE"};
|
||||
for (int i = 0; i < countries.length; i++) {
|
||||
String country = countries[i];
|
||||
if (geolocations.get(country) == null) {
|
||||
geolocations.put(country, 0);
|
||||
|
@ -91,7 +91,7 @@ public class RawAnalysisData {
|
|||
public Map<String, String> getGeocodes() {
|
||||
return geocodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gmZero
|
||||
|
@ -379,8 +379,8 @@ public class RawAnalysisData {
|
|||
public void setGenders(int[] gender) {
|
||||
this.genders = gender;
|
||||
}
|
||||
|
||||
|
||||
public void addToGender(int i, int amount) {
|
||||
this.genders[i] = this.genders[i]+amount;
|
||||
this.genders[i] = this.genders[i] + amount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,4 +56,8 @@ public class SessionData {
|
|||
public String toString() {
|
||||
return "s:" + sessionStart + " e:" + sessionEnd;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return sessionStart <= sessionEnd;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,13 +155,13 @@ public class UserData {
|
|||
public String toString() {
|
||||
return "{" + "accessing:" + accessing + "|uuid:" + uuid + "|location:" + location + "|locations:" + locations + "|ips:" + ips + "|nicknames:" + nicknames + "|lastNick:" + lastNick + "|registered:" + registered + "|lastPlayed:" + lastPlayed + "|playTime:" + playTime + "|loginTimes:" + loginTimes + "|timesKicked:" + timesKicked + "|lastGmSwapTime:" + lastGmSwapTime + "|lastGamemode:" + lastGamemode + "|gmTimes:" + gmTimes + "|isOp:" + isOp + "|isBanned:" + isBanned + "|demData:" + demData + "|mobKills:" + mobKills + "|playerKills:" + playerKills + "|deaths:" + deaths + "|name:" + name + "|isOnline:" + isOnline + "|currentSession:" + currentSession + "|sessions:" + sessions + '}';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ip
|
||||
*/
|
||||
public void addIpAddress(InetAddress ip) {
|
||||
if (!ips.contains(ip)) {
|
||||
if (ip != null && !ips.contains(ip)) {
|
||||
ips.add(ip);
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,8 @@ public class UserData {
|
|||
* @param addIps
|
||||
*/
|
||||
public void addIpAddresses(Collection<InetAddress> addIps) {
|
||||
ips.addAll(addIps);
|
||||
ips.addAll(addIps.stream().filter(ip -> ip != null).collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,7 +217,7 @@ public class UserData {
|
|||
* @param addNicks
|
||||
*/
|
||||
public void addNicknames(Collection<String> addNicks) {
|
||||
nicknames.addAll(addNicks);
|
||||
nicknames.addAll(addNicks.stream().filter(nick -> nick != null).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -228,7 +229,9 @@ public class UserData {
|
|||
if (gmTimes == null) {
|
||||
gmTimes = new HashMap<>();
|
||||
}
|
||||
gmTimes.put(gm, time);
|
||||
if (gm != null) {
|
||||
gmTimes.put(gm, time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,7 +257,7 @@ public class UserData {
|
|||
* @param session
|
||||
*/
|
||||
public void addSession(SessionData session) {
|
||||
if (session != null) {
|
||||
if (session != null && session.isValid()) {
|
||||
sessions.add(session);
|
||||
}
|
||||
}
|
||||
|
@ -266,6 +269,7 @@ public class UserData {
|
|||
public void addSessions(Collection<SessionData> sessions) {
|
||||
Collection<SessionData> filteredSessions = sessions.parallelStream()
|
||||
.filter(session -> session != null)
|
||||
.filter(session -> session.isValid())
|
||||
.collect(Collectors.toList());
|
||||
this.sessions.addAll(filteredSessions);
|
||||
}
|
||||
|
@ -278,6 +282,10 @@ public class UserData {
|
|||
currentSession = session;
|
||||
}
|
||||
|
||||
public SessionData getCurrentSession() {
|
||||
return currentSession;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param isBanned
|
||||
|
|
|
@ -133,7 +133,7 @@ public class HookHandler {
|
|||
TownyHook tH = townyHook;
|
||||
addReplace.put("%towntable%", tH.isEnabled() ? SortableTownTableCreator.createSortableTownsTable(tH.getTopTowns(), tH) : "");
|
||||
addReplace.put("%factionstable%", fH.isEnabled() ? SortableFactionsTableCreator.createSortableFactionsTable(fH.getTopFactions(), fH) : "");
|
||||
addReplace.put("%essentialswarps%", eH.isEnabled() ? Html.WARPS.parse(eH.getWarps().toString()) : "");
|
||||
addReplace.put("%essentialswarps%", eH.isEnabled() ? Html.WARPS.parse(eH.getWarps().toString()) : "");
|
||||
return addReplace;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class HookHandler {
|
|||
SuperbVoteHook sH = superbVoteHook;
|
||||
FactionsHook fH = factionsHook;
|
||||
TownyHook tH = townyHook;
|
||||
addReplace.put("%achievements%", (aH.isEnabled() ? Html.ACHIEVEMENTS.parse(aH.getPlayerAchievements(uuid)+"",aH.getTotalAchievements()+"") : ""));
|
||||
addReplace.put("%achievements%", (aH.isEnabled() ? Html.ACHIEVEMENTS.parse(aH.getPlayerAchievements(uuid) + "", aH.getTotalAchievements() + "") : ""));
|
||||
if (eH.isEnabled()) {
|
||||
HashMap<String, Serializable> essData = eH.getEssentialsData(uuid);
|
||||
addReplace.put("%essentials%", ((boolean) essData.get("JAILED") ? Html.JAILED.parse() : "")
|
||||
|
@ -158,16 +158,16 @@ public class HookHandler {
|
|||
addReplace.put("%essentials%", "");
|
||||
}
|
||||
|
||||
addReplace.put("%votes%", sH.isEnabled() ? Html.VOTES.parse(sH.getVotes(uuid)+"") : "");
|
||||
addReplace.put("%votes%", sH.isEnabled() ? Html.VOTES.parse(sH.getVotes(uuid) + "") : "");
|
||||
if (fH.isEnabled()) {
|
||||
HashMap<String, Serializable> facInfo = fH.getPlayerInfo(uuid);
|
||||
addReplace.put("%faction%", Html.FACTION.parse(facInfo.get("FACTION")+"",facInfo.get("POWER")+"",facInfo.get("MAXPOWER")+""));
|
||||
addReplace.put("%faction%", Html.FACTION.parse(facInfo.get("FACTION") + "", facInfo.get("POWER") + "", facInfo.get("MAXPOWER") + ""));
|
||||
} else {
|
||||
addReplace.put("%faction%", "");
|
||||
}
|
||||
if (tH.isEnabled()) {
|
||||
HashMap<String, Serializable> townInfo = tH.getPlayerInfo(uuid);
|
||||
addReplace.put("%town%", Html.TOWN.parse(townInfo.get("TOWN")+""));
|
||||
addReplace.put("%town%", Html.TOWN.parse(townInfo.get("TOWN") + ""));
|
||||
} else {
|
||||
addReplace.put("%town%", "");
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public class DemographicsHandler {
|
|||
demData.setGeoLocation(results[2]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
demData.setGeoLocation(Phrase.DEM_UNKNOWN+"");
|
||||
demData.setGeoLocation(Phrase.DEM_UNKNOWN + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import main.java.com.djrapitops.plan.data.UserData;
|
|||
* @author Rsl1122
|
||||
*/
|
||||
public class KillHandler {
|
||||
|
||||
private Plan plugin;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +22,7 @@ public class KillHandler {
|
|||
public KillHandler(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param killerData
|
||||
|
@ -29,31 +30,31 @@ public class KillHandler {
|
|||
* @param weapon
|
||||
*/
|
||||
public void handlePlayerKill(UserData killerData, UUID victimUUID, String weapon) {
|
||||
long now = new Date().toInstant().getEpochSecond()*(long)1000;
|
||||
long now = new Date().toInstant().getEpochSecond() * (long) 1000;
|
||||
int victimID;
|
||||
try {
|
||||
victimID = plugin.getDB().getUserId(victimUUID+"");
|
||||
victimID = plugin.getDB().getUserId(victimUUID + "");
|
||||
} catch (SQLException e) {
|
||||
plugin.toLog(this.getClass().getName(), e);
|
||||
return;
|
||||
}
|
||||
killerData.addPlayerKill(new KillData(victimUUID, victimID, weapon, now));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void handlePlayerDeath(UserData data) {
|
||||
data.setDeaths(data.getDeaths()+1);
|
||||
data.setDeaths(data.getDeaths() + 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void handleMobKill(UserData data) {
|
||||
data.setMobKills(data.getMobKills()+1);
|
||||
data.setMobKills(data.getMobKills() + 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class PlayerActivityGraphCreator {
|
|||
int amount = 0;
|
||||
amount = sessionStarts.parallelStream()
|
||||
.filter((start) -> (start == j))
|
||||
.map((_item) -> 1)
|
||||
.map((item) -> 1)
|
||||
.reduce(amount, Integer::sum);
|
||||
lastPValue += amount;
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ public class PlayerActivityGraphCreator {
|
|||
int amount = 0;
|
||||
amount = sessionEnds.parallelStream()
|
||||
.filter((end) -> (end == j))
|
||||
.map((_item) -> 1)
|
||||
.map((item) -> 1)
|
||||
.reduce(amount, Integer::sum);
|
||||
lastPValue -= amount;
|
||||
}
|
||||
|
||||
if (lastSavedPValue != lastPValue || i - lastSaveI > (scale / (long) 75)) {
|
||||
lastSaveI = i;
|
||||
labels.add("\""+FormatUtils.formatTimeStamp(i+"")+"\"");
|
||||
labels.add("\"" + FormatUtils.formatTimeStamp(i + "") + "\"");
|
||||
lastSavedPValue = lastPValue;
|
||||
playersOnline.add(lastPValue);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class SortableCommandUseTableCreator {
|
|||
} catch (IllegalArgumentException e) {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
plugin.toLog("SortableCommandUseTableCreator", e);
|
||||
plugin.toLog("Cause: "+values[0]+" "+values[1]);
|
||||
plugin.toLog("Cause: " + values[0] + " " + values[1]);
|
||||
}
|
||||
}
|
||||
return html;
|
||||
|
|
|
@ -28,11 +28,11 @@ public class SortableFactionsTableCreator {
|
|||
HashMap<String, Serializable> info = fHook.getFactionInfo(factionName);
|
||||
String leader = (String) info.get("LEADER");
|
||||
html += Html.TABLELINE_4.parse(
|
||||
factionName,
|
||||
info.get("POWER")+"",
|
||||
info.get("LAND")+"",
|
||||
factionName,
|
||||
info.get("POWER") + "",
|
||||
info.get("LAND") + "",
|
||||
Html.LINK.parse(HtmlUtils.getInspectUrl(leader), leader)
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
html += Html.TABLE_END.parse();
|
||||
|
|
|
@ -29,14 +29,14 @@ public class SortableKillsTableCreator {
|
|||
if (i >= 10) {
|
||||
break;
|
||||
}
|
||||
long date = kill.getDate();
|
||||
long date = kill.getDate();
|
||||
OfflinePlayer victim = getOfflinePlayer(kill.getVictim());
|
||||
String name = victim.getName();
|
||||
html += Html.TABLELINE_3_CUSTOMKEY_1.parse(
|
||||
date+"", FormatUtils.formatTimeStamp(date+""),
|
||||
date + "", FormatUtils.formatTimeStamp(date + ""),
|
||||
Html.LINK.parse(HtmlUtils.getInspectUrl(name), name),
|
||||
kill.getWeapon()
|
||||
);
|
||||
);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ public class SortablePlayersTableCreator {
|
|||
: (AnalysisUtils.isActive(uData.getLastPlayed(), uData.getPlayTime(), uData.getLoginTimes())
|
||||
? Html.GRAPH_ACTIVE.parse() : Html.GRAPH_INACTIVE.parse());
|
||||
|
||||
html += Html.TABLELINE_PLAYERS.parse("<img style=\"float: left; padding: 2px 2px 0px 2px\" alt=\""+uData.getName()+"\" src=\"https://minotar.net/avatar/"+uData.getName()+"/19\"> "+Html.LINK.parse(HtmlUtils.getInspectUrl(uData.getName()), uData.getName()), bORaORi,
|
||||
html += Html.TABLELINE_PLAYERS.parse("<img style=\"float: left; padding: 2px 2px 0px 2px\" alt=\"" + uData.getName() + "\" src=\"https://minotar.net/avatar/" + uData.getName() + "/19\"> " + Html.LINK.parse(HtmlUtils.getInspectUrl(uData.getName()), uData.getName()), bORaORi,
|
||||
uData.getPlayTime() + "", FormatUtils.formatTimeAmount(uData.getPlayTime() + ""),
|
||||
uData.getLoginTimes() + "",
|
||||
uData.getRegistered() + "", FormatUtils.formatTimeStamp(uData.getRegistered() + ""),
|
||||
uData.getLastPlayed() + "", FormatUtils.formatTimeStamp(uData.getLastPlayed() + ""),
|
||||
uData.getDemData().getGeoLocation()
|
||||
);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
return html;
|
||||
|
|
|
@ -37,9 +37,9 @@ public class SortableSessionTableCreator {
|
|||
continue;
|
||||
}
|
||||
html += Html.TABLELINE_3_CUSTOMKEY.parse(
|
||||
start+"", FormatUtils.formatTimeStamp(start+""),
|
||||
end+"", FormatUtils.formatTimeStamp(end+""),
|
||||
length+"", FormatUtils.formatTimeAmount(length+"")
|
||||
start + "", FormatUtils.formatTimeStamp(start + ""),
|
||||
end + "", FormatUtils.formatTimeStamp(end + ""),
|
||||
length + "", FormatUtils.formatTimeAmount(length + "")
|
||||
);
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class WebSocketServer {
|
|||
if (ENABLED) {
|
||||
return;
|
||||
}
|
||||
plugin.log(Phrase.WEBSERVER_INIT+"");
|
||||
plugin.log(Phrase.WEBSERVER_INIT + "");
|
||||
try {
|
||||
//Setup server
|
||||
try {
|
||||
|
@ -85,7 +85,7 @@ public class WebSocketServer {
|
|||
|
||||
ENABLED = true;
|
||||
|
||||
plugin.log(Phrase.WEBSERVER_RUNNING.parse(server.getLocalPort()+""));
|
||||
plugin.log(Phrase.WEBSERVER_RUNNING.parse(server.getLocalPort() + ""));
|
||||
} catch (IllegalArgumentException | IllegalStateException e) {
|
||||
ENABLED = false;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class WebSocketServer {
|
|||
* Shuts down the server - Async thread is closed with shutdown boolean.
|
||||
*/
|
||||
public void stop() {
|
||||
plugin.log(Phrase.WEBSERVER_CLOSE+"");
|
||||
plugin.log(Phrase.WEBSERVER_CLOSE + "");
|
||||
shutdown = true;
|
||||
try {
|
||||
server.close();
|
||||
|
|
|
@ -115,8 +115,8 @@ public class FormatUtils {
|
|||
if (versionArray.length != 3) {
|
||||
throw new NumberFormatException("Wrong format used");
|
||||
}
|
||||
int main = Integer.parseInt(versionArray[0]) * 100;
|
||||
int major = Integer.parseInt(versionArray[1]) * 10;
|
||||
int main = Integer.parseInt(versionArray[0]) * 10000;
|
||||
int major = Integer.parseInt(versionArray[1]) * 100;
|
||||
int minor = Integer.parseInt(versionArray[2]);
|
||||
int versionNumber = main + major + minor;
|
||||
return versionNumber;
|
||||
|
@ -175,7 +175,7 @@ public class FormatUtils {
|
|||
*/
|
||||
public static String cutDecimals(double d) {
|
||||
DecimalFormat df = new DecimalFormat("#.##");
|
||||
df.setRoundingMode(RoundingMode.CEILING);
|
||||
// df.setRoundingMode(RoundingMode.CEILING);
|
||||
return df.format(d);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,13 +98,13 @@ public class PlaceholderUtils {
|
|||
replaceMap.put("%gmcolors%", "\"#" + Settings.HCOLOR_GMP_0 + "\",\"#" + Settings.HCOLOR_GMP_1
|
||||
+ "\",\"#" + Settings.HCOLOR_GMP_2 + "\",\"#" + Settings.HCOLOR_GMP_3 + "\"");
|
||||
replaceMap.put("%genderdata%", Arrays.toString(data.getGenderData()));
|
||||
replaceMap.put("%gendermale%", data.getGenderData()[0]+"");
|
||||
replaceMap.put("%genderfemale%", data.getGenderData()[1]+"");
|
||||
replaceMap.put("%gendermale%", data.getGenderData()[0] + "");
|
||||
replaceMap.put("%genderfemale%", data.getGenderData()[1] + "");
|
||||
replaceMap.put("%genderlabels%", "[\"Male\", \"Female\", \"Unknown\"]");
|
||||
replaceMap.put("%gendercolors%", "\"#" + Settings.HCOLOR_GENP_M + "\",\"#" + Settings.HCOLOR_GENP_F
|
||||
+ "\",\"#" + Settings.HCOLOR_GENP_U + "\"");
|
||||
replaceMap.put("%genderfcolor%", "#" +Settings.HCOLOR_GENP_F);
|
||||
replaceMap.put("%gendermcolor%", "#" +Settings.HCOLOR_GENP_M);
|
||||
replaceMap.put("%genderfcolor%", "#" + Settings.HCOLOR_GENP_F);
|
||||
replaceMap.put("%gendermcolor%", "#" + Settings.HCOLOR_GENP_M);
|
||||
replaceMap.putAll(plugin.getHookHandler().getAdditionalAnalysisReplaceRules());
|
||||
replaceMap.put("%sessionaverage%", FormatUtils.formatTimeAmount(data.getSessionAverage() + ""));
|
||||
replaceMap.put("%geomapcountries%", data.getGeomapCountries());
|
||||
|
@ -145,9 +145,9 @@ public class PlaceholderUtils {
|
|||
gmThree = 0;
|
||||
}
|
||||
long[] gmData = new long[]{
|
||||
(gmTimes.get(GameMode.SURVIVAL) != null ? gmTimes.get(GameMode.SURVIVAL):0L),
|
||||
(gmTimes.get(GameMode.CREATIVE) != null ? gmTimes.get(GameMode.CREATIVE):0L),
|
||||
(gmTimes.get(GameMode.ADVENTURE) != null ? gmTimes.get(GameMode.ADVENTURE):0L),
|
||||
(gmTimes.get(GameMode.SURVIVAL) != null ? gmTimes.get(GameMode.SURVIVAL) : 0L),
|
||||
(gmTimes.get(GameMode.CREATIVE) != null ? gmTimes.get(GameMode.CREATIVE) : 0L),
|
||||
(gmTimes.get(GameMode.ADVENTURE) != null ? gmTimes.get(GameMode.ADVENTURE) : 0L),
|
||||
gmThree
|
||||
};
|
||||
long total = gmData[0] + gmData[1] + gmData[2] + gmData[3];
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan;
|
||||
|
||||
import java.io.File;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class PhraseTest {
|
||||
|
||||
public PhraseTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
Phrase instance = Phrase.REPLACE0;
|
||||
String expResult = "REPLACE0";
|
||||
String result = instance.toString();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_0args() {
|
||||
Phrase instance = Phrase.REPLACE0;
|
||||
String expResult = "REPLACE0";
|
||||
String result = instance.parse();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_StringArr() {
|
||||
Phrase instance = Phrase.REPLACE0;
|
||||
String expResult = "Test";
|
||||
String result = instance.parse(expResult);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColor() {
|
||||
System.out.println("color");
|
||||
Phrase instance = Phrase.COLOR_MAIN;
|
||||
ChatColor expResult = ChatColor.RED;
|
||||
instance.setColor("c");
|
||||
ChatColor result = instance.color();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetText() {
|
||||
System.out.println("setText");
|
||||
Phrase instance = Phrase.REPLACE0;
|
||||
String expResult = "Test";
|
||||
instance.setText(expResult);
|
||||
String result = instance.toString();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data;
|
||||
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class SessionDataTest {
|
||||
|
||||
private SessionData test;
|
||||
|
||||
public SessionDataTest() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
test = new SessionData(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEndSession() {
|
||||
test.endSession(1L);
|
||||
assertTrue("End not 1", test.getSessionEnd() == 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSessionStart() {
|
||||
assertTrue("Start not 0", test.getSessionStart() == 0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsValid() {
|
||||
test.endSession(1L);
|
||||
assertTrue("Supposed to be valid.", test.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalid() {
|
||||
assertTrue("Supposed to be invalid.", !test.isValid());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import org.bukkit.GameMode;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class UserDataTest {
|
||||
|
||||
private UserData test;
|
||||
|
||||
public UserDataTest() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DemographicsData demData = null;
|
||||
test = new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, GameMode.CREATIVE, demData, "Testname", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddIpAddress() throws UnknownHostException {
|
||||
InetAddress ip = InetAddress.getByName("247.183.163.155");
|
||||
InetAddress ip2 = InetAddress.getByName("95.19.221.226");
|
||||
test.addIpAddress(ip);
|
||||
test.addIpAddress(ip2);
|
||||
test.addIpAddress(ip2);
|
||||
test.addIpAddress(null);
|
||||
assertTrue("Didn't add 1", test.getIps().contains(ip));
|
||||
assertTrue("Didn't add 2", test.getIps().contains(ip2));
|
||||
assertTrue("Added null", !test.getIps().contains(null));
|
||||
assertTrue("Added multiples", test.getIps().size() == 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddIpAddresses() throws UnknownHostException {
|
||||
List<InetAddress> ips = new ArrayList<>();
|
||||
InetAddress ip = InetAddress.getByName("247.183.163.155");
|
||||
InetAddress ip2 = InetAddress.getByName("95.19.221.226");
|
||||
ips.add(ip);
|
||||
ips.add(ip2);
|
||||
ips.add(ip2);
|
||||
ips.add(null);
|
||||
test.addIpAddresses(ips);
|
||||
assertTrue("Didn't add 1", test.getIps().contains(ip));
|
||||
assertTrue("Didn't add 2", test.getIps().contains(ip2));
|
||||
assertTrue("Added null", !test.getIps().contains(null));
|
||||
assertTrue("Added multiples", test.getIps().size() == 2);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testAddLocation() {
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testAddLocations() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNickname() {
|
||||
String one = "Test1";
|
||||
String two = "Test2";
|
||||
boolean n = test.addNickname(one);
|
||||
boolean n1 = test.addNickname(two);
|
||||
boolean n2 = test.addNickname(two);
|
||||
test.addNickname(null);
|
||||
assertTrue("Didn't add 1", test.getNicknames().contains(one));
|
||||
assertTrue("Didn't add 2", test.getNicknames().contains(two));
|
||||
assertTrue("1 is new", n);
|
||||
assertTrue("2 is new", n1);
|
||||
assertTrue("2 is not new", !n2);
|
||||
assertTrue("Added null", !test.getNicknames().contains(null));
|
||||
assertTrue("Added multiples", test.getNicknames().size() == 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNicknames() {
|
||||
String one = "Test1";
|
||||
String two = "Test2";
|
||||
List<String> o = new ArrayList<>();
|
||||
o.add(one);
|
||||
o.add(two);
|
||||
o.add(two);
|
||||
o.add(null);
|
||||
test.addNicknames(o);
|
||||
assertTrue("Didn't add 1", test.getNicknames().contains(one));
|
||||
assertTrue("Didn't add 2", test.getNicknames().contains(two));
|
||||
assertTrue("Added null", !test.getNicknames().contains(null));
|
||||
assertTrue("Added multiples", test.getNicknames().size() == 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetGMTime() {
|
||||
test.setGMTime(GameMode.SURVIVAL, 1L);
|
||||
assertTrue("" + test.getGmTimes().get(GameMode.SURVIVAL), test.getGmTimes().get(GameMode.SURVIVAL) == 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetGMTimeWhenGMTimesNull() {
|
||||
test.setGmTimes(null);
|
||||
test.setGMTime(GameMode.SURVIVAL, 1L);
|
||||
assertTrue("" + test.getGmTimes().get(GameMode.SURVIVAL), test.getGmTimes().get(GameMode.SURVIVAL) == 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetGMTimeNull() {
|
||||
test.setGMTime(null, 0L);
|
||||
assertTrue("Added null", !test.getGmTimes().containsKey(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAllGMTimes() {
|
||||
HashMap<GameMode, Long> gmTimes = new HashMap<>();
|
||||
gmTimes.put(null, 0L);
|
||||
test.setGmTimes(gmTimes);
|
||||
test.setAllGMTimes(1L, 2L, 3L, 4L);
|
||||
HashMap<GameMode, Long> times = test.getGmTimes();
|
||||
assertTrue("Cleared gmTimes", !times.containsKey(null));
|
||||
assertTrue("Not equal 0", times.get(GameMode.SURVIVAL) == 1L);
|
||||
assertTrue("Not equal 1", times.get(GameMode.CREATIVE) == 2L);
|
||||
assertTrue("Not equal 2", times.get(GameMode.ADVENTURE) == 3L);
|
||||
assertTrue("Not equal 3", times.get(GameMode.SPECTATOR) == 4L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddSession() {
|
||||
SessionData correct = new SessionData(0, 1);
|
||||
test.addSession(correct);
|
||||
assertTrue("Didn't add correct one", test.getSessions().contains(correct));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddSessionIncorrect() {
|
||||
SessionData incorrect = new SessionData(0);
|
||||
test.addSession(incorrect);
|
||||
assertTrue("Added incorrect one", !test.getSessions().contains(incorrect));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddSessionNull() {
|
||||
SessionData incorrect = null;
|
||||
test.addSession(incorrect);
|
||||
assertTrue("Added null", !test.getSessions().contains(incorrect));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddSessions() {
|
||||
SessionData correct = new SessionData(0, 1);
|
||||
SessionData incorrect = new SessionData(0);
|
||||
List<SessionData> o = new ArrayList<>();
|
||||
o.add(correct);
|
||||
o.add(incorrect);
|
||||
o.add(null);
|
||||
test.addSessions(o);
|
||||
assertTrue("Didn't add correct one", test.getSessions().contains(correct));
|
||||
assertTrue("Added incorrect one", !test.getSessions().contains(incorrect));
|
||||
assertTrue("Added null", !test.getSessions().contains(incorrect));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetCurrentSession() {
|
||||
SessionData s = new SessionData(0);
|
||||
test.setCurrentSession(s);
|
||||
assertEquals(test.getCurrentSession(), s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBanned() {
|
||||
test.updateBanned(true);
|
||||
assertTrue("Not true", test.isBanned());
|
||||
test.updateBanned(false);
|
||||
assertTrue("True", !test.isBanned());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAccessed() {
|
||||
test.access();
|
||||
assertTrue("Not accessed, even though accessing", test.isAccessed());
|
||||
test.access();
|
||||
test.stopAccessing();
|
||||
assertTrue("Not accessed, even though accessing", test.isAccessed());
|
||||
test.stopAccessing();
|
||||
assertTrue("Accessed, even though not accessing", !test.isAccessed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccess() {
|
||||
test.access();
|
||||
assertTrue("Not accessed, even though accessing", test.isAccessed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStopAccessing() {
|
||||
test.access();
|
||||
test.stopAccessing();
|
||||
assertTrue("Accessed, even though not accessing", !test.isAccessed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
assertTrue("Not Equals!", test.equals(new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, GameMode.CREATIVE, null, "Testname", true)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsNot() {
|
||||
UserData notEqual = new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, GameMode.CREATIVE, null, "WRONG", true);
|
||||
assertTrue("Equals!", !notEqual.equals(test));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsNot2() {
|
||||
Object o = "NOT";
|
||||
assertTrue("Equals!", !test.equals(o));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.ui;
|
||||
|
||||
import java.io.File;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class HtmlTest {
|
||||
|
||||
public HtmlTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_0args() {
|
||||
Html instance = Html.REPLACE0;
|
||||
String expResult = "REPLACE0";
|
||||
String result = instance.parse();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_StringArr() {
|
||||
Html instance = Html.REPLACE0;
|
||||
String expResult = "Test";
|
||||
String result = instance.parse(expResult);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetHtml() {
|
||||
Html instance = Html.REPLACE0;
|
||||
String expResult = "Test";
|
||||
instance.setHtml(expResult);
|
||||
String result = instance.parse();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoBackSlash() {
|
||||
assertTrue("Null for some reason", Html.TABLELINE_2.parse("/\\", "0") != null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import java.util.Date;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class FormatUtilsTest {
|
||||
|
||||
public FormatUtilsTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatTimeAmount() {
|
||||
String string = "" + 1000L;
|
||||
String expResult = "1s";
|
||||
String result = FormatUtils.formatTimeAmount(string);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatTimeAmountSinceDate() {
|
||||
Date before = new Date(300000L);
|
||||
Date now = new Date(310000L);
|
||||
String expResult = "10s";
|
||||
String result = FormatUtils.formatTimeAmountSinceDate(before, now);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatTimeStamp() {
|
||||
String string = "0";
|
||||
String expResult = "Jan 01 02:00:00";
|
||||
String result = FormatUtils.formatTimeStamp(string);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatTimeAmountSinceString() {
|
||||
String string = "" + new Date(310000L).toInstant().getEpochSecond() * 1000L;
|
||||
Date now = new Date(300000L);
|
||||
String expResult = "10s";
|
||||
String result = FormatUtils.formatTimeAmountSinceString(string, now);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveLetters() {
|
||||
String dataPoint = "435729847jirggu.eiwb¤#¤%¤#";
|
||||
String expResult = "435729847.";
|
||||
String result = FormatUtils.removeLetters(dataPoint);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseVersionNumber() {
|
||||
String versionString = "2.10.2";
|
||||
int expResult = 21002;
|
||||
int result = FormatUtils.parseVersionNumber(versionString);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVersionNumber() {
|
||||
String versionString = "2.10.2";
|
||||
String versionString2 = "2.9.3";
|
||||
int result = FormatUtils.parseVersionNumber(versionString);
|
||||
int result2 = FormatUtils.parseVersionNumber(versionString2);
|
||||
assertTrue("Higher version not higher", result > result2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMergeArrays() {
|
||||
String[][] arrays = new String[][]{new String[]{"Test", "One"}, new String[]{"Test", "Two"}};
|
||||
String[] expResult = new String[]{"Test", "One", "Test","Two"};
|
||||
String[] result = FormatUtils.mergeArrays(arrays);
|
||||
assertArrayEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Ignore @Test
|
||||
public void testFormatLocation() {
|
||||
Location loc = null;
|
||||
String expResult = "";
|
||||
String result = FormatUtils.formatLocation(loc);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCutDecimals() {
|
||||
double d = 0.05234;
|
||||
String expResult = "0,05";
|
||||
String result = FormatUtils.cutDecimals(d);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
@Test
|
||||
public void testCutDecimals2() {
|
||||
double d = 0.05634;
|
||||
String expResult = "0,06";
|
||||
String result = FormatUtils.cutDecimals(d);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class HtmlUtilsTest {
|
||||
|
||||
public HtmlUtilsTest() {
|
||||
}
|
||||
|
||||
@Ignore("Mock JavaPlugin") @Test
|
||||
public void testGetHtmlStringFromResource() throws Exception {
|
||||
System.out.println("getHtmlStringFromResource");
|
||||
String fileName = "";
|
||||
String expResult = "";
|
||||
String result = HtmlUtils.getHtmlStringFromResource(fileName);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplacePlaceholders() {
|
||||
String html = "%test%";
|
||||
HashMap<String, String> replaceMap = new HashMap<>();
|
||||
replaceMap.put("%test%", "Success");
|
||||
String expResult = "Success";
|
||||
String result = HtmlUtils.replacePlaceholders(html, replaceMap);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplacePlaceholdersBackslash() {
|
||||
HashMap<String, String> replace = new HashMap<>();
|
||||
replace.put("%test%", "/\\");
|
||||
String result = HtmlUtils.replacePlaceholders("%test% alright %test%", replace);
|
||||
String exp = "/\\ alright /\\";
|
||||
assertEquals(result, exp);
|
||||
}
|
||||
|
||||
@Ignore("Mock JavaPlugin") @Test
|
||||
public void testGetServerAnalysisUrl() {
|
||||
System.out.println("getServerAnalysisUrl");
|
||||
String expResult = "";
|
||||
String result = HtmlUtils.getServerAnalysisUrl();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
@Ignore("Mock JavaPlugin") @Test
|
||||
public void testGetInspectUrl() {
|
||||
String playerName = "";
|
||||
String expResult = "";
|
||||
String result = HtmlUtils.getInspectUrl(playerName);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveXSS() {
|
||||
String xss = "<script></script><!--";
|
||||
boolean passed = HtmlUtils.removeXSS(xss).length() < xss.length();
|
||||
assertEquals(true, passed);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import java.util.Set;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class MiscUtilsTest {
|
||||
|
||||
public MiscUtilsTest() {
|
||||
}
|
||||
|
||||
@Ignore @Test
|
||||
public void testCheckVersion() {
|
||||
System.out.println("checkVersion");
|
||||
String result = MiscUtils.checkVersion();
|
||||
assertTrue("Failed", !result.equals(Phrase.VERSION_CHECK_ERROR + ""));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGetPlayerDisplayname() {
|
||||
System.out.println("getPlayerDisplayname");
|
||||
String[] args = null;
|
||||
CommandSender sender = null;
|
||||
String expResult = "";
|
||||
String result = MiscUtils.getPlayerDisplayname(args, sender);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGetMatchingDisplaynames() {
|
||||
System.out.println("getMatchingDisplaynames");
|
||||
String search = "";
|
||||
Set<OfflinePlayer> expResult = null;
|
||||
Set<OfflinePlayer> result = MiscUtils.getMatchingDisplaynames(search);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue