Skip to content

Commit

Permalink
Add configuration to enable/disable GUI alternatives to commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Sep 8, 2024
1 parent 0215947 commit 62dcd90
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions .changelog/0.1.3.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Added new permissions to shared accounts; TRANSFER_OWNERSHIP and DELETE
- Added ability for messages from some money commands to be sent to players on different servers through bungee/redis/velocity
- Added $pos placeholder for TopEntry message.
- Added configuration to enabled/disable GUI alternatives to the chat-based commands.

## Internals
- Various improvements to the module system
Expand Down
3 changes: 3 additions & 0 deletions Core/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ Core:
#Configuration if money action commands, such as give/take/set require individual permissions.
LimitCurrency: false

#Should the commands in TNE use their GUI alternatives?
GUIAlternatives: true

#Configurations relating to balance commands.
Balance:

Expand Down
2 changes: 1 addition & 1 deletion Core/resources/data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Data:
#All configurations relating to the database
Database:

#The database type to use. Current options: MySQL, Maria, YAML.
#The database type to use. Current options: maria-outdated, MySQL, Maria, YAML.
#You may use maria-outdated for MariaDB versions less than 10.7.0 or MySQL versions less than 8.0.0.
Type: "yaml"

Expand Down
5 changes: 5 additions & 0 deletions Core/src/net/tnemc/core/command/MoneyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public static void onBalance(CmdSource<?> sender, Currency currency, String regi
}
}

if(sender.player().isPresent() && MainConfig.yaml().getBoolean("Core.Commands.GUIAlternatives", true)) {
sender.player().get().inventory().openMenu(sender.player().get(), "my_bal");
return;
}

final Optional<Account> account = BaseCommand.account(sender, "balance");
if(account.isEmpty()) {
final MessageData data = new MessageData("Messages.General.NoPlayer");
Expand Down
8 changes: 7 additions & 1 deletion Core/src/net/tnemc/core/command/TransactionCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.tnemc.core.TNECore;
import net.tnemc.core.account.Account;
import net.tnemc.core.account.PlayerAccount;
import net.tnemc.core.config.MainConfig;
import net.tnemc.core.manager.TransactionManager;
import net.tnemc.core.transaction.Receipt;
import net.tnemc.core.transaction.history.AwayHistory;
Expand All @@ -44,6 +45,11 @@ public class TransactionCommand {
public static void away(CmdSource<?> sender, int page) {
final Optional<Account> account = BaseCommand.account(sender, "away");

if(sender.player().isPresent() && MainConfig.yaml().getBoolean("Core.Commands.GUIAlternatives", true)) {
sender.player().get().inventory().openMenu(sender.player().get(), "transaction_away");
return;
}

if(account.isEmpty()) {
sender.message(new MessageData("Messages.Transaction.AwayNone"));
return;
Expand Down Expand Up @@ -75,7 +81,7 @@ public static void away(CmdSource<?> sender, int page) {

//[page:#] [world:name/all] [player:name]
public static void history(CmdSource<?> sender, int page, String region, Account account) {
if(sender.player().isPresent()) {
if(sender.player().isPresent() && MainConfig.yaml().getBoolean("Core.Commands.GUIAlternatives", true)) {
sender.player().get().inventory().openMenu(sender.player().get(), "transaction_menu");
return;
}
Expand Down

0 comments on commit 62dcd90

Please sign in to comment.