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 build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "com.eternalcode"
version = "0.0.2-SNAPSHOT"
version = "0.1.0-SNAPSHOT"

repositories {
gradlePluginPortal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ public void onEnable() {
lockerManager,
userManager,
itemStorageManager,
parcelDispatchService
parcelDispatchService,
parcelContentManager,
deliveryManager
);

MainGui mainGUI = new MainGui(
Expand All @@ -182,7 +184,7 @@ public void onEnable() {
new ParcelCommand(mainGUI),
new ParcelLockersCommand(configService, config, noticeService),
new DebugCommand(parcelService, lockerManager, itemStorageManager, parcelContentManager,
noticeService)
noticeService, deliveryManager)
))
.invalidUsage(new InvalidUsageHandlerImpl(noticeService))
.missingPermission(new MissingPermissionsHandlerImpl(noticeService))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@
import com.eternalcode.commons.bukkit.ItemUtil;
import com.eternalcode.multification.notice.Notice;
import com.eternalcode.parcellockers.content.ParcelContentManager;
import com.eternalcode.parcellockers.delivery.DeliveryManager;
import com.eternalcode.parcellockers.itemstorage.ItemStorageManager;
import com.eternalcode.parcellockers.locker.LockerManager;
import com.eternalcode.parcellockers.notification.NoticeService;
import com.eternalcode.parcellockers.parcel.Parcel;
import com.eternalcode.parcellockers.parcel.ParcelService;
import com.eternalcode.parcellockers.parcel.ParcelSize;
import com.eternalcode.parcellockers.parcel.ParcelStatus;
import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.command.Command;
import dev.rollczi.litecommands.annotations.context.Sender;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import java.util.Arrays;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ItemType;

@Command(name = "parcel debug")
@Permission("parcellockers.debug")
Expand All @@ -34,19 +32,21 @@ public class DebugCommand {
private final ItemStorageManager itemStorageManager;
private final ParcelContentManager contentManager;
private final NoticeService noticeService;
private final DeliveryManager deliveryManager;

public DebugCommand(
ParcelService parcelService,
LockerManager lockerManager,
ItemStorageManager itemStorageManager,
ParcelContentManager contentManager,
NoticeService noticeService
NoticeService noticeService, DeliveryManager deliveryManager
) {
this.parcelService = parcelService;
this.lockerManager = lockerManager;
this.itemStorageManager = itemStorageManager;
this.contentManager = contentManager;
this.noticeService = noticeService;
this.deliveryManager = deliveryManager;
}

@Execute(name = "delete parcels")
Expand All @@ -69,9 +69,15 @@ void deleteItems(@Sender CommandSender sender) {
this.contentManager.deleteAll(sender, this.noticeService);
}

@Execute(name = "delete delivieries")
void deleteDeliveries(@Sender CommandSender sender) {
this.deliveryManager.deleteAll(sender, this.noticeService);
}

@Execute(name = "delete all")
void deleteAll(@Sender CommandSender sender) {
this.deleteItemStorages(sender);
this.deleteDeliveries(sender);
this.deleteLockers(sender);
this.deleteParcels(sender);
this.deleteItems(sender);
Expand All @@ -84,45 +90,20 @@ void getRandomItem(@Sender Player player, @Arg int stacks) {
return;
}

List<Material> itemMaterials = Arrays.stream(Material.values()).filter(Material::isItem).toList();
Registry<ItemType> itemTypeRegistry = RegistryAccess.registryAccess().getRegistry(RegistryKey.ITEM);
List<ItemType> types = itemTypeRegistry.keyStream().map(itemTypeRegistry::get).toList();

if (itemMaterials.isEmpty()) { // should never happen
if (types.isEmpty()) { // should never happen
this.noticeService.player(player.getUniqueId(), messages -> Notice.chat("&cNo valid item materials found."));
return;
}

Random random = ThreadLocalRandom.current();

// Give player random items
for (int i = 0; i < stacks; i++) {
Material randomMaterial = itemMaterials.get(random.nextInt(itemMaterials.size()));
int randomAmount = Math.min(random.nextInt(64) + 1, randomMaterial.getMaxStackSize());

ItemStack itemStack = new ItemStack(randomMaterial, randomAmount);
ItemUtil.giveItem(player, itemStack);
}
}

@Execute(name = "send")
void send(@Sender Player player, @Arg int count) {
for (int i = 0; i < count; i++) {
UUID locker = UUID.randomUUID();
this.parcelService.send(
player,
new Parcel(
UUID.randomUUID(),
player.getUniqueId(),
"test",
"test",
false,
player.getUniqueId(),
ParcelSize.MEDIUM,
locker,
locker,
ParcelStatus.DELIVERED
),
List.of(new ItemStack(Material.DIRT, 1))
);
ItemType randomItem = types.get(random.nextInt(types.size()));
int randomAmount = Math.min(random.nextInt(64) + 1, randomItem.getMaxStackSize());
ItemUtil.giveItem(player, randomItem.createItemStack(randomAmount));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import eu.okaeri.configs.annotation.Header;
import org.bukkit.Sound;
import io.papermc.paper.registry.keys.SoundEventKeys;

@SuppressWarnings("ALL")
@Header({
"# This file contains messages used by the ParcelLockers plugin.",
"# You can customize these messages to fit your server's theme or language.",
Expand All @@ -21,7 +20,7 @@ public class MessageConfig extends OkaeriConfig {
public Notice playerNotFound = Notice.chat("&4✘ &cThe specified player could not be found!");
public Notice invalidUsage = Notice.builder()
.chat("&4» &cCorrect usage: &6{USAGE}")
.sound(Sound.BLOCK_NOTE_BLOCK_PLING.key())
.sound(SoundEventKeys.BLOCK_NOTE_BLOCK_PLING)
.build();

public Notice reload = Notice.chat("&3❣ &bConfiguration has been successfully reloaded!");
Expand All @@ -41,82 +40,82 @@ public class MessageConfig extends OkaeriConfig {
public static class ParcelMessages extends OkaeriConfig {
public Notice sent = Notice.builder()
.chat("&2✔ &aParcel sent successfully.")
.sound(Sound.ENTITY_ITEM_PICKUP.key())
.sound(SoundEventKeys.ENTITY_ITEM_PICKUP)
.build();
public Notice cannotSend = Notice.builder()
.chat("&4✘ &cAn error occurred while sending the parcel. Check the console for more information.")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice nameCannotBeEmpty = Notice.builder()
.chat("&4✘ &cThe parcel name cannot be empty!")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice nameSet = Notice.builder()
.chat("&2✔ &aParcel name set successfully.")
.sound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP.key())
.sound(SoundEventKeys.ENTITY_EXPERIENCE_ORB_PICKUP)
.build();
public Notice cannotBeEmpty = Notice.builder()
.chat("&4✘ &cThe parcel cannot be empty!")
.sound(Sound.ENTITY_ENDERMAN_AMBIENT.key())
.sound(SoundEventKeys.ENTITY_ENDERMAN_AMBIENT)
.build();
public Notice receiverSet = Notice.builder()
.chat("&2✔ &aParcel receiver set successfully.")
.sound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP.key())
.sound(SoundEventKeys.ENTITY_EXPERIENCE_ORB_PICKUP)
.build();
public Notice descriptionSet = Notice.builder()
.chat("&2✔ &aParcel name set successfully.")
.sound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP.key())
.chat("&2✔ &aParcel description set successfully.")
.sound(SoundEventKeys.ENTITY_EXPERIENCE_ORB_PICKUP)
.build();
public Notice destinationSet = Notice.builder()
.chat("&2✔ &aParcel destination locker set successfully.")
.sound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP.key())
.sound(SoundEventKeys.ENTITY_EXPERIENCE_ORB_PICKUP)
.build();
public Notice cannotCollect = Notice.builder()
.chat("&4✘ &cAn error occurred while collecting the parcel.")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice noInventorySpace = Notice.builder()
.chat("&4✘ &cYou don't have enough space in your inventory to collect the parcel!")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice collected = Notice.builder()
.chat("&2✔ &aParcel collected successfully.")
.sound(Sound.ENTITY_PLAYER_LEVELUP.key())
.sound(SoundEventKeys.ENTITY_PLAYER_LEVELUP)
.build();
public Notice nameNotSet = Notice.builder()
.chat("&4✘ &cThe parcel name is not set!")
.sound(Sound.ENTITY_ENDERMAN_AMBIENT.key())
.sound(SoundEventKeys.ENTITY_ENDERMAN_AMBIENT)
.build();
public Notice receiverNotSet = Notice.builder()
.chat("&4✘ &cThe parcel receiver is not set!")
.sound(Sound.ENTITY_ENDERMAN_AMBIENT.key())
.sound(SoundEventKeys.ENTITY_ENDERMAN_AMBIENT)
.build();
public Notice destinationNotSet = Notice.builder()
.chat("&4✘ &cThe parcel destination locker is not set!")
.sound(Sound.ENTITY_ENDERMAN_AMBIENT.key())
.sound(SoundEventKeys.ENTITY_ENDERMAN_AMBIENT)
.build();
public Notice lockerFull = Notice.builder()
.chat("&4✘ &cThe destination locker is full! Please select another locker.")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice illegalItem = Notice.builder()
.chat("&4✘ &cThe parcel contains illegal items that cannot be sent. ({ITEMS})")
.build();
public Notice cannotDelete = Notice.builder()
.chat("&4✘ &cAn error occurred while deleting the parcel.")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice deleted = Notice.builder()
.chat("&2✔ &aParcel deleted successfully.")
.sound(Sound.ENTITY_ITEM_BREAK.key())
.sound(SoundEventKeys.ENTITY_ITEM_BREAK)
.build();
public Notice insufficientFunds = Notice.builder()
.chat("&4✘ &cYou do not have enough funds to send this parcel! Required: &6${AMOUNT}&c.")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice feeWithdrawn = Notice.builder()
.chat("&2✔ &a${AMOUNT} has been withdrawn from your account to cover the parcel sending fee.")
.sound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP.key())
.sound(SoundEventKeys.ENTITY_EXPERIENCE_ORB_PICKUP)
.build();

@Comment({"", "# The parcel info message." })
Expand All @@ -131,36 +130,36 @@ public static class ParcelMessages extends OkaeriConfig {
"&f• &6Priority: &e{PRIORITY}",
"&f• &6Description: &e{DESCRIPTION}"
)
.sound(Sound.BLOCK_NOTE_BLOCK_CHIME.key())
.sound(SoundEventKeys.BLOCK_NOTE_BLOCK_CHIME)
.build();
}

public static class LockerMessages extends OkaeriConfig {
public Notice cannotCreate = Notice.builder()
.chat("&4✘ &cCould not create the parcel locker.")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice created = Notice.builder()
.chat("&2✔ &aParcel locker created successfully.")
.sound(Sound.BLOCK_ANVIL_USE.key())
.sound(SoundEventKeys.BLOCK_ANVIL_USE)
.build();
public String descriptionPrompt = "&6Enter a name for the parcel locker:";
public Notice cannotBreak = Notice.builder()
.chat("&4✘ &cYou have no permission to break the parcel locker.")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice deleted = Notice.builder()
.chat("&2✔ &aParcel locker deleted successfully.")
.sound(Sound.BLOCK_ANVIL_BREAK.key())
.sound(SoundEventKeys.BLOCK_ANVIL_BREAK)
.build();
public Notice broadcastRemoved = Notice.chat("&4❣ &cThe parcel locker at &4{X} {Y} {Z} &cin &4{WORLD} &chas been removed by &4{PLAYER}!");
public Notice alreadyCreating = Notice.builder()
.chat("&4✘ &cYou are already creating a parcel locker!")
.sound(Sound.ENTITY_VILLAGER_NO.key())
.sound(SoundEventKeys.ENTITY_VILLAGER_NO)
.build();
public Notice addedToInventory = Notice.builder()
.chat("&2✔ &aParcel locker item added to your inventory.")
.sound(Sound.ENTITY_ITEM_PICKUP.key())
.sound(SoundEventKeys.ENTITY_ITEM_PICKUP)
.build();
}

Expand All @@ -170,8 +169,5 @@ public static class AdminMessages extends OkaeriConfig {
public Notice deletedItemStorages = Notice.chat("&4⚠ &cAll ({COUNT}) item storages have been deleted!");
public Notice deletedContents = Notice.chat("&4⚠ &cAll ({COUNT}) parcel contents have been deleted!");
public Notice deletedDeliveries = Notice.chat("&4⚠ &cAll ({COUNT}) deliveries have been deleted!");
public Notice deletedUsers = Notice.chat("&4⚠ &cAll ({COUNT}) users have been deleted!");
public Notice invalidNumberOfStacks = Notice.chat("&4✘ &cInvalid number of stacks. Must be between 1 and 36.");
public Notice invalidItemMaterials = Notice.chat("&4✘ &cItem materials to give are invalid (should never happen, if it does report this on our discord).");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static class GuiSettings extends OkaeriConfig {
public ConfigItem cornerItem = new ConfigItem()
.name("")
.lore(Collections.emptyList())
.type(Material.ORANGE_STAINED_GLASS_PANE);
.type(Material.BLUE_STAINED_GLASS_PANE);

@Comment({ "", "# The item of the parcel submit button" })
public ConfigItem submitParcelItem = new ConfigItem()
Expand Down Expand Up @@ -216,6 +216,9 @@ public static class GuiSettings extends OkaeriConfig {
)
.type(Material.CHEST_MINECART);

@Comment({ "", "# The lore line showing when the parcel will arrive. Placeholders: {DURATION} - time remaining, {DATE} - arrival date" })
public String parcelArrivingLine = "&6Arriving in: &e{DURATION} &7({DATE})";

@Comment({ "", "# The item of the parcel item storage button" })
public ConfigItem parcelStorageItem = new ConfigItem()
.name("&6\uD83D\uDCBE Parcel storage")
Expand Down Expand Up @@ -328,6 +331,12 @@ public static class GuiSettings extends OkaeriConfig {
Material.END_PORTAL_FRAME
);

@Comment({ "", "# The first line of lore when the parcel contains items in the collection GUI."})
public String parcelItemsCollectionGui = "&6Items:";

@Comment({ "", "# The line of lore containing the item name and amount when the parcel contains items in the collection GUI."})
public String parcelItemCollectionFormat = "&6- <gradient:#f6d14a:#862f51>{AMOUNT}x {ITEM}</gradient>";

@Comment({ "", "# The item of the parcel item in the collection GUI" })
public ConfigItem parcelCollectionItem = new ConfigItem()
.name("&a{NAME}")
Expand All @@ -344,5 +353,8 @@ public static class GuiSettings extends OkaeriConfig {
.name("&4✘ &cNo parcels found")
.lore(List.of("&cYou don't have any parcels to collect."))
.type(Material.STRUCTURE_VOID);

@Comment({ "", "# The lore line showing when the parcel has arrived. Placeholders: {DATE} - arrival date" })
public String parcelArrivedLine = "&aArrived on: &2{DATE}";
}
}
Loading