Fix remaining Configurate nullability issues (#4370)

This commit is contained in:
Josh Roy 2021-08-02 05:32:41 -07:00 committed by GitHub
parent 082950cc18
commit aaddb2af1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -621,7 +621,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
public Map<Pattern, Long> getCommandCooldowns() { public Map<Pattern, Long> getCommandCooldowns() {
final Map<Pattern, Long> map = new HashMap<>(); final Map<Pattern, Long> map = new HashMap<>();
for (final CommandCooldown c : getCooldownsList()) { for (final CommandCooldown c : getCooldownsList()) {
if (c == null) { if (c == null || c.isIncomplete()) {
// stupid solution to stupid problem // stupid solution to stupid problem
continue; continue;
} }
@ -632,7 +632,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
public Date getCommandCooldownExpiry(final String label) { public Date getCommandCooldownExpiry(final String label) {
for (CommandCooldown cooldown : getCooldownsList()) { for (CommandCooldown cooldown : getCooldownsList()) {
if (cooldown == null) { if (cooldown == null || cooldown.isIncomplete()) {
// stupid solution to stupid problem // stupid solution to stupid problem
continue; continue;
} }
@ -661,7 +661,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
return false; // false for no modification return false; // false for no modification
} }
if (getCooldownsList().removeIf(cooldown -> cooldown.pattern().equals(pattern))) { if (getCooldownsList().removeIf(cooldown -> cooldown != null && !cooldown.isIncomplete() && cooldown.pattern().equals(pattern))) {
save(); save();
return true; return true;
} }

View File

@ -32,6 +32,9 @@ public class Commandunlimited extends EssentialsCommand {
user.sendMessage(getList(target)); user.sendMessage(getList(target));
} else if (args[0].equalsIgnoreCase("clear")) { } else if (args[0].equalsIgnoreCase("clear")) {
for (final Material m : new HashSet<>(target.getUnlimited())) { for (final Material m : new HashSet<>(target.getUnlimited())) {
if (m == null) {
continue;
}
toggleUnlimited(user, target, m.toString()); toggleUnlimited(user, target, m.toString());
} }
} else { } else {
@ -48,6 +51,9 @@ public class Commandunlimited extends EssentialsCommand {
} }
final StringJoiner joiner = new StringJoiner(", "); final StringJoiner joiner = new StringJoiner(", ");
for (final Material material : items) { for (final Material material : items) {
if (material == null) {
continue;
}
joiner.add(material.toString().toLowerCase(Locale.ENGLISH).replace("_", "")); joiner.add(material.toString().toLowerCase(Locale.ENGLISH).replace("_", ""));
} }
output.append(joiner.toString()); output.append(joiner.toString());

View File

@ -22,6 +22,9 @@ public class MaterialTypeSerializer extends ScalarSerializer<Material> {
@Override @Override
protected Object serialize(Material item, Predicate<Class<?>> typeSupported) { protected Object serialize(Material item, Predicate<Class<?>> typeSupported) {
if (item == null) {
return null;
}
return item.name(); return item.name();
} }
} }