|
|
|
@ -1,8 +1,10 @@ |
|
|
|
package xyz.soukup.ecoCraftCore.commands; |
|
|
|
package xyz.soukup.ecoCraftCore.commands; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.mojang.brigadier.LiteralMessage; |
|
|
|
import com.mojang.brigadier.arguments.FloatArgumentType; |
|
|
|
import com.mojang.brigadier.arguments.FloatArgumentType; |
|
|
|
import com.mojang.brigadier.arguments.StringArgumentType; |
|
|
|
import com.mojang.brigadier.arguments.StringArgumentType; |
|
|
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder; |
|
|
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder; |
|
|
|
|
|
|
|
import com.mojang.brigadier.builder.RequiredArgumentBuilder; |
|
|
|
import com.mojang.brigadier.context.CommandContext; |
|
|
|
import com.mojang.brigadier.context.CommandContext; |
|
|
|
import com.mojang.brigadier.exceptions.CommandSyntaxException; |
|
|
|
import com.mojang.brigadier.exceptions.CommandSyntaxException; |
|
|
|
import io.papermc.paper.command.brigadier.CommandSourceStack; |
|
|
|
import io.papermc.paper.command.brigadier.CommandSourceStack; |
|
|
|
@ -16,36 +18,56 @@ import xyz.soukup.ecoCraftCore.objects.Transaction; |
|
|
|
import xyz.soukup.ecoCraftCore.utilities.Messages; |
|
|
|
import xyz.soukup.ecoCraftCore.utilities.Messages; |
|
|
|
import xyz.soukup.ecoCraftCore.utilities.PHHM; |
|
|
|
import xyz.soukup.ecoCraftCore.utilities.PHHM; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("UnstableApiUsage") |
|
|
|
public class MoneyCommand { |
|
|
|
public class MoneyCommand { |
|
|
|
public static LiteralArgumentBuilder<CommandSourceStack> createCommand() { |
|
|
|
public static LiteralArgumentBuilder<CommandSourceStack> createCommand() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, PlayerSelectorArgumentResolver> playerArgument = Commands.argument("player", ArgumentTypes.player()); |
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, Float> amountArgument = Commands.argument("amount", FloatArgumentType.floatArg(0.1F)); |
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, String> ownerArgument = Commands.argument("owner", StringArgumentType.word()); |
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, String> typeArgument = Commands.argument("type", StringArgumentType.word()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LiteralArgumentBuilder<CommandSourceStack> send = Commands.literal("send") |
|
|
|
|
|
|
|
.requires(source -> source.getSender() instanceof Player) |
|
|
|
|
|
|
|
.then(playerArgument.then(amountArgument.executes(MoneyCommand::sendMoney))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, Float> selfGive = amountArgument |
|
|
|
|
|
|
|
.requires(source -> source.getSender() instanceof Player) |
|
|
|
|
|
|
|
.executes(MoneyCommand::giveMoneySelf); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, PlayerSelectorArgumentResolver> playerGive = playerArgument |
|
|
|
|
|
|
|
.then(amountArgument.executes(MoneyCommand::giveMoneyPlayer)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, String> giveOther = typeArgument.then(ownerArgument.then(amountArgument.executes(MoneyCommand::giveMoneyOther))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LiteralArgumentBuilder<CommandSourceStack> give = Commands.literal("give") |
|
|
|
|
|
|
|
.then(selfGive) |
|
|
|
|
|
|
|
.then(playerGive) |
|
|
|
|
|
|
|
.then(giveOther); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, Float> removeSelf = amountArgument |
|
|
|
|
|
|
|
.requires(source -> source.getSender() instanceof Player) |
|
|
|
|
|
|
|
.executes(MoneyCommand::removeMoneySelf); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, PlayerSelectorArgumentResolver> removePlayer = playerArgument |
|
|
|
|
|
|
|
.then(amountArgument.executes(MoneyCommand::removeMoneyPlayer)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RequiredArgumentBuilder<CommandSourceStack, String> removeOther = typeArgument |
|
|
|
|
|
|
|
.then(ownerArgument |
|
|
|
|
|
|
|
.then(amountArgument.executes(MoneyCommand::removeMoneyOther))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LiteralArgumentBuilder<CommandSourceStack> remove = Commands.literal("remove") |
|
|
|
|
|
|
|
.then(removeSelf) |
|
|
|
|
|
|
|
.then(removePlayer) |
|
|
|
|
|
|
|
.then(removeOther); |
|
|
|
|
|
|
|
|
|
|
|
return Commands.literal("money") |
|
|
|
return Commands.literal("money") |
|
|
|
.then(Commands.literal("send") |
|
|
|
.then(send) |
|
|
|
.requires(source -> source.getSender() instanceof Player) |
|
|
|
.then(give) |
|
|
|
.then(Commands.argument("player", ArgumentTypes.player()) |
|
|
|
.then(remove) |
|
|
|
.then(Commands.argument("amount", FloatArgumentType.floatArg(0.1F)) |
|
|
|
|
|
|
|
.executes(MoneyCommand::sendMoney)))) |
|
|
|
|
|
|
|
.then(Commands.literal("give") |
|
|
|
|
|
|
|
.then(Commands.argument("amount", FloatArgumentType.floatArg(0.1F)) |
|
|
|
|
|
|
|
.requires(source -> source.getSender() instanceof Player) |
|
|
|
|
|
|
|
.executes(MoneyCommand::giveMoneySelf)) |
|
|
|
|
|
|
|
.then(Commands.argument("player", ArgumentTypes.player()) |
|
|
|
|
|
|
|
.then(Commands.argument("amount", FloatArgumentType.floatArg(0.1F)) |
|
|
|
|
|
|
|
.executes(MoneyCommand::giveMoneyPlayer))) |
|
|
|
|
|
|
|
.then(Commands.argument("type", StringArgumentType.word()) |
|
|
|
|
|
|
|
.then(Commands.argument("owner", StringArgumentType.word()) |
|
|
|
|
|
|
|
.then(Commands.argument("amount", FloatArgumentType.floatArg(0.1F)) |
|
|
|
|
|
|
|
.executes(MoneyCommand::giveMoneyOther))))) |
|
|
|
|
|
|
|
.then(Commands.literal("remove") |
|
|
|
|
|
|
|
.then(Commands.argument("amount", FloatArgumentType.floatArg(0.1F)) |
|
|
|
|
|
|
|
.requires(source -> source.getSender() instanceof Player) |
|
|
|
|
|
|
|
.executes(MoneyCommand::removeMoneySelf)) |
|
|
|
|
|
|
|
.then(Commands.argument("player", ArgumentTypes.player()) |
|
|
|
|
|
|
|
.then(Commands.argument("amount", FloatArgumentType.floatArg(0.1F)) |
|
|
|
|
|
|
|
.executes(MoneyCommand::removeMoneyPlayer))) |
|
|
|
|
|
|
|
.then(Commands.argument("type", StringArgumentType.word()) |
|
|
|
|
|
|
|
.then(Commands.argument("owner", StringArgumentType.word()) |
|
|
|
|
|
|
|
.then(Commands.argument("amount", FloatArgumentType.floatArg(0.1F)) |
|
|
|
|
|
|
|
.executes(MoneyCommand::removeMoneyOther))))) |
|
|
|
|
|
|
|
.executes(MoneyCommand::getBalance); |
|
|
|
.executes(MoneyCommand::getBalance); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|