Skip to content

Commit 34d961f

Browse files
Code Polish v1 (#2103)
* Remove Spigot platform modules and related dependencies This commit removes all Spigot platform-specific modules, classes, and build configurations, including `AbstractSpigotPlatform`, `NbtApiInitializer`, and corresponding project configuration files (POMs). This cleanup helps streamline the project and eliminates dependencies on Spigot and NBT-API. * Bumped Java version usage to 21. * Remove deprecated economy-related classes and implementations. This commit removes obsolete economy-related classes, interfaces, and implementations. The code cleanup includes `AbstractEconomy`, `Benefit`, `DepositEconomyOperation`, and economy implementations like `Economy_Vault` and `Economy_VaultUnlocked`. These were either redundant or replaced by new approaches. * Refactor economy package structure. Renamed and updated references for the "economyrevamp" package to "economy" for better clarity and consistency across the project. This includes file paths, imports, and related classes. No functional changes were made. * Remove deprecated classes and methods from the codebase. This commit eliminates several deprecated classes and methods across various packages, including ItemExpression, ShopModerator, and VaultPermissionProvider. Redundant functionality has been consolidated or replaced with newer implementations, improving maintainability and reducing legacy code bloat. * Fix typo in method documentation in Shop.java Corrected "attacked" to "attached" in the JavaDoc of the `checkShop` method to ensure the comment accurately describes the method's purpose. This improves code clarity and reduces potential confusion for developers. * Update changelog. * Update dependencies and adjust logging and API methods Updated several dependencies, including updating commons-lang3 to 3.18.0, and adjusted dependency scopes and exclusions for better modularity. Refactored the `getPlayerLocale` method to use `QUser` instead of `UUID`. Minor logging implementation improvements were also applied. * Switch to `CommonUtil` and refactor method calls for consistency. Replaced usages of `StringUtils` with `CommonUtil` and updated methods for improved readability and modernized coding conventions. Bumped version in relevant `pom.xml` files to ensure compatibility, streamlined code paths using `getFirst()` replacements, and adjusted dependency scopes for better package management. * Refactor type declarations and optimize utility methods Replaced `EnumSet` and `EnumMap` with `HashSet` and `HashMap` for better maintainability and flexibility. Streamlined `instanceof` type casts by adding `final` for clarity and potential performance benefits. Removed deprecated or redundant methods and added logical safeguards for more robust behavior. * Add a config to enable/disable enchants for display items, add a workaround for PacketEvents not supporting custom enchants for itemstack conversion. * Revert distribution changes since updated changes don't seem to work when implemented according to the CodeMC docs.
1 parent 253d5e6 commit 34d961f

212 files changed

Lines changed: 3792 additions & 6702 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changelog/6.2.0.11.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
- Update configuration system?
88
- auto updating?
99
- Allows removal of the update code
10-
- Remove waste spigot modules?
11-
- Any versions of 1.20 that can be discarded due to low use?
1210
- Bug fixing, of course
1311
- Sign parser implementation?
1412
- probably have to re-evaluate since it's been awhile since it has been looked at...
1513

1614
# 6.2.0.11
1715

1816
## Major Changes
17+
- Removed Spigot Platform Modules, and stopped loading QS if Spigot is detected. This will mean that unless the protocol changes that we use for display items, QS won't need updated for each version.
18+
- Revamped Economy Code Completely
19+
- New classes for all economy-related systems
20+
- Any economy-related or benefits-related events are incompatible with previous versions.
1921

20-
## Internals/DeveloperAPIs
22+
## Internals/Developer APIs
23+
- Removed several deprecated methods and classes.
2124
- Revamped the interaction manager. It is now more flexible and allows external additions
2225
- This involves two classes InteractionBehavior and InteractionType.
2326
- InteractionType details the type of interaction such as: STANDING_LEFT_CLICK_SIGN, STANDING_LEFT_CLICK_SHOP
@@ -30,7 +33,11 @@
3033
manager.interaction(new MyTradeInteraction());
3134
manager.behavior(new MyTradeBehavior());
3235
```
36+
- Replaced some apache commons calls that could be easily replaced with built-in java methods, reduces some calls by ~ 1100ms/method call
3337

3438
## Minor Changes
39+
- Bump Java version up to 21
40+
- Added shop.display-allow-enchants to enable/disable enchantments for display items on shops.
41+
- Added workaround for packetevents not supporting custom enchants on itemstacks for virtual display items.
3542

3643
## Fixes

addon/bluemap/pom.xml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.ghostchu</groupId>
99
<artifactId>quickshop-hikari</artifactId>
10-
<version>6.2.0.11-SNAPSHOT-1</version>
10+
<version>6.2.0.11-SNAPSHOT-4</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>
@@ -47,22 +47,16 @@
4747

4848
<dependencies>
4949
<dependency>
50-
<groupId>org.spigotmc</groupId>
51-
<artifactId>spigot-api</artifactId>
50+
<groupId>io.papermc.paper</groupId>
51+
<artifactId>paper-api</artifactId>
52+
<version>${depend.paper}</version>
5253
</dependency>
5354
<dependency>
5455
<groupId>com.ghostchu</groupId>
5556
<artifactId>quickshop-bukkit</artifactId>
5657
<version>${project.parent.version}</version>
5758
<scope>provided</scope>
5859
</dependency>
59-
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
60-
<dependency>
61-
<groupId>org.apache.commons</groupId>
62-
<artifactId>commons-lang3</artifactId>
63-
<version>${depend.commons.lang3}</version>
64-
<scope>provided</scope>
65-
</dependency>
6660
<dependency>
6761
<groupId>de.bluecolored.bluemap</groupId>
6862
<artifactId>BlueMapAPI</artifactId>

addon/discordsrv/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.ghostchu</groupId>
99
<artifactId>quickshop-hikari</artifactId>
10-
<version>6.2.0.11-SNAPSHOT-1</version>
10+
<version>6.2.0.11-SNAPSHOT-4</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>
@@ -50,8 +50,9 @@
5050

5151
<dependencies>
5252
<dependency>
53-
<groupId>org.spigotmc</groupId>
54-
<artifactId>spigot-api</artifactId>
53+
<groupId>io.papermc.paper</groupId>
54+
<artifactId>paper-api</artifactId>
55+
<version>${depend.paper}</version>
5556
</dependency>
5657
<dependency>
5758
<groupId>com.ghostchu</groupId>

addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/Main.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void onEnable() {
7070
quickshop.getShopPermissionManager().registerPermission(BuiltInShopPermissionGroup.ADMINISTRATOR.getNamespacedNode(), this, "discordalert");
7171
try {
7272
this.databaseHelper = new DiscordDatabaseHelper(this, quickshop.getSqlManager(), quickshop.getDbPrefix());
73-
} catch(SQLException e) {
73+
} catch(final SQLException e) {
7474
getLogger().log(Level.SEVERE, "Failed to connect to database, please check your database settings.", e);
7575
Bukkit.getPluginManager().disablePlugin(this);
7676
return;
@@ -94,12 +94,6 @@ public JDAWrapper getJdaWrapper() {
9494
return jdaWrapper;
9595
}
9696

97-
@Deprecated
98-
public boolean isServerNotifactionFeatureEnabled(@NotNull final NotificationFeature feature) {
99-
100-
return isServerNotificationFeatureEnabled(feature);
101-
}
102-
10397
public boolean isServerNotificationFeatureEnabled(@NotNull final NotificationFeature feature) {
10498

10599
return getConfig().getBoolean("features." + feature.getConfigNode(), true);

addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/command/SubCommand_Discord.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void onCommand(final Player sender, @NotNull final String commandLabel, @
3737
qs.text().of(sender, "command-incorrect", "/quickshop discord <features> <enable/disable>").send();
3838
return;
3939
}
40-
final NotificationFeature feature = getFeatureByName(parser.getArgs().get(0));
40+
final NotificationFeature feature = getFeatureByName(parser.getArgs().getFirst());
4141
if(feature == null) {
4242
qs.text().of(sender, "command-incorrect", "/quickshop discord <features> <enable/disable>").send();
4343
return;

addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/database/DiscordDatabaseHelper.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.ghostchu.quickshop.common.util.JsonUtil;
1111
import com.ghostchu.quickshop.util.Util;
1212
import com.ghostchu.quickshop.util.logger.Log;
13-
import org.apache.commons.lang3.StringUtils;
1413
import org.jetbrains.annotations.NotNull;
1514
import org.jetbrains.annotations.Nullable;
1615

@@ -30,7 +29,7 @@ public DiscordDatabaseHelper(@NotNull final Main plugin, @NotNull final SQLManag
3029
this.plugin = plugin;
3130
try {
3231
DiscordTables.initializeTables(sqlManager, dbPrefix);
33-
} catch(SQLException e) {
32+
} catch(final SQLException e) {
3433
plugin.getLogger().log(Level.WARNING, "Cannot initialize tables", e);
3534
throw e;
3635
}
@@ -50,11 +49,11 @@ public DiscordDatabaseHelper(@NotNull final Main plugin, @NotNull final SQLManag
5049
} else {
5150
settings.getSettings().put(feature, status);
5251
}
53-
try(SQLQuery query = DiscordTables.DISCORD_PLAYERS.createQuery()
52+
try(final SQLQuery query = DiscordTables.DISCORD_PLAYERS.createQuery()
5453
.setLimit(1)
5554
.addCondition("player", playerUuid)
5655
.build().execute();
57-
ResultSet set = query.getResultSet()) {
56+
final ResultSet set = query.getResultSet()) {
5857
final Integer integer;
5958
if(set.next()) {
6059
integer = DiscordTables.DISCORD_PLAYERS.createUpdate()
@@ -77,12 +76,12 @@ public DiscordDatabaseHelper(@NotNull final Main plugin, @NotNull final SQLManag
7776
public NotificationSettings getPlayerNotifactionSetting(@NotNull final UUID uuid) throws SQLException {
7877

7978
Util.ensureThread(true);
80-
try(SQLQuery query = DiscordTables.DISCORD_PLAYERS.createQuery().selectColumns("notifaction").addCondition("player",
81-
uuid).setLimit(1).build().execute(); ResultSet set = query.getResultSet()) {
79+
try(final SQLQuery query = DiscordTables.DISCORD_PLAYERS.createQuery().selectColumns("notifaction").addCondition("player",
80+
uuid).setLimit(1).build().execute(); final ResultSet set = query.getResultSet()) {
8281
if(set.next()) {
8382
final String json = set.getString("notifaction");
8483
Log.debug("Json data: " + json);
85-
if(StringUtils.isNotEmpty(json)) {
84+
if(!CommonUtil.isEmptyString(json)) {
8685
if(CommonUtil.isJson(json)) {
8786
return JsonUtil.getGson().fromJson(json, NotificationSettings.class);
8887
}
@@ -109,7 +108,7 @@ public boolean isNotifactionFeatureEnabled(@NotNull final UUID uuid, @NotNull fi
109108
final NotificationSettings settings = getPlayerNotifactionSetting(uuid);
110109
Log.debug("Notifaction Settings: " + settings);
111110
return settings.getSettings().getOrDefault(feature, defValue);
112-
} catch(SQLException e) {
111+
} catch(final SQLException e) {
113112
return defValue;
114113
}
115114
}

addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/message/MessageManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import com.ghostchu.quickshop.addon.discordsrv.Main;
44
import com.ghostchu.quickshop.api.obj.QUser;
5+
import com.ghostchu.quickshop.common.util.CommonUtil;
56
import github.scarsz.discordsrv.dependencies.jda.api.EmbedBuilder;
67
import github.scarsz.discordsrv.dependencies.jda.api.entities.MessageEmbed;
7-
import org.apache.commons.lang3.StringUtils;
88
import org.jetbrains.annotations.NotNull;
99
import org.jetbrains.annotations.Nullable;
1010

@@ -46,7 +46,7 @@ private void scanClass(@Nullable final Object obj) {
4646
if(annotation == null) {
4747
continue;
4848
}
49-
if(StringUtils.isEmpty(annotation.key())) {
49+
if(CommonUtil.isEmptyString(annotation.key())) {
5050
continue;
5151
}
5252

@@ -57,7 +57,7 @@ private void scanClass(@Nullable final Object obj) {
5757
} else {
5858
plugin.getLogger().warning("Skipping message " + obj.getClass().getName() + "." + declaredMethod.getName() + " for registering: Unsupported return type: " + declaredMethod.getReturnType().getName());
5959
}
60-
} catch(Throwable e) {
60+
} catch(final Throwable e) {
6161
plugin.getLogger().log(Level.WARNING, "Failed to register message: " + declaredMethod.getDeclaringClass().getName() + "." + declaredMethod.getName(), e);
6262
}
6363
}
@@ -76,12 +76,12 @@ public MessageEmbed getEmbedMessage(@NotNull final String key, @Nullable final Q
7676
}
7777
try {
7878
final Object returns = method.getValue().invoke(method.getKey(), receiver, placeholders);
79-
if(!(returns instanceof MessageEmbed embed)) {
79+
if(!(returns instanceof final MessageEmbed embed)) {
8080
plugin.getLogger().log(Level.WARNING, "Cannot handle embed message: " + key + " Mismatched type!");
8181
return failSafeEmbedMessage(key);
8282
}
8383
return embed;
84-
} catch(IllegalAccessException | InvocationTargetException e) {
84+
} catch(final IllegalAccessException | InvocationTargetException e) {
8585
plugin.getLogger().log(Level.WARNING, "Cannot handle embed message: " + key, e);
8686
return failSafeEmbedMessage(key);
8787
}
@@ -111,12 +111,12 @@ public String getRegularMessage(@NotNull final String key, @Nullable final UUID
111111
}
112112
try {
113113
final Object returns = method.getValue().invoke(method.getKey(), receiver, placeholders);
114-
if(!(returns instanceof String msg)) {
114+
if(!(returns instanceof final String msg)) {
115115
plugin.getLogger().log(Level.WARNING, "Cannot handle message: " + key + " Mismatched type!");
116116
return failSafeMessage(key);
117117
}
118118
return msg;
119-
} catch(IllegalAccessException | InvocationTargetException e) {
119+
} catch(final IllegalAccessException | InvocationTargetException e) {
120120
plugin.getLogger().log(Level.WARNING, "Cannot handle message: " + key, e);
121121
return failSafeMessage(key);
122122
}

addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/message/MessageRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import com.ghostchu.quickshop.QuickShop;
44
import com.ghostchu.quickshop.addon.discordsrv.parser.EmbedMessageParser;
55
import com.ghostchu.quickshop.api.obj.QUser;
6+
import com.ghostchu.quickshop.common.util.CommonUtil;
67
import github.scarsz.discordsrv.dependencies.jda.api.EmbedBuilder;
78
import github.scarsz.discordsrv.dependencies.jda.api.entities.MessageEmbed;
89
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
9-
import org.apache.commons.lang3.StringUtils;
1010
import org.jetbrains.annotations.NotNull;
1111
import org.jetbrains.annotations.Nullable;
1212

@@ -44,7 +44,7 @@ private MessageEmbed applyPlaceHolders(@NotNull final MessageEmbed embed, @NotNu
4444

4545
final EmbedBuilder builder = new EmbedBuilder(embed);
4646
for(final Map.Entry<String, String> entry : placeholders.entrySet()) {
47-
if(StringUtils.isEmpty(entry.getValue())) {
47+
if(CommonUtil.isEmptyString(entry.getValue())) {
4848
entry.setValue(ZERO_WIDTH_SPACE);
4949
}
5050
}

addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/parser/EmbedMessageParser.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import github.scarsz.discordsrv.dependencies.jda.api.entities.MessageEmbed;
99
import lombok.Data;
1010
import lombok.NoArgsConstructor;
11-
import org.apache.commons.lang3.StringUtils;
1211
import org.jetbrains.annotations.NotNull;
1312
import org.jetbrains.annotations.Nullable;
1413

@@ -50,7 +49,7 @@ public MessageEmbed parse(@NotNull final String json) {
5049
if(dto.getThumbnail() != null) {
5150
builder.setThumbnail(emptyDefault(dto.getThumbnail().getUrl()));
5251
}
53-
if(dto.getImage() != null && StringUtils.isNotBlank(dto.getImage().getUrl())) {
52+
if(dto.getImage() != null && !CommonUtil.isBlank(dto.getImage().getUrl())) {
5453
builder.setImage(emptyDefault(dto.getImage().getUrl()));
5554
}
5655
if(dto.getAuthor() != null) {
@@ -62,10 +61,10 @@ public MessageEmbed parse(@NotNull final String json) {
6261
if(field != null && field.getName() != null && field.getValue() != null) {
6362
String fieldName = field.getName();
6463
String fieldValue = field.getValue();
65-
if(StringUtils.isEmpty(fieldName)) {
64+
if(CommonUtil.isEmptyString(fieldName)) {
6665
fieldName = ZERO_WIDTH_SPACE;
6766
}
68-
if(StringUtils.isEmpty(fieldValue)) {
67+
if(CommonUtil.isEmptyString(fieldValue)) {
6968
fieldValue = ZERO_WIDTH_SPACE;
7069
}
7170
builder.addField(fieldName, fieldValue, field.inline);
@@ -78,7 +77,7 @@ public MessageEmbed parse(@NotNull final String json) {
7877
@Nullable
7978
private String emptyDefault(@Nullable final String v) {
8079

81-
if(v == null || StringUtils.isBlank(v) || !v.startsWith("http")) {
80+
if(v == null || CommonUtil.isBlank(v) || !v.startsWith("http")) {
8281
return null;
8382
}
8483
return v;

addon/discount/pom.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.ghostchu</groupId>
99
<artifactId>quickshop-hikari</artifactId>
10-
<version>6.2.0.11-SNAPSHOT-1</version>
10+
<version>6.2.0.11-SNAPSHOT-4</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>
@@ -49,8 +49,9 @@
4949

5050
<dependencies>
5151
<dependency>
52-
<groupId>org.spigotmc</groupId>
53-
<artifactId>spigot-api</artifactId>
52+
<groupId>io.papermc.paper</groupId>
53+
<artifactId>paper-api</artifactId>
54+
<version>${depend.paper}</version>
5455
</dependency>
5556
<dependency>
5657
<groupId>com.ghostchu</groupId>
@@ -59,11 +60,11 @@
5960
<scope>provided</scope>
6061
</dependency>
6162
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
62-
<dependency>
63+
<!--<dependency>
6364
<groupId>org.apache.commons</groupId>
6465
<artifactId>commons-lang3</artifactId>
6566
<version>${depend.commons.lang3}</version>
6667
<scope>provided</scope>
67-
</dependency>
68+
</dependency>-->
6869
</dependencies>
6970
</project>

0 commit comments

Comments
 (0)