Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-100 Implement EternalCodeCommons #107

Merged
merged 6 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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/CODEOWNERS
Jakubk15 marked this conversation as resolved.
Show resolved Hide resolved
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @EternalCodeTeam/team @Jakubk15
* @Jakubk15
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repositories {

dependencies {
// minecraft development api
compileOnly("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT")
Jakubk15 marked this conversation as resolved.
Show resolved Hide resolved
implementation("net.kyori:adventure-platform-bukkit:4.3.4")
implementation("net.kyori:adventure-text-minimessage:4.17.0")
implementation("dev.rollczi:litecommands-bukkit:3.6.0")
Expand Down Expand Up @@ -80,6 +80,10 @@ dependencies {
// completable-futures
implementation("com.spotify:completable-futures:0.3.6")

// eternalcode-commons
implementation("com.eternalcode:eternalcode-commons-adventure:1.1.3")
implementation("com.eternalcode:eternalcode-commons-bukkit:1.1.3")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.1")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.eternalcode.parcellockers;

import com.eternalcode.commons.adventure.AdventureLegacyColorPostProcessor;
import com.eternalcode.commons.adventure.AdventureLegacyColorPreProcessor;
import com.eternalcode.parcellockers.command.handler.InvalidUsageImpl;
import com.eternalcode.parcellockers.command.handler.PermissionMessage;
import com.eternalcode.parcellockers.configuration.ConfigurationManager;
Expand Down Expand Up @@ -31,7 +33,6 @@
import com.eternalcode.parcellockers.user.UserManager;
import com.eternalcode.parcellockers.user.UserRepository;
import com.eternalcode.parcellockers.user.UserRepositoryImpl;
import com.eternalcode.parcellockers.util.legacy.LegacyColorProcessor;
import com.google.common.base.Stopwatch;
import com.zaxxer.hikari.HikariDataSource;
import dev.rollczi.litecommands.LiteCommands;
Expand Down Expand Up @@ -78,7 +79,8 @@ public void onEnable() {

this.audiences = BukkitAudiences.create(this);
MiniMessage miniMessage = MiniMessage.builder()
.postProcessor(new LegacyColorProcessor())
.preProcessor(new AdventureLegacyColorPreProcessor())
.postProcessor(new AdventureLegacyColorPostProcessor())
.build();
NotificationAnnouncer announcer = new NotificationAnnouncer(this.audiences, miniMessage);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.eternalcode.parcellockers.configuration.implementation;


import com.eternalcode.parcellockers.util.legacy.LegacyColorProcessor;
import com.eternalcode.commons.adventure.AdventureLegacyColorPostProcessor;
import com.eternalcode.commons.adventure.AdventureUtil;
import dev.triumphteam.gui.builder.item.ItemBuilder;
import dev.triumphteam.gui.components.GuiAction;
import dev.triumphteam.gui.guis.GuiItem;
Expand All @@ -17,14 +18,12 @@
import java.util.ArrayList;
import java.util.List;

import static com.eternalcode.parcellockers.util.AdventureUtil.RESET_ITEM;

@Contextual
public class ConfigItem implements Cloneable {

@Exclude
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder()
.postProcessor(new LegacyColorProcessor())
.postProcessor(new AdventureLegacyColorPostProcessor())
Jakubk15 marked this conversation as resolved.
Show resolved Hide resolved
.build();

public Material type = Material.STONE;
Expand All @@ -34,8 +33,8 @@ public class ConfigItem implements Cloneable {

public GuiItem toGuiItem(GuiAction<InventoryClickEvent> action) {
return ItemBuilder.from(this.type)
.name(RESET_ITEM.append(MINI_MESSAGE.deserialize(this.name)))
.lore(this.lore.stream().map(element -> RESET_ITEM.append(MINI_MESSAGE.deserialize(element))).toList())
.name(AdventureUtil.resetItalic(MINI_MESSAGE.deserialize(this.name)))
.lore(this.lore.stream().map(element -> AdventureUtil.resetItalic(MINI_MESSAGE.deserialize(element))).toList())
.flags(ItemFlag.HIDE_ATTRIBUTES)
.flags(ItemFlag.HIDE_ENCHANTS)
.glow(this.glow)
Expand All @@ -44,8 +43,8 @@ public GuiItem toGuiItem(GuiAction<InventoryClickEvent> action) {

public @NotNull ItemBuilder toBuilder() {
return ItemBuilder.from(this.type)
.name(RESET_ITEM.append(MINI_MESSAGE.deserialize(this.name)))
.lore(this.lore.stream().map(element -> RESET_ITEM.append(MINI_MESSAGE.deserialize(element))).toList())
.name(AdventureUtil.resetItalic(MINI_MESSAGE.deserialize(this.name)))
.lore(this.lore.stream().map(element -> AdventureUtil.resetItalic(MINI_MESSAGE.deserialize(element))).toList())
.flags(ItemFlag.HIDE_ATTRIBUTES)
.flags(ItemFlag.HIDE_ENCHANTS)
.glow(this.glow);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

import static com.eternalcode.parcellockers.util.AdventureUtil.RESET_ITEM;
import static com.eternalcode.commons.adventure.AdventureUtil.resetItalic;

public class LockerMainGUI extends GuiView {

Expand Down Expand Up @@ -57,7 +57,7 @@ public void show(Player player) {
Component guiTitle = this.miniMessage.deserialize(this.config.guiSettings.mainGuiTitle);

Gui gui = Gui.gui()
.title(RESET_ITEM.append(guiTitle))
.title(resetItalic(guiTitle))
.rows(6)
.disableAllInteractions()
.create();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.eternalcode.parcellockers.gui.implementation.locker;

import com.eternalcode.commons.adventure.AdventureUtil;
import com.eternalcode.parcellockers.configuration.implementation.ConfigItem;
import com.eternalcode.parcellockers.configuration.implementation.PluginConfiguration;
import com.eternalcode.parcellockers.content.ParcelContent;
Expand Down Expand Up @@ -35,8 +36,6 @@
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import static com.eternalcode.parcellockers.util.AdventureUtil.RESET_ITEM;

public class ParcelSendingGUI extends GuiView {

private final Plugin plugin;
Expand Down Expand Up @@ -273,7 +272,7 @@ else if (slotsSize <= 18 && this.state.getSize() == ParcelSize.SMALL) {
this.state
).show(player)));

this.gui.setItem(30, guiSettings.destinationLockerItem.toGuiItem(event -> new DestinationSelectionGUI(
this.gui.setItem(30, guiSettings.parcelDestinationLockerItem.toGuiItem(event -> new DestinationSelectionGUI(
this.plugin,
this.scheduler,
this.config,
Expand Down Expand Up @@ -333,20 +332,20 @@ public void updateDestinationItem(Player player, String destinationLockerDesc) {
this.announcer.sendMessage(player, this.config.messages.parcelDestinationSet);

if (destinationLockerDesc == null || destinationLockerDesc.isEmpty()) {
this.gui.updateItem(30, this.config.guiSettings.destinationLockerItem.toItemStack());
this.gui.updateItem(30, this.config.guiSettings.parcelDestinationLockerItem.toItemStack());
return;
}

String line = this.config.guiSettings.parcelDestinationLockerSetLine.replace("{DESCRIPTION}", destinationLockerDesc);
this.gui.updateItem(30, this.createActiveItem(this.config.guiSettings.destinationLockerItem, line));
this.gui.updateItem(30, this.createActiveItem(this.config.guiSettings.parcelDestinationLockerItem, line));
}

private @NotNull ItemStack createActiveItem(ConfigItem item, String appendLore) {
List<String> itemLore = new ArrayList<>(item.lore);
itemLore.add(appendLore);

return item.toBuilder()
.lore(itemLore.stream().map(element -> RESET_ITEM.append(this.miniMessage.deserialize(element))).toList())
.lore(itemLore.stream().map(element -> AdventureUtil.resetItalic(this.miniMessage.deserialize(element))).toList())
.glow(true)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

import static com.eternalcode.parcellockers.util.AdventureUtil.RESET_ITEM;
import static com.eternalcode.commons.adventure.AdventureUtil.resetItalic;

public class MainGUI extends GuiView {

Expand Down Expand Up @@ -45,7 +45,7 @@ public void show(Player player) {

Gui gui = Gui.gui()
.type(GuiType.CHEST)
.title(RESET_ITEM.append(this.miniMessage.deserialize(guiSettings.mainGuiTitle)))
.title(resetItalic(this.miniMessage.deserialize(guiSettings.mainGuiTitle)))
.disableAllInteractions()
.rows(6)
.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import java.util.List;

import static com.eternalcode.parcellockers.util.AdventureUtil.RESET_ITEM;
import static com.eternalcode.commons.adventure.AdventureUtil.resetItalic;

public class ParcelListGUI extends GuiView {

Expand Down Expand Up @@ -63,7 +63,7 @@ public void show(Player player) {

private void show(Player player, Page page) {
PaginatedGui gui = Gui.paginated()
.title(RESET_ITEM.append(this.miniMessage.deserialize(this.config.guiSettings.parcelListGuiTitle)))
.title(resetItalic(this.miniMessage.deserialize(this.config.guiSettings.parcelListGuiTitle)))
.disableAllInteractions()
.rows(6)
.create();
Expand Down Expand Up @@ -93,7 +93,7 @@ private void show(Player player, Page page) {
ItemBuilder parcelItem = item.toBuilder();

List<Component> newLore = ParcelPlaceholderUtil.replaceParcelPlaceholders(parcel, item.lore, this.userManager, this.lockerRepository).stream()
.map(line -> RESET_ITEM.append(this.miniMessage.deserialize(line)))
.map(line -> resetItalic(this.miniMessage.deserialize(line)))
.toList();
parcelItem.lore(newLore);
parcelItem.name(this.miniMessage.deserialize(item.name.replace("{NAME}", parcel.name())));
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.