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() {
final Map<Pattern, Long> map = new HashMap<>();
for (final CommandCooldown c : getCooldownsList()) {
if (c == null) {
if (c == null || c.isIncomplete()) {
// stupid solution to stupid problem
continue;
}
@ -632,7 +632,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
public Date getCommandCooldownExpiry(final String label) {
for (CommandCooldown cooldown : getCooldownsList()) {
if (cooldown == null) {
if (cooldown == null || cooldown.isIncomplete()) {
// stupid solution to stupid problem
continue;
}
@ -661,7 +661,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
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();
return true;
}

View file

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

View file

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