1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-02-14 19:31:33 +01:00

Fixed issue when the itembonus not works

Closes #745

(NBTs are shit)

- Fixed NPEs when player name are null in some cases
This commit is contained in:
montlikadani 2020-04-18 11:44:59 +02:00
parent d16fc7e50d
commit 9d69d17741
4 changed files with 21 additions and 31 deletions

View File

@ -70,14 +70,13 @@ public enum CMIEnchantment {
break; break;
} }
} catch (Exception | Error e) { } catch (Exception | Error e) {
} try {
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
try { enchantment = one;
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) { break;
enchantment = one; }
break; } catch (Exception | Error ex) {
} }
} catch (Exception | Error e) {
} }
} }
@ -93,43 +92,34 @@ public enum CMIEnchantment {
// now checks for subnames // now checks for subnames
if (enchantment == null) { if (enchantment == null) {
for (Enchantment one : Enchantment.values()) { en: for (Enchantment one : Enchantment.values()) {
for (String subs : this.subName) { for (String subs : this.subName) {
try { try {
if (one.getName().toLowerCase().replace("_", "").contains(subs.toLowerCase().replace("_", ""))) { if (one.getName().toLowerCase().replace("_", "").contains(subs.toLowerCase().replace("_", ""))) {
enchantment = one; enchantment = one;
break; break en;
} }
} catch (Exception | Error e) { } catch (Exception | Error e) {
} try {
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
try { enchantment = one;
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) { break en;
enchantment = one; }
break; } catch (Exception | Error ex) {
} }
} catch (Exception | Error e) {
} }
} }
if (enchantment != null) {
break;
}
} }
} }
if (enchantment == null) { if (enchantment == null) {
for (Enchantment one : Enchantment.values()) { o: for (Enchantment one : Enchantment.values()) {
for (String subs : this.subName) { for (String subs : this.subName) {
if (one.toString().toLowerCase().replace("_", "").contains(subs.toLowerCase().replace("_", ""))) { if (one.toString().toLowerCase().replace("_", "").contains(subs.toLowerCase().replace("_", ""))) {
enchantment = one; enchantment = one;
break; break o;
} }
} }
if (enchantment != null) {
break;
}
} }
} }
} }

View File

@ -118,14 +118,14 @@ public class PlayerManager {
} }
public void addPlayerToCache(JobsPlayer jPlayer) { public void addPlayerToCache(JobsPlayer jPlayer) {
if (jPlayer.getName() != null && !playersCache.containsKey(jPlayer.getName().toLowerCase())) if (!playersCache.containsKey(jPlayer.getName().toLowerCase()))
playersCache.put(jPlayer.getName().toLowerCase(), jPlayer); playersCache.put(jPlayer.getName().toLowerCase(), jPlayer);
if (jPlayer.getUniqueId() != null && !playersUUIDCache.containsKey(jPlayer.getUniqueId())) if (jPlayer.getUniqueId() != null && !playersUUIDCache.containsKey(jPlayer.getUniqueId()))
playersUUIDCache.put(jPlayer.getUniqueId(), jPlayer); playersUUIDCache.put(jPlayer.getUniqueId(), jPlayer);
} }
public void addPlayer(JobsPlayer jPlayer) { public void addPlayer(JobsPlayer jPlayer) {
if (jPlayer.getName() != null && !players.containsKey(jPlayer.getName().toLowerCase())) if (!players.containsKey(jPlayer.getName().toLowerCase()))
players.put(jPlayer.getName().toLowerCase(), jPlayer); players.put(jPlayer.getName().toLowerCase(), jPlayer);
if (jPlayer.getUniqueId() != null && !playersUUID.containsKey(jPlayer.getUniqueId())) if (jPlayer.getUniqueId() != null && !playersUUID.containsKey(jPlayer.getUniqueId()))
playersUUID.put(jPlayer.getUniqueId(), jPlayer); playersUUID.put(jPlayer.getUniqueId(), jPlayer);

View File

@ -39,7 +39,7 @@ import com.gamingmesh.jobs.stuff.TimeManage;
public class JobsPlayer { public class JobsPlayer {
// the player the object belongs to // the player the object belongs to
private String userName; private String userName = "Unknown";
// progression of the player in each job // progression of the player in each job
public UUID playerUUID; public UUID playerUUID;
public ArrayList<JobProgression> progression = new ArrayList<>(); public ArrayList<JobProgression> progression = new ArrayList<>();
@ -80,7 +80,7 @@ public class JobsPlayer {
private PlayerPoints pointsData = null; private PlayerPoints pointsData = null;
public JobsPlayer(String userName) { public JobsPlayer(String userName) {
this.userName = userName; this.userName = userName == null ? "Unknown" : userName;
} }
public PlayerPoints getPointsData() { public PlayerPoints getPointsData() {

View File

@ -15,7 +15,7 @@ public class PlayerInfo {
private JobsPlayer player; private JobsPlayer player;
public PlayerInfo(String name, int id, UUID uuid, Long seen, Integer questsDone, String questProgression) { public PlayerInfo(String name, int id, UUID uuid, Long seen, Integer questsDone, String questProgression) {
this.name = name; this.name = name == null ? "Unknown" : name;
this.id = id; this.id = id;
this.uuid = uuid; this.uuid = uuid;
this.seen = seen; this.seen = seen;