Skip to content

Commit 818cecf

Browse files
committed
Merge branch 'master' into add-integration-tests
# Conflicts: # build.gradle.kts
2 parents 5526bf4 + ac2a55e commit 818cecf

File tree

6 files changed

+84
-45
lines changed

6 files changed

+84
-45
lines changed

build.gradle.kts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
`java-library`
33
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
44
id("xyz.jpenilla.run-paper") version "2.3.1"
5-
id("com.gradleup.shadow") version "8.3.8"
5+
id("com.gradleup.shadow") version "9.0.1"
66
}
77

88
group = "com.eternalcode"
@@ -23,18 +23,18 @@ repositories {
2323

2424
dependencies {
2525
// minecraft development api
26-
compileOnly("org.spigotmc:spigot-api:1.21.5-R0.1-SNAPSHOT")
27-
implementation("net.kyori:adventure-platform-bukkit:4.4.0")
28-
implementation("net.kyori:adventure-text-minimessage:4.23.0")
29-
implementation("dev.rollczi:litecommands-bukkit:3.10.2")
30-
implementation("dev.rollczi:litecommands-adventure:3.10.2")
26+
compileOnly("org.spigotmc:spigot-api:1.21.7-R0.1-SNAPSHOT")
27+
implementation("net.kyori:adventure-platform-bukkit:4.4.1")
28+
implementation("net.kyori:adventure-text-minimessage:4.24.0")
29+
implementation("dev.rollczi:litecommands-bukkit:3.10.4")
30+
implementation("dev.rollczi:litecommands-adventure:3.10.4")
3131

3232
// skull api
3333
implementation("dev.rollczi:liteskullapi:2.0.0")
3434

3535
// gui
3636
implementation("dev.triumphteam:triumph-gui:3.1.11")
37-
implementation("de.rapha149.signgui:signgui:2.5.3")
37+
implementation("de.rapha149.signgui:signgui:2.5.4")
3838

3939
// CDN
4040
implementation("net.dzikoysk:cdn:1.14.9")
@@ -47,10 +47,10 @@ dependencies {
4747

4848
// metrics and sentry
4949
implementation("org.bstats:bstats-bukkit:3.1.0")
50-
implementation("io.sentry:sentry:8.16.0")
50+
implementation("io.sentry:sentry:8.18.0")
5151

5252
// database
53-
implementation("com.zaxxer:HikariCP:6.3.0")
53+
implementation("com.zaxxer:HikariCP:7.0.1")
5454
implementation("com.j256.ormlite:ormlite-jdbc:6.1")
5555
implementation("com.h2database:h2:2.3.232")
5656
implementation("org.postgresql:postgresql:42.7.7")
@@ -75,20 +75,20 @@ dependencies {
7575
implementation("com.spotify:completable-futures:0.3.6")
7676

7777
// eternalcode-commons
78-
implementation("com.eternalcode:eternalcode-commons-adventure:1.1.7")
79-
implementation("com.eternalcode:eternalcode-commons-bukkit:1.1.7")
78+
implementation("com.eternalcode:eternalcode-commons-adventure:1.2.0")
79+
implementation("com.eternalcode:eternalcode-commons-bukkit:1.2.0")
8080

81-
testImplementation("org.junit.jupiter:junit-jupiter-api:5.13.3")
82-
testImplementation("org.junit.jupiter:junit-jupiter-params:5.13.3")
83-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.13.3")
81+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.13.4")
82+
testImplementation("org.junit.jupiter:junit-jupiter-params:5.13.4")
83+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.13.4")
8484
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
8585
testImplementation("org.testcontainers:junit-jupiter:1.21.3")
8686
testImplementation("org.testcontainers:mysql:1.21.3")
8787
testImplementation("mysql:mysql-connector-java:8.0.33")
8888

8989
testImplementation("org.spigotmc:spigot-api:1.21.5-R0.1-SNAPSHOT")
90-
testImplementation("net.kyori:adventure-platform-bukkit:4.4.0")
91-
testImplementation("net.kyori:adventure-text-minimessage:4.23.0")
90+
testImplementation("net.kyori:adventure-platform-bukkit:4.4.1")
91+
testImplementation("net.kyori:adventure-text-minimessage:4.24.0")
9292
testImplementation("net.dzikoysk:cdn:1.14.9")
9393
}
9494

@@ -116,7 +116,7 @@ tasks.withType<JavaCompile> {
116116

117117
tasks {
118118
runServer {
119-
minecraftVersion("1.21.5")
119+
minecraftVersion("1.21.7")
120120
}
121121

122122
clean {

gradle/wrapper/gradle-wrapper.jar

1.65 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright © 2015-2021 the original authors.
4+
# Copyright © 2015 the original authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.

src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelSendingGui.java

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838

3939
public class ParcelSendingGui implements GuiView {
4040

41+
private static final int RECEIVER_ITEM_SLOT = 23;
42+
private static final int SMALL_BUTTON_SLOT = 12;
43+
private static final int MEDIUM_BUTTON_SLOT = 13;
44+
private static final int LARGE_BUTTON_SLOT = 14;
45+
private static final int NAME_ITEM_SLOT = 21;
46+
private static final int DESCRIPTION_ITEM_SLOT = 22;
47+
private static final int DESTINATION_ITEM_SLOT = 30;
48+
private static final int STORAGE_ITEM_SLOT = 37;
49+
private static final int PRIORITY_BUTTON_SLOT = 42;
50+
private static final int SUBMIT_ITEM_SLOT = 43;
51+
private static final int CLOSE_ITEM_SLOT = 49;
4152
private final Plugin plugin;
4253
private final BukkitScheduler scheduler;
4354
private final PluginConfiguration config;
@@ -104,7 +115,7 @@ public void show(Player player) {
104115
.setHandler((p, result) -> {
105116
String name = result.getLineWithoutColor(1);
106117

107-
if (name.isEmpty() || name.isBlank()) {
118+
if (name.isBlank()) {
108119
this.announcer.sendMessage(player, settings.messages.parcelNameCannotBeEmpty);
109120
return Collections.emptyList();
110121
}
@@ -120,7 +131,7 @@ public void show(Player player) {
120131
lore.add(this.config.guiSettings.parcelNameSetLine.replace("{NAME}", this.state.getParcelName() == null
121132
? "None" : this.state.getParcelName()));
122133

123-
this.gui.updateItem(21, nameItem
134+
this.gui.updateItem(NAME_ITEM_SLOT, nameItem
124135
.setLore(lore)
125136
.toItemStack());
126137
return List.of(SignGUIAction.runSync((JavaPlugin) this.plugin, () -> this.gui.open(player)));
@@ -154,7 +165,7 @@ public void show(Player player) {
154165

155166
lore.add(this.config.guiSettings.parcelDescriptionSetLine.replace("{DESCRIPTION}", description));
156167

157-
this.gui.updateItem(22, descriptionItem
168+
this.gui.updateItem(DESCRIPTION_ITEM_SLOT, descriptionItem
158169
.setLore(lore)
159170
.toItemStack());
160171
return List.of(SignGUIAction.runSync((JavaPlugin) this.plugin, () -> this.gui.open(player)));
@@ -248,12 +259,12 @@ public void show(Player player) {
248259
this.gui.setItem(slot, cornerItem);
249260
}
250261

251-
this.gui.setItem(12, smallButton.toGuiItem(event -> this.setSelected(this.gui, ParcelSize.SMALL)));
252-
this.gui.setItem(13, mediumButton.toGuiItem(event -> this.setSelected(this.gui, ParcelSize.MEDIUM)));
253-
this.gui.setItem(14, largeButton.toGuiItem(event -> this.setSelected(this.gui, ParcelSize.LARGE)));
254-
this.gui.setItem(21, nameGuiItem);
255-
this.gui.setItem(22, descriptionGuiItem);
256-
this.gui.setItem(23, guiSettings.parcelReceiverItem.toGuiItem(event -> new ReceiverSelectionGui(
262+
this.gui.setItem(SMALL_BUTTON_SLOT, smallButton.toGuiItem(event -> this.setSelected(this.gui, ParcelSize.SMALL)));
263+
this.gui.setItem(MEDIUM_BUTTON_SLOT, mediumButton.toGuiItem(event -> this.setSelected(this.gui, ParcelSize.MEDIUM)));
264+
this.gui.setItem(LARGE_BUTTON_SLOT, largeButton.toGuiItem(event -> this.setSelected(this.gui, ParcelSize.LARGE)));
265+
this.gui.setItem(NAME_ITEM_SLOT, nameGuiItem);
266+
this.gui.setItem(DESCRIPTION_ITEM_SLOT, descriptionGuiItem);
267+
this.gui.setItem(RECEIVER_ITEM_SLOT, guiSettings.parcelReceiverItem.toGuiItem(event -> new ReceiverSelectionGui(
257268
this.plugin,
258269
this.scheduler,
259270
this.config,
@@ -264,7 +275,7 @@ public void show(Player player) {
264275
this.state
265276
).show(player)));
266277

267-
this.gui.setItem(30, guiSettings.parcelDestinationLockerItem.toGuiItem(event -> new DestinationSelectionGui(
278+
this.gui.setItem(DESTINATION_ITEM_SLOT, guiSettings.parcelDestinationLockerItem.toGuiItem(event -> new DestinationSelectionGui(
268279
this.plugin,
269280
this.scheduler,
270281
this.config,
@@ -274,13 +285,23 @@ public void show(Player player) {
274285
this.state
275286
).show(player)));
276287

277-
this.gui.setItem(37, storageItem);
278-
this.gui.setItem(43, submitItem);
279-
this.gui.setItem(42, priorityItem.toGuiItem(event -> this.setSelected(this.gui, !this.state.isPriority())));
280-
this.gui.setItem(49, closeItem);
288+
this.gui.setItem(STORAGE_ITEM_SLOT, storageItem);
289+
this.gui.setItem(SUBMIT_ITEM_SLOT, submitItem);
290+
this.gui.setItem(PRIORITY_BUTTON_SLOT, priorityItem.toGuiItem(event -> this.setSelected(this.gui, !this.state.isPriority())));
291+
this.gui.setItem(CLOSE_ITEM_SLOT, closeItem);
281292

282293
this.setSelected(this.gui, this.state.getSize() == null ? ParcelSize.SMALL : this.state.getSize());
283294

295+
this.updateNameItem();
296+
this.updateDescriptionItem();
297+
this.userRepository.getUser(this.state.getReceiver()).thenAccept(userOptional -> {
298+
userOptional.ifPresent(user -> this.updateReceiverItem(player, user.name()));
299+
});
300+
this.lockerRepository.findByUUID(this.state.getDestinationLocker()).thenAccept(lockerOptional -> {
301+
lockerOptional.ifPresent(locker -> this.updateDestinationItem(player, locker.description()));
302+
});
303+
304+
284305
this.gui.open(player);
285306
}
286307

@@ -293,10 +314,10 @@ private void setSelected(Gui gui, ParcelSize size) {
293314
ConfigItem largeButton = size == ParcelSize.LARGE ? settings.selectedLargeParcelSizeItem : settings.largeParcelSizeItem;
294315
ConfigItem priorityButton = this.state.isPriority() ? settings.selectedPriorityItem : settings.priorityItem;
295316

296-
gui.updateItem(12, smallButton.toItemStack());
297-
gui.updateItem(13, mediumButton.toItemStack());
298-
gui.updateItem(14, largeButton.toItemStack());
299-
gui.updateItem(42, priorityButton.toItemStack());
317+
gui.updateItem(SMALL_BUTTON_SLOT, smallButton.toItemStack());
318+
gui.updateItem(MEDIUM_BUTTON_SLOT, mediumButton.toItemStack());
319+
gui.updateItem(LARGE_BUTTON_SLOT, largeButton.toItemStack());
320+
gui.updateItem(PRIORITY_BUTTON_SLOT, priorityButton.toItemStack());
300321
}
301322

302323
private void setSelected(Gui gui, boolean priority) {
@@ -305,31 +326,51 @@ private void setSelected(Gui gui, boolean priority) {
305326

306327
ConfigItem priorityButton = priority ? settings.selectedPriorityItem : settings.priorityItem;
307328

308-
gui.updateItem(42, priorityButton.toItemStack());
329+
gui.updateItem(PRIORITY_BUTTON_SLOT, priorityButton.toItemStack());
330+
}
331+
332+
public void updateNameItem() {
333+
if (this.state.getParcelName() == null || this.state.getParcelName().isEmpty()) {
334+
this.gui.updateItem(NAME_ITEM_SLOT, this.config.guiSettings.parcelNameItem.toItemStack());
335+
return;
336+
}
337+
338+
String line = this.config.guiSettings.parcelNameSetLine.replace("{NAME}", this.state.getParcelName());
339+
this.gui.updateItem(NAME_ITEM_SLOT, this.createActiveItem(this.config.guiSettings.parcelNameItem, line));
340+
}
341+
342+
public void updateDescriptionItem() {
343+
if (this.state.getParcelDescription() == null || this.state.getParcelDescription().isEmpty()) {
344+
this.gui.updateItem(DESCRIPTION_ITEM_SLOT, this.config.guiSettings.parcelDescriptionItem.toItemStack());
345+
return;
346+
}
347+
348+
String line = this.config.guiSettings.parcelDescriptionSetLine.replace("{DESCRIPTION}", this.state.getParcelDescription());
349+
this.gui.updateItem(DESCRIPTION_ITEM_SLOT, this.createActiveItem(this.config.guiSettings.parcelDescriptionItem, line));
309350
}
310351

311352
public void updateReceiverItem(Player player, String receiverName) {
312353
this.announcer.sendMessage(player, this.config.messages.parcelReceiverSet);
313354

314355
if (receiverName == null || receiverName.isEmpty()) {
315-
this.gui.updateItem(23, this.config.guiSettings.parcelReceiverItem.toItemStack());
356+
this.gui.updateItem(RECEIVER_ITEM_SLOT, this.config.guiSettings.parcelReceiverItem.toItemStack());
316357
return;
317358
}
318359

319360
String line = this.config.guiSettings.parcelReceiverGuiSetLine.replace("{RECEIVER}", receiverName);
320-
this.gui.updateItem(23, this.createActiveItem(this.config.guiSettings.parcelReceiverItem, line));
361+
this.gui.updateItem(RECEIVER_ITEM_SLOT, this.createActiveItem(this.config.guiSettings.parcelReceiverItem, line));
321362
}
322363

323364
public void updateDestinationItem(Player player, String destinationLockerDesc) {
324365
this.announcer.sendMessage(player, this.config.messages.parcelDestinationSet);
325366

326367
if (destinationLockerDesc == null || destinationLockerDesc.isEmpty()) {
327-
this.gui.updateItem(30, this.config.guiSettings.parcelDestinationLockerItem.toItemStack());
368+
this.gui.updateItem(DESTINATION_ITEM_SLOT, this.config.guiSettings.parcelDestinationLockerItem.toItemStack());
328369
return;
329370
}
330371

331372
String line = this.config.guiSettings.parcelDestinationLockerSetLine.replace("{DESCRIPTION}", destinationLockerDesc);
332-
this.gui.updateItem(30, this.createActiveItem(this.config.guiSettings.parcelDestinationLockerItem, line));
373+
this.gui.updateItem(DESTINATION_ITEM_SLOT, this.createActiveItem(this.config.guiSettings.parcelDestinationLockerItem, line));
333374
}
334375

335376
private @NotNull ItemStack createActiveItem(ConfigItem item, String appendLore) {

src/main/java/com/eternalcode/parcellockers/locker/controller/LockerInteractionController.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import org.bukkit.event.block.Action;
1212
import org.bukkit.event.player.PlayerInteractEvent;
1313

14-
import java.util.Set;
15-
1614
public class LockerInteractionController implements Listener {
1715

1816
private final LockerCache cache;
@@ -26,7 +24,7 @@ public LockerInteractionController(LockerCache cache, LockerMainGui lockerMainGU
2624
@EventHandler
2725
public void onInventoryOpen(PlayerInteractEvent event) {
2826
Player player = event.getPlayer();
29-
Position blockPos = PositionAdapter.convert(player.getTargetBlock(Set.of(Material.AIR), 5).getLocation());
27+
Position blockPos = PositionAdapter.convert(event.getClickedBlock().getLocation());
3028

3129
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
3230
return;

0 commit comments

Comments
 (0)