Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve comments, indents and pom.xml #246

Merged
merged 6 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 52 additions & 50 deletions Java/Test/me/dilley/MineStatTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* JUnit tests for MineStat.java class */
/* Contributed by Annukka Tormala (nukka) */
/*
* JUnit tests for MineStat.java class
* Contributed by Annukka Tormala (nukka)
*/

package me.dilley;

Expand All @@ -8,65 +10,65 @@

public class MineStatTest
{
@Test
// Tests if address is correct
public void checkAddress()
@Test
// Tests if address is correct
public void checkAddress()
{
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setAddress("minecraft.frag.land");
assertEquals("minecraft.frag.land", ms.getAddress());
}
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setAddress("minecraft.frag.land");
assertEquals("minecraft.frag.land", ms.getAddress());
}

@Test
// Tests if port number is correct
public void checkPort()
@Test
// Tests if port number is correct
public void checkPort()
{
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setPort(25565);
assertEquals(25565, ms.getPort());
}
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setPort(25565);
assertEquals(25565, ms.getPort());
}

@Test
// Tests if version number is correct
public void checkVersion()
@Test
// Tests if version number is correct
public void checkVersion()
{
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setVersion("BungeeCord 1.8.x-1.12.x");
assertEquals("BungeeCord 1.8.x-1.12.x", ms.getVersion());
}
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setVersion("BungeeCord 1.8.x-1.12.x");
assertEquals("BungeeCord 1.8.x-1.12.x", ms.getVersion());
}

@Test
// Tests if number of current players is correct
public void checkNumberOfCurrentPlayers()
@Test
// Tests if number of current players is correct
public void checkNumberOfCurrentPlayers()
{
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setCurrentPlayers(0);
assertEquals(0, ms.getCurrentPlayers());
}
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setCurrentPlayers(0);
assertEquals(0, ms.getCurrentPlayers());
}

@Test
// Tests if number of maximum players is correct
public void checkNumberOfMaximumPlayers()
@Test
// Tests if number of maximum players is correct
public void checkNumberOfMaximumPlayers()
{
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setMaximumPlayers(32);
assertEquals(32, ms.getMaximumPlayers());
}
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setMaximumPlayers(32);
assertEquals(32, ms.getMaximumPlayers());
}

@Test
// Tests if the message of the day is correct
public void checkMessageOfTheDay()
@Test
// Tests if the message of the day is correct
public void checkMessageOfTheDay()
{
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setMotd("Frag Land");
assertEquals("Frag Land", ms.getMotd());
}
MineStat ms = new MineStat("minecraft.frag.land", 25565);
ms.setMotd("Frag Land");
assertEquals("Frag Land", ms.getMotd());
}

@Test
// Tests if the server is up
public void checkThatServerIsUp()
@Test
// Tests if the server is up
public void checkThatServerIsUp()
{
MineStat ms = new MineStat("minecraft.frag.land", 25565);
assertTrue(ms.isServerUp());
}
MineStat ms = new MineStat("minecraft.frag.land", 25565);
assertTrue(ms.isServerUp());
}
}
16 changes: 8 additions & 8 deletions Java/me/dilley/MineStat.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MineStat.java - A Minecraft server status checker
* Copyright (C) 2014-2022 Lloyd Dilley
* Copyright (C) 2014-2024 Lloyd Dilley
* http://www.dilley.me/
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -18,10 +18,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

/**
* @author Lloyd Dilley
*/

package me.dilley;

import com.google.gson.*;
Expand All @@ -32,6 +28,9 @@
import java.util.Base64;
import java.util.Date;

/**
* @author Lloyd Dilley
*/
public class MineStat
{
public static final String VERSION = "3.0.6"; // MineStat version
Expand Down Expand Up @@ -59,9 +58,10 @@
private final int magicNumber;
private final String shortDescription;

private ConnectionStatus(int magicNumber, String shortDescription) {
this.magicNumber = magicNumber;
this.shortDescription = shortDescription;
private ConnectionStatus(int magicNumber, String shortDescription)
{
this.magicNumber = magicNumber;
this.shortDescription = shortDescription;
}

public int getMagicNumber() { return magicNumber; }
Expand Down Expand Up @@ -687,7 +687,7 @@
*/
public boolean isDataValid()
{
// Do not check for empty motd in case server has none

Check warning on line 690 in Java/me/dilley/MineStat.java

View check run for this annotation

codefactor.io / CodeFactor

Java/me/dilley/MineStat.java#L690

Conditional logic can be removed. (com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck)
if(this.motd != null && this.version != null && !this.version.trim().isEmpty() && currentPlayers >= 0 && maximumPlayers >= 0)
return true;
else
Expand Down
19 changes: 10 additions & 9 deletions Java/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>MineStat</name>

<groupId>io.github.fragland</groupId>
<artifactId>MineStat</artifactId>
<version>3.0.6</version>
<packaging>jar</packaging>

<name>MineStat</name>
<description>MineStat is a Minecraft server status checker.</description>
<url>https://github.com/fragland/minestat</url>

Expand Down Expand Up @@ -36,18 +38,17 @@
</properties>

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>

<distributionManagement>
Expand All @@ -64,6 +65,7 @@
<plugins>
<!-- Build .class files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
Expand Down Expand Up @@ -151,7 +153,6 @@
</execution>
</executions>
</plugin>

<!-- Javadoc plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down