From fb5a520f1a0b09a30b90fd8387308a7b873978c4 Mon Sep 17 00:00:00 2001 From: Zrips Date: Mon, 14 Nov 2022 14:52:38 +0200 Subject: [PATCH] Translating enchant material names --- .../com/gamingmesh/jobs/commands/list/bp.java | 1 - .../jobs/config/BlockProtectionManager.java | 5 ---- .../jobs/config/NameTranslatorManager.java | 24 ++++++++++++++++--- .../jobs/container/BoostCounter.java | 20 ++++++++-------- .../jobs/container/JobProgression.java | 14 +++++------ .../gamingmesh/jobs/container/JobsPlayer.java | 12 ++++------ .../gamingmesh/jobs/economy/PaymentData.java | 4 ++-- 7 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/bp.java b/src/main/java/com/gamingmesh/jobs/commands/list/bp.java index fafde225..d91e8cb0 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/bp.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/bp.java @@ -16,7 +16,6 @@ import com.gamingmesh.jobs.container.DBAction; import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Version.Version; diff --git a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java index 2997b709..6ab32bde 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java @@ -125,11 +125,6 @@ public class BlockProtectionManager { } locations.put(v, Bp); - -// if (locations.size() > 10) { -// Jobs.getJobsDAO().saveBlockProtection(loc.getWorld().getName(), new HashMap(locations)); -// locations.clear(); -// } } public void saveCache() { diff --git a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java index 65033e49..2ff15cac 100644 --- a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -35,7 +35,7 @@ public class NameTranslatorManager { private final Map listOfEnchants = new HashMap<>(); private final Map listOfMMEntities = new HashMap<>(); private final Map listOfPotionEffects = new HashMap<>(); - + public String translate(String materialName, JobInfo info) { return translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName()); } @@ -71,11 +71,11 @@ public class NameTranslatorManager { if (nameLs != null && !mat.isNone()) { if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Util.getPotionByName(meta) != null) { - + NameList record = listOfPotionEffects.get(meta.toLowerCase().replace("_", "")); if (record != null) meta = record.getMinecraftName(); - + return nameLs.getName() + ":" + meta; } @@ -156,6 +156,24 @@ public class NameTranslatorManager { level = ":" + split[1]; } + mat = CMIMaterial.get(mName); + nameLs = listOfNames.get(mat); + + if (nameLs != null && !mat.isNone()) { + if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Util.getPotionByName(meta) != null) { + + NameList record = listOfPotionEffects.get(meta.toLowerCase().replace("_", "")); + if (record != null) + meta = record.getMinecraftName(); + + return nameLs.getName() + ":" + meta; + } + + if (name != null && !name.isEmpty()) { + return nameLs.getName(); + } + } + NameList nameInfo = listOfEnchants.get(mName.toLowerCase().replace("_", "")); if (nameInfo != null) { return nameInfo.getMinecraftName() + level; diff --git a/src/main/java/com/gamingmesh/jobs/container/BoostCounter.java b/src/main/java/com/gamingmesh/jobs/container/BoostCounter.java index a74bafd3..60ba4fd9 100644 --- a/src/main/java/com/gamingmesh/jobs/container/BoostCounter.java +++ b/src/main/java/com/gamingmesh/jobs/container/BoostCounter.java @@ -3,31 +3,31 @@ package com.gamingmesh.jobs.container; public class BoostCounter { private CurrencyType type; private double boost; - private Long calculatedon; + private long calculatedon; - public BoostCounter(CurrencyType type, double boost, Long calculatedon) { - this.type = type; - this.boost = boost; - this.calculatedon = calculatedon; + public BoostCounter(CurrencyType type, double boost, long calculatedon) { + this.type = type; + this.boost = boost; + this.calculatedon = calculatedon; } public CurrencyType getType() { - return type; + return type; } public long getTime() { - return calculatedon; + return calculatedon; } public double getBoost() { - return boost; + return boost; } public void setTime(long calculatedon) { - this.calculatedon = calculatedon; + this.calculatedon = calculatedon; } public void setBoost(double boost) { - this.boost = boost; + this.boost = boost; } } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java index ff5b258b..6cce09dc 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java @@ -31,10 +31,10 @@ public class JobProgression { private Job job; private JobsPlayer jPlayer; private double experience; - private Double lastExperience; + private double lastExperience = 0; private int level; private transient int maxExperience = -1; - private Long leftOn = null; + private long leftOn = 0; public JobProgression(Job job, JobsPlayer jPlayer, int level, double experience) { this.job = job; @@ -258,7 +258,7 @@ public class JobProgression { } public boolean canRejoin() { - if (leftOn == null || leftOn + job.getRejoinCd() < System.currentTimeMillis()) + if (leftOn == 0 || leftOn + job.getRejoinCd() < System.currentTimeMillis()) return true; org.bukkit.entity.Player player = jPlayer != null ? jPlayer.getPlayer() : null; @@ -266,14 +266,14 @@ public class JobProgression { } public String getRejoinTimeMessage() { - return leftOn == null ? "" : CMITimeManager.to24hourShort(leftOn + job.getRejoinCd() - System.currentTimeMillis()); + return leftOn == 0 ? "" : CMITimeManager.to24hourShort(leftOn + job.getRejoinCd() - System.currentTimeMillis()); } - public Double getLastExperience() { - return lastExperience == null ? 0D : lastExperience; + public double getLastExperience() { + return lastExperience; } - public void setLastExperience(Double lastExperience) { + public void setLastExperience(double lastExperience) { this.lastExperience = lastExperience; } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 21c449ed..f0ec0501 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -39,13 +39,11 @@ import com.gamingmesh.jobs.api.JobsLevelUpEvent; import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes; import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.economy.PaymentData; -import com.gamingmesh.jobs.stuff.TimeManage; import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Equations.Parser; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Time.CMITimeManager; public class JobsPlayer { @@ -84,10 +82,10 @@ public class JobsPlayer { private Map logList = new HashMap<>(); - private Long seen = System.currentTimeMillis(); + private long seen = System.currentTimeMillis(); private Map permissionsCache; - private Long lastPermissionUpdate = -1L; + private long lastPermissionUpdate = -1L; private final Map> qProgression = new HashMap<>(); private int doneQuests = 0; @@ -937,11 +935,11 @@ public class JobsPlayer { this.isSaved = isSaved; } - public Long getSeen() { + public long getSeen() { return seen; } - public void setSeen(Long seen) { + public void setSeen(long seen) { this.seen = seen; } @@ -957,7 +955,7 @@ public class JobsPlayer { permissionsCache.put(permission, state); } - public Long getLastPermissionUpdate() { + public long getLastPermissionUpdate() { return lastPermissionUpdate; } diff --git a/src/main/java/com/gamingmesh/jobs/economy/PaymentData.java b/src/main/java/com/gamingmesh/jobs/economy/PaymentData.java index b6df755c..c73702f4 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/PaymentData.java +++ b/src/main/java/com/gamingmesh/jobs/economy/PaymentData.java @@ -7,7 +7,7 @@ import com.gamingmesh.jobs.container.CurrencyType; public class PaymentData { - private Long lastAnnouced = 0L; + private long lastAnnouced = 0L; private final java.util.Map payments = new HashMap<>(); @@ -53,7 +53,7 @@ public class PaymentData { return data == null ? 0D : (int) (data.getAmount() * 100) / 100D; } - public Long getLastAnnounced() { + public long getLastAnnounced() { return lastAnnouced; }