Skip to content

Commit 440ab7d

Browse files
authored
Merge pull request #802 from Ghost-chu/hikari
4.1.0.4
2 parents de04a55 + 17bbd97 commit 440ab7d

File tree

59 files changed

+524
-426
lines changed

Some content is hidden

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

59 files changed

+524
-426
lines changed

addon/discordsrv/pom.xml

Lines changed: 4 additions & 9 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>4.1.0.3</version>
10+
<version>4.1.0.4</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>
@@ -69,14 +69,9 @@
6969
<dependency>
7070
<groupId>com.discordsrv</groupId>
7171
<artifactId>discordsrv</artifactId>
72-
<version>1.26.0</version>
73-
<scope>provided</scope>
74-
<exclusions>
75-
<exclusion>
76-
<artifactId>JDA</artifactId>
77-
<groupId>net.dv8tion</groupId>
78-
</exclusion>
79-
</exclusions>
72+
<version>1.26.1</version>
73+
<scope>system</scope>
74+
<systemPath>${project.basedir}/lib/DiscordSRV-Build-1.26.1.jar</systemPath>
8075
</dependency>
8176
</dependencies>
8277
</project>

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.ghostchu.quickshop.addon.discordsrv;
22

33
import com.ghostchu.quickshop.QuickShop;
4-
import com.ghostchu.quickshop.addon.discordsrv.bean.NotifactionFeature;
4+
import com.ghostchu.quickshop.addon.discordsrv.bean.NotificationFeature;
55
import com.ghostchu.quickshop.addon.discordsrv.command.SubCommand_Discord;
66
import com.ghostchu.quickshop.addon.discordsrv.database.DiscordDatabaseHelper;
77
import com.ghostchu.quickshop.addon.discordsrv.listener.QuickShopEventListener;
@@ -84,7 +84,12 @@ public JDAWrapper getJdaWrapper() {
8484
return jdaWrapper;
8585
}
8686

87-
public boolean isServerNotifactionFeatureEnabled(@NotNull NotifactionFeature feature) {
87+
@Deprecated
88+
public boolean isServerNotifactionFeatureEnabled(@NotNull NotificationFeature feature) {
89+
return isServerNotificationFeatureEnabled(feature);
90+
}
91+
92+
public boolean isServerNotificationFeatureEnabled(@NotNull NotificationFeature feature) {
8893
return getConfig().getBoolean("features." + feature.getConfigNode(), true);
8994
}
9095

addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/bean/NotifactionSettings.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/bean/NotifactionFeature.java renamed to addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/bean/NotificationFeature.java

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

33
import org.jetbrains.annotations.NotNull;
44

5-
public enum NotifactionFeature {
5+
public enum NotificationFeature {
66
USER_SHOP_PERMISSION_CHANGED("notify-shop-permission-changed", "user.shop.permission_changed", true),
77
USER_SHOP_PRICE_CHANGED("notify-shop-price-changed", "user.shop.price_changed", true),
88
USER_SHOP_TRANSFER("notify-shop-transfer", "user.shop.transfer", true),
@@ -17,7 +17,7 @@ public enum NotifactionFeature {
1717
private final String configNode;
1818
private final boolean playerToggleable;
1919

20-
NotifactionFeature(String configNode, String databaseNode, boolean playerToggleable) {
20+
NotificationFeature(String configNode, String databaseNode, boolean playerToggleable) {
2121
this.configNode = configNode;
2222
this.databaseNode = databaseNode;
2323
this.playerToggleable = playerToggleable;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.ghostchu.quickshop.addon.discordsrv.bean;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
6+
7+
import java.util.Map;
8+
9+
@AllArgsConstructor
10+
@NoArgsConstructor
11+
@Data
12+
public class NotificationSettings {
13+
private Map<NotificationFeature, Boolean> settings;
14+
}

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

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

33
import com.ghostchu.quickshop.QuickShop;
44
import com.ghostchu.quickshop.addon.discordsrv.Main;
5-
import com.ghostchu.quickshop.addon.discordsrv.bean.NotifactionFeature;
5+
import com.ghostchu.quickshop.addon.discordsrv.bean.NotificationFeature;
66
import com.ghostchu.quickshop.api.command.CommandHandler;
77
import com.ghostchu.quickshop.util.Util;
88
import com.ghostchu.quickshop.util.logger.Log;
@@ -32,7 +32,7 @@ public void onCommand(Player sender, @NotNull String commandLabel, @NotNull Stri
3232
qs.text().of(sender, "command-incorrect", "/qs discord <features> <enable/disable>").send();
3333
return;
3434
}
35-
NotifactionFeature feature = getFeatureByName(cmdArg[0]);
35+
NotificationFeature feature = getFeatureByName(cmdArg[0]);
3636
if (feature == null) {
3737
qs.text().of(sender, "command-incorrect", "/qs discord <features> <enable/disable>").send();
3838
return;
@@ -52,9 +52,9 @@ public void onCommand(Player sender, @NotNull String commandLabel, @NotNull Stri
5252
}
5353

5454
@Nullable
55-
private NotifactionFeature getFeatureByName(String name) {
56-
for (NotifactionFeature value : NotifactionFeature.values()) {
57-
NotifactionFeature selected = null;
55+
private NotificationFeature getFeatureByName(String name) {
56+
for (NotificationFeature value : NotificationFeature.values()) {
57+
NotificationFeature selected = null;
5858
if (value.name().equalsIgnoreCase(name))
5959
selected = value;
6060
else if (value.getConfigNode().equalsIgnoreCase(name))
@@ -71,9 +71,9 @@ else if (value.getDatabaseNode().equalsIgnoreCase(name))
7171
@Override
7272
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
7373
if (cmdArg.length == 1) {
74-
return Arrays.stream(NotifactionFeature.values())
75-
.filter(NotifactionFeature::isPlayerToggleable)
76-
.map(NotifactionFeature::getConfigNode)
74+
return Arrays.stream(NotificationFeature.values())
75+
.filter(NotificationFeature::isPlayerToggleable)
76+
.map(NotificationFeature::getConfigNode)
7777
.toList();
7878
}
7979
if (cmdArg.length == 2) {

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import cc.carm.lib.easysql.api.SQLManager;
44
import cc.carm.lib.easysql.api.SQLQuery;
55
import com.ghostchu.quickshop.addon.discordsrv.Main;
6-
import com.ghostchu.quickshop.addon.discordsrv.bean.NotifactionFeature;
7-
import com.ghostchu.quickshop.addon.discordsrv.bean.NotifactionSettings;
6+
import com.ghostchu.quickshop.addon.discordsrv.bean.NotificationFeature;
7+
import com.ghostchu.quickshop.addon.discordsrv.bean.NotificationSettings;
88
import com.ghostchu.quickshop.common.util.JsonUtil;
99
import com.ghostchu.quickshop.util.MsgUtil;
1010
import com.ghostchu.quickshop.util.Util;
@@ -34,13 +34,13 @@ public DiscordDatabaseHelper(@NotNull Main plugin, @NotNull SQLManager sqlManage
3434

3535
}
3636

37-
public @NotNull Integer setNotifactionFeatureEnabled(@NotNull UUID uuid, @NotNull NotifactionFeature feature, @Nullable Boolean status) throws SQLException {
37+
public @NotNull Integer setNotifactionFeatureEnabled(@NotNull UUID uuid, @NotNull NotificationFeature feature, @Nullable Boolean status) throws SQLException {
3838
Util.ensureThread(true);
39-
NotifactionSettings settings = getPlayerNotifactionSetting(uuid);
39+
NotificationSettings settings = getPlayerNotifactionSetting(uuid);
4040
if (status == null) {
41-
settings.settings().remove(feature);
41+
settings.getSettings().remove(feature);
4242
} else {
43-
settings.settings().put(feature, status);
43+
settings.getSettings().put(feature, status);
4444
}
4545
try (ResultSet set = DiscordTables.DISCORD_PLAYERS.createQuery()
4646
.setLimit(1)
@@ -64,36 +64,36 @@ public DiscordDatabaseHelper(@NotNull Main plugin, @NotNull SQLManager sqlManage
6464
}
6565

6666
@NotNull
67-
public NotifactionSettings getPlayerNotifactionSetting(@NotNull UUID player) throws SQLException {
67+
public NotificationSettings getPlayerNotifactionSetting(@NotNull UUID player) throws SQLException {
6868
Util.ensureThread(true);
6969
try (SQLQuery query = DiscordTables.DISCORD_PLAYERS.createQuery().selectColumns("notifaction").addCondition("player", player.toString()).setLimit(1).build().execute(); ResultSet set = query.getResultSet()) {
7070
if (set.next()) {
7171
String json = set.getString("notifaction");
7272
Log.debug("Json data: " + json);
7373
if (StringUtils.isNotEmpty(json)) {
7474
if (MsgUtil.isJson(json)) {
75-
return JsonUtil.getGson().fromJson(json, NotifactionSettings.class);
75+
return JsonUtil.getGson().fromJson(json, NotificationSettings.class);
7676
}
7777
}
7878
}
7979
Log.debug("Generating default value...");
80-
Map<NotifactionFeature, Boolean> booleanMap = new HashMap<>();
81-
for (NotifactionFeature feature : NotifactionFeature.values()) {
82-
booleanMap.put(feature, plugin.isServerNotifactionFeatureEnabled(feature));
80+
Map<NotificationFeature, Boolean> booleanMap = new HashMap<>();
81+
for (NotificationFeature feature : NotificationFeature.values()) {
82+
booleanMap.put(feature, plugin.isServerNotificationFeatureEnabled(feature));
8383
}
84-
return new NotifactionSettings(booleanMap);
84+
return new NotificationSettings(booleanMap);
8585
}
8686
}
8787

8888
@SuppressWarnings("ConstantValue")
89-
public boolean isNotifactionFeatureEnabled(@NotNull UUID uuid, @NotNull NotifactionFeature feature) {
89+
public boolean isNotifactionFeatureEnabled(@NotNull UUID uuid, @NotNull NotificationFeature feature) {
9090
Util.ensureThread(true);
91-
boolean defValue = plugin.isServerNotifactionFeatureEnabled(feature);
91+
boolean defValue = plugin.isServerNotificationFeatureEnabled(feature);
9292
if (!defValue) return false; // If server disabled it, do not send it
9393
try {
94-
NotifactionSettings settings = getPlayerNotifactionSetting(uuid);
94+
NotificationSettings settings = getPlayerNotifactionSetting(uuid);
9595
Log.debug("Notifaction Settings: " + settings);
96-
return settings.settings().getOrDefault(feature, defValue);
96+
return settings.getSettings().getOrDefault(feature, defValue);
9797
} catch (SQLException e) {
9898
return defValue;
9999
}

addon/discordsrv/src/main/java/com/ghostchu/quickshop/addon/discordsrv/listener/QuickShopEventListener.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.ghostchu.quickshop.addon.discordsrv.listener;
22

33
import com.ghostchu.quickshop.addon.discordsrv.Main;
4-
import com.ghostchu.quickshop.addon.discordsrv.bean.NotifactionFeature;
4+
import com.ghostchu.quickshop.addon.discordsrv.bean.NotificationFeature;
55
import com.ghostchu.quickshop.addon.discordsrv.database.DiscordDatabaseHelper;
66
import com.ghostchu.quickshop.addon.discordsrv.wrapper.JDAWrapper;
77
import com.ghostchu.quickshop.api.event.*;
@@ -40,18 +40,18 @@ public void onPurchase(ShopSuccessPurchaseEvent event) {
4040
private void notifyShopPurchase(ShopSuccessPurchaseEvent event) {
4141
Util.asyncThreadRun(() -> {
4242
MessageEmbed embed = plugin.getFactory().shopPurchasedSelf(event);
43-
sendMessageIfEnabled(event.getShop().getOwner(), embed, NotifactionFeature.USER_SHOP_PURCHASE);
43+
sendMessageIfEnabled(event.getShop().getOwner(), embed, NotificationFeature.USER_SHOP_PURCHASE);
4444
// Send to permission users
4545
for (UUID uuid : event.getShop().getPermissionAudiences().keySet()) {
46-
sendMessageIfEnabled(uuid, event.getShop(), embed, NotifactionFeature.USER_SHOP_PURCHASE);
46+
sendMessageIfEnabled(uuid, event.getShop(), embed, NotificationFeature.USER_SHOP_PURCHASE);
4747
}
4848
});
4949
}
5050

5151
private void notifyModShopPurchase(ShopSuccessPurchaseEvent event) {
5252
Util.asyncThreadRun(() -> {
5353
MessageEmbed embed = plugin.getFactory().modShopPurchase(event);
54-
sendModeratorChannelMessageIfEnabled(embed, NotifactionFeature.MOD_SHOP_PURCHASE);
54+
sendModeratorChannelMessageIfEnabled(embed, NotificationFeature.MOD_SHOP_PURCHASE);
5555
});
5656
}
5757

@@ -60,10 +60,10 @@ private void notifyShopOutOfStock(ShopSuccessPurchaseEvent event) {
6060
Util.asyncThreadRun(() -> {
6161
// Send to owner
6262
MessageEmbed embed = plugin.getFactory().shopOutOfStock(event);
63-
sendMessageIfEnabled(event.getShop().getOwner(), event.getShop(), embed, NotifactionFeature.USER_SHOP_OUT_OF_STOCK);
63+
sendMessageIfEnabled(event.getShop().getOwner(), event.getShop(), embed, NotificationFeature.USER_SHOP_OUT_OF_STOCK);
6464
// Send to permission users
6565
for (UUID uuid : event.getShop().getPermissionAudiences().keySet()) {
66-
sendMessageIfEnabled(uuid, event.getShop(), embed, NotifactionFeature.USER_SHOP_OUT_OF_STOCK);
66+
sendMessageIfEnabled(uuid, event.getShop(), embed, NotificationFeature.USER_SHOP_OUT_OF_STOCK);
6767
}
6868
});
6969
}
@@ -74,26 +74,26 @@ private void notifyShopOutOfSpace(ShopSuccessPurchaseEvent event) {
7474
Util.asyncThreadRun(() -> {
7575
// Send to owner
7676
MessageEmbed embed = plugin.getFactory().shopOutOfSpace(event);
77-
sendMessageIfEnabled(event.getShop().getOwner(), event.getShop(), embed, NotifactionFeature.USER_SHOP_OUT_OF_SPACE);
77+
sendMessageIfEnabled(event.getShop().getOwner(), event.getShop(), embed, NotificationFeature.USER_SHOP_OUT_OF_SPACE);
7878
// Send to permission users
7979
for (UUID uuid : event.getShop().getPermissionAudiences().keySet()) {
8080
if (event.getShop().playerAuthorize(uuid, plugin, "discordalert")) {
81-
sendMessageIfEnabled(uuid, event.getShop(), embed, NotifactionFeature.USER_SHOP_OUT_OF_SPACE);
81+
sendMessageIfEnabled(uuid, event.getShop(), embed, NotificationFeature.USER_SHOP_OUT_OF_SPACE);
8282
}
8383
}
8484
});
8585
}
8686

8787
}
8888

89-
private void sendMessageIfEnabled(@NotNull UUID uuid, @NotNull MessageEmbed embed, @NotNull NotifactionFeature feature) {
89+
private void sendMessageIfEnabled(@NotNull UUID uuid, @NotNull MessageEmbed embed, @NotNull NotificationFeature feature) {
9090
Util.ensureThread(true);
9191
if (databaseHelper.isNotifactionFeatureEnabled(uuid, feature)) {
9292
jdaWrapper.sendMessage(uuid, embed);
9393
}
9494
}
9595

96-
private void sendMessageIfEnabled(@NotNull UUID uuid, @NotNull Shop shop, @NotNull MessageEmbed embed, @NotNull NotifactionFeature feature) {
96+
private void sendMessageIfEnabled(@NotNull UUID uuid, @NotNull Shop shop, @NotNull MessageEmbed embed, @NotNull NotificationFeature feature) {
9797
Util.ensureThread(true);
9898
if (shop.playerAuthorize(uuid, plugin, "discordalert")) {
9999
if (databaseHelper.isNotifactionFeatureEnabled(uuid, feature)) {
@@ -102,9 +102,9 @@ private void sendMessageIfEnabled(@NotNull UUID uuid, @NotNull Shop shop, @NotNu
102102
}
103103
}
104104

105-
public void sendModeratorChannelMessageIfEnabled(@NotNull MessageEmbed embed, @NotNull NotifactionFeature feature) {
105+
public void sendModeratorChannelMessageIfEnabled(@NotNull MessageEmbed embed, @NotNull NotificationFeature feature) {
106106
Util.ensureThread(true);
107-
if (plugin.isServerNotifactionFeatureEnabled(feature)) {
107+
if (plugin.isServerNotificationFeatureEnabled(feature)) {
108108
plugin.sendModeratorChannelMessage(embed);
109109
}
110110
}
@@ -116,11 +116,11 @@ public void onShopTransfer(ShopOwnershipTransferEvent event) {
116116
}
117117

118118
private void notifyShopTransfer(ShopOwnershipTransferEvent event) {
119-
Util.asyncThreadRun(() -> sendMessageIfEnabled(event.getNewOwner(), plugin.getFactory().shopTransferToYou(event), NotifactionFeature.USER_SHOP_TRANSFER));
119+
Util.asyncThreadRun(() -> sendMessageIfEnabled(event.getNewOwner(), plugin.getFactory().shopTransferToYou(event), NotificationFeature.USER_SHOP_TRANSFER));
120120
}
121121

122122
private void notifyModShopTransfer(ShopOwnershipTransferEvent event) {
123-
Util.asyncThreadRun(() -> sendModeratorChannelMessageIfEnabled(plugin.getFactory().modShopTransfer(event), NotifactionFeature.MOD_SHOP_TRANSFER));
123+
Util.asyncThreadRun(() -> sendModeratorChannelMessageIfEnabled(plugin.getFactory().modShopTransfer(event), NotificationFeature.MOD_SHOP_TRANSFER));
124124
}
125125

126126
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
@@ -129,7 +129,7 @@ public void onShopDelete(ShopDeleteEvent event) {
129129
}
130130

131131
private void notifyModShopRemoved(ShopDeleteEvent event) {
132-
Util.asyncThreadRun(() -> sendModeratorChannelMessageIfEnabled(plugin.getFactory().modShopRemoved(event), NotifactionFeature.MOD_SHOP_REMOVED));
132+
Util.asyncThreadRun(() -> sendModeratorChannelMessageIfEnabled(plugin.getFactory().modShopRemoved(event), NotificationFeature.MOD_SHOP_REMOVED));
133133
}
134134

135135
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
@@ -141,17 +141,17 @@ public void onShopPriceChanged(ShopPriceChangeEvent event) {
141141
private void notifyShopPriceChanged(ShopPriceChangeEvent event) {
142142
Util.asyncThreadRun(() -> {
143143
MessageEmbed embed = plugin.getFactory().priceChanged(event);
144-
sendMessageIfEnabled(event.getShop().getOwner(), event.getShop(), embed, NotifactionFeature.USER_SHOP_PRICE_CHANGED);
144+
sendMessageIfEnabled(event.getShop().getOwner(), event.getShop(), embed, NotificationFeature.USER_SHOP_PRICE_CHANGED);
145145
// Send to permission users
146146
for (UUID uuid : event.getShop().getPermissionAudiences().keySet()) {
147-
sendMessageIfEnabled(uuid, event.getShop(), embed, NotifactionFeature.USER_SHOP_PRICE_CHANGED);
147+
sendMessageIfEnabled(uuid, event.getShop(), embed, NotificationFeature.USER_SHOP_PRICE_CHANGED);
148148
}
149149
});
150150

151151
}
152152

153153
private void notifyModShopPriceChanged(ShopPriceChangeEvent event) {
154-
Util.asyncThreadRun(() -> sendModeratorChannelMessageIfEnabled(plugin.getFactory().modPriceChanged(event), NotifactionFeature.MOD_SHOP_PRICE_CHANGED));
154+
Util.asyncThreadRun(() -> sendModeratorChannelMessageIfEnabled(plugin.getFactory().modPriceChanged(event), NotificationFeature.MOD_SHOP_PRICE_CHANGED));
155155
}
156156

157157
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
@@ -162,10 +162,10 @@ public void onShopPermissionChanged(ShopPlayerGroupSetEvent event) {
162162
private void notifyShopPermissionChanged(ShopPlayerGroupSetEvent event) {
163163
Util.asyncThreadRun(() -> {
164164
MessageEmbed embed = plugin.getFactory().shopPermissionChanged(event);
165-
sendMessageIfEnabled(event.getShop().getOwner(), event.getShop(), embed, NotifactionFeature.USER_SHOP_PERMISSION_CHANGED);
165+
sendMessageIfEnabled(event.getShop().getOwner(), event.getShop(), embed, NotificationFeature.USER_SHOP_PERMISSION_CHANGED);
166166
// Send to permission users
167167
for (UUID uuid : event.getShop().getPermissionAudiences().keySet()) {
168-
sendMessageIfEnabled(event.getPlayer(), event.getShop(), embed, NotifactionFeature.USER_SHOP_PERMISSION_CHANGED);
168+
sendMessageIfEnabled(event.getPlayer(), event.getShop(), embed, NotificationFeature.USER_SHOP_PERMISSION_CHANGED);
169169
}
170170
});
171171
}

addon/discount/pom.xml

Lines changed: 1 addition & 1 deletion
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>4.1.0.3</version>
10+
<version>4.1.0.4</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>

addon/limited/pom.xml

Lines changed: 1 addition & 1 deletion
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>4.1.0.3</version>
10+
<version>4.1.0.4</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>

0 commit comments

Comments
 (0)