Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions eternaleconomy-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ bukkit {

tasks.runServer {
minecraftVersion("1.21.1")
downloadPlugins {
github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
}
}

tasks.shadowJar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,29 @@ public void onEnable() {

this.liteCommands = LiteBukkitFactory.builder("eternaleconomy", this, server)
.extension(new LiteJakartaExtension<>(), settings -> settings
.violationMessage(Positive.class, BigDecimal.class, new InvalidBigDecimalMessage<>(noticeService))
.violationMessage(Positive.class, BigDecimal.class, new InvalidBigDecimalMessage<>(noticeService, messageConfig))
)

.annotations(extension -> extension.validator(
Account.class,
NotSender.class,
new NotSenderValidator(messageConfig)))

.missingPermission(new MissingPermissionHandlerImpl(noticeService))
.invalidUsage(new InvalidUsageHandlerImpl(noticeService))
.missingPermission(new MissingPermissionHandlerImpl(noticeService, messageConfig))
.invalidUsage(new InvalidUsageHandlerImpl(noticeService, messageConfig))

.message(LiteMessages.COMMAND_COOLDOWN, new CommandCooldownMessage(noticeService, commandsConfig))
.message(LiteMessages.COMMAND_COOLDOWN, new CommandCooldownMessage(noticeService, commandsConfig, messageConfig))
.editorGlobal(new CommandCooldownEditor(commandsConfig))

.commands(
new AdminAddCommand(accountPaymentService, decimalFormatter, noticeService),
new AdminRemoveCommand(accountPaymentService, decimalFormatter, noticeService),
new AdminSetCommand(accountPaymentService, decimalFormatter, noticeService),
new AdminResetCommand(accountPaymentService, noticeService),
new AdminBalanceCommand(noticeService, decimalFormatter),
new MoneyBalanceCommand(noticeService, decimalFormatter),
new MoneyTransferCommand(accountPaymentService, decimalFormatter, noticeService, pluginConfig),
new EconomyReloadCommand(configService, noticeService)
new AdminAddCommand(accountPaymentService, decimalFormatter, noticeService, messageConfig),
new AdminRemoveCommand(accountPaymentService, decimalFormatter, noticeService, messageConfig),
new AdminSetCommand(accountPaymentService, decimalFormatter, noticeService, messageConfig),
new AdminResetCommand(accountPaymentService, noticeService, messageConfig),
new AdminBalanceCommand(noticeService, decimalFormatter, messageConfig),
new MoneyBalanceCommand(noticeService, decimalFormatter, messageConfig),
new MoneyTransferCommand(accountPaymentService, decimalFormatter, noticeService, pluginConfig, messageConfig),
new EconomyReloadCommand(configService, noticeService, messageConfig)
)

.context(Account.class, new AccountContext(accountManager, messageConfig))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.eternalcode.economy;

import com.eternalcode.economy.config.ConfigService;
import com.eternalcode.economy.config.implementation.messages.MessageConfig;
import com.eternalcode.economy.multification.NoticeService;
import com.eternalcode.multification.notice.Notice;
import com.google.common.base.Stopwatch;
Expand All @@ -16,16 +17,21 @@
@Permission(EconomyPermissionConstant.ADMIN_RELOAD_PERMISSION)
public class EconomyReloadCommand {

private static final Notice RELOADED = Notice.chat("<b><gradient:#00FFA2:#34AE00>ECONOMY</gradient></b> "
+ "<dark_gray>➤</dark_gray> <white>Reloaded "
private static final Notice RELOADED = Notice.chat("{PREFIX}<white>Reloaded "
+ "EternalEconomy in <gradient:#00FFA2:#34AE00>{TIME}ms!</gradient></white>");

private final ConfigService configService;
private final NoticeService noticeService;
private final MessageConfig messageConfig;

public EconomyReloadCommand(ConfigService configService, NoticeService noticeService) {
public EconomyReloadCommand(
ConfigService configService,
NoticeService noticeService,
MessageConfig messageConfig
) {
this.configService = configService;
this.noticeService = noticeService;
this.messageConfig = messageConfig;
}

@Execute
Expand All @@ -38,6 +44,7 @@ void execute(@Context CommandSender sender) {
this.noticeService.create()
.notice(RELOADED)
.placeholder("{TIME}", String.valueOf(elapsed.toMillis()))
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.viewer(sender)
.send();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.eternalcode.economy.EconomyPermissionConstant;
import com.eternalcode.economy.account.Account;
import com.eternalcode.economy.account.AccountPaymentService;
import com.eternalcode.economy.config.implementation.messages.MessageConfig;
import com.eternalcode.economy.format.DecimalFormatter;
import com.eternalcode.economy.multification.NoticeService;
import dev.rollczi.litecommands.annotations.argument.Arg;
Expand All @@ -21,15 +22,18 @@ public class AdminAddCommand {
private final AccountPaymentService accountPaymentService;
private final DecimalFormatter decimalFormatter;
private final NoticeService noticeService;
private final MessageConfig messageConfig;

public AdminAddCommand(
AccountPaymentService accountPaymentService,
DecimalFormatter decimalFormatter,
NoticeService noticeService
NoticeService noticeService,
MessageConfig messageConfig
) {
this.accountPaymentService = accountPaymentService;
this.decimalFormatter = decimalFormatter;
this.noticeService = noticeService;
this.messageConfig = messageConfig;
}

@Execute
Expand All @@ -40,13 +44,15 @@ void execute(@Context CommandSender sender, @Arg Account receiver, @Arg @Positiv
.notice(notice -> notice.admin.added)
.placeholder("{AMOUNT}", this.decimalFormatter.format(amount))
.placeholder("{PLAYER}", receiver.name())
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.viewer(sender)
.send();

this.noticeService.create()
.notice(notice -> notice.player.added)
.placeholder("{AMOUNT}", this.decimalFormatter.format(amount))
.placeholder("{PLAYER}", receiver.name())
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.player(receiver.uuid())
.send();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.eternalcode.economy.EconomyPermissionConstant;
import com.eternalcode.economy.account.Account;
import com.eternalcode.economy.config.implementation.messages.MessageConfig;
import com.eternalcode.economy.format.DecimalFormatter;
import com.eternalcode.economy.multification.NoticeService;
import dev.rollczi.litecommands.annotations.argument.Arg;
Expand All @@ -17,10 +18,16 @@ public class AdminBalanceCommand {

private final NoticeService noticeService;
private final DecimalFormatter decimalFormatter;
private final MessageConfig messageConfig;

public AdminBalanceCommand(NoticeService noticeService, DecimalFormatter decimalFormatter) {
public AdminBalanceCommand(
NoticeService noticeService,
DecimalFormatter decimalFormatter,
MessageConfig messageConfig
) {
this.noticeService = noticeService;
this.decimalFormatter = decimalFormatter;
this.messageConfig = messageConfig;
}

@Execute
Expand All @@ -29,6 +36,7 @@ public void execute(@Context CommandSender sender, @Arg Account account) {
.notice(notice -> notice.admin.balance)
.placeholder("{BALANCE}", this.decimalFormatter.format(account.balance()))
.placeholder("{PLAYER}", account.name())
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.viewer(sender)
.send();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.eternalcode.economy.EconomyPermissionConstant;
import com.eternalcode.economy.account.Account;
import com.eternalcode.economy.account.AccountPaymentService;
import com.eternalcode.economy.config.implementation.messages.MessageConfig;
import com.eternalcode.economy.format.DecimalFormatter;
import com.eternalcode.economy.multification.NoticeService;
import dev.rollczi.litecommands.annotations.argument.Arg;
Expand All @@ -21,15 +22,18 @@ public class AdminRemoveCommand {
private final AccountPaymentService accountPaymentService;
private final DecimalFormatter decimalFormatter;
private final NoticeService noticeService;
private final MessageConfig messageConfig;

public AdminRemoveCommand(
AccountPaymentService accountPaymentService,
DecimalFormatter decimalFormatter,
NoticeService noticeService
NoticeService noticeService,
MessageConfig messageConfig
) {
this.accountPaymentService = accountPaymentService;
this.decimalFormatter = decimalFormatter;
this.noticeService = noticeService;
this.messageConfig = messageConfig;
}

@Execute
Expand All @@ -40,6 +44,7 @@ void execute(@Context CommandSender sender, @Arg Account receiver, @Arg @Positiv
.notice(notice -> notice.admin.insufficientFunds)
.placeholder("{PLAYER}", receiver.name())
.placeholder("{MISSING_BALANCE}", this.decimalFormatter.format(subtract))
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.viewer(sender)
.send();

Expand All @@ -52,12 +57,14 @@ void execute(@Context CommandSender sender, @Arg Account receiver, @Arg @Positiv
.notice(notice -> notice.admin.removed)
.placeholder("{AMOUNT}", this.decimalFormatter.format(amount))
.placeholder("{PLAYER}", receiver.name())
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.viewer(sender)
.send();

this.noticeService.create()
.notice(notice -> notice.player.removed)
.placeholder("{AMOUNT}", this.decimalFormatter.format(amount))
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.placeholder("{PLAYER}", receiver.name())
.player(receiver.uuid())
.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.eternalcode.economy.EconomyPermissionConstant;
import com.eternalcode.economy.account.Account;
import com.eternalcode.economy.account.AccountPaymentService;
import com.eternalcode.economy.config.implementation.messages.MessageConfig;
import com.eternalcode.economy.multification.NoticeService;
import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.command.Command;
Expand All @@ -17,13 +18,16 @@ public class AdminResetCommand {

private final AccountPaymentService accountPaymentService;
private final NoticeService noticeService;
private final MessageConfig messageConfig;

public AdminResetCommand(
AccountPaymentService accountPaymentService,
NoticeService noticeService
NoticeService noticeService,
MessageConfig messageConfig
) {
this.accountPaymentService = accountPaymentService;
this.noticeService = noticeService;
this.messageConfig = messageConfig;
}

@Execute
Expand All @@ -33,12 +37,14 @@ void execute(@Context CommandSender sender, @Arg Account receiver) {
this.noticeService.create()
.notice(notice -> notice.admin.reset)
.placeholder("{PLAYER}", receiver.name())
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.viewer(sender)
.send();

this.noticeService.create()
.notice(notice -> notice.player.reset)
.placeholder("{PLAYER}", receiver.name())
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.player(receiver.uuid())
.send();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.eternalcode.economy.EconomyPermissionConstant;
import com.eternalcode.economy.account.Account;
import com.eternalcode.economy.account.AccountPaymentService;
import com.eternalcode.economy.config.implementation.messages.MessageConfig;
import com.eternalcode.economy.format.DecimalFormatter;
import com.eternalcode.economy.multification.NoticeService;
import dev.rollczi.litecommands.annotations.argument.Arg;
Expand All @@ -11,25 +12,29 @@
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import jakarta.validation.constraints.Positive;
import java.math.BigDecimal;
import org.bukkit.command.CommandSender;

import java.math.BigDecimal;

@Command(name = "economy admin set")
@Permission(EconomyPermissionConstant.ADMIN_SET_PERMISSION)
public class AdminSetCommand {

private final AccountPaymentService accountPaymentService;
private final DecimalFormatter decimalFormatter;
private final NoticeService noticeService;
private final MessageConfig messageConfig;

public AdminSetCommand(
AccountPaymentService accountPaymentService,
DecimalFormatter decimalFormatter,
NoticeService noticeService
NoticeService noticeService,
MessageConfig messageConfig
) {
this.accountPaymentService = accountPaymentService;
this.decimalFormatter = decimalFormatter;
this.noticeService = noticeService;
this.messageConfig = messageConfig;
}

@Execute
Expand All @@ -40,13 +45,15 @@ void execute(@Context CommandSender sender, @Arg Account receiver, @Arg @Positiv
.notice(notice -> notice.admin.set)
.placeholder("{AMOUNT}", this.decimalFormatter.format(amount))
.placeholder("{PLAYER}", receiver.name())
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.viewer(sender)
.send();

this.noticeService.create()
.notice(notice -> notice.player.set)
.placeholder("{AMOUNT}", this.decimalFormatter.format(amount))
.placeholder("{PLAYER}", receiver.name())
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.player(receiver.uuid())
.send();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

import java.time.Duration;


public class CommandCooldownConfig extends OkaeriConfig {
@Comment("Duration of the cooldown (e.g. 5s, 10m, 1h)")
public Duration duration = Duration.ofSeconds(5);
@Comment("Permission for admins to bypass the cooldown")
public String bypassPermission = "eternaleconomy.player.pay.bypass";
public Notice message = Notice.builder()
.chat("<b><gradient:#00FFA2:#34AE00>ECONOMY</gradient></b> <dark_gray>➤</dark_gray> "
+ "<white>You must wait <gradient:#00FFA2:#34AE00>{TIME}</gradient> before using /pay again.")
.chat("{PREFIX}<white>You must wait <gradient:#00FFA2:#34AE00>{TIME}</gradient> before using /pay again.")
.actionBar("<gradient:#00FFA2:#34AE00>Wait {TIME}!</gradient>")
.build();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.eternalcode.economy.command.cooldown;

import com.eternalcode.economy.config.implementation.CommandsConfig;
import com.eternalcode.economy.config.implementation.messages.MessageConfig;
import com.eternalcode.economy.multification.NoticeService;
import dev.rollczi.litecommands.cooldown.CooldownState;
import dev.rollczi.litecommands.invocation.Invocation;
Expand All @@ -15,10 +16,16 @@ public class CommandCooldownMessage implements InvokedMessage<CommandSender, Obj

private final NoticeService noticeService;
private final CommandsConfig commandsConfig;
private final MessageConfig messageConfig;

public CommandCooldownMessage(NoticeService noticeService, CommandsConfig commandsConfig) {
public CommandCooldownMessage(
NoticeService noticeService,
CommandsConfig commandsConfig,
MessageConfig messageConfig
) {
this.noticeService = noticeService;
this.commandsConfig = commandsConfig;
this.messageConfig = messageConfig;
}

@Override
Expand All @@ -34,6 +41,7 @@ public Object get(Invocation<CommandSender> invocation, CooldownState cooldownSt
return noticeService.create()
.notice(notice -> cooldown.message)
.placeholder("{TIME}", formatted)
.placeholder("{PREFIX}", messageConfig.messagesPrefix)
.viewer(invocation.sender());
}

Expand Down
Loading