Skip to content

Commit e255256

Browse files
authored
Merge pull request #1105 from Ghost-chu/hikari
5.1.0.0
2 parents d40534a + 25e8959 commit e255256

File tree

136 files changed

+1529
-1467
lines changed

Some content is hidden

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

136 files changed

+1529
-1467
lines changed

addon/bluemap/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>5.0.0.7</version>
10+
<version>5.1.0.0</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>
Lines changed: 27 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.ghostchu.quickshop.addon.bluemap;
22

33
import com.ghostchu.quickshop.QuickShop;
4-
import com.ghostchu.quickshop.api.event.*;
54
import com.ghostchu.quickshop.api.localization.text.TextManager;
65
import com.ghostchu.quickshop.api.shop.Shop;
76
import com.ghostchu.quickshop.api.shop.ShopType;
@@ -14,11 +13,9 @@
1413
import net.kyori.adventure.text.Component;
1514
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
1615
import org.bukkit.Bukkit;
17-
import org.bukkit.event.EventHandler;
16+
import org.bukkit.Location;
1817
import org.bukkit.event.HandlerList;
1918
import org.bukkit.event.Listener;
20-
import org.bukkit.event.world.WorldLoadEvent;
21-
import org.bukkit.event.world.WorldUnloadEvent;
2219
import org.bukkit.plugin.Plugin;
2320
import org.bukkit.plugin.java.JavaPlugin;
2421
import org.jetbrains.annotations.NotNull;
@@ -44,65 +41,17 @@ public void onEnable() {
4441
saveDefaultConfig();
4542
plugin = QuickShop.getInstance();
4643
getLogger().info("Registering the per shop permissions...");
47-
Bukkit.getScheduler().runTaskAsynchronously(this,()->{
48-
while(BlueMapAPI.getInstance().isEmpty()){
49-
try {
50-
Thread.sleep(1000);
51-
} catch (InterruptedException e) {
52-
throw new RuntimeException(e);
53-
}
54-
}
55-
getLogger().info("Found Pl3xMap loaded! Hooking!");
56-
blueMapAPI = BlueMapAPI.getInstance().orElseThrow();
57-
Bukkit.getPluginManager().registerEvents(this, this);
58-
Bukkit.getScheduler().runTaskLater(this, this::updateAllMarkers, 80);
59-
});
60-
}
44+
BlueMapAPI.onEnable(blueMapAPI -> {
45+
getLogger().info("Found BlueMap loaded! Hooking!");
46+
createMarkerSet();
47+
Bukkit.getScheduler().runTaskTimerAsynchronously(this, ()->{
48+
updateAllMarkers();
49+
}, 1, getConfig().getInt("refresh-per-seconds") * 20L);
50+
});
51+
52+
BlueMapAPI.onDisable(api -> Bukkit.getScheduler().cancelTasks(this));
53+
}
6154

62-
@EventHandler(ignoreCancelled = true)
63-
public void onEvent(WorldLoadEvent event){
64-
Util.mainThreadRun(this::updateAllMarkers);
65-
}
66-
@EventHandler(ignoreCancelled = true)
67-
public void onEvent(WorldUnloadEvent event){
68-
Util.mainThreadRun(this::updateAllMarkers);
69-
}
70-
@EventHandler(ignoreCancelled = true)
71-
public void onEvent(QSConfigurationReloadEvent event){
72-
Util.mainThreadRun(this::updateAllMarkers);
73-
}
74-
@EventHandler(ignoreCancelled = true)
75-
public void onEvent(ShopCreateSuccessEvent event){
76-
updateShopMarker(event.getShop());
77-
}
78-
@EventHandler(ignoreCancelled = true)
79-
public void onEvent(ShopDeleteEvent event){
80-
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
81-
}
82-
@EventHandler(ignoreCancelled = true)
83-
public void onEvent(ShopPriceChangeEvent event){
84-
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
85-
}
86-
@EventHandler(ignoreCancelled = true)
87-
public void onEvent(ShopItemChangeEvent event){
88-
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
89-
}
90-
@EventHandler(ignoreCancelled = true)
91-
public void onEvent(ShopOwnershipTransferEvent event){
92-
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
93-
}
94-
@EventHandler(ignoreCancelled = true)
95-
public void onEvent(ShopSuccessPurchaseEvent event){
96-
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
97-
}
98-
@EventHandler(ignoreCancelled = true)
99-
public void onEvent(ShopTypeChangeEvent event){
100-
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
101-
}
102-
@EventHandler(ignoreCancelled = true)
103-
public void onEvent(ShopNamingEvent event){
104-
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
105-
}
10655
@NotNull
10756
public String plain(@NotNull Component component) {
10857
return PlainTextComponentSerializer.plainText().serialize(component);
@@ -136,37 +85,32 @@ public void updateShopMarker(Shop shop) {
13685
}
13786
for (BlueMapMap map : bWorld.get().getMaps()) {
13887
MarkerSet markerSet = map.getMarkerSets().computeIfAbsent("quickshop-hikari-shops",(key)-> createMarkerSet());
139-
String markerName = plain(text().of("addon.bluemap.marker-name",
140-
shopName,
141-
plain(shop.ownerName()),
142-
plain(Util.getItemStackName(shop.getItem())),
143-
plugin.getShopManager().format(shop.getPrice(), shop),
144-
shop.getShopStackingAmount(),
145-
shop.getShopType() == ShopType.SELLING ? plain(text().of("shop-type.selling").forLocale()) : plain(text().of("shop-type.buying").forLocale()),
146-
shop.isUnlimited(),
147-
posStr
148-
).forLocale());
149-
String desc = plain(text().of("addon.bluemap.marker-description",
150-
shopName,
151-
plain(shop.ownerName()),
152-
plain(Util.getItemStackName(shop.getItem())),
153-
plugin.getShopManager().format(shop.getPrice(), shop),
154-
shop.getShopStackingAmount(),
155-
shop.getShopType() == ShopType.SELLING ? plain(text().of("shop-type.selling").forLocale()) : plain(text().of("shop-type.buying").forLocale()),
156-
shop.isUnlimited(),
157-
posStr
158-
).forLocale());
88+
String markerName = fillPlaceholders(getConfig().getString("marker-label"), shop);
89+
String desc = fillPlaceholders(getConfig().getString("marker-detail"), shop);
15990
POIMarker marker = POIMarker.builder()
16091
.label(markerName)
16192
.position(shop.getLocation().getX(),
16293
shop.getLocation().getY(),
16394
shop.getLocation().getZ())
164-
.maxDistance(1000)
95+
.maxDistance(getConfig().getDouble("max-distance"))
16596
.detail(desc)
16697
.styleClasses()
16798
.build();
16899
markerSet.getMarkers().put("quickshop-hikari-shop"+shop.getShopId(), marker);
169100
}
170101
}
171102

103+
private String fillPlaceholders(String s, Shop shop){
104+
Location loc = shop.getLocation();
105+
String x = String.valueOf(loc.getX());
106+
String y = String.valueOf(loc.getY());
107+
String z = String.valueOf(loc.getZ());
108+
s = s.replace("%owner%", plain(shop.ownerName()));
109+
s = s.replace("%item%", shop.getItem().getType().name());
110+
s = s.replace("%price%", String.valueOf(shop.getPrice()));
111+
s = s.replace("%stock%", String.valueOf(shop.getRemainingStock()));
112+
s = s.replace("%type%", shop.getShopType().name());
113+
s = s.replace("%location%", x + "," + y + "," + z );
114+
return s;
115+
}
172116
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
11
config-version: 1
2-
display-by-default: true
2+
# If you want the marker set/markers to display by default when opening the map.
3+
display-by-default: true
4+
#Location for the image you want as your quick-shop marker, it's defaulted to the BlueMap assets folder.
5+
icon-file-location: "/assets/chest.png"
6+
# If you want to display the marker icon.
7+
display-icon: true
8+
# Max distance of range where the user can see the marker, useful for lag reduction in frames.
9+
max-distance: 1000
10+
# This is where the name of each quick-shop marker when looking at the list (placeholders are %item%, %price%, %stock%, %owner%, %type%, %location%).
11+
marker-label: "%item%, %price%, %stock%, %owner%, %type%"
12+
# This is the popup text when clicking the shop marker itself.
13+
marker-detail: '<span style="font-size: 120%">Chest Shop</span><hr><span>Owner: <strong>%owner%</strong></span><br><span>Item: <strong>%item%</strong></span><br><span>Price: <strong>%price%</strong><br><span>Stock: <strong>%stock%</strong><br><span>Type: <strong>%type%</strong><br><span>Location: <strong>%location%</strong></span>'
14+
# How many times per second does the plugin refresh the chestshops?
15+
refresh-per-seconds: 5

addon/discordsrv/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>5.0.0.7</version>
10+
<version>5.1.0.0</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>

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

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

3-
import com.fasterxml.jackson.annotation.JsonProperty;
43
import com.ghostchu.quickshop.common.util.CommonUtil;
54
import com.ghostchu.quickshop.common.util.JsonUtil;
65
import com.google.common.reflect.TypeToken;
6+
import com.google.gson.annotations.SerializedName;
77
import github.scarsz.discordsrv.dependencies.jda.api.EmbedBuilder;
88
import github.scarsz.discordsrv.dependencies.jda.api.entities.MessageEmbed;
99
import lombok.Data;
@@ -85,73 +85,73 @@ private String emptyDefault(@Nullable String v) {
8585
@NoArgsConstructor
8686
@Data
8787
public static class PackageDTO {
88-
@JsonProperty("embed")
88+
@SerializedName("embed")
8989
private EmbedDTO embed;
9090

9191
@NoArgsConstructor
9292
@Data
9393
public static class EmbedDTO {
94-
@JsonProperty("title")
94+
@SerializedName("title")
9595
private String title;
96-
@JsonProperty("description")
96+
@SerializedName("description")
9797
private String description;
98-
@JsonProperty("color")
98+
@SerializedName("color")
9999
private Integer color;
100-
@JsonProperty("url")
100+
@SerializedName("url")
101101
private String url;
102-
@JsonProperty("author")
102+
@SerializedName("author")
103103
private AuthorDTO author;
104-
@JsonProperty("thumbnail")
104+
@SerializedName("thumbnail")
105105
private ThumbnailDTO thumbnail;
106-
@JsonProperty("image")
106+
@SerializedName("image")
107107
private ImageDTO image;
108-
@JsonProperty("footer")
108+
@SerializedName("footer")
109109
private FooterDTO footer;
110-
@JsonProperty("fields")
110+
@SerializedName("fields")
111111
private List<FieldsDTO> fields;
112112

113113
@NoArgsConstructor
114114
@Data
115115
public static class AuthorDTO {
116-
@JsonProperty("name")
116+
@SerializedName("name")
117117
private String name;
118-
@JsonProperty("url")
118+
@SerializedName("url")
119119
private String url;
120-
@JsonProperty("icon_url")
120+
@SerializedName("icon_url")
121121
private String iconUrl;
122122
}
123123

124124
@NoArgsConstructor
125125
@Data
126126
public static class ThumbnailDTO {
127-
@JsonProperty("url")
127+
@SerializedName("url")
128128
private String url;
129129
}
130130

131131
@NoArgsConstructor
132132
@Data
133133
public static class ImageDTO {
134-
@JsonProperty("url")
134+
@SerializedName("url")
135135
private String url;
136136
}
137137

138138
@NoArgsConstructor
139139
@Data
140140
public static class FooterDTO {
141-
@JsonProperty("text")
141+
@SerializedName("text")
142142
private String text;
143-
@JsonProperty("icon_url")
143+
@SerializedName("icon_url")
144144
private String iconUrl;
145145
}
146146

147147
@NoArgsConstructor
148148
@Data
149149
public static class FieldsDTO {
150-
@JsonProperty("name")
150+
@SerializedName("name")
151151
private String name;
152-
@JsonProperty("value")
152+
@SerializedName("value")
153153
private String value;
154-
@JsonProperty("inline")
154+
@SerializedName("inline")
155155
private Boolean inline;
156156
}
157157
}

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>5.0.0.7</version>
10+
<version>5.1.0.0</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>

addon/displaycontrol/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>5.0.0.7</version>
10+
<version>5.1.0.0</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>

addon/dynmap/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>5.0.0.7</version>
10+
<version>5.1.0.0</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>5.0.0.7</version>
10+
<version>5.1.0.0</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>

addon/list/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>5.0.0.7</version>
10+
<version>5.1.0.0</version>
1111
<relativePath>../../pom.xml</relativePath>
1212
</parent>
1313
<groupId>com.ghostchu.quickshop.addon</groupId>

0 commit comments

Comments
 (0)