mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-12 18:31:32 +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:
parent
d16fc7e50d
commit
9d69d17741
@ -70,14 +70,13 @@ public enum CMIEnchantment {
|
||||
break;
|
||||
}
|
||||
} catch (Exception | Error e) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break;
|
||||
try {
|
||||
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break;
|
||||
}
|
||||
} catch (Exception | Error ex) {
|
||||
}
|
||||
} catch (Exception | Error e) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,43 +92,34 @@ public enum CMIEnchantment {
|
||||
|
||||
// now checks for subnames
|
||||
if (enchantment == null) {
|
||||
for (Enchantment one : Enchantment.values()) {
|
||||
en: for (Enchantment one : Enchantment.values()) {
|
||||
for (String subs : this.subName) {
|
||||
try {
|
||||
if (one.getName().toLowerCase().replace("_", "").contains(subs.toLowerCase().replace("_", ""))) {
|
||||
enchantment = one;
|
||||
break;
|
||||
break en;
|
||||
}
|
||||
} catch (Exception | Error e) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break;
|
||||
try {
|
||||
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break en;
|
||||
}
|
||||
} catch (Exception | Error ex) {
|
||||
}
|
||||
} catch (Exception | Error e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (enchantment != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enchantment == null) {
|
||||
for (Enchantment one : Enchantment.values()) {
|
||||
o: for (Enchantment one : Enchantment.values()) {
|
||||
for (String subs : this.subName) {
|
||||
if (one.toString().toLowerCase().replace("_", "").contains(subs.toLowerCase().replace("_", ""))) {
|
||||
enchantment = one;
|
||||
break;
|
||||
break o;
|
||||
}
|
||||
}
|
||||
|
||||
if (enchantment != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,14 +118,14 @@ public class PlayerManager {
|
||||
}
|
||||
|
||||
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);
|
||||
if (jPlayer.getUniqueId() != null && !playersUUIDCache.containsKey(jPlayer.getUniqueId()))
|
||||
playersUUIDCache.put(jPlayer.getUniqueId(), 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);
|
||||
if (jPlayer.getUniqueId() != null && !playersUUID.containsKey(jPlayer.getUniqueId()))
|
||||
playersUUID.put(jPlayer.getUniqueId(), jPlayer);
|
||||
|
@ -39,7 +39,7 @@ import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
|
||||
public class JobsPlayer {
|
||||
// the player the object belongs to
|
||||
private String userName;
|
||||
private String userName = "Unknown";
|
||||
// progression of the player in each job
|
||||
public UUID playerUUID;
|
||||
public ArrayList<JobProgression> progression = new ArrayList<>();
|
||||
@ -80,7 +80,7 @@ public class JobsPlayer {
|
||||
private PlayerPoints pointsData = null;
|
||||
|
||||
public JobsPlayer(String userName) {
|
||||
this.userName = userName;
|
||||
this.userName = userName == null ? "Unknown" : userName;
|
||||
}
|
||||
|
||||
public PlayerPoints getPointsData() {
|
||||
|
@ -15,7 +15,7 @@ public class PlayerInfo {
|
||||
private JobsPlayer player;
|
||||
|
||||
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.uuid = uuid;
|
||||
this.seen = seen;
|
||||
|
Loading…
Reference in New Issue
Block a user