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
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Build with Gradle
run: ./gradlew clean shadowJar
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.5.0
with:
name: 'ParcelLockers (MC 1.8.8 - 1.20.x)'
path: build/libs/ParcelLockers*
30 changes: 15 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ dependencies {
// minecraft development api
compileOnly("org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT")
implementation("net.kyori:adventure-platform-bukkit:4.3.4")
implementation("net.kyori:adventure-text-minimessage:4.17.0")
implementation("dev.rollczi:litecommands-bukkit:3.9.1")
implementation("dev.rollczi:litecommands-adventure:3.9.1")
implementation("net.kyori:adventure-text-minimessage:4.18.0")
implementation("dev.rollczi:litecommands-bukkit:3.9.5")
implementation("dev.rollczi:litecommands-adventure:3.9.5")

// skull api
implementation("dev.rollczi:liteskullapi:1.3.0")

// gui library
implementation("dev.triumphteam:triumph-gui:3.1.10")
implementation("dev.triumphteam:triumph-gui:3.1.11")

// economy
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1")
Expand All @@ -53,14 +53,14 @@ dependencies {

// metrics and sentry
implementation("org.bstats:bstats-bukkit:3.1.0")
implementation("io.sentry:sentry:7.17.0")
implementation("io.sentry:sentry:7.19.1")

// database
implementation("com.zaxxer:HikariCP:6.1.0")
implementation("com.zaxxer:HikariCP:6.2.1")

// lombok
compileOnly("org.projectlombok:lombok:1.18.34")
annotationProcessor("org.projectlombok:lombok:1.18.34")
compileOnly("org.projectlombok:lombok:1.18.36")
annotationProcessor("org.projectlombok:lombok:1.18.36")

// jetbrains annotations
api("org.jetbrains:annotations:26.0.1")
Expand All @@ -69,7 +69,7 @@ dependencies {
implementation("io.papermc:paperlib:1.0.8")

// signgui
implementation("de.rapha149.signgui:signgui:2.4.2")
implementation("de.rapha149.signgui:signgui:2.5.0")

// panda-utilities
implementation("org.panda-lang:panda-utilities:0.5.2-alpha")
Expand All @@ -84,12 +84,12 @@ dependencies {
implementation("com.eternalcode:eternalcode-commons-adventure:1.1.4")
implementation("com.eternalcode:eternalcode-commons-bukkit:1.1.4")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.3")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.3")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.4")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.4")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.4")

testImplementation("org.testcontainers:junit-jupiter:1.20.3")
testImplementation("org.testcontainers:mysql:1.20.3")
testImplementation("org.testcontainers:junit-jupiter:1.20.4")
testImplementation("org.testcontainers:mysql:1.20.4")
testImplementation("mysql:mysql-connector-java:8.0.33")
}

Expand All @@ -98,7 +98,7 @@ java {
}

checkstyle {
toolVersion = "10.20.1"
toolVersion = "10.21.0"

configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")

Expand Down
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-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 1 addition & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
import dev.rollczi.litecommands.LiteCommands;
import dev.rollczi.litecommands.adventure.LiteAdventureExtension;
import dev.rollczi.litecommands.annotations.LiteCommandsAnnotations;
import dev.rollczi.litecommands.bukkit.LiteBukkitFactory;
import dev.rollczi.litecommands.bukkit.LiteBukkitMessages;
import dev.rollczi.litecommands.bukkit.LiteCommandsBukkit;
import dev.rollczi.liteskullapi.LiteSkullFactory;
import dev.rollczi.liteskullapi.SkullAPI;
import io.papermc.lib.PaperLib;
Expand Down Expand Up @@ -125,7 +125,7 @@ public void onEnable() {
MainGUI mainGUI = new MainGUI(this, server, miniMessage, config, parcelRepository, lockerRepository, userManager);
ParcelListGUI parcelListGUI = new ParcelListGUI(this, server, miniMessage, config, parcelRepository, lockerRepository, userManager, mainGUI);

this.liteCommands = LiteCommandsBukkit.builder("parcellockers", this)
this.liteCommands = LiteBukkitFactory.builder("parcellockers", this)
.argument(Parcel.class, new ParcelArgument(parcelRepository))
.argument(Locker.class, new ParcelLockerArgument(lockerRepository))
.extension(new LiteAdventureExtension<>())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.eternalcode.parcellockers.user.UserRepository;
import de.rapha149.signgui.SignGUI;
import de.rapha149.signgui.SignGUIAction;
import de.rapha149.signgui.exception.SignGUIVersionException;
import dev.rollczi.liteskullapi.SkullAPI;
import dev.triumphteam.gui.guis.Gui;
import dev.triumphteam.gui.guis.GuiItem;
Expand Down Expand Up @@ -94,63 +95,73 @@ public void show(Player player) {
GuiItem cornerItem = guiSettings.cornerItem.toGuiItem();
ConfigItem nameItem = guiSettings.parcelNameItem.clone();
GuiItem nameGuiItem = nameItem.toGuiItem(event -> {
SignGUI nameSignGui = SignGUI.builder()
.setColor(DyeColor.BLACK)
.setType(Material.OAK_SIGN)
.setLine(0, "Enter parcel name:")
.setHandler((p, result) -> {
String name = result.getLineWithoutColor(1);

if (name.isEmpty() || name.isBlank()) {
this.announcer.sendMessage(player, settings.messages.parcelNameCannotBeEmpty);
return Collections.emptyList();
}
SignGUI nameSignGui = null;
try {
nameSignGui = SignGUI.builder()
.setColor(DyeColor.BLACK)
.setType(Material.OAK_SIGN)
.setLine(0, "Enter parcel name:")
.setHandler((p, result) -> {
String name = result.getLineWithoutColor(1);

if (name.isEmpty() || name.isBlank()) {
this.announcer.sendMessage(player, settings.messages.parcelNameCannotBeEmpty);
return Collections.emptyList();
}

this.state.setParcelName(name);
this.announcer.sendMessage(player, settings.messages.parcelNameSet);
this.state.setParcelName(name);
this.announcer.sendMessage(player, settings.messages.parcelNameSet);

List<String> lore = nameItem.lore;
if (lore.size() > 1) {
lore.remove(1);
}
List<String> lore = nameItem.lore;
if (lore.size() > 1) {
lore.remove(1);
}

lore.add(this.config.guiSettings.parcelNameSetLine.replace("{NAME}", this.state.getParcelName() == null
? "None" : this.state.getParcelName()));
lore.add(this.config.guiSettings.parcelNameSetLine.replace("{NAME}", this.state.getParcelName() == null
? "None" : this.state.getParcelName()));

this.gui.updateItem(21, nameItem
.setLore(lore)
.toItemStack());
return List.of(SignGUIAction.runSync((JavaPlugin) this.plugin, () -> this.gui.open(player)));
})
.build();
this.gui.updateItem(21, nameItem
.setLore(lore)
.toItemStack());
return List.of(SignGUIAction.runSync((JavaPlugin) this.plugin, () -> this.gui.open(player)));
})
.build();
} catch (SignGUIVersionException e) {
this.plugin.getLogger().severe("The server version is unsupported by SignGUI API!");
}
nameSignGui.open(player);
});

ConfigItem descriptionItem = guiSettings.parcelDescriptionItem.clone();
GuiItem descriptionGuiItem = descriptionItem.toGuiItem(event -> {
SignGUI descriptionSignGui = SignGUI.builder()
.setColor(DyeColor.BLACK)
.setType(Material.OAK_SIGN)
.setLine(0, "Enter parcel description:")
.setHandler((p, result) -> {
String description = result.getLineWithoutColor(1);

this.state.setParcelDescription(description);
this.announcer.sendMessage(player, settings.messages.parcelDescriptionSet);

List<String> lore = descriptionItem.clone().lore;
if (lore.size() > 1) {
lore.remove(1);
}
SignGUI descriptionSignGui = null;
try {
descriptionSignGui = SignGUI.builder()
.setColor(DyeColor.BLACK)
.setType(Material.OAK_SIGN)
.setLine(0, "Enter parcel description:")
.setHandler((p, result) -> {
String description = result.getLineWithoutColor(1);

this.state.setParcelDescription(description);
this.announcer.sendMessage(player, settings.messages.parcelDescriptionSet);

List<String> lore = descriptionItem.clone().lore;
if (lore.size() > 1) {
lore.remove(1);
}

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

this.gui.updateItem(22, descriptionItem
.setLore(lore)
.toItemStack());
return List.of(SignGUIAction.runSync((JavaPlugin) this.plugin, () -> this.gui.open(player)));
})
.build();
this.gui.updateItem(22, descriptionItem
.setLore(lore)
.toItemStack());
return List.of(SignGUIAction.runSync((JavaPlugin) this.plugin, () -> this.gui.open(player)));
})
.build();
} catch (SignGUIVersionException e) {
this.plugin.getLogger().severe("The server version is unsupported by SignGUI API!");
}
descriptionSignGui.open(player);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

public class LockerBreakController implements Listener {

private final LockerRepository parcelLockerRepository;
private final LockerRepository lockerRepository;
private final NotificationAnnouncer announcer;
private final PluginConfiguration.Messages messages;

public LockerBreakController(LockerRepository parcelLockerRepository, NotificationAnnouncer announcer, PluginConfiguration.Messages messages) {
this.parcelLockerRepository = parcelLockerRepository;
public LockerBreakController(LockerRepository lockerRepository, NotificationAnnouncer announcer, PluginConfiguration.Messages messages) {
this.lockerRepository = lockerRepository;
this.announcer = announcer;
this.messages = messages;
}
Expand All @@ -40,15 +40,24 @@ public void onBlockBreak(BlockBreakEvent event) {
Position position = PositionAdapter.convert(location);
Player player = event.getPlayer();

if (this.parcelLockerRepository.isInCache(position)) {
this.lockerRepository.findByPosition(position).whenComplete((locker, throwable) -> {
if (locker.isEmpty()) {
return;
}

if (throwable != null) {
throwable.printStackTrace();
return;
}

if (!player.hasPermission("parcellockers.admin.break")) {
event.setCancelled(true);
this.announcer.sendMessage(player, this.messages.cannotBreakParcelLocker);
return;
}

UUID toRemove = this.parcelLockerRepository.positionCache().get(position);
this.parcelLockerRepository.remove(toRemove);
UUID toRemove = this.lockerRepository.positionCache().get(position);
this.lockerRepository.remove(toRemove);

this.announcer.sendMessage(player, this.messages.parcelLockerSuccessfullyDeleted);

Expand All @@ -60,8 +69,7 @@ public void onBlockBreak(BlockBreakEvent event) {
.register("{PLAYER}", player.getName());

this.announcer.broadcast(formatter.format(this.messages.broadcastParcelLockerRemoved));
}

});
}

@EventHandler
Expand All @@ -70,7 +78,7 @@ public void onBlockBurn(BlockBurnEvent event) {
Location location = block.getLocation();
Position position = PositionAdapter.convert(location);

if (this.parcelLockerRepository.isInCache(position)) {
if (this.lockerRepository.isInCache(position)) {
event.setCancelled(true);
}
}
Expand All @@ -81,7 +89,7 @@ public void onBlockExplode(BlockExplodeEvent event) {
Location location = block.getLocation();
Position position = PositionAdapter.convert(location);

if (this.parcelLockerRepository.isInCache(position)) {
if (this.lockerRepository.isInCache(position)) {
event.setCancelled(true);
}
}
Expand All @@ -91,7 +99,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
event.blockList().removeIf(block -> {
Location location = block.getLocation();
Position position = PositionAdapter.convert(location);
return this.parcelLockerRepository.isInCache(position);
return this.lockerRepository.isInCache(position);
});
}

Expand All @@ -101,7 +109,7 @@ public void onBlockIgnite(BlockIgniteEvent event) {
Location location = block.getLocation();
Position position = PositionAdapter.convert(location);

if (this.parcelLockerRepository.isInCache(position)) {
if (this.lockerRepository.isInCache(position)) {
event.setCancelled(true);
}
}
Expand All @@ -112,7 +120,7 @@ public void onBlockDamage(BlockDamageEvent event) {
Location location = block.getLocation();
Position position = PositionAdapter.convert(location);

if (this.parcelLockerRepository.isInCache(position)) {
if (this.lockerRepository.isInCache(position)) {
event.setCancelled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.bukkit.command.CommandSender;

import java.util.UUID;
import java.util.concurrent.CompletableFuture;

public class ParcelArgument extends ArgumentResolver<CommandSender, Parcel> {

Expand All @@ -23,12 +24,12 @@ public ParcelArgument(ParcelRepository cache) {

@Override
protected ParseResult<Parcel> parse(Invocation<CommandSender> invocation, Argument<Parcel> context, String argument) {
Parcel parcel = this.databaseService.findParcel(UUID.fromString(argument)).orElse(null);

if (parcel == null) {
return ParseResult.failure(InvalidUsage.Cause.MISSING_ARGUMENT);
}
return ParseResult.success(parcel);
UUID parcelId = UUID.fromString(argument);
CompletableFuture<ParseResult<Parcel>> future = this.databaseService.findByUUID(parcelId)
.thenApply(optional -> optional
.map(ParseResult::success)
.orElse(ParseResult.failure(InvalidUsage.Cause.INVALID_ARGUMENT)));
return ParseResult.completableFuture(future);
}

@Override
Expand All @@ -37,5 +38,7 @@ public SuggestionResult suggest(Invocation<CommandSender> invocation, Argument<P
.map(Parcel::uuid)
.map(UUID::toString)
.collect(SuggestionResult.collector());


}
}
Loading