Skip to content
Closed
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
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/CommonConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ fun Project.applyCommonConfiguration() {
}
}

// Only set Java 1.8 for non-Fabric modules
// Only set Java 17 for non-Fabric modules
// Fabric uses toolchain configuration in its build.gradle.kts
plugins.withId("java") {
if (!plugins.hasPlugin("fabric-loom")) {
the<JavaPluginExtension>().setSourceCompatibility("1.8")
the<JavaPluginExtension>().setTargetCompatibility("1.8")
the<JavaPluginExtension>().setSourceCompatibility("17")
the<JavaPluginExtension>().setTargetCompatibility("17")
}
}
}
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/LibsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ fun Project.applyLibrariesConfiguration() {
}

plugins.withId("java") {
the<JavaPluginExtension>().setSourceCompatibility("1.8")
the<JavaPluginExtension>().setTargetCompatibility("1.8")
the<JavaPluginExtension>().setSourceCompatibility("17")
the<JavaPluginExtension>().setTargetCompatibility("17")
}

group = "${rootProject.group}.BanManagerWebEnhancerLibs"
Expand Down Expand Up @@ -89,7 +89,7 @@ fun Project.applyLibrariesConfiguration() {
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
}
outgoing.artifact(tasks.named("jar"))
}
Expand All @@ -104,7 +104,7 @@ fun Project.applyLibrariesConfiguration() {
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
}
outgoing.artifact(tasks.named("jar"))
}
Expand Down
2 changes: 1 addition & 1 deletion bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
api(project(":BanManagerWebEnhancerCommon")) {
isTransitive = true
}
compileOnly("me.confuser.banmanager:BanManagerBukkit:7.11.0-SNAPSHOT")
compileOnly("me.confuser.banmanager:BanManagerBukkit:8.0.0-SNAPSHOT")

compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT") {
exclude("junit", "junit")
Expand Down
2 changes: 1 addition & 1 deletion bungee/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
api(project(":BanManagerWebEnhancerCommon")) {
isTransitive = true
}
compileOnly("me.confuser.banmanager:BanManagerBungee:7.11.0-SNAPSHOT")
compileOnly("me.confuser.banmanager:BanManagerBungee:8.0.0-SNAPSHOT")

compileOnly("net.md-5:bungeecord-api:1.21-R0.4")
"shadeOnly"("org.bstats:bstats-bungeecord:2.2.1")
Expand Down
4 changes: 2 additions & 2 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ applyPlatformAndCoreConfiguration()
dependencies {
api(project(":BanManagerWebEnhancerLibs"))

api("me.confuser.banmanager:BanManagerCommon:7.11.0-SNAPSHOT")
api("me.confuser.banmanager.BanManagerLibs:BanManagerLibs:7.11.0-SNAPSHOT")
api("me.confuser.banmanager:BanManagerCommon:8.0.0-SNAPSHOT")
api("me.confuser.banmanager.BanManagerLibs:BanManagerLibs:8.0.0-SNAPSHOT")

// Test dependencies
testImplementation("junit:junit:4.13")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ public boolean onCommand(CommonSender sender, CommandParser parser) {
try {
player = getPlugin().getPlayerStorage().queryForId(sender.getData().getId());
} catch (SQLException e) {
sender.sendMessage(Message.get("sender.error.exception").toString());
Message.get("sender.error.exception").sendTo(sender);
e.printStackTrace();
return;
}

PlayerPinData pin = plugin.getPlayerPinStorage().getValidPin(player);

if (pin == null) {
sender.sendMessage(Message.get("sender.error.exception").toString());
Message.get("sender.error.exception").sendTo(sender);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public CommonPlayerDeniedListener(WebEnhancerPlugin plugin) {
}

public void handlePin(PlayerData player, Message message) {
if (!message.toString().contains("[pin]")) return;
String template = message.getRawTemplate();
if (template == null || !template.contains("<pin>")) return;

PlayerPinData pin = plugin.getPlayerPinStorage().getValidPin(player);


if (pin != null) {
message.set("pin", String.valueOf(pin.getGeneratedPin()));
}
Expand Down
6 changes: 3 additions & 3 deletions common/src/main/resources/messages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
messages:
pin:
notify: '&6Your pin expires in [expires]'
pin: '[pin]'
rateLimited: '&cPlease wait [seconds] seconds before generating a new pin'
notify: '<gold>Your pin expires in <expires>'
pin: '<pin>'
rateLimited: '<red>Please wait <seconds> seconds before generating a new pin'
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ public void setUp() {

@Test
public void handlePin_replacesPlaceholderWithPin() {
// Setup
when(playerPinStorage.getValidPin(player)).thenReturn(pinData);
when(pinData.getGeneratedPin()).thenReturn(123456);

// Create a mocked message with [pin] placeholder
Message message = mock(Message.class);
when(message.toString()).thenReturn("Your login pin is: [pin]");
when(message.getRawTemplate()).thenReturn("Your login pin is: <pin>");

listener.handlePin(player, message);

Expand All @@ -54,9 +52,8 @@ public void handlePin_replacesPlaceholderWithPin() {

@Test
public void handlePin_ignoresMessagesWithoutPlaceholder() {
// Create a mocked message without [pin] placeholder
Message message = mock(Message.class);
when(message.toString()).thenReturn("You have been banned!");
when(message.getRawTemplate()).thenReturn("You have been banned!");

listener.handlePin(player, message);

Expand All @@ -66,15 +63,24 @@ public void handlePin_ignoresMessagesWithoutPlaceholder() {

@Test
public void handlePin_handlesNullPinGracefully() {
// Setup - getValidPin returns null
when(playerPinStorage.getValidPin(player)).thenReturn(null);

// Create a mocked message with [pin] placeholder
Message message = mock(Message.class);
when(message.toString()).thenReturn("Your login pin is: [pin]");
when(message.getRawTemplate()).thenReturn("Your login pin is: <pin>");

listener.handlePin(player, message);

verify(message, never()).set(anyString(), anyString());
}

@Test
public void handlePin_handlesNullTemplateGracefully() {
Message message = mock(Message.class);
when(message.getRawTemplate()).thenReturn(null);

listener.handlePin(player, message);

verify(playerPinStorage, never()).getValidPin(any());
verify(message, never()).set(anyString(), anyString());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
messages:
pin:
notify: '&6Your pin expires in [expires]'
pin: '[pin]'

notify: '<gold>Your pin expires in <expires>'
pin: '<pin>'
rateLimited: '<red>Please wait <seconds> seconds before generating a new pin'
Loading
Loading