Skip to content

Commit

Permalink
Merge pull request #1143 from Ghost-chu/hikari
Browse files Browse the repository at this point in the history
5.2.0.2
  • Loading branch information
Ghost-chu authored Sep 23, 2023
2 parents 72d1633 + 08f7e99 commit 94da632
Show file tree
Hide file tree
Showing 169 changed files with 1,043 additions and 3,088 deletions.
2 changes: 1 addition & 1 deletion addon/bluemap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.1</version>
<version>5.2.0.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.api.localization.text.TextManager;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.api.shop.ShopType;
import com.ghostchu.quickshop.util.Util;
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.BlueMapWorld;
Expand All @@ -26,6 +24,7 @@ public final class Main extends JavaPlugin implements Listener {
static Main instance;
private QuickShop plugin;
private BlueMapAPI blueMapAPI;

@Override
public void onLoad() {
instance = this;
Expand All @@ -41,16 +40,16 @@ public void onEnable() {
saveDefaultConfig();
plugin = QuickShop.getInstance();
getLogger().info("Registering the per shop permissions...");
BlueMapAPI.onEnable(blueMapAPI -> {
getLogger().info("Found BlueMap loaded! Hooking!");
createMarkerSet();
Bukkit.getScheduler().runTaskTimerAsynchronously(this, ()->{
updateAllMarkers();
}, 1, getConfig().getInt("refresh-per-seconds") * 20L);
});
BlueMapAPI.onEnable(blueMapAPI -> {
getLogger().info("Found BlueMap loaded! Hooking!");
createMarkerSet();
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
updateAllMarkers();
}, 1, getConfig().getInt("refresh-per-seconds") * 20L);
});

BlueMapAPI.onDisable(api -> Bukkit.getScheduler().cancelTasks(this));
}
}

@NotNull
public String plain(@NotNull Component component) {
Expand All @@ -62,29 +61,30 @@ public TextManager text() {
return plugin.getTextManager();
}

public MarkerSet createMarkerSet(){
public MarkerSet createMarkerSet() {
return MarkerSet.builder()
.defaultHidden(true)
.label(plain(text().of("addon.bluemap.markerset-title").forLocale()))
.defaultHidden(getConfig().getBoolean("display-by-default"))
.toggleable(true)
.build();
}

private void updateAllMarkers() {
blueMapAPI.getWorlds().forEach(bWorld-> bWorld.getMaps().forEach(bMap-> bMap.getMarkerSets().remove("quickshop-hikari-shops")));
blueMapAPI.getWorlds().forEach(bWorld -> bWorld.getMaps().forEach(bMap -> bMap.getMarkerSets().remove("quickshop-hikari-shops")));
plugin.getShopManager().getAllShops().forEach(this::updateShopMarker);
}

public void updateShopMarker(Shop shop) {
Optional<BlueMapWorld> bWorld = blueMapAPI.getWorld(shop.getLocation().getWorld());
if(bWorld.isEmpty()) return;
if (bWorld.isEmpty()) return;
String shopName = shop.getShopName();
String posStr = String.format("%s %s, %s, %s", shop.getLocation().getWorld().getName(), shop.getLocation().getBlockX(), shop.getLocation().getBlockY(), shop.getLocation().getBlockZ());
if (shopName == null) {
shopName = posStr;
}
for (BlueMapMap map : bWorld.get().getMaps()) {
MarkerSet markerSet = map.getMarkerSets().computeIfAbsent("quickshop-hikari-shops",(key)-> createMarkerSet());
MarkerSet markerSet = map.getMarkerSets().computeIfAbsent("quickshop-hikari-shops", (key) -> createMarkerSet());
String markerName = fillPlaceholders(getConfig().getString("marker-label"), shop);
String desc = fillPlaceholders(getConfig().getString("marker-detail"), shop);
POIMarker marker = POIMarker.builder()
Expand All @@ -96,11 +96,11 @@ public void updateShopMarker(Shop shop) {
.detail(desc)
.styleClasses()
.build();
markerSet.getMarkers().put("quickshop-hikari-shop"+shop.getShopId(), marker);
markerSet.getMarkers().put("quickshop-hikari-shop" + shop.getShopId(), marker);
}
}

private String fillPlaceholders(String s, Shop shop){
private String fillPlaceholders(String s, Shop shop) {
Location loc = shop.getLocation();
String x = String.valueOf(loc.getX());
String y = String.valueOf(loc.getY());
Expand All @@ -110,7 +110,7 @@ private String fillPlaceholders(String s, Shop shop){
s = s.replace("%price%", String.valueOf(shop.getPrice()));
s = s.replace("%stock%", String.valueOf(shop.getRemainingStock()));
s = s.replace("%type%", shop.getShopType().name());
s = s.replace("%location%", x + "," + y + "," + z );
s = s.replace("%location%", x + "," + y + "," + z);
return s;
}
}
2 changes: 1 addition & 1 deletion addon/discordsrv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.1</version>
<version>5.2.0.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.ghostchu.quickshop.api.event.*;
import com.ghostchu.quickshop.api.obj.QUser;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.common.util.QuickExecutor;
import com.ghostchu.quickshop.obj.QUserImpl;
import com.ghostchu.quickshop.util.Util;
import github.scarsz.discordsrv.dependencies.jda.api.entities.MessageEmbed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void scanClass(@Nullable Object obj) {

@NotNull
public MessageEmbed getEmbedMessage(@NotNull String key, @Nullable QUser receiver, @NotNull Map<String, String> placeholders) {
if(receiver == null){
if (receiver == null) {
return failSafeEmbedMessage(key);
}
Map.Entry<Object, Method> method = embedMessageRegistry.get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class MessageRepository {
private static final String ADDON_TRANSLATION_KEY_PREFIX = "addon.discord.discord-messages.";
Expand Down
2 changes: 1 addition & 1 deletion addon/discount/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.1</version>
<version>5.2.0.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void create(CommandSender sender, String[] passThroughArgs) {
"/quickshop discount install " + code,
"/quickshop discount config " + code + " addshop").send();
}
Log.debug("Discount code created: "+ main.getCodeManager().getCode(code));
Log.debug("Discount code created: " + main.getCodeManager().getCode(code));
}

private void remove(CommandSender sender, String[] passThroughArgs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ public void onPrePurchase(ShopInfoPanelEvent event) {
return;
}
String code = codeInstalled.getCode();
Util.mainThreadRun(()->{
Util.mainThreadRun(() -> {
switch (codeInstalled.applicableShop(purchaser, shop)) {
case APPLICABLE -> quickshop.text().of(purchaser, "addon.discount.discount-code-applicable", code).send();
case APPLICABLE ->
quickshop.text().of(purchaser, "addon.discount.discount-code-applicable", code).send();
case APPLICABLE_WITH_THRESHOLD ->
quickshop.text().of(purchaser, "addon.discount.discount-code-applicable", code, quickshop.getEconomy().format(codeInstalled.getThreshold(), shop.getLocation().getWorld(), shop.getCurrency())).send();
case NOT_APPLICABLE ->
Expand Down
2 changes: 1 addition & 1 deletion addon/displaycontrol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.1</version>
<version>5.2.0.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
Expand Down
2 changes: 1 addition & 1 deletion addon/dynmap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.1</version>
<version>5.2.0.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,60 @@ public void onEnable() {
}

@EventHandler(ignoreCancelled = true)
public void onEvent(WorldLoadEvent event){
public void onEvent(WorldLoadEvent event) {
Util.mainThreadRun(this::updateAllMarkers);
}

@EventHandler(ignoreCancelled = true)
public void onEvent(WorldUnloadEvent event){
public void onEvent(WorldUnloadEvent event) {
Util.mainThreadRun(this::updateAllMarkers);
}

@EventHandler(ignoreCancelled = true)
public void onEvent(QSConfigurationReloadEvent event){
public void onEvent(QSConfigurationReloadEvent event) {
Util.mainThreadRun(this::updateAllMarkers);
}

@EventHandler(ignoreCancelled = true)
public void onEvent(ShopCreateSuccessEvent event){
public void onEvent(ShopCreateSuccessEvent event) {
updateShopMarker(event.getShop());
}

@EventHandler(ignoreCancelled = true)
public void onEvent(ShopDeleteEvent event){
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
public void onEvent(ShopDeleteEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}

@EventHandler(ignoreCancelled = true)
public void onEvent(ShopPriceChangeEvent event){
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
public void onEvent(ShopPriceChangeEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}

@EventHandler(ignoreCancelled = true)
public void onEvent(ShopItemChangeEvent event){
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
public void onEvent(ShopItemChangeEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}

@EventHandler(ignoreCancelled = true)
public void onEvent(ShopOwnershipTransferEvent event){
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
public void onEvent(ShopOwnershipTransferEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}

@EventHandler(ignoreCancelled = true)
public void onEvent(ShopSuccessPurchaseEvent event){
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
public void onEvent(ShopSuccessPurchaseEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}

@EventHandler(ignoreCancelled = true)
public void onEvent(ShopTypeChangeEvent event){
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
public void onEvent(ShopTypeChangeEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}

@EventHandler(ignoreCancelled = true)
public void onEvent(ShopNamingEvent event){
Util.mainThreadRun(()->updateShopMarker(event.getShop()));
public void onEvent(ShopNamingEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}

@NotNull
public String plain(@NotNull Component component) {
return PlainTextComponentSerializer.plainText().serialize(component);
Expand Down
2 changes: 1 addition & 1 deletion addon/limited/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.1</version>
<version>5.2.0.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void onCommand(Player sender, @NotNull String commandLabel, @NotNull Comm
quickshop.text().of(sender, "addon.limited.success-setup").send();
shop.setExtra(Main.instance, manager);
} catch (IllegalArgumentException ignored) {
quickshop.text().of(sender, "command.wrong-args",parser.getArgs().get(1)).send();
quickshop.text().of(sender, "command.wrong-args", parser.getArgs().get(1)).send();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion addon/list/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.1</version>
<version>5.2.0.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
Expand Down
11 changes: 3 additions & 8 deletions addon/plan/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.1</version>
<version>5.2.0.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
Expand All @@ -24,13 +24,8 @@

<repositories>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
<repository>
<id>Scarsz-Nexus</id>
<url>https://nexus.scarsz.me/content/groups/public/</url>
<id>jitpack</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

Expand Down
Loading

0 comments on commit 94da632

Please sign in to comment.