Skip to content

Commit 2fd934f

Browse files
authored
Merge pull request #33 from dhiepp/master
2 parents 73ab88f + 0b1bea5 commit 2fd934f

7 files changed

Lines changed: 40 additions & 23 deletions

File tree

build.gradle

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ dependencies {
6262

6363
}
6464

65-
//publishing {
66-
// publications {
67-
// maven(MavenPublication) {
68-
// from(components.java)
69-
// }
70-
// }
71-
//}
65+
publishing {
66+
publications {
67+
mavenJava(MavenPublication) {
68+
from components.java
69+
}
70+
}
71+
repositories {
72+
mavenLocal()
73+
}
74+
}
7275

7376
processResources {
7477
from(sourceSets.main.resources.srcDirs) {

src/main/java/me/playernguyen/opteco/command/SubCommandAdd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ private boolean execute(CommandSender sender, ArrayList<String> args) {
5151
String _target = args.get(0);
5252
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
5353
String _value = args.get(1);
54-
// If this offline player has never played before and is not online
55-
if (!target.hasPlayedBefore() && !target.isOnline()) {
54+
// If this offline player is not online and does not have an account
55+
if (!target.isOnline() && !getPlugin().getAccountDatabase().hasAccount(target.getUniqueId())) {
5656
sender.sendMessage(
5757
getMessageFormat()
5858
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))

src/main/java/me/playernguyen/opteco/command/SubCommandCheck.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ private boolean exec(CommandSender sender, ArrayList<String> args) {
6161
}
6262
String _target = args.get(0);
6363
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
64-
// If this offline player has never played before and is not online
65-
if (!target.hasPlayedBefore() && !target.isOnline()) {
64+
// If this offline player is not online and does not have an account
65+
if (!target.isOnline() && !getPlugin().getAccountDatabase().hasAccount(target.getUniqueId())) {
6666
sender.sendMessage(
6767
getMessageFormat()
6868
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))

src/main/java/me/playernguyen/opteco/command/SubCommandPay.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public boolean onPlayerCommand(Player player, ArrayList<String> args) {
4848
String _target = args.get(0);
4949
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
5050
String _value = args.get(1);
51-
// If this offline player has never played before and is not online
52-
if (!target.hasPlayedBefore() && !target.isOnline()) {
51+
// If this offline player is not online
52+
if (!target.isOnline()) {
5353
player.sendMessage(
5454
getMessageFormat()
5555
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))

src/main/java/me/playernguyen/opteco/command/SubCommandPayConfirm.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ public boolean onPlayerCommand(Player player, ArrayList<String> args) {
4141
Player tranSender = Bukkit.getPlayer(transaction.getPlayer());
4242
Player tranReceiver = Bukkit.getPlayer(transaction.getTarget());
4343
if (tranSender != null) {
44+
String receiverName = "";
45+
if (tranReceiver != null) receiverName = tranReceiver.getName();
4446
tranSender.sendMessage(
4547
getMessageFormat().format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.PAY_SUCCESS))
46-
.replace("%who%", tranSender.getName())
48+
.replace("%who%", receiverName)
4749
.replace("%value%", getMessageFormat().numberFormat(transaction.getAmount()))
4850
.replace("%currency%", getPlugin().getConfigurationLoader()
4951
.getString(OptEcoConfiguration.CURRENCY_SYMBOL)
@@ -53,9 +55,11 @@ public boolean onPlayerCommand(Player player, ArrayList<String> args) {
5355
this.getAccountManager().refresh(tranSender.getUniqueId());
5456
}
5557
if (tranReceiver != null) {
58+
String senderName = "";
59+
if (tranSender != null) senderName = tranSender.getName();
5660
tranReceiver.sendMessage(
5761
getMessageFormat().format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.PAY_SUCCESS_TARGET))
58-
.replace("%who%", tranReceiver.getName())
62+
.replace("%who%", senderName)
5963
.replace("%value%", getMessageFormat().numberFormat(transaction.getAmount()))
6064
.replace("%currency%", getPlugin().getConfigurationLoader()
6165
.getString(OptEcoConfiguration.CURRENCY_SYMBOL)

src/main/java/me/playernguyen/opteco/command/SubCommandSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ private boolean execute(CommandSender sender, ArrayList<String> args) {
5050
String _target = args.get(0);
5151
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
5252
String _value = args.get(1);
53-
// If this offline player has never played before and is not online
54-
if (!target.hasPlayedBefore() && !target.isOnline()) {
53+
// If this offline player is not online and does not have an account
54+
if (!target.isOnline() && !getPlugin().getAccountDatabase().hasAccount(target.getUniqueId())) {
5555
sender.sendMessage(
5656
getMessageFormat()
5757
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))

src/main/java/me/playernguyen/opteco/command/SubCommandTake.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ private boolean execute(CommandSender sender, ArrayList<String> args) {
5252
String _target = args.get(0);
5353
OfflinePlayer target = Bukkit.getOfflinePlayer(_target);
5454
String _value = args.get(1);
55-
// If this offline player has never played before and is not online
56-
if (!target.hasPlayedBefore() && !target.isOnline()) {
55+
// If this offline player is not online and does not have an account
56+
if (!target.isOnline() && !getPlugin().getAccountDatabase().hasAccount(target.getUniqueId())) {
5757
sender.sendMessage(
5858
getMessageFormat()
5959
.format(getPlugin().getLanguageLoader().getLanguage(OptEcoLanguage.VAR_PLAYER_NOT_FOUND))
@@ -77,11 +77,21 @@ private boolean execute(CommandSender sender, ArrayList<String> args) {
7777
);
7878
return true;
7979
}
80-
// If sender don't have enough points
81-
// if ((getPlugin().getAccountDatabase().getBalance(target.getUniqueId()) - Double.parseDouble(_value)) <
82-
OptEcoCacheAccount optEcoCacheAccount = getAccountManager().get(target.getUniqueId());
83-
double balance = optEcoCacheAccount.getBalance();
8480

81+
double balance;
82+
// Player is online
83+
if (target.isOnline()) {
84+
OptEcoCacheAccount optEcoCacheAccount = getAccountManager().get(target.getUniqueId());
85+
if (optEcoCacheAccount == null)
86+
throw new NullPointerException("Cache player not found: " + target.getUniqueId());
87+
balance = optEcoCacheAccount.getBalance();
88+
}
89+
//Player is not online
90+
else {
91+
balance = getPlugin().getAccountDatabase().getBalance(target.getUniqueId());
92+
}
93+
94+
// If player doesn't have enough points
8595
if ((balance - Double.parseDouble(_value)) <
8696
getPlugin().getConfigurationLoader().getDouble(OptEcoConfiguration.MIN_BALANCE)) {
8797
sender.sendMessage(

0 commit comments

Comments
 (0)