Skip to content

Commit

Permalink
Merged develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgrandt committed Dec 28, 2016
2 parents bee6bf3 + 0135005 commit 1c44437
Show file tree
Hide file tree
Showing 29 changed files with 805 additions and 202 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
v1.5.2

+ CHANGE: Changed output for when an error occurs during the reloading of configuration files
+ FIX: Baltop command now sorts balances in descending order

v1.5.1

+ CHANGE: Accounts configuration file now saves while the server is in the process of stopping
+ CHANGE: Changed the way display names are retrieved
+ CHANGE: Changed the way block ids are handled
+ CHANGE: Admin pay command can now be used to remove money (/adminpay [PLAYER] -[VALUE])
+ FIX: EconomyTransactionEvent no longer encounters a cast exception
+ FIX: Kills with bows are now properly handled

v 1.5.0

+ Balance Top command (/balancetop, /baltop)
Expand Down
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Contributing to Total Economy
Thanks for your interest in contributing to Total Economy. There are a few guidelines that I would like contributors to follow to make the process as easy as possible.

### Contributing Issues
* Be as descriptive as possible
* Include a complete error log
* Include pictures if possible

### Contributing Code
* Fork the repository
* Create a new branch from ‘develop'. Use slash notation (e.g. feature/feature-name)
* Types:
* feature
* fix
* update
* Follow the same format/style as the rest of the code
* Add comments for new functions:
``` java
/**
* Description of the function
*
* @param firstArg description of argument
* @param secondArg description of argument
* @return int player's balance
*/
```
* Test the change/addition and make sure nothing was accidently broken
* Make sure your commit message clearly describes the change/addition and includes the issue number if one exists
* Submit a pull request

### Git Commit Message
* Keep length of first line to 72 characters or less
* Use present tense (e.g. “Update” instead of “Updated”)
* Include any new commands/permissions/nodes/etc. and a description for each for easy addition to documentation. New line for each one.
3 changes: 2 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2016 Eric
Copyright (c) Eric Grandt <https://www.ericgrandt.com>
Copyright (c) contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All in one economy plugin for Minecraft and Sponge.
/job - Display information about your current job as well as a job list
/job set [jobName] - Set your job
/job toggle - Toggle job reward notifications on/off
/job info - Displays a paginated list of all items/blocks/mobs that reward exp/money for the player's current job
/setbalance [player] [amount] - Set a player's balance (/setbal)
/adminpay [player] [amount] - Pay a player without having money removed from your balance
/viewbalance [player] - View the balance of another player (/vbal)
Expand All @@ -20,10 +21,12 @@ All in one economy plugin for Minecraft and Sponge.
```
totaleconomy.command.pay
totaleconomy.command.balance
totaleconomy.command.job
totaleconomy.command.jobset
totaleconomy.command.jobtoggle
totaleconomy.command.job
totaleconomy.command.jobinfo
totaleconomy.command.setbalance
totaleconomy.command.adminpay
totaleconomy.command.viewbalance
```
totaleconomy.command.balancetop
```
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Aug 14 12:35:04 CDT 2016
#Thu Sep 29 10:15:08 CDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
57 changes: 42 additions & 15 deletions src/main/java/com/erigitic/commands/AdminPayCommand.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
* This file is part of Total Economy, licensed under the MIT License (MIT).
*
* Copyright (c) Eric Grandt <https://www.ericgrandt.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.erigitic.commands;

import com.erigitic.config.AccountManager;
Expand All @@ -20,9 +45,6 @@

import java.math.BigDecimal;

/**
* Created by Eric on 9/7/2015.
*/
public class AdminPayCommand implements CommandExecutor {
private Logger logger;
private TotalEconomy totalEconomy;
Expand All @@ -44,24 +66,29 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
Player recipient = args.<Player>getOne("player").get();

if (TotalEconomy.isNumeric(strAmount)) {
if (!strAmount.contains("-")) {
BigDecimal amount = new BigDecimal((String) args.getOne("amount").get()).setScale(2, BigDecimal.ROUND_DOWN);
TEAccount recipientAccount = (TEAccount) accountManager.getOrCreateAccount(recipient.getUniqueId()).get();
BigDecimal amount = new BigDecimal((String) args.getOne("amount").get()).setScale(2, BigDecimal.ROUND_DOWN);
TEAccount recipientAccount = (TEAccount) accountManager.getOrCreateAccount(recipient.getUniqueId()).get();
Text amountText = Text.of(defaultCurrency.format(amount).toPlain().replace("-", ""));

TransactionResult transactionResult = recipientAccount.deposit(accountManager.getDefaultCurrency(), amount, Cause.of(NamedCause.of("TotalEconomy", totalEconomy.getPluginContainer())));

TransactionResult transactionResult = recipientAccount.deposit(accountManager.getDefaultCurrency(), amount, Cause.of(NamedCause.of("TotalEconomy", totalEconomy.getPluginContainer())));
if (transactionResult.getResult() == ResultType.SUCCESS) {
if (!strAmount.contains("-")) {
src.sendMessage(Text.of(TextColors.GRAY, "You have sent ", TextColors.GOLD, amountText,
TextColors.GRAY, " to ", TextColors.GOLD, recipient.getName(), TextColors.GRAY, "."));

if (transactionResult.getResult() == ResultType.SUCCESS) {
src.sendMessage(Text.of(TextColors.GRAY, "You have sent ", TextColors.GOLD, defaultCurrency.format(amount),
TextColors.GRAY, " to ", TextColors.GOLD, recipient.getName()));
recipient.sendMessage(Text.of(TextColors.GRAY, "You have received ", TextColors.GOLD, amountText,
TextColors.GRAY, " from ", TextColors.GOLD, src.getName(), TextColors.GRAY, "."));
} else {
src.sendMessage(Text.of(TextColors.GRAY, "You have removed ", TextColors.GOLD, amountText,
TextColors.GRAY, " from ", TextColors.GOLD, recipient.getName(), "'s", TextColors.GRAY, " account."));

recipient.sendMessage(Text.of(TextColors.GRAY, "You have received ", TextColors.GOLD, defaultCurrency.format(amount),
TextColors.GRAY, " from ", TextColors.GOLD, src.getName(), "."));
recipient.sendMessage(Text.of(TextColors.GOLD, amountText, TextColors.GRAY, " has been removed from your account by ",
TextColors.GOLD, src.getName(), TextColors.GRAY, "."));
}
} else {
src.sendMessage(Text.of(TextColors.RED, "The amount must be positive."));
}
} else {
src.sendMessage(Text.of(TextColors.RED, "The amount must only contain numbers and a single decimal point if needed."));
src.sendMessage(Text.of(TextColors.RED, "The amount must be numeric."));
}

return CommandResult.success();
Expand Down
28 changes: 25 additions & 3 deletions src/main/java/com/erigitic/commands/BalanceCommand.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
* This file is part of Total Economy, licensed under the MIT License (MIT).
*
* Copyright (c) Eric Grandt <https://www.ericgrandt.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.erigitic.commands;

import com.erigitic.config.AccountManager;
Expand All @@ -14,9 +39,6 @@
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;

/**
* Created by Eric on 5/4/2015.
*/
public class BalanceCommand implements CommandExecutor {
private Logger logger;
private TotalEconomy totalEconomy;
Expand Down
49 changes: 38 additions & 11 deletions src/main/java/com/erigitic/commands/BalanceTopCommand.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
* This file is part of Total Economy, licensed under the MIT License (MIT).
*
* Copyright (c) Eric Grandt <https://www.ericgrandt.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.erigitic.commands;

import com.erigitic.config.AccountManager;
Expand All @@ -21,13 +46,9 @@
import org.spongepowered.api.text.format.TextColor;
import org.spongepowered.api.text.format.TextColors;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.math.BigDecimal;
import java.util.*;

/**
* Created by Eric on 6/2/2016.
*/
public class BalanceTopCommand implements CommandExecutor {
private Logger logger;
private TotalEconomy totalEconomy;
Expand All @@ -47,20 +68,26 @@ public BalanceTopCommand(TotalEconomy totalEconomy) {
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
ConfigurationNode accountNode = accountManager.getAccountConfig();
List<Text> accountBalances = new ArrayList<>();
Map<String, BigDecimal> accountBalancesMap = new HashMap<>();
Currency defaultCurrency = accountManager.getDefaultCurrency();

// TODO: Add customization to this (amount of accounts to show).
accountNode.getChildrenMap().keySet().forEach(accountUUID -> {
TEAccount playerAccount = (TEAccount) accountManager.getOrCreateAccount(UUID.fromString(accountUUID.toString())).get();
Currency defaultCurrency = accountManager.getDefaultCurrency();
Text playerName = playerAccount.getDisplayName();
Text playerBalance = defaultCurrency.format(playerAccount.getBalance(defaultCurrency));

accountBalances.add(Text.of(TextColors.GRAY, playerName.toPlain(), ": ", TextColors.GOLD, playerBalance.toPlain()));
accountBalancesMap.put(playerName.toPlain(), playerAccount.getBalance(defaultCurrency));
});

builder.reset().title(Text.of(TextColors.GOLD, "Top Balances"))
List<Map.Entry<String, BigDecimal>> unsortedList = new LinkedList<>(accountBalancesMap.entrySet());
unsortedList.sort((Map.Entry<String, BigDecimal> o1, Map.Entry<String, BigDecimal> o2) -> (o1.getValue()).compareTo(o2.getValue()));

Collections.reverse(unsortedList);

unsortedList.forEach(entry -> accountBalances.add(Text.of(TextColors.GRAY, entry.getKey(), ": ", TextColors.GOLD, defaultCurrency.format(entry.getValue()).toPlain())));

builder.title(Text.of(TextColors.GOLD, "Top Balances"))
.contents(accountBalances)
.padding(Text.of(TextColors.GRAY, "-"))
.sendTo(src);

return CommandResult.success();
Expand Down
28 changes: 25 additions & 3 deletions src/main/java/com/erigitic/commands/JobCommand.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
* This file is part of Total Economy, licensed under the MIT License (MIT).
*
* Copyright (c) Eric Grandt <https://www.ericgrandt.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.erigitic.commands;

import com.erigitic.config.AccountManager;
Expand All @@ -12,9 +37,6 @@
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;

/**
* Created by Eric on 5/5/2015.
*/
public class JobCommand implements CommandExecutor {
private AccountManager accountManager;
private TEJobs teJobs;
Expand Down
35 changes: 31 additions & 4 deletions src/main/java/com/erigitic/commands/JobInfoCommand.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
* This file is part of Total Economy, licensed under the MIT License (MIT).
*
* Copyright (c) Eric Grandt <https://www.ericgrandt.com>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.erigitic.commands;

import com.erigitic.config.AccountManager;
Expand All @@ -21,9 +46,6 @@
import java.util.ArrayList;
import java.util.List;

/**
* Created by Eric on 11/3/2015.
*/
public class JobInfoCommand implements CommandExecutor {
private TEJobs teJobs;
private AccountManager accountManager;
Expand Down Expand Up @@ -79,9 +101,14 @@ private List<Text> getJobValues(String jobName, String nodeName, String title) {

jobsConfig.getNode(jobName, nodeName).getChildrenMap().keySet().forEach(value -> {
if (value instanceof String) {
String valueFormatted = WordUtils.capitalize(((String) value).replaceAll("_", " "));
String expReward = jobsConfig.getNode(jobName, nodeName, value, "expreward").getString();
String moneyReward = jobsConfig.getNode(jobName, nodeName, value, "pay").getString();
String valueFormatted;

if (((String) value).contains(":"))
value = ((String) value).split(":")[1];

valueFormatted = WordUtils.capitalize(((String) value).replaceAll("_", " "));

jobValues.add(Text.of(TextColors.LIGHT_PURPLE, WordUtils.capitalize(nodeName + ": "), TextColors.GRAY,
valueFormatted, " | ", TextColors.GREEN, expReward, " exp", TextColors.GRAY, " | ", TextColors.GOLD,
Expand Down
Loading

0 comments on commit 1c44437

Please sign in to comment.