1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

points -> pts

Same formating for info in chat and GUI for payment
Decimal value limits
This commit is contained in:
Zrips 2018-02-01 14:54:06 +02:00
parent f79526f711
commit 23d32d0765
8 changed files with 70 additions and 29 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>Jobs</groupId>
<artifactId>jobs</artifactId>
<version>4.3.0</version>
<version>4.3.1</version>
<name>Jobs</name>
<url>http://maven.apache.org</url>
<properties>

View File

@ -192,22 +192,36 @@ public class GuiManager {
int y = 1;
for (int z = 0; z < info.size(); z++) {
String itemName = info.get(z).getName().toLowerCase().replace('_', ' ');
itemName = Character.toUpperCase(itemName.charAt(0)) + itemName.substring(1);
itemName = Jobs.getNameTranslatorManager().Translate(itemName, info.get(z));
itemName = org.bukkit.ChatColor.translateAlternateColorCodes('&', itemName);
String itemName = info.get(z).getRealisticName();
double income = info.get(z).getIncome(level, numjobs);
income = income + (income * boost.getFinal(CurrencyType.MONEY));
ChatColor incomeColor = income >= 0 ? ChatColor.GREEN : ChatColor.DARK_RED;
income = boost.getFinalAmount(CurrencyType.MONEY, income);
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
double xp = info.get(z).getExperience(level, numjobs);
xp = xp + (xp * boost.getFinal(CurrencyType.EXP));
ChatColor xpColor = xp >= 0 ? ChatColor.YELLOW : ChatColor.GRAY;
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
String xpString = String.format("%.2fxp", xp);
double points = info.get(z).getPoints(level, numjobs);
points = boost.getFinalAmount(CurrencyType.POINTS, points);
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
Lore.add(ChatColor.translateAlternateColorCodes('&', "&7" + itemName + " " + xpColor + xpString + " " + incomeColor + Jobs.getEconomy().format(income)));
if (income == 0D && points == 0D && xp == 0D)
continue;
String val = "";
if (income != 0.0)
val += Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor + String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income));
if (points != 0.0)
val += Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor + String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points));
if (xp != 0.0)
val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor + String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp));
Lore.add(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", itemName) + val);
if (y >= 10) {
y = 1;

View File

@ -138,7 +138,7 @@ public class JobsCommands implements CommandExecutor {
cmdString = cmdString.replace("[arguments]", " " + Jobs.getLanguage().getMessage(key));
} else {
cmdString = cmdString.replace("[arguments]", "");
}
}
return cmdString;
}
@ -448,10 +448,7 @@ public class JobsCommands implements CommandExecutor {
List<JobInfo> jobInfo = job.getJobInfo(type);
for (JobInfo info : jobInfo) {
String materialName = info.getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().Translate(materialName, info);
materialName = org.bukkit.ChatColor.translateAlternateColorCodes('&', materialName);
String materialName = info.getRealisticName();
double income = info.getIncome(level, numjobs);
@ -478,13 +475,13 @@ public class JobsCommands implements CommandExecutor {
message.append(" -> ");
if (income != 0.0)
message.append(Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor + String.format("%.2f", income)));
message.append(Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor + String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income)));
if (points != 0.0)
message.append(Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor + String.format("%.2f", points)));
message.append(Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor + String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points)));
if (xp != 0.0)
message.append(Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor + String.format("%.2f", xp)));
message.append(Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor + String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp)));
if (info.getFromLevel() > 1 && info.getUntilLevel() != -1)
message.append(Jobs.getLanguage().getMessage("command.info.help.levelRange", "%levelFrom%", info.getFromLevel(), "%levelUntil%", info.getUntilLevel()));

View File

@ -103,6 +103,8 @@ public class GeneralConfigManager {
EmptyServerAcountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin;
private String DecimalPlacesMoney, DecimalPlacesExp, DecimalPlacesPoints;
public ItemStack guiBackButton;
public ItemStack guiFiller;
@ -451,6 +453,12 @@ public class GeneralConfigManager {
"When set to true staff will be informed about new Jobs plugin version", "You need to have jobs.versioncheck permission node");
ShowNewVersion = c.get("Optimizations.NewVersion", true);
c.getW().addComment("Optimizations.DecimalPlaces.Money",
"Decimal places to be shown");
DecimalPlacesMoney = "%." + c.get("Optimizations.DecimalPlaces.Money", 2) + "f";
DecimalPlacesExp = "%." + c.get("Optimizations.DecimalPlaces.Exp", 2) + "f";
DecimalPlacesPoints = "%." + c.get("Optimizations.DecimalPlaces.Points", 2) + "f";
c.getW().addComment("Optimizations.DBCleaning.Jobs.Use",
"Warning!!! before enabling this feature, please make data base backup, just in case there will be some issues with data base cleaning",
"When set to true, jobs data base will be cleaned on each startup to avoid having not used jobs",
@ -944,4 +952,17 @@ public class GeneralConfigManager {
public int getBrowseAmountToShow() {
return BrowseAmountToShow;
}
public String getDecimalPlacesMoney() {
return DecimalPlacesMoney;
}
public String getDecimalPlacesExp() {
return DecimalPlacesExp;
}
public String getDecimalPlacesPoints() {
return DecimalPlacesPoints;
}
}

View File

@ -333,7 +333,7 @@ public class LanguageManager {
c.get("command.info.help.levelUntil", " &a(until &e%levelUntil% &alevel)");
c.get("command.info.help.money", " &2%money%\u0024");
c.get("command.info.help.points", " &6%points%points");
c.get("command.info.help.points", " &6%points%pts");
c.get("command.info.help.exp", " &e%exp%xp");
c.get("command.info.gui.pickjob", "&ePick your job!");
@ -436,7 +436,7 @@ public class LanguageManager {
c.get("command.quests.help.info", "List available quests");
c.get("command.quests.help.args", "(playername)");
c.get("command.quests.error.noquests", "There are no quests");
c.get("command.quests.error.noquests", "&cThere are no quests");
c.get("command.quests.toplineseparator", "&7*********************** &6[playerName]&2(&f[questsDone]&2) &7***********************");
c.get("command.quests.output.completed", "&2 !Completed!&r ");
c.get("command.quests.output.questLine", "[progress] &7[questName] &f[done]&7/&8[required]");

View File

@ -24,7 +24,7 @@ import com.gamingmesh.jobs.resources.jfep.Parser;
public class JobInfo {
private ActionType actionType;
private int id;
private String meta;
private String meta;
private String name;
private double baseIncome, baseXp, basePoints;
private Parser moneyEquation, xpEquation, pointsEquation;
@ -77,6 +77,14 @@ public class JobInfo {
return this.name;
}
public String getRealisticName() {
String materialName = getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().Translate(materialName, this);
materialName = org.bukkit.ChatColor.translateAlternateColorCodes('&', materialName);
return materialName;
}
public int getId() {
return this.id;
}

View File

@ -31,7 +31,7 @@ public class ActionBar {
private Class<?> ChatMessageclz;
private Class<?> sub;
private Object[] consts;
public ActionBar() {
try {
version = Jobs.getVersionCheckManager().getVersion();
@ -58,7 +58,7 @@ public class ActionBar {
}
public void ShowActionBar(BufferedPayment payment) {
if (!payment.getOfflinePlayer().isOnline())
return;
@ -78,11 +78,12 @@ public class ActionBar {
if (abp != null && show) {
String Message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main");
if (payment.getAmount() != 0D)
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format("%.2f", payment.getAmount()));
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format(Jobs.getGCManager().getDecimalPlacesMoney(), payment
.getAmount()));
if (payment.getPoints() != 0D)
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format("%.2f", payment.getPoints()));
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format(Jobs.getGCManager().getDecimalPlacesPoints(), payment.getPoints()));
if (payment.getExp() != 0D)
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format("%.2f", payment.getExp()));
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format(Jobs.getGCManager().getDecimalPlacesExp(), payment.getExp()));
send(abp, ChatColor.GREEN + Message);
}
}
@ -94,7 +95,7 @@ public class ActionBar {
if (receivingPacket == null)
return;
if (version.isLower(Version.v1_8_R1) || !(receivingPacket instanceof Player)) {
receivingPacket.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
return;

View File

@ -1,7 +1,7 @@
name: Jobs
description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.Jobs
version: 4.3.0
version: 4.3.1
website: https://www.spigotmc.org/resources/jobs-reborn.4216/
author: phrstbrn
softdepend: [Vault, iConomy, MythicMobs, McMMO, WorldGuard, MyPet]