Skip to content
Open
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
2 changes: 0 additions & 2 deletions PlayerHeadHunt.iml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<configuration>
<autoDetectTypes>
<platformType>PAPER</platformType>
<platformType>ADVENTURE</platformType>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
Expand Down
47 changes: 40 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.apache.hc</pattern>
<shadedPattern> org.modularsoft.PlayerHeadHunt.shaded.org.apache.hc</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

<resources>
Expand Down Expand Up @@ -60,13 +81,6 @@
</exclusions>
</dependency>

<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>

<!-- WorldEdit -->
<dependency>
<groupId>com.sk89q.worldedit</groupId>
Expand Down Expand Up @@ -100,6 +114,25 @@
<version>1.18.30</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.0</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2</version>
</dependency>

<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

import java.util.List;

import static org.modularsoft.PlayerHeadHunt.HeadQuery.foundHeadsAlreadyCount;

public class HeadChatController {
private final PlayerHeadHuntMain plugin;
private final HeadQuery headQuery;

public HeadChatController(PlayerHeadHuntMain plugin) {
public HeadChatController(PlayerHeadHuntMain plugin, HeadQuery headQuery) {
this.plugin = plugin;
this.headQuery = headQuery;
}

public void headFoundResponse(Player player, boolean hasAlreadyBeenFound, int headCount, int x, int y, int z) {
Expand All @@ -28,7 +28,8 @@ public void headFoundResponse(Player player, boolean hasAlreadyBeenFound, int he
player.playSound(player.getLocation(), plugin.config().getHeadFoundSound(), 1, 1);
}

int otherPlayerFoundHead = foundHeadsAlreadyCount(plugin, x, y, z) - 1;
// Get the number of other players who have found this head
int otherPlayerFoundHead = Math.max(0, headQuery.foundHeadsAlreadyCount(x, y, z) - 1);

String otherPlayersHaveFoundSuffix;
if (otherPlayerFoundHead == 0) {
Expand All @@ -39,18 +40,18 @@ public void headFoundResponse(Player player, boolean hasAlreadyBeenFound, int he
}
} else if (otherPlayerFoundHead == 1) {
otherPlayersHaveFoundSuffix = plugin.config().getLangHeadNotFirstFinderSingle()
.replace("%OTHERPLAYERSFOUNDHEAD%", "" + otherPlayerFoundHead);
.replace("%OTHERPLAYERSFOUNDHEAD%", String.valueOf(otherPlayerFoundHead));
} else {
otherPlayersHaveFoundSuffix = plugin.config().getLangHeadNotFirstFinderMultiple()
.replace("%OTHERPLAYERSFOUNDHEAD%", "" + otherPlayerFoundHead);
.replace("%OTHERPLAYERSFOUNDHEAD%", String.valueOf(otherPlayerFoundHead));
}

// Replace placeholders in the message
String message = baseMessage
.replace("%FOUNDHEADS%", "" + headCount)
.replace("%NUMBEROFHEADS%", "" + plugin.config().getTotalHeads())
.replace("%FOUNDHEADS%", String.valueOf(headCount))
.replace("%NUMBEROFHEADS%", String.valueOf(plugin.config().getTotalHeads()))
.replace("%ALREADYFOUNDHEADS%", otherPlayersHaveFoundSuffix);

// Play sound for a Player Head that is found.
player.sendMessage(message);
}

Expand Down Expand Up @@ -100,9 +101,9 @@ public void newPlayerJoinsTheHunt(Player player) {
}

public void playersOwnHeadCountResponse(Player player) {
// Players wants to see their own head count
// Use the instance of HeadQuery to call the method
player.sendMessage(plugin.config().getLangHeadCount()
.replace("%FOUNDHEADS%", "" + HeadQuery.foundHeadsCount(plugin, player))
.replace("%FOUNDHEADS%", "" + headQuery.foundHeadsCount(player))
.replace("%NUMBEROFHEADS%", "" + plugin.config().getTotalHeads()));
}

Expand Down
Loading