Skip to content

Commit

Permalink
Added "%COURSE_NAME%" internal placeholder
Browse files Browse the repository at this point in the history
Rearranged events to ensure Record events happen before Finish event
Bumped dependencies & optimised build size
  • Loading branch information
A5H73Y committed May 13, 2024
1 parent 4c0e749 commit 9f7c05a
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build

env:
artifact_name: 'Parkour-7.2.2'
artifact_name: 'Parkour-7.2.3'
release_type: '-RELEASE'

on: push
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For the list of known supported plugins and tutorials on how to set them up, [cl
<dependency>
<groupId>com.github.A5H73Y</groupId>
<artifactId>Parkour</artifactId>
<version>7.2.2</version>
<version>7.2.3</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
Expand All @@ -48,5 +48,5 @@ repositories {
```

```
compile 'com.github.A5H73Y:Parkour:7.2.2'
compile 'com.github.A5H73Y:Parkour:7.2.3'
```
6 changes: 6 additions & 0 deletions docs/changelogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Changelogs

Please note that each version of Parkour is backwards compatible with the previous version and will automatically upgrade your config upon server start up. There will be no manual intervention, unless stated in breaking changes.

## 7.2.3

* Added "%COURSE_NAME%" internal placeholder
* Rearranged events to ensure Record events happen before Finish event
* Bumped dependencies & optimised build size

## 7.2.2

* Added "OnCourse.ManualCheckpointAnyPressurePlate" setting
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/compatible-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ To achieve seamless integration with the plugin, Parkour's event command system

To apply to every single Course, set the `CourseDefault.Command.Join` to:

`replay start %PLAYER%-%COURSE% %PLAYER%`
`replay start %PLAYER%-%COURSE_NAME% %PLAYER%`

This means only the Player which joined the Course is recorded, the recording name will be a combination of the Player's name and the Course name.

To avoid complications, the recording will only be saved if they complete the Course with either their best time ever, or the Course's best time ever. All other events will discard the recording.

Set the `Leave`, `Finish` commands to `replay stop %PLAYER%-%COURSE% -nosave`
Set the `Leave`, `Finish` commands to `replay stop %PLAYER%-%COURSE_NAME% -nosave`

Set the `PlayerCourseRecord` and `GlobalCourseRecord` commands to `replay stop %PLAYER%-%COURSE% -force`
Set the `PlayerCourseRecord` and `GlobalCourseRecord` commands to `replay stop %PLAYER%-%COURSE_NAME% -force`

Now you can use `/replay play (player)-(course)` to see that Player's best time on the Course. Also, if you have PlaceholderAPI integration you could evaluate the best Player on a given Course to see the best Course time run.
Now you can use `/replay play (player)-(course)` to see that Player's best time on the Course. Also, if you have PlaceholderAPI integration you could evaluate the best player's name using `%parkour_course_record_(course)_player%` when wanting to watch the best player's run for the given Course.
36 changes: 25 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.a5h73y</groupId>
<artifactId>Parkour</artifactId>
<version>7.2.2</version>
<version>7.2.3</version>
<packaging>jar</packaging>

<name>Parkour</name>
Expand Down Expand Up @@ -112,14 +112,12 @@
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<!-- MySQL Database -->
<dependency>
<groupId>com.github.Huskehhh</groupId>
<artifactId>MySQL</artifactId>
<version>63040a058d</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -132,21 +130,18 @@
<groupId>de.themoep</groupId>
<artifactId>inventorygui</artifactId>
<version>1.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- XSeries -->
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>9.8.0</version>
<scope>compile</scope>
<version>10.0.0</version>
</dependency>
<!-- Version Compare -->
<dependency>
<groupId>io.github.g00fy2</groupId>
<artifactId>versioncompare</artifactId>
<version>1.5.0</version>
<scope>compile</scope>
</dependency>
<!-- Simplix Storage -->
<dependency>
Expand All @@ -159,16 +154,31 @@
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20231013</version>
<version>20240303</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.esotericsoftware.yamlbeans</groupId>
<artifactId>yamlbeans</artifactId>
<version>1.17</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.0-jre</version>
<scope>provided</scope>
</dependency>
</dependencies>

Expand All @@ -179,6 +189,10 @@
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>parkourPlaceholders.json</exclude>
<exclude>parkourCheckstyles.xml</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
Expand All @@ -187,7 +201,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.0</version>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand All @@ -197,7 +211,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.1</version>
<configuration>
<outputDirectory>${export_dir}</outputDirectory>
</configuration>
Expand All @@ -206,7 +220,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<version>3.5.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class ParkourConstants {

public static final String COURSE_PLACEHOLDER = "%COURSE%";

public static final String COURSE_NAME_PLACEHOLDER = "%COURSE_NAME%";

public static final String PLAYER_PLACEHOLDER = "%PLAYER%";

public static final String PLAYER_DISPLAY_PLACEHOLDER = "%PLAYER_DISPLAY%";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,11 @@ public void finishCourse(final Player player) {
playerConfig.setLastCompletedCourse(courseName);
playerConfig.setExistingSessionCourseName(null);

submitPlayerLeaderboard(player, session);
parkour.getParkourSessionManager().forceVisible(player);
parkour.getParkourSessionManager().deleteParkourSession(player, courseName);
parkour.getCourseManager().runEventCommands(player, session, FINISH);
parkour.getConfigManager().getCourseConfig(courseName).incrementCompletions();
submitPlayerLeaderboard(player, session);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static io.github.a5h73y.parkour.other.ParkourConstants.ARGUMENTS_PLACEHOLDER;
import static io.github.a5h73y.parkour.other.ParkourConstants.CHECKPOINT_PLACEHOLDER;
import static io.github.a5h73y.parkour.other.ParkourConstants.COMMAND_PLACEHOLDER;
import static io.github.a5h73y.parkour.other.ParkourConstants.COURSE_NAME_PLACEHOLDER;
import static io.github.a5h73y.parkour.other.ParkourConstants.COURSE_PLACEHOLDER;
import static io.github.a5h73y.parkour.other.ParkourConstants.DEATHS_PLACEHOLDER;
import static io.github.a5h73y.parkour.other.ParkourConstants.PLAYER_DISPLAY_PLACEHOLDER;
Expand All @@ -18,10 +19,9 @@
import io.github.a5h73y.parkour.Parkour;
import io.github.a5h73y.parkour.type.course.ParkourEventType;
import io.github.a5h73y.parkour.type.player.session.ParkourSession;
import io.github.a5h73y.parkour.utility.time.MillisecondConverter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import io.github.a5h73y.parkour.utility.time.MillisecondConverter;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand All @@ -45,7 +45,7 @@ public class TranslationUtils {
* @return String of appropriate translation
*/
public static String getTranslation(@Nullable String translationKey,
boolean prefix) {
boolean prefix) {
if (!ValidationUtils.isStringValid(translationKey)) {
return "Invalid translation.";
}
Expand Down Expand Up @@ -84,8 +84,8 @@ public static String getTranslation(@Nullable String translationKey) {
* @return String of appropriate translation
*/
public static String getValueTranslation(@Nullable String translationKey,
@Nullable String value,
boolean prefix) {
@Nullable String value,
boolean prefix) {
return VALUE_PLACEHOLDER.matcher(getTranslation(translationKey, prefix))
.replaceAll(value == null ? "" : Matcher.quoteReplacement(value));
}
Expand All @@ -101,8 +101,8 @@ public static String getValueTranslation(@Nullable String translationKey,
* @return String of appropriate translation
*/
public static String getValueTranslation(@Nullable String translationKey,
@Nullable Number value,
boolean prefix) {
@Nullable Number value,
boolean prefix) {
return getValueTranslation(translationKey, String.valueOf(value), prefix);
}

Expand All @@ -116,7 +116,7 @@ public static String getValueTranslation(@Nullable String translationKey,
* @return String of appropriate translation
*/
public static String getValueTranslation(@Nullable String translationKey,
@Nullable String value) {
@Nullable String value) {
return getValueTranslation(translationKey, value, true);
}

Expand All @@ -131,8 +131,8 @@ public static String getValueTranslation(@Nullable String translationKey,
* @return course event message
*/
public static String getCourseEventMessage(@NotNull ParkourSession session,
@NotNull ParkourEventType eventType,
@Nullable String fallbackKey) {
@NotNull ParkourEventType eventType,
@Nullable String fallbackKey) {
String result = Parkour.getInstance().getConfigManager().getCourseConfig(session.getCourseName())
.getEventMessage(eventType);

Expand All @@ -152,7 +152,7 @@ public static String getCourseEventMessage(@NotNull ParkourSession session,
* @param recipients targets to receive the message
*/
public static void sendTranslation(@Nullable String translationKey, boolean prefix,
@Nullable CommandSender... recipients) {
@Nullable CommandSender... recipients) {
String translation = getTranslation(translationKey, prefix);
if (recipients != null && !translation.isEmpty()) {
for (CommandSender recipient : recipients) {
Expand All @@ -168,7 +168,7 @@ public static void sendTranslation(@Nullable String translationKey, boolean pref
* @param players to receive the message
*/
public static void sendTranslation(@Nullable String translationKey,
@Nullable CommandSender... players) {
@Nullable CommandSender... players) {
sendTranslation(translationKey, true, players);
}

Expand All @@ -180,8 +180,8 @@ public static void sendTranslation(@Nullable String translationKey,
* @param players targets to receive the message
*/
public static void sendValueTranslation(@Nullable String translationKey,
@Nullable String value,
@Nullable CommandSender... players) {
@Nullable String value,
@Nullable CommandSender... players) {
sendValueTranslation(translationKey, value, true, players);
}

Expand All @@ -193,8 +193,8 @@ public static void sendValueTranslation(@Nullable String translationKey,
* @param recipients targets to receive the message
*/
public static void sendValueTranslation(@Nullable String translationKey,
@Nullable String value, boolean prefix,
@Nullable CommandSender... recipients) {
@Nullable String value, boolean prefix,
@Nullable CommandSender... recipients) {
String translation = getValueTranslation(translationKey, value, prefix);
if (recipients != null && !translation.isEmpty()) {
for (CommandSender recipient : recipients) {
Expand Down Expand Up @@ -402,6 +402,7 @@ public static String replaceAllParkourPlaceholders(String input, Player player,
String result = input.replace(PLAYER_PLACEHOLDER, player.getName())
.replace(PLAYER_DISPLAY_PLACEHOLDER, player.getDisplayName())
.replace(COURSE_PLACEHOLDER, session.getCourse().getDisplayName())
.replace(COURSE_NAME_PLACEHOLDER, session.getCourse().getName())
.replace(DEATHS_PLACEHOLDER, String.valueOf(session.getDeaths()))
.replace(TIME_PLACEHOLDER, session.getDisplayTime())
.replace(TIME_MS_PLACEHOLDER, String.valueOf(session.getAccumulatedTime()))
Expand Down

0 comments on commit 9f7c05a

Please sign in to comment.