dicemc money integration #82
This commit is contained in:
parent
bf9fd48a5f
commit
f372579bfc
@ -12,7 +12,7 @@ public class Flan {
|
||||
|
||||
public static final Logger logger = LogManager.getLogger("flan");
|
||||
|
||||
public static boolean permissionAPI, gunpowder, playerAbilityLib, ftbRanks;
|
||||
public static boolean permissionAPI, gunpowder, playerAbilityLib, ftbRanks, diceMCMoneySign;
|
||||
|
||||
public static final DateTimeFormatter onlineTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
|
||||
|
@ -18,7 +18,7 @@ import io.github.flemmli97.flan.claim.PermHelper;
|
||||
import io.github.flemmli97.flan.config.ConfigHandler;
|
||||
import io.github.flemmli97.flan.gui.ClaimMenuScreenHandler;
|
||||
import io.github.flemmli97.flan.gui.PersonalGroupScreenHandler;
|
||||
import io.github.flemmli97.flan.integration.gunpowder.CommandCurrency;
|
||||
import io.github.flemmli97.flan.integration.currency.CommandCurrency;
|
||||
import io.github.flemmli97.flan.integration.permissions.PermissionNodeHandler;
|
||||
import io.github.flemmli97.flan.player.EnumDisplayType;
|
||||
import io.github.flemmli97.flan.player.EnumEditMode;
|
||||
|
@ -122,7 +122,7 @@ public class LangConfig {
|
||||
public String buyFail = "Not enough money";
|
||||
public String sellSuccess = "Sold %1$s claimblocks for %2$s";
|
||||
public String buySuccess = "Bought %1$s claimblocks for %2$s";
|
||||
public String gunpowderMissing = "Missing gunpowder currency mod";
|
||||
public String currencyMissing = "Missing a supported currency mod";
|
||||
|
||||
public String trappedRescue = "Rescuing. Don't move for 5 seconds";
|
||||
public String trappedFail = "Rescue not necessary or already rescuing";
|
||||
|
@ -1,4 +1,4 @@
|
||||
package io.github.flemmli97.flan.integration.gunpowder;
|
||||
package io.github.flemmli97.flan.integration.currency;
|
||||
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
@ -1,4 +1,4 @@
|
||||
package io.github.flemmli97.flan.integration.gunpowder.fabric;
|
||||
package io.github.flemmli97.flan.integration.currency.fabric;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
@ -20,7 +20,7 @@ public class CommandCurrencyImpl {
|
||||
|
||||
public static int sellClaimBlocks(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
if (!Flan.gunpowder) {
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.gunpowderMissing, Formatting.DARK_RED), false);
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
if (ConfigHandler.config.sellPrice == -1) {
|
||||
@ -43,7 +43,7 @@ public class CommandCurrencyImpl {
|
||||
|
||||
public static int buyClaimBlocks(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
if (!Flan.gunpowder) {
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.gunpowderMissing, Formatting.DARK_RED), false);
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
if (ConfigHandler.config.buyPrice == -1) {
|
||||
@ -53,7 +53,7 @@ public class CommandCurrencyImpl {
|
||||
StoredBalance bal = GunpowderMod.getInstance().getRegistry().getModelHandler(BalanceHandler.class).getUser(context.getSource().getPlayer().getUuid());
|
||||
int amount = Math.max(0, IntegerArgumentType.getInteger(context, "amount"));
|
||||
BigDecimal price = BigDecimal.valueOf(amount * ConfigHandler.config.buyPrice);
|
||||
if (bal.getBalance().compareTo(price) > 0) {
|
||||
if (bal.getBalance().compareTo(price) >= 0) {
|
||||
PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayer());
|
||||
data.setAdditionalClaims(data.getAdditionalClaims() + amount);
|
||||
bal.setBalance(bal.getBalance().subtract(price));
|
@ -22,6 +22,10 @@ repositories {
|
||||
name = "FTB"
|
||||
url = "https://maven.saps.dev/minecraft"
|
||||
}
|
||||
maven {
|
||||
name = "CurseMaven"
|
||||
url "https://www.cursemaven.com"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -37,7 +41,8 @@ dependencies {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
modImplementation("dev.ftb.mods:ftb-ranks-forge:1605.1.2-build.17")
|
||||
modImplementation("dev.ftb.mods:ftb-ranks-forge:${ftb_ranks}")
|
||||
modImplementation(dicemcmm)
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -18,6 +18,7 @@ public class FlanForge {
|
||||
|
||||
public FlanForge() {
|
||||
Flan.ftbRanks = ModList.get().isLoaded("ftbranks");
|
||||
Flan.diceMCMoneySign = ModList.get().isLoaded("dicemcmm");
|
||||
|
||||
IEventBus forge = MinecraftForge.EVENT_BUS;
|
||||
forge.addListener(WorldEventsForge::modifyExplosion);
|
||||
|
@ -0,0 +1,68 @@
|
||||
package io.github.flemmli97.flan.integration.currency.forge;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import dicemc.money.MoneyMod;
|
||||
import dicemc.money.api.MoneyManager;
|
||||
import dicemc.money.storage.MoneyWSD;
|
||||
import io.github.flemmli97.flan.Flan;
|
||||
import io.github.flemmli97.flan.claim.PermHelper;
|
||||
import io.github.flemmli97.flan.config.ConfigHandler;
|
||||
import io.github.flemmli97.flan.player.PlayerClaimData;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandCurrencyImpl {
|
||||
|
||||
public static int sellClaimBlocks(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
if (!Flan.diceMCMoneySign) {
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
if (ConfigHandler.config.sellPrice == -1) {
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.sellDisabled, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
int amount = Math.max(0, IntegerArgumentType.getInteger(context, "amount"));
|
||||
PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayer());
|
||||
if (data.getAdditionalClaims() - Math.max(0, data.usedClaimBlocks() - data.getClaimBlocks()) < amount) {
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.sellFail, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
double price = amount * ConfigHandler.config.sellPrice;
|
||||
MoneyWSD.get(context.getSource().getWorld()).changeBalance(MoneyMod.AcctTypes.PLAYER.key, context.getSource().getPlayer().getUuid(), price);
|
||||
data.setAdditionalClaims(data.getAdditionalClaims() - amount);
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.sellSuccess, amount, price), Formatting.GOLD), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int buyClaimBlocks(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
if (!Flan.diceMCMoneySign) {
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
if (ConfigHandler.config.buyPrice == -1) {
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.buyDisabled, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
UUID uuid = context.getSource().getPlayer().getUuid();
|
||||
MoneyWSD manager = MoneyWSD.get(context.getSource().getWorld());
|
||||
double bal = manager.getBalance(MoneyMod.AcctTypes.PLAYER.key, uuid);
|
||||
int amount = Math.max(0, IntegerArgumentType.getInteger(context, "amount"));
|
||||
double price = amount * ConfigHandler.config.buyPrice;
|
||||
if (bal >= price) {
|
||||
PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayer());
|
||||
data.setAdditionalClaims(data.getAdditionalClaims() + amount);
|
||||
manager.changeBalance(MoneyMod.AcctTypes.PLAYER.key, uuid, -price);
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.buySuccess, amount, price), Formatting.GOLD), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.buyFail, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package io.github.flemmli97.flan.integration.gunpowder.forge;
|
||||
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import io.github.flemmli97.flan.claim.PermHelper;
|
||||
import io.github.flemmli97.flan.config.ConfigHandler;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
public class CommandCurrencyImpl {
|
||||
|
||||
public static int sellClaimBlocks(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.gunpowderMissing, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int buyClaimBlocks(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.gunpowderMissing, Formatting.DARK_RED), false);
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ gunpowder_currency_version=1.0.2+gunpowder.0.3.7.mc.1.16.5
|
||||
fabric_permissions_api=0.1-SNAPSHOT
|
||||
player_ability_lib=1.2.2
|
||||
ftb_ranks=1605.1.2-build.17
|
||||
dicemcmm=curse.maven:dicemcmoney-406972:3397211
|
||||
# Curse properties
|
||||
curse_page_fabric=https://www.curseforge.com/minecraft/mc-mods/flan
|
||||
curse_versions=1.16.5, Java 8
|
||||
|
Loading…
x
Reference in New Issue
Block a user