mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
parent
beac6c059c
commit
f61bfab4c4
@ -105,11 +105,14 @@ public class GuiManager {
|
||||
if (Jobs.getGCManager().ShowTotalWorkers)
|
||||
lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
|
||||
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus)
|
||||
if (job.getBonus() < 0)
|
||||
lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1));
|
||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
|
||||
double bonus = job.getBonus();
|
||||
|
||||
if (bonus < 0)
|
||||
lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (bonus * 100) * -1));
|
||||
else
|
||||
lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
|
||||
lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (bonus * 100)));
|
||||
}
|
||||
|
||||
if (job.getDescription().isEmpty()) {
|
||||
lore.addAll(job.getFullDescription());
|
||||
@ -127,6 +130,7 @@ public class GuiManager {
|
||||
|
||||
for (ActionType actionType : ActionType.values()) {
|
||||
List<JobInfo> info = job.getJobInfo(actionType);
|
||||
|
||||
if (info != null && !info.isEmpty()) {
|
||||
lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
}
|
||||
@ -210,7 +214,7 @@ public class GuiManager {
|
||||
ItemStack guiItem = job.getGuiItem();
|
||||
|
||||
int level = prog != null ? prog.getLevel() : 1,
|
||||
numjobs = jPlayer.getJobProgression().size(),
|
||||
numjobs = jPlayer.progression.size(),
|
||||
nextButton = Jobs.getGCManager().getJobsGUINextButton(),
|
||||
backButton = Jobs.getGCManager().getJobsGUIBackButton();
|
||||
|
||||
@ -363,7 +367,7 @@ public class GuiManager {
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
|
||||
|
||||
int numjobs = jPlayer.getJobProgression().size();
|
||||
int numjobs = jPlayer.progression.size();
|
||||
int level = jPlayer.getJobProgression(job) != null ? jPlayer.getJobProgression(job).getLevel() : 1;
|
||||
|
||||
ItemStack guiItem = job.getGuiItem();
|
||||
|
@ -935,9 +935,8 @@ public class ConfigManager {
|
||||
|
||||
for (String jobKey : jobsSection.getKeys(false)) {
|
||||
// Ignore example job
|
||||
if (jobKey.equalsIgnoreCase(EXAMPLEJOBINTERNALNAME)) {
|
||||
if (jobKey.equalsIgnoreCase(EXAMPLEJOBINTERNALNAME))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Translating unicode
|
||||
jobKey = StringEscapeUtils.unescapeJava(jobKey);
|
||||
@ -1020,8 +1019,10 @@ public class ConfigManager {
|
||||
displayMethod = DisplayMethod.NONE;
|
||||
}
|
||||
|
||||
boolean isNoneJob = jobKey.equalsIgnoreCase("none");
|
||||
|
||||
Parser maxExpEquation;
|
||||
String maxExpEquationInput = jobKey.equalsIgnoreCase("None") ? "0" : jobSection.getString("leveling-progression-equation", "0");
|
||||
String maxExpEquationInput = isNoneJob ? "0" : jobSection.getString("leveling-progression-equation", "0");
|
||||
try {
|
||||
maxExpEquation = new Parser(maxExpEquationInput);
|
||||
// test equation
|
||||
@ -1050,7 +1051,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
Parser expEquation;
|
||||
String expEquationInput = jobKey.equalsIgnoreCase("None") ? "0" : jobSection.getString("experience-progression-equation", "0");
|
||||
String expEquationInput = isNoneJob ? "0" : jobSection.getString("experience-progression-equation", "0");
|
||||
try {
|
||||
expEquation = new Parser(expEquationInput);
|
||||
// test equation
|
||||
@ -1565,7 +1566,7 @@ public class ConfigManager {
|
||||
job.setJobInfo(actionType, jobInfo);
|
||||
}
|
||||
|
||||
if (jobKey.equalsIgnoreCase("none"))
|
||||
if (isNoneJob)
|
||||
Jobs.setNoneJob(job);
|
||||
else {
|
||||
return job;
|
||||
@ -1576,8 +1577,6 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
private double updateValue(CurrencyType type, double amount) {
|
||||
Double mult = Jobs.getGCManager().getGeneralMulti(type);
|
||||
amount += (amount * mult);
|
||||
return amount;
|
||||
return amount += (amount * Jobs.getGCManager().getGeneralMulti(type));
|
||||
}
|
||||
}
|
||||
|
@ -1113,8 +1113,8 @@ public class GeneralConfigManager {
|
||||
return JobsGUISkipAmount;
|
||||
}
|
||||
|
||||
public Double getGeneralMulti(CurrencyType type) {
|
||||
return generalMulti.get(type);
|
||||
public double getGeneralMulti(CurrencyType type) {
|
||||
return generalMulti.getOrDefault(type, 0D);
|
||||
}
|
||||
|
||||
public ConfigReader getConfig() {
|
||||
|
@ -46,10 +46,6 @@ public class NameTranslatorManager {
|
||||
case BREW:
|
||||
case FISH:
|
||||
case STRIPLOGS:
|
||||
String fallbackMaterialName = Arrays.stream(materialName.split("\\s|:"))
|
||||
.map(word -> word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase())
|
||||
.collect(Collectors.joining(" ")); // returns capitalized word (from this -> To This)
|
||||
|
||||
materialName = materialName.replace(" ", "");
|
||||
|
||||
CMIMaterial mat = CMIMaterial.get(materialName);
|
||||
@ -75,15 +71,21 @@ public class NameTranslatorManager {
|
||||
if (meta != null && !meta.isEmpty()) {
|
||||
mat = CMIMaterial.get(materialName + ":" + meta);
|
||||
nameLs = listOfNames.get(mat);
|
||||
|
||||
if (nameLs == null) {
|
||||
mat = CMIMaterial.get(materialName.replace(" ", ""));
|
||||
nameLs = listOfNames.get(mat);
|
||||
|
||||
NameList nameMeta = listOfNames.get(CMIMaterial.get(meta.replace(" ", "")));
|
||||
if (nameLs != null && nameMeta != null) {
|
||||
return nameLs + ":" + nameMeta;
|
||||
}
|
||||
|
||||
if (mat == CMIMaterial.NONE) {
|
||||
String fallbackMaterialName = Arrays.stream(materialName.split("\\s|:"))
|
||||
.map(word -> word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase())
|
||||
.collect(Collectors.joining(" ")); // returns capitalized word (from this -> To This)
|
||||
|
||||
return fallbackMaterialName;
|
||||
}
|
||||
|
||||
@ -94,6 +96,7 @@ public class NameTranslatorManager {
|
||||
if (id > 0 && meta != null && !meta.isEmpty()) {
|
||||
mat = CMIMaterial.get(id + ":" + meta);
|
||||
nameLs = listOfNames.get(mat);
|
||||
|
||||
if (nameLs == null) {
|
||||
return mat.getName();
|
||||
}
|
||||
@ -106,14 +109,19 @@ public class NameTranslatorManager {
|
||||
case TAME:
|
||||
for (NameList one : listOfEntities) {
|
||||
String ids = one.getId() + ":" + one.getMeta();
|
||||
if (!one.getMeta().isEmpty() && ids.equalsIgnoreCase(id + ":" + meta) && !one.getId().equals("0")) {
|
||||
|
||||
if (!one.getMeta().isEmpty() && !one.getId().equals("0") && ids.equalsIgnoreCase(id + ":" + meta)) {
|
||||
return one.getName();
|
||||
}
|
||||
|
||||
ids = one.getId();
|
||||
if (ids.equalsIgnoreCase(Integer.toString(id)) && !one.getId().equals("0")) {
|
||||
|
||||
if (!one.getId().equals("0") && ids.equalsIgnoreCase(Integer.toString(id))) {
|
||||
return one.getName();
|
||||
}
|
||||
|
||||
ids = one.getMinecraftName();
|
||||
|
||||
if (ids.equalsIgnoreCase(name)) {
|
||||
return one.getName();
|
||||
}
|
||||
@ -122,15 +130,18 @@ public class NameTranslatorManager {
|
||||
case ENCHANT:
|
||||
String mName = materialName;
|
||||
String level = "";
|
||||
|
||||
if (mName.contains(":")) {
|
||||
String[] split = materialName.split(":", 2);
|
||||
mName = split[0];
|
||||
level = ":" + split[1];
|
||||
}
|
||||
|
||||
NameList nameInfo = listOfEnchants.get(mName.toLowerCase().replace("_", ""));
|
||||
if (nameInfo != null) {
|
||||
return nameInfo.getMinecraftName() + level;
|
||||
}
|
||||
|
||||
break;
|
||||
case SHEAR:
|
||||
for (NameList one : listOfColors) {
|
||||
@ -145,8 +156,10 @@ public class NameTranslatorManager {
|
||||
return fallbackColorName;
|
||||
case MMKILL:
|
||||
NameList got = listOfMMEntities.get(materialName.toLowerCase());
|
||||
|
||||
if (got != null && got.getName() != null)
|
||||
return got.getName();
|
||||
|
||||
return HookManager.getMythicManager() == null ? materialName : HookManager.getMythicManager().getDisplayName(materialName);
|
||||
default:
|
||||
break;
|
||||
|
@ -384,6 +384,7 @@ public class ShopManager {
|
||||
for (int k = 0; k < performCommands.size(); k++) {
|
||||
performCommands.set(k, CMIChatColor.translate(performCommands.get(k)));
|
||||
}
|
||||
sItem.setCommands(performCommands);
|
||||
|
||||
ConfigurationSection itemsSection = nameSection.getConfigurationSection("GiveItems");
|
||||
if (itemsSection != null) {
|
||||
@ -449,7 +450,7 @@ public class ShopManager {
|
||||
}
|
||||
|
||||
items.add(new JobItems(oneItemName.toLowerCase(), id == null ? CMIMaterial.STONE : CMIMaterial.get(id), amount, name, giveLore,
|
||||
enchants, new BoostMultiplier(), new ArrayList<Job>(), potionData, null));
|
||||
enchants, new BoostMultiplier(), new ArrayList<>(), potionData, null));
|
||||
}
|
||||
sItem.setitems(items);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class BoostMultiplier implements Cloneable {
|
||||
}
|
||||
|
||||
public BoostMultiplier add(double amount) {
|
||||
if (amount > 0) {
|
||||
if (amount != 0) {
|
||||
for (CurrencyType one : CurrencyType.values()) {
|
||||
map.put(one, amount);
|
||||
}
|
||||
|
@ -984,7 +984,9 @@ public class JobsPlayer {
|
||||
return false;
|
||||
|
||||
for (QuestProgression one : qpl.values()) {
|
||||
if (one.getQuest() != null && one.getQuest().getConfigName().equalsIgnoreCase(questName))
|
||||
Quest quest = one.getQuest();
|
||||
|
||||
if (quest != null && quest.getConfigName().equalsIgnoreCase(questName))
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1001,13 +1003,17 @@ public class JobsPlayer {
|
||||
return ls;
|
||||
|
||||
for (QuestProgression prog : qpl.values()) {
|
||||
if (prog.isEnded() || prog.getQuest() == null)
|
||||
if (prog.isEnded())
|
||||
continue;
|
||||
|
||||
for (Map<String, QuestObjective> oneAction : prog.getQuest().getObjectives().values()) {
|
||||
Quest quest = prog.getQuest();
|
||||
if (quest == null)
|
||||
continue;
|
||||
|
||||
for (Map<String, QuestObjective> oneAction : quest.getObjectives().values()) {
|
||||
for (QuestObjective oneObjective : oneAction.values()) {
|
||||
if (type == null || type.name().equals(oneObjective.getAction().name())) {
|
||||
ls.add(prog.getQuest().getConfigName().toLowerCase());
|
||||
ls.add(quest.getConfigName().toLowerCase());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1023,8 +1029,10 @@ public class JobsPlayer {
|
||||
|
||||
public void resetQuests(List<QuestProgression> quests) {
|
||||
for (QuestProgression oneQ : quests) {
|
||||
if (oneQ.getQuest() != null) {
|
||||
Map<String, QuestProgression> map = qProgression.remove(oneQ.getQuest().getJob().getName());
|
||||
Quest quest = oneQ.getQuest();
|
||||
|
||||
if (quest != null) {
|
||||
Map<String, QuestProgression> map = qProgression.remove(quest.getJob().getName());
|
||||
|
||||
if (map != null) {
|
||||
map.clear();
|
||||
@ -1044,17 +1052,23 @@ public class JobsPlayer {
|
||||
}
|
||||
|
||||
public void getNewQuests(Job job) {
|
||||
java.util.Optional.ofNullable(qProgression.get(job.getName())).ifPresent(Map::clear);
|
||||
Map<String, QuestProgression> prog = qProgression.get(job.getName());
|
||||
if (prog != null) {
|
||||
prog.clear();
|
||||
qProgression.put(job.getName(), prog);
|
||||
}
|
||||
}
|
||||
|
||||
public void replaceQuest(Quest quest) {
|
||||
Map<String, QuestProgression> orProg = qProgression.get(quest.getJob().getName());
|
||||
Job job = quest.getJob();
|
||||
Map<String, QuestProgression> orProg = qProgression.get(job.getName());
|
||||
|
||||
Quest q = quest.getJob().getNextQuest(getQuestNameList(quest.getJob(), null), getJobProgression(quest.getJob()).getLevel());
|
||||
Quest q = job.getNextQuest(getQuestNameList(job, null), getJobProgression(job).getLevel());
|
||||
if (q == null) {
|
||||
for (JobProgression one : progression) {
|
||||
if (one.getJob().isSame(quest.getJob()))
|
||||
if (one.getJob().isSame(job))
|
||||
continue;
|
||||
|
||||
q = one.getJob().getNextQuest(getQuestNameList(one.getJob(), null), getJobProgression(one.getJob()).getLevel());
|
||||
if (q != null)
|
||||
break;
|
||||
@ -1064,10 +1078,12 @@ public class JobsPlayer {
|
||||
if (q == null)
|
||||
return;
|
||||
|
||||
Map<String, QuestProgression> prog = qProgression.get(q.getJob().getName());
|
||||
Job qJob = q.getJob();
|
||||
|
||||
Map<String, QuestProgression> prog = qProgression.get(qJob.getName());
|
||||
if (prog == null) {
|
||||
prog = new HashMap<>();
|
||||
qProgression.put(q.getJob().getName(), prog);
|
||||
qProgression.put(qJob.getName(), prog);
|
||||
}
|
||||
|
||||
if (q.getConfigName().equals(quest.getConfigName()))
|
||||
@ -1078,7 +1094,7 @@ public class JobsPlayer {
|
||||
if (prog.containsKey(confName))
|
||||
return;
|
||||
|
||||
if (q.getJob() != quest.getJob() && prog.size() >= q.getJob().getMaxDailyQuests())
|
||||
if (!qJob.isSame(job) && prog.size() >= qJob.getMaxDailyQuests())
|
||||
return;
|
||||
|
||||
if (orProg != null) {
|
||||
@ -1130,8 +1146,9 @@ public class JobsPlayer {
|
||||
continue;
|
||||
|
||||
QuestProgression qp = new QuestProgression(q);
|
||||
if (qp.getQuest() != null)
|
||||
g.put(qp.getQuest().getConfigName().toLowerCase(), qp);
|
||||
Quest quest = qp.getQuest();
|
||||
if (quest != null)
|
||||
g.put(quest.getConfigName().toLowerCase(), qp);
|
||||
|
||||
if (g.size() >= job.getMaxDailyQuests())
|
||||
break;
|
||||
@ -1277,8 +1294,8 @@ public class JobsPlayer {
|
||||
private Integer questSignUpdateShed;
|
||||
|
||||
public void addDoneQuest(final Job job) {
|
||||
this.doneQuests++;
|
||||
this.setSaved(false);
|
||||
doneQuests++;
|
||||
setSaved(false);
|
||||
|
||||
if (questSignUpdateShed == null) {
|
||||
questSignUpdateShed = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
|
@ -25,7 +25,11 @@ public class QuestProgression {
|
||||
}
|
||||
|
||||
public Quest getQuest() {
|
||||
return (quest == null || quest.getJob() == null) ? null : quest.getJob().getQuest(quest.getConfigName());
|
||||
if (quest == null)
|
||||
return null;
|
||||
|
||||
Job job = quest.getJob();
|
||||
return job == null ? null : job.getQuest(quest.getConfigName());
|
||||
}
|
||||
|
||||
public void setQuest(Quest quest) {
|
||||
|
@ -34,7 +34,7 @@ public class JobsConnectionPool {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public synchronized void closeConnection() {
|
||||
public void closeConnection() {
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.closeConnection();
|
||||
|
@ -505,8 +505,12 @@ public abstract class JobsDAO {
|
||||
public abstract boolean drop(String table);
|
||||
|
||||
public boolean isConnected() {
|
||||
if (pool == null)
|
||||
return false;
|
||||
|
||||
try {
|
||||
return pool != null && pool.getConnection() != null && !pool.getConnection().isClosed();
|
||||
JobsConnection conn = pool.getConnection();
|
||||
return conn != null && !conn.isClosed();
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
}
|
||||
@ -2657,7 +2661,7 @@ public abstract class JobsDAO {
|
||||
/**
|
||||
* Close all active database handles
|
||||
*/
|
||||
public synchronized void closeConnections() {
|
||||
public void closeConnections() {
|
||||
pool.closeConnection();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user