Adds experimental support `EconomyShopGUI` support for AutoSell

Pretty stupid/ugly how the API is accessed and users enabled this feature.
Something for the future when the new SongodaCore release is ready.

Requested by multiple users on Discord.
This commit is contained in:
Christian Koop 2023-03-31 20:40:07 +02:00
parent 785abbaa6c
commit 38d9995d6c
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
4 changed files with 50 additions and 6 deletions

View File

@ -151,6 +151,13 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Gypopo</groupId>
<artifactId>EconomyShopGUI-API</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>UltimateStacker</artifactId>

View File

@ -10,6 +10,7 @@ import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.settings.Settings;
import com.songoda.epichoppers.utils.Methods;
import com.songoda.epichoppers.utils.StorageContainerCache;
import me.gypopo.economyshopgui.api.EconomyShopGUIHook;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@ -75,7 +76,7 @@ public class ModuleAutoSell extends Module {
continue;
}
// Get the value from config or ShopGuiPlus
// Get the value from config or ShopGuiPlus or EconomyShopGui
double value;
if (Settings.AUTOSELL_SHOPGUIPLUS.getBoolean() && player.isOnline()) {
try {
@ -85,9 +86,22 @@ public class ModuleAutoSell extends Module {
} catch (Exception e) {
value = 0;
}
} else
} else if (Settings.AUTOSELL_ECONOMY_SHOP_GUI.getBoolean() && player.isOnline() && (Bukkit.getPluginManager().isPluginEnabled("EconomyShopGUI") || Bukkit.getPluginManager().isPluginEnabled("EconomyShopGUI-Premium"))) {
value = 0;
try {
ItemStack clone = itemStack.clone();
clone.setAmount(1);
Double sellPrice = EconomyShopGUIHook.getItemSellPrice(player.getPlayer(), clone);
if (sellPrice != null) {
value = sellPrice;
}
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
value = Settings.AUTOSELL_PRICES.getStringList().stream().filter(line -> CompatibleMaterial.valueOf(line.split(",")[0]) == CompatibleMaterial.getMaterial(itemStack)).findFirst()
.map(s -> Double.valueOf(s.split(",")[1])).orElse(0.0);
}
if (value <= 0) continue;
@ -186,4 +200,4 @@ public class ModuleAutoSell extends Module {
if (time == null) return -9999;
return (int) time;
}
}
}

View File

@ -86,9 +86,13 @@ public class Settings {
public static final ConfigSetting AUTOSELL_SHOPGUIPLUS = new ConfigSetting(config, "Main.Use ShopGuiPlus for Prices", false,
"Should prices be grabbed from ShopGuiPlus?",
"If ShopGuiPlus is not enabled or the player is offline the default price list will be used.",
"If ShopGuiPlus is not enabled or the player is offline the default price list will be used (or EconomyShopGUI if enabled).",
"If this is something that you do not want then you should empty the default list.");
public static final ConfigSetting AUTOSELL_ECONOMY_SHOP_GUI = new ConfigSetting(config, "Main.Use EconomyShopGUI for Prices", false,
"Should prices be grabbed from EconomyShopGUI?",
"If 'Use ShopGuiPlus for Prices' is enabled and the player is online, this will be ignored.");
public static final ConfigSetting ECONOMY_PLUGIN = new ConfigSetting(config, "Main.Economy", EconomyManager.getEconomy() == null ? "Vault" : EconomyManager.getEconomy().getName(),
"Which economy plugin should be used?",
"Supported plugins you have installed: \"" + EconomyManager.getManager().getRegisteredPlugins().stream().collect(Collectors.joining("\", \"")) + "\".");
@ -150,4 +154,4 @@ public class Settings {
config.saveChanges();
}
}
}

View File

@ -1,7 +1,26 @@
name: EpicHoppers
description: EpicHoppers
main: com.songoda.epichoppers.EpicHoppers
softdepend: [ FabledSkyBlock, LiquidTanks, UltimateStacker, WildStacker, Reserve, Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault, EpicFarming, AdvancedChests ]
softdepend:
- ASkyBlock
- AdvancedChests
- EconomyShopGUI
- EconomyShopGUI-Premium
- EpicFarming
- FabledSkyBlock
- Factions
- GriefPrevention
- Kingdoms
- LiquidTanks
- PlotsSquared
- RedProtect
- Reserve
- Towny
- USkyBlock
- UltimateStacker
- Vault
- WildStacker
- WorldGuard
version: maven-version-number
author: Songoda
api-version: 1.13