Skip to content
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
24 changes: 12 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
java
id("xyz.jpenilla.run-paper") version "2.3.0"
id("com.gradleup.shadow") version "9.3.1"
id("xyz.jpenilla.run-paper") version "3.0.2"
id("com.gradleup.shadow") version "9.6.1"
}

group = "io.github.md5sha256"
version = "1.0.1-SNAPSHOT"
version = "1.1.0-SNAPSHOT"

repositories {
mavenCentral()
Expand Down Expand Up @@ -48,7 +48,7 @@ repositories {
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
compileOnly("com.arcaniax:HeadDatabase-API:1.3.2")
compileOnly("com.github.MilkBowl:VaultAPI:1.7") {
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
exclude(group = "org.bukkit", module = "bukkit")
exclude(group = "org.spigotmc", module = "spigot-api")
exclude(group = "io.papermc.paper", module = "paper-api")
Expand All @@ -59,24 +59,24 @@ dependencies {
exclude(group = "io.papermc.paper", module = "paper-api")
}
// Provided by spigot library
compileOnly("org.mariadb.jdbc:mariadb-java-client:3.4.0")
compileOnly("com.zaxxer:HikariCP:5.1.0")
compileOnly("org.mariadb.jdbc:mariadb-java-client:3.5.10")
compileOnly("com.zaxxer:HikariCP:7.1.0")
// Shaded libs
implementation("de.themoep:inventorygui:1.6.1-SNAPSHOT")
implementation("org.spongepowered:configurate-yaml:4.1.2")
implementation("org.spongepowered:configurate-gson:4.1.2")
implementation("org.incendo:cloud-paper:2.0.0-beta.10") {
implementation("org.spongepowered:configurate-yaml:4.2.0")
implementation("org.spongepowered:configurate-gson:4.2.0")
implementation("org.incendo:cloud-paper:2.0.0") {
exclude("com.google.guava")
}
implementation("org.incendo:cloud-processors-confirmation:1.0.0-rc.1") {
exclude("com.google.guava")
}
implementation("org.incendo:cloud-annotations:2.0.0") {
implementation("org.incendo:cloud-annotations:2.1.0") {
exclude("com.google.guava")
}
testImplementation(platform("org.junit:junit-bom:5.10.2"))
testImplementation(platform("org.junit:junit-bom:6.1.2"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

val targetJavaVersion = 21
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 8 additions & 6 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,40 @@
import org.spongepowered.configurate.objectmapping.meta.Setting;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.time.Duration;
import java.util.Locale;

@ConfigSerializable
public record PostSettings(
@Setting @Required long packageExpirySeconds,
@Setting @Required long returnPackageExpirySeconds,
@Setting @Required long expiryNotificationExpiryThresholdSeconds,
@Setting @Required double postPrice,
@Setting @Required boolean skipUndeserializableItems
@Setting @Required boolean skipUndeserializableItems,
@Setting @Nullable String priceFormatPattern
) {

/**
* Pattern used when none is configured. Any literal prefix/suffix in the pattern is used
* verbatim, so the currency symbol can be replaced by editing the pattern.
*/
public static final String DEFAULT_PRICE_FORMAT_PATTERN = "$#,##0.00";

/**
* Formats the given amount using the configured {@link #priceFormatPattern()}.
*/
@Nonnull
public String formatPrice(double amount) {
String pattern = this.priceFormatPattern == null || this.priceFormatPattern.isEmpty()
? DEFAULT_PRICE_FORMAT_PATTERN
: this.priceFormatPattern;
DecimalFormat format = new DecimalFormat(pattern, DecimalFormatSymbols.getInstance(Locale.ROOT));
return format.format(amount);
}

@Nonnull
public Duration packageExpiryDuration() {
return Duration.ofSeconds(this.packageExpirySeconds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import javax.annotation.Nonnull;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayDeque;
import java.util.ArrayList;
Expand All @@ -53,7 +51,6 @@
import java.util.function.Consumer;

public class PostOfficeMenu {
private static final NumberFormat PRICE_FORMAT = NumberFormat.getCurrencyInstance();

private final JavaPlugin plugin;
private final ConversationFactory conversationFactory;
Expand Down Expand Up @@ -285,8 +282,7 @@ private ItemStack createSendPackageIcon() {
Component displayName = this.messageContainer.messageFor("menu.parcel.post-parcel")
.decoration(TextDecoration.ITALIC, false);
meta.displayName(displayName);
double price = this.postSettings.postPrice();
String formattedPrice = PRICE_FORMAT.format(price);
String formattedPrice = this.postSettings.formatPrice(this.postSettings.postPrice());
Component priceIndicator = this.messageContainer.messageFor("menu.parcel.post-parcel-price")
.replaceText(builder -> builder.matchLiteral("%price%").replacement(formattedPrice))
.decoration(TextDecoration.ITALIC, false);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ commands:
permission: "democracypost.view"

libraries:
- 'org.mariadb.jdbc:mariadb-java-client:3.4.0'
- 'com.zaxxer:HikariCP:5.1.0'
- 'org.mariadb.jdbc:mariadb-java-client:3.5.10'
- 'com.zaxxer:HikariCP:7.1.0'
3 changes: 3 additions & 0 deletions src/main/resources/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ post-settings:
expiry-notification-expiry-threshold-seconds: 259200
post-price: 0.50
skip-undeserializable-items: true
# java.text.DecimalFormat pattern used to render prices.
# Any literal text around the number is kept as-is, so replace the '$' to change the currency symbol.
price-format-pattern: '$#,##0.00'

save-duration-seconds: 600
join-message-delay-seconds: 10
Expand Down
Loading