Move related utility methods to dependency class, part 3

This commit is contained in:
PikaMug 2019-11-05 18:36:32 -05:00
parent 0eb9c36386
commit cb02c965a7
5 changed files with 33 additions and 25 deletions

View File

@ -19,6 +19,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import me.blackvein.quests.util.DenizenAPI;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.WorldGuardAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import net.citizensnpcs.api.CitizensPlugin;
@ -223,6 +224,25 @@ public class Dependencies {
return (permission != null);
}
public String getCurrency(boolean plural) {
if (getVaultEconomy() == null) {
return Lang.get("money");
}
if (plural) {
if (getVaultEconomy().currencyNamePlural().trim().isEmpty()) {
return Lang.get("money");
} else {
return getVaultEconomy().currencyNamePlural();
}
} else {
if (getVaultEconomy().currencyNameSingular().trim().isEmpty()) {
return Lang.get("money");
} else {
return getVaultEconomy().currencyNameSingular();
}
}
}
public boolean runDenizenScript(String scriptName, Quester quester) {
return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester);
}

View File

@ -3395,24 +3395,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
}
}
/**
* @deprecated
*/
public String getCurrency(boolean plural) {
if (depends.getVaultEconomy() == null) {
return Lang.get("money");
}
if (plural) {
if (depends.getVaultEconomy().currencyNamePlural().trim().isEmpty()) {
return Lang.get("money");
} else {
return depends.getVaultEconomy().currencyNamePlural();
}
} else {
if (depends.getVaultEconomy().currencyNameSingular().trim().isEmpty()) {
return Lang.get("money");
} else {
return depends.getVaultEconomy().currencyNameSingular();
}
}
return depends.getCurrency(plural);
}
public static boolean removeItem(Inventory inventory, ItemStack is) {

View File

@ -388,18 +388,18 @@ public class CmdExecutor implements CommandExecutor {
.getVaultEconomy().getBalance(quester.getOfflinePlayer()) >= reqs.getMoney()) {
if (reqs.getMoney() == 1) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " "
+ plugin.getCurrency(false));
+ plugin.getDependencies().getCurrency(false));
} else {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " "
+ plugin.getCurrency(true));
+ plugin.getDependencies().getCurrency(true));
}
} else {
if (reqs.getMoney() == 1) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " "
+ plugin.getCurrency(false));
+ plugin.getDependencies().getCurrency(false));
} else {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " "
+ plugin.getCurrency(true));
+ plugin.getDependencies().getCurrency(true));
}
}
}

View File

@ -159,8 +159,8 @@ public class RequirementsPrompt extends NumericPrompt {
} else {
int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY);
return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyReq + " "
+ (moneyReq > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY
+ ")";
+ (moneyReq > 1 ? plugin.getDependencies().getCurrency(true)
: plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")";
}
case 2:
if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) {

View File

@ -133,8 +133,8 @@ public class RewardsPrompt extends NumericPrompt {
} else {
int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY);
return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyRew + " "
+ (moneyRew > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY
+ ")";
+ (moneyRew > 1 ? plugin.getDependencies().getCurrency(true)
: plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")";
}
case 2:
if (context.getSessionData(CK.REW_QUEST_POINTS) == null) {