1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-20 07:01:22 +01:00

Lets avoid generating all known materials in old versions

This changes will not generating 1.16 materials in 1.8 servers in the translatable file
This commit is contained in:
montlikadani 2020-11-30 10:27:09 +01:00
parent ec2d4a1846
commit e8eae4d4e2
5 changed files with 43 additions and 34 deletions

View File

@ -1419,9 +1419,7 @@ public enum CMIMaterial {
public static CMIMaterial get(int id) { public static CMIMaterial get(int id) {
for (CMIMaterial one : CMIMaterial.values()) { for (CMIMaterial one : CMIMaterial.values()) {
if (one.getMaterial() == null) if (one.getMaterial() != null && one.getId() == id) {
continue;
if (one.getId() == id) {
return one; return one;
} }
} }

View File

@ -28,9 +28,8 @@ public class ItemManager {
static { static {
for (CMIMaterial one : CMIMaterial.values()) { for (CMIMaterial one : CMIMaterial.values()) {
if (one == null)
continue;
one.updateMaterial(); one.updateMaterial();
Material mat = one.getMaterial(); Material mat = one.getMaterial();
if (mat == null) { if (mat == null) {
continue; continue;
@ -48,8 +47,11 @@ public class ItemManager {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
mojangName = mojangName == null ? mat.toString().replace("_", "").replace(" ", "").toLowerCase() if (mojangName == null) {
: mojangName.replace("_", "").replace(" ", "").toLowerCase(); mojangName = mat.toString();
}
mojangName = mojangName.replace("_", "").replace(" ", "").toLowerCase();
if (one.isCanHavePotionType()) { if (one.isCanHavePotionType()) {
for (Potion p : Potion.values()) { for (Potion p : Potion.values()) {

View File

@ -557,22 +557,28 @@ public class Jobs extends JavaPlugin {
boolean found = false; boolean found = false;
t: for (JobProgression prog : jPlayer.getJobProgression()) { for (JobProgression prog : jPlayer.getJobProgression()) {
for (JobInfo info : jPlayer.getJobProgression(prog.getJob()).getJob().getJobInfo(type)) { for (JobInfo info : jPlayer.getJobProgression(prog.getJob()).getJob().getJobInfo(type)) {
if (info.getActionType() == type) { if (info.getActionType() == type) {
found = true; found = true;
break t; break;
} }
} }
if (!found) {
for (Quest q : prog.getJob().getQuests()) { for (Quest q : prog.getJob().getQuests()) {
if (q != null && q.hasAction(type)) { if (q != null && q.hasAction(type)) {
found = true; found = true;
break t; break;
} }
} }
} }
if (found) {
break;
}
}
return found; return found;
} }

View File

@ -149,7 +149,7 @@ public class PermissionManager {
double temp = Double.parseDouble(permission.getKey().replace(perm, "")); double temp = Double.parseDouble(permission.getKey().replace(perm, ""));
if (cumulative) if (cumulative)
amount += temp; amount += temp;
else if (amount == 0D || allowMinus || temp > amount) else if (allowMinus || temp > amount)
amount = temp; amount = temp;
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
// Should be ignored // Should be ignored

View File

@ -4,8 +4,10 @@ import java.io.File;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIEnchantment; import com.gamingmesh.jobs.CMILib.CMIEnchantment;
@ -289,16 +291,16 @@ public class NameTranslatorManager {
ConfigReader c = new ConfigReader(f); ConfigReader c = new ConfigReader(f);
c.copyDefaults(true); c.copyDefaults(true);
for (CMIMaterial one : CMIMaterial.values()) { for (Material one : Material.values()) {
if (one.getMaterial() == null) CMIMaterial mat = CMIMaterial.get(one);
if (mat == null || mat.getMaterial() == null)
continue; continue;
String n = one.getLegacyId() + (one.getLegacyData() == -1 ? "" : ":" + one.getLegacyData()); String n = mat.getLegacyId() + (mat.getLegacyData() == -1 ? "" : ":" + mat.getLegacyData());
String name = null; String name = null;
if (c.getC().isString("ItemList." + one.toString())) { if (c.getC().isString("ItemList." + mat.toString())) {
name = c.getC().getString("ItemList." + one.toString()); name = c.getC().getString("ItemList." + mat.toString());
} }
if (name == null && c.getC().isConfigurationSection("ItemList." + n)) { if (name == null && c.getC().isConfigurationSection("ItemList." + n)) {
@ -306,59 +308,60 @@ public class NameTranslatorManager {
} }
if (name == null) { if (name == null) {
n = one.getLegacyId() + ":" + one.getLegacyData(); n = mat.getLegacyId() + ":" + mat.getLegacyData();
if (c.getC().isConfigurationSection("ItemList." + n)) { if (c.getC().isConfigurationSection("ItemList." + n)) {
name = c.getC().getString("ItemList." + n + ".Name"); name = c.getC().getString("ItemList." + n + ".Name");
} }
} }
if (name == null) { if (name == null) {
n = String.valueOf(one.getLegacyId()); n = String.valueOf(mat.getLegacyId());
if (c.getC().isConfigurationSection("ItemList." + n)) { if (c.getC().isConfigurationSection("ItemList." + n)) {
name = c.getC().getString("ItemList." + n + ".Name"); name = c.getC().getString("ItemList." + n + ".Name");
} }
} }
if (name == null) { if (name == null) {
n = String.valueOf(one.getId()); n = String.valueOf(mat.getId());
if (c.getC().isConfigurationSection("ItemList." + n)) { if (c.getC().isConfigurationSection("ItemList." + n)) {
name = c.getC().getString("ItemList." + n + ".Name"); name = c.getC().getString("ItemList." + n + ".Name");
} }
} }
if (name == null) { if (name == null) {
n = one.getLegacyId() + ":" + one.getLegacyData() + "-" + one.getBukkitName(); n = mat.getLegacyId() + ":" + mat.getLegacyData() + "-" + mat.getBukkitName();
if (c.getC().isString("ItemList." + n)) { if (c.getC().isString("ItemList." + n)) {
name = c.getC().getString("ItemList." + n); name = c.getC().getString("ItemList." + n);
} }
} }
if (name == null) { if (name == null) {
n = String.valueOf(one.getLegacyId()) + "-" + one.getBukkitName(); n = String.valueOf(mat.getLegacyId()) + "-" + mat.getBukkitName();
if (c.getC().isString("ItemList." + n)) { if (c.getC().isString("ItemList." + n)) {
name = c.getC().getString("ItemList." + n); name = c.getC().getString("ItemList." + n);
} }
} }
if (name == null) { if (name == null) {
n = String.valueOf(one.getId()) + "-" + one.getBukkitName(); n = String.valueOf(mat.getId()) + "-" + mat.getBukkitName();
if (c.getC().isString("ItemList." + n)) { if (c.getC().isString("ItemList." + n)) {
name = c.getC().getString("ItemList." + n); name = c.getC().getString("ItemList." + n);
} }
} }
if (name == null) { if (name == null) {
name = one.getName(); name = mat.getName();
} }
c.get("ItemList." + one.toString(), name); c.get("ItemList." + mat.toString(), name);
} }
for (CMIEntityType one : CMIEntityType.values()) { for (EntityType one : EntityType.values()) {
if (!one.isAlive()) CMIEntityType ent = CMIEntityType.getByType(one);
if (ent == null || !ent.isAlive())
continue; continue;
String n = String.valueOf(one.getId()); String n = String.valueOf(ent.getId());
String name = null; String name = null;
@ -367,17 +370,17 @@ public class NameTranslatorManager {
} }
if (name == null) { if (name == null) {
n += "-" + one.toString(); n += "-" + ent.toString();
if (c.getC().isConfigurationSection("EntityList." + n)) { if (c.getC().isConfigurationSection("EntityList." + n)) {
name = c.getC().getString("EntityList." + n); name = c.getC().getString("EntityList." + n);
} }
} }
if (name == null) { if (name == null) {
name = one.getName(); name = ent.getName();
} }
c.get("EntityList." + one.getId() + "-" + one.toString(), name); c.get("EntityList." + ent.getId() + "-" + ent.toString(), name);
} }
for (Enchantment one : Enchantment.values()) { for (Enchantment one : Enchantment.values()) {