Skip to content

Commit 7d26ede

Browse files
committed
Use QuickShop Hikari
1 parent 9cfdc86 commit 7d26ede

6 files changed

Lines changed: 30 additions & 16 deletions

File tree

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repositories {
2626
}
2727

2828
maven("https://repo.codemc.io/repository/maven-public/") {
29-
mavenContent { includeGroup("org.maxgamer") }
29+
mavenContent { includeGroup("com.ghostchu") }
3030
}
3131
}
3232

@@ -41,6 +41,7 @@ dependencies {
4141
compileOnly(libs.quickshop) {
4242
exclude("*")
4343
}
44+
compileOnly(libs.quickshop.api)
4445
implementation(libs.hikaricp) {
4546
exclude(group = "org.slf4j", module = "slf4j-api")
4647
}

gradle/libs.versions.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[versions]
2-
paper = "1.21.8-R0.1-SNAPSHOT"
2+
paper = "1.21.1-R0.1-SNAPSHOT"
33
javalin = "6.7.0"
44
discordsrv = "1.27.0"
55
quarters = "e9ed8a133a"
66
towny = "0.102.0.0"
77
mysterymaster-api = "1.0.0"
88
superbvote = "0.6.0"
9-
quickshop = "5.1.2.5-SNAPSHOT"
9+
quickshop = "6.2.0.11"
1010
hikaricp = "7.0.2"
1111

1212
# plugins
@@ -21,7 +21,8 @@ javalin = { group = "io.javalin", name = "javalin", version.ref = "javalin" }
2121
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
2222
mysterymaster-api = { group = "net.earthmc.mysterymaster", name = "mysterymaster-api", version.ref = "mysterymaster-api" }
2323
superbvote = { group = "net.earthmc.superbvote", name = "SuperbVote", version.ref = "superbvote" }
24-
quickshop = { group = "org.maxgamer", name = "QuickShop", version.ref = "quickshop" }
24+
quickshop = { group = "com.ghostchu", name = "quickshop-bukkit", version.ref = "quickshop" }
25+
quickshop-api = { group = "com.ghostchu", name = "quickshop-api", version.ref = "quickshop" }
2526
hikaricp = { group = "com.zaxxer", name = "HikariCP", version.ref = "hikaricp" }
2627

2728
[plugins]

src/main/java/net/earthmc/emcapi/endpoint/ShopEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.earthmc.emcapi.endpoint;
22

3+
import com.ghostchu.quickshop.api.shop.Shop;
34
import com.google.gson.JsonElement;
45
import com.google.gson.JsonObject;
56
import io.javalin.http.BadRequestResponse;
@@ -10,7 +11,6 @@
1011
import net.earthmc.emcapi.util.EndpointUtils;
1112
import net.earthmc.emcapi.util.JSONUtil;
1213
import org.jetbrains.annotations.Nullable;
13-
import org.maxgamer.quickshop.api.shop.Shop;
1414

1515
import java.time.Instant;
1616
import java.util.ArrayList;
@@ -73,7 +73,7 @@ public JsonElement getJsonElement(List<Shop> object, @Nullable String key) {
7373
final List<CompletableFuture<Void>> shopFutures = new ArrayList<>();
7474

7575
for (Shop shop : object) {
76-
if (!shop.getOwner().equals(keyOwner)) continue;
76+
if (!keyOwner.equals(shop.getOwner().getUniqueId())) continue;
7777

7878
final CompletableFuture<Void> shopFuture = new CompletableFuture<>();
7979
shopFutures.add(shopFuture);

src/main/java/net/earthmc/emcapi/integration/QuickShopIntegration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package net.earthmc.emcapi.integration;
22

3+
import com.ghostchu.quickshop.api.QuickShopAPI;
4+
import com.ghostchu.quickshop.api.shop.Shop;
35
import net.earthmc.emcapi.manager.KeyManager;
4-
import org.maxgamer.quickshop.QuickShop;
5-
import org.maxgamer.quickshop.api.shop.Shop;
66

77
import java.util.List;
88
import java.util.UUID;
@@ -20,6 +20,6 @@ public List<Shop> getPlayerShops(UUID player, String key) {
2020
if (!player.equals(KeyManager.getKeyOwner(key))) {
2121
return List.of();
2222
}
23-
return QuickShop.getInstance().getShopManager().getPlayerAllShops(player);
23+
return QuickShopAPI.getInstance().getShopManager().getAllShops(player);
2424
}
2525
}

src/main/java/net/earthmc/emcapi/sse/listeners/ShopSSEListener.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package net.earthmc.emcapi.sse.listeners;
22

3+
import com.ghostchu.quickshop.api.event.economy.ShopSuccessPurchaseEvent;
4+
import com.ghostchu.quickshop.api.obj.QUser;
5+
import com.ghostchu.quickshop.api.shop.Shop;
36
import com.google.gson.JsonObject;
47
import com.palmergames.bukkit.towny.TownyAPI;
58
import com.palmergames.bukkit.towny.object.Resident;
69
import net.earthmc.emcapi.sse.SSEManager;
710
import net.earthmc.emcapi.util.EndpointUtils;
811
import org.bukkit.event.EventHandler;
912
import org.bukkit.event.EventPriority;
10-
import org.maxgamer.quickshop.api.event.ShopSuccessPurchaseEvent;
11-
import org.maxgamer.quickshop.api.shop.Shop;
1213

1314
import java.util.UUID;
1415

@@ -21,7 +22,10 @@ public ShopSSEListener(SSEManager sseManager) {
2122
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
2223
public void onShopPurchase(ShopSuccessPurchaseEvent event) {
2324
Shop shop = event.getShop();
24-
UUID owner = shop.getOwner();
25+
UUID owner = shop.getOwner().getUniqueId();
26+
if (owner == null) {
27+
return;
28+
}
2529

2630
boolean isSelling = shop.isSelling();
2731
String purchaser = getPlayerName(event.getPurchaser());
@@ -55,15 +59,23 @@ private void checkShopOut(Shop shop) {
5559
JsonObject alertMessage = new JsonObject();
5660
alertMessage.addProperty("action", isSelling ? "out_of_stock" : "out_of_space");
5761
alertMessage.add("shop", EndpointUtils.getShopObject(shop));
58-
sse.sendEvent("ShopOutOf" + (isSelling ? "Stock " : "Space"), alertMessage, shop.getOwner());
62+
sse.sendEvent("ShopOutOf" + (isSelling ? "Stock " : "Space"), alertMessage, shop.getOwner().getUniqueId());
5963
}
6064

61-
private String getPlayerName(UUID uuid) {
65+
private String getPlayerName(QUser user) {
66+
String name = user.getUsername();
67+
if (name != null) {
68+
return name;
69+
}
70+
UUID uuid = user.getUniqueId();
71+
if (uuid == null) {
72+
return "Unknown player";
73+
}
6274
Resident res = TownyAPI.getInstance().getResident(uuid);
6375
if (res != null) {
6476
return res.getName();
6577
} else {
66-
return "Unknown player `(" + uuid + ")`";
78+
return "Unknown player (" + uuid + ")";
6779
}
6880
}
6981
}

src/main/java/net/earthmc/emcapi/util/EndpointUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.earthmc.emcapi.util;
22

3+
import com.ghostchu.quickshop.api.shop.Shop;
34
import com.google.gson.JsonArray;
45
import com.google.gson.JsonObject;
56
import com.palmergames.bukkit.towny.object.Nation;
@@ -10,7 +11,6 @@
1011
import org.bukkit.Location;
1112
import org.bukkit.entity.Player;
1213
import org.jetbrains.annotations.Nullable;
13-
import org.maxgamer.quickshop.api.shop.Shop;
1414

1515
import java.util.ArrayList;
1616
import java.util.Collections;

0 commit comments

Comments
 (0)