1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +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) {
for (CMIMaterial one : CMIMaterial.values()) {
if (one.getMaterial() == null)
continue;
if (one.getId() == id) {
if (one.getMaterial() != null && one.getId() == id) {
return one;
}
}

View File

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

View File

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

View File

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

View File

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