support for EightsEconomyP close #149
This commit is contained in:
parent
986d694851
commit
80174b058d
@ -1,6 +1,7 @@
|
||||
Flan 1.7.6
|
||||
================
|
||||
- Fix delete command using wrong permission node
|
||||
- Fabric: Support for EightsEconomyP
|
||||
|
||||
Flan 1.7.5
|
||||
================
|
||||
|
@ -15,7 +15,7 @@ public class Flan {
|
||||
|
||||
public static final Logger logger = LogManager.getLogger("flan");
|
||||
|
||||
public static boolean permissionAPI, gunpowder, playerAbilityLib, ftbRanks, diceMCMoneySign;
|
||||
public static boolean permissionAPI, gunpowder, playerAbilityLib, ftbRanks, diceMCMoneySign, octoEconomy;
|
||||
|
||||
public static final DateTimeFormatter onlineTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
|
||||
|
@ -45,6 +45,7 @@ repositories {
|
||||
name = "CurseMaven"
|
||||
url "https://www.cursemaven.com"
|
||||
}
|
||||
maven { url = "https://jitpack.io" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -62,11 +63,14 @@ dependencies {
|
||||
modCompileOnly("curse.maven:gunpowdercurrency-402041:3584557") {
|
||||
exclude group: "com.google.guava", module:"failureaccess"
|
||||
}
|
||||
modImplementation "com.github.ExcessiveAmountsOfZombies:OctoEconomyApi:5137175b1c"
|
||||
modRuntimeOnly "curse.maven:gunpowdercurrency-559967:3590217"
|
||||
|
||||
//modImplementation "io.github.ladysnake:PlayerAbilityLib:${rootProject.player_ability_lib}"
|
||||
modCompileOnly "io.github.ladysnake:PlayerAbilityLib:${rootProject.player_ability_lib}"
|
||||
|
||||
modCompileOnly("dev.ftb.mods:ftb-ranks-fabric:${rootProject.ftb_ranks}")
|
||||
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -57,6 +57,7 @@ public class FlanFabric implements ModInitializer {
|
||||
Flan.gunpowder = FabricLoader.getInstance().isModLoaded("gunpowder-currency");
|
||||
Flan.playerAbilityLib = FabricLoader.getInstance().isModLoaded("playerabilitylib");
|
||||
Flan.ftbRanks = FabricLoader.getInstance().isModLoaded("ftbranks");
|
||||
Flan.octoEconomy = FabricLoader.getInstance().isModLoaded("octo-economy-api");
|
||||
if (Flan.playerAbilityLib)
|
||||
PlayerAbilityEvents.register();
|
||||
ClaimCriterias.init();
|
||||
|
@ -1,5 +1,8 @@
|
||||
package io.github.flemmli97.flan.fabric.platform.integration.currency;
|
||||
|
||||
import com.epherical.octoecon.OctoEconomy;
|
||||
import com.epherical.octoecon.api.Currency;
|
||||
import com.epherical.octoecon.api.user.UniqueUser;
|
||||
import io.github.flemmli97.flan.Flan;
|
||||
import io.github.flemmli97.flan.claim.PermHelper;
|
||||
import io.github.flemmli97.flan.config.ConfigHandler;
|
||||
@ -9,6 +12,7 @@ import io.github.gunpowder.entities.StoredBalance;
|
||||
import io.github.gunpowder.modelhandlers.BalanceHandler;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -16,6 +20,8 @@ import java.util.function.Consumer;
|
||||
|
||||
public class CommandCurrencyImpl implements CommandCurrency {
|
||||
|
||||
private static final ResourceLocation eightyEconomyCurrencyName = new ResourceLocation("eights_economy", "dollars");
|
||||
|
||||
@Override
|
||||
public boolean sellClaimBlocks(ServerPlayer player, int blocks, float value, Consumer<Component> message) {
|
||||
if (value == -1) {
|
||||
@ -36,6 +42,24 @@ public class CommandCurrencyImpl implements CommandCurrency {
|
||||
message.accept(PermHelper.simpleColoredText(String.format(ConfigHandler.langManager.get("sellSuccess"), blocks, price), ChatFormatting.GOLD));
|
||||
return true;
|
||||
}
|
||||
if (Flan.octoEconomy) {
|
||||
PlayerClaimData data = PlayerClaimData.get(player);
|
||||
if (data.getAdditionalClaims() - Math.max(0, data.usedClaimBlocks() - data.getClaimBlocks()) < blocks) {
|
||||
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("sellFail"), ChatFormatting.DARK_RED));
|
||||
return false;
|
||||
}
|
||||
Currency currency = OctoEconomy.getInstance().getCurrentEconomy().getCurrency(eightyEconomyCurrencyName);
|
||||
if (currency == null) {
|
||||
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("currencyMissing"), ChatFormatting.DARK_RED));
|
||||
return false;
|
||||
}
|
||||
UniqueUser user = OctoEconomy.getInstance().getCurrentEconomy()
|
||||
.getOrCreatePlayerAccount(player.getUUID());
|
||||
double price = blocks * value;
|
||||
user.depositMoney(currency, price, "flan.claimblocks.sell");
|
||||
data.setAdditionalClaims(data.getAdditionalClaims() - blocks);
|
||||
message.accept(PermHelper.simpleColoredText(String.format(ConfigHandler.langManager.get("sellSuccess"), blocks, price), ChatFormatting.GOLD));
|
||||
}
|
||||
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("currencyMissing"), ChatFormatting.DARK_RED));
|
||||
return false;
|
||||
}
|
||||
@ -60,6 +84,25 @@ public class CommandCurrencyImpl implements CommandCurrency {
|
||||
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("buyFail"), ChatFormatting.DARK_RED));
|
||||
return false;
|
||||
}
|
||||
if (Flan.octoEconomy) {
|
||||
Currency currency = OctoEconomy.getInstance().getCurrentEconomy().getCurrency(eightyEconomyCurrencyName);
|
||||
if (currency == null) {
|
||||
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("currencyMissing"), ChatFormatting.DARK_RED));
|
||||
return false;
|
||||
}
|
||||
UniqueUser user = OctoEconomy.getInstance().getCurrentEconomy()
|
||||
.getOrCreatePlayerAccount(player.getUUID());
|
||||
double price = Math.max(0, blocks * value);
|
||||
if (user.getBalance(currency) >= price) {
|
||||
PlayerClaimData data = PlayerClaimData.get(player);
|
||||
data.setAdditionalClaims(data.getAdditionalClaims() + blocks);
|
||||
user.withdrawMoney(currency, price, "flan.claimblocks.buy");
|
||||
message.accept(PermHelper.simpleColoredText(String.format(ConfigHandler.langManager.get("buySuccess"), blocks, price), ChatFormatting.GOLD));
|
||||
return true;
|
||||
}
|
||||
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("buyFail"), ChatFormatting.DARK_RED));
|
||||
return false;
|
||||
}
|
||||
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("currencyMissing"), ChatFormatting.DARK_RED));
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user