mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-01 11:11:21 +01:00
Vault support: money condition
This commit is contained in:
parent
8b108c1aa1
commit
d3a187cec2
BIN
lib/Vault.jar
Normal file
BIN
lib/Vault.jar
Normal file
Binary file not shown.
7
pom.xml
7
pom.xml
@ -240,6 +240,13 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Holograms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl</groupId>
|
||||
<artifactId>vault</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Vault.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
|
@ -5,7 +5,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.Indyuce.mmoitems.comp.mythicmobs.MythicMobsLoader;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -28,6 +27,7 @@ import net.Indyuce.mmoitems.comp.AdvancedEnchantmentsHook;
|
||||
import net.Indyuce.mmoitems.comp.MMOItemsMetrics;
|
||||
import net.Indyuce.mmoitems.comp.MMOItemsRewardTypes;
|
||||
import net.Indyuce.mmoitems.comp.RealDualWieldHook;
|
||||
import net.Indyuce.mmoitems.comp.eco.VaultSupport;
|
||||
import net.Indyuce.mmoitems.comp.flags.DefaultFlags;
|
||||
import net.Indyuce.mmoitems.comp.flags.FlagPlugin;
|
||||
import net.Indyuce.mmoitems.comp.flags.ResidenceFlags;
|
||||
@ -157,6 +157,11 @@ public class MMOItems extends JavaPlugin {
|
||||
blockManager = new BlockManager();
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
|
||||
new VaultSupport();
|
||||
getLogger().log(Level.INFO, "Hooked onto Vault");
|
||||
}
|
||||
|
||||
getLogger().log(Level.INFO, "Loading crafting stations, please wait..");
|
||||
stationRecipeManager.reload();
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
package net.Indyuce.mmoitems.comp.eco;
|
||||
|
||||
import net.Indyuce.mmoitems.api.crafting.condition.Condition;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
|
||||
public class MoneyCondition extends Condition {
|
||||
private final double amount;
|
||||
private final Economy economy;
|
||||
|
||||
public MoneyCondition(Economy economy, MMOLineConfig config) {
|
||||
super("money");
|
||||
|
||||
config.validate("amount");
|
||||
amount = config.getDouble("amount");
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMet(PlayerData data) {
|
||||
return economy.has(data.getPlayer(), amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatDisplay(String string) {
|
||||
return string.replace("#money#", "" + amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCrafting(PlayerData data) {
|
||||
economy.withdrawPlayer(data.getPlayer(), amount);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.Indyuce.mmoitems.comp.eco;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
|
||||
public class VaultSupport {
|
||||
private final Economy economy;
|
||||
|
||||
public VaultSupport() {
|
||||
|
||||
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager()
|
||||
.getRegistration(Economy.class);
|
||||
economy = economyProvider != null ? economyProvider.getProvider() : null;
|
||||
|
||||
if (economy == null) {
|
||||
MMOItems.plugin.getLogger().log(Level.SEVERE, "Could not load Vault");
|
||||
return;
|
||||
}
|
||||
|
||||
MMOItems.plugin.getCrafting().registerCondition("money", config -> new MoneyCondition(economy, config),
|
||||
new ConditionalDisplay("&a" + AltChar.check + " Requires $#money#",
|
||||
"&c" + AltChar.cross + " Requires $#money#"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user