Skip to content

Commit

Permalink
Merge pull request #33 from dhiepp/master
Browse files Browse the repository at this point in the history
  • Loading branch information
PlayerNguyen authored Nov 23, 2021
2 parents 73ab88f + 0b1bea5 commit 2fd934f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 23 deletions.
17 changes: 10 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ dependencies {

}

//publishing {
// publications {
// maven(MavenPublication) {
// from(components.java)
// }
// }
//}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
}
}

processResources {
from(sourceSets.main.resources.srcDirs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ private boolean execute(CommandSender sender, ArrayList<String> args) {
String _target = args.get(0);
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
String _value = args.get(1);
// If this offline player has never played before and is not online
if (!target.hasPlayedBefore() && !target.isOnline()) {
// If this offline player is not online and does not have an account
if (!target.isOnline() && !getPlugin().getAccountDatabase().hasAccount(target.getUniqueId())) {
sender.sendMessage(
getMessageFormat()
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ private boolean exec(CommandSender sender, ArrayList<String> args) {
}
String _target = args.get(0);
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
// If this offline player has never played before and is not online
if (!target.hasPlayedBefore() && !target.isOnline()) {
// If this offline player is not online and does not have an account
if (!target.isOnline() && !getPlugin().getAccountDatabase().hasAccount(target.getUniqueId())) {
sender.sendMessage(
getMessageFormat()
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public boolean onPlayerCommand(Player player, ArrayList<String> args) {
String _target = args.get(0);
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
String _value = args.get(1);
// If this offline player has never played before and is not online
if (!target.hasPlayedBefore() && !target.isOnline()) {
// If this offline player is not online
if (!target.isOnline()) {
player.sendMessage(
getMessageFormat()
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ public boolean onPlayerCommand(Player player, ArrayList<String> args) {
Player tranSender = Bukkit.getPlayer(transaction.getPlayer());
Player tranReceiver = Bukkit.getPlayer(transaction.getTarget());
if (tranSender != null) {
String receiverName = "";
if (tranReceiver != null) receiverName = tranReceiver.getName();
tranSender.sendMessage(
getMessageFormat().format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.PAY_SUCCESS))
.replace("%who%", tranSender.getName())
.replace("%who%", receiverName)
.replace("%value%", getMessageFormat().numberFormat(transaction.getAmount()))
.replace("%currency%", getPlugin().getConfigurationLoader()
.getString(OptEcoConfiguration.CURRENCY_SYMBOL)
Expand All @@ -53,9 +55,11 @@ public boolean onPlayerCommand(Player player, ArrayList<String> args) {
this.getAccountManager().refresh(tranSender.getUniqueId());
}
if (tranReceiver != null) {
String senderName = "";
if (tranSender != null) senderName = tranSender.getName();
tranReceiver.sendMessage(
getMessageFormat().format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.PAY_SUCCESS_TARGET))
.replace("%who%", tranReceiver.getName())
.replace("%who%", senderName)
.replace("%value%", getMessageFormat().numberFormat(transaction.getAmount()))
.replace("%currency%", getPlugin().getConfigurationLoader()
.getString(OptEcoConfiguration.CURRENCY_SYMBOL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ private boolean execute(CommandSender sender, ArrayList<String> args) {
String _target = args.get(0);
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
String _value = args.get(1);
// If this offline player has never played before and is not online
if (!target.hasPlayedBefore() && !target.isOnline()) {
// If this offline player is not online and does not have an account
if (!target.isOnline() && !getPlugin().getAccountDatabase().hasAccount(target.getUniqueId())) {
sender.sendMessage(
getMessageFormat()
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))
Expand Down
22 changes: 16 additions & 6 deletions src/main/java/me/playernguyen/opteco/command/SubCommandTake.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ private boolean execute(CommandSender sender, ArrayList<String> args) {
String _target = args.get(0);
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
String _value = args.get(1);
// If this offline player has never played before and is not online
if (!target.hasPlayedBefore() && !target.isOnline()) {
// If this offline player is not online and does not have an account
if (!target.isOnline() && !getPlugin().getAccountDatabase().hasAccount(target.getUniqueId())) {
sender.sendMessage(
getMessageFormat()
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))
Expand All @@ -77,11 +77,21 @@ private boolean execute(CommandSender sender, ArrayList<String> args) {
);
return true;
}
// If sender don't have enough points
// if ((getPlugin().getAccountDatabase().getBalance(target.getUniqueId()) - Double.parseDouble(_value)) <
OptEcoCacheAccount optEcoCacheAccount = getAccountManager().get(target.getUniqueId());
double balance = optEcoCacheAccount.getBalance();

double balance;
// Player is online
if (target.isOnline()) {
OptEcoCacheAccount optEcoCacheAccount = getAccountManager().get(target.getUniqueId());
if (optEcoCacheAccount == null)
throw new NullPointerException("Cache player not found: " + target.getUniqueId());
balance = optEcoCacheAccount.getBalance();
}
//Player is not online
else {
balance = getPlugin().getAccountDatabase().getBalance(target.getUniqueId());
}

// If player doesn't have enough points
if ((balance - Double.parseDouble(_value)) <
getPlugin().getConfigurationLoader().getDouble(OptEcoConfiguration.MIN_BALANCE)) {
sender.sendMessage(
Expand Down

0 comments on commit 2fd934f

Please sign in to comment.