Don't spit NPEs on NonNull values

This commit is contained in:
Hannes Greule 2020-12-09 22:45:47 +01:00
parent 3ca8a94419
commit 3e99f90eb1
4 changed files with 9 additions and 7 deletions

View File

@ -401,9 +401,9 @@ public abstract class Command {
public int getMatch(String[] args, Command cmd, PlotPlayer<?> player) {
String perm = cmd.getPermission();
HashSet<String> desc = new HashSet<>();
int count = cmd.getAliases().stream().filter(alias -> alias.startsWith(args[0]))
.mapToInt(alias -> 5).sum();
HashSet<String> desc = new HashSet<>();
Collections.addAll(desc, cmd.getDescription().getComponent(player).split(" "));
for (String arg : args) {
if (perm.startsWith(arg)) {

View File

@ -25,8 +25,6 @@
*/
package com.plotsquared.core.configuration.caption;
import com.plotsquared.core.configuration.caption.LocaleHolder;
import javax.annotation.Nonnull;
/**

View File

@ -42,7 +42,11 @@ public class LocalizedCaptionMap implements CaptionMap {
}
@Override @Nonnull public String getMessage(@Nonnull final TranslatableCaption caption) {
return this.captions.get(caption);
String message = this.captions.get(caption);
if (message == null) {
throw new NoSuchCaptionException(caption);
}
return message;
}
@Override @Nonnull public String getMessage(@Nonnull final TranslatableCaption caption,

View File

@ -675,7 +675,6 @@
"commands.description.backup.save": "<gray>Create a plot backup.</gray>",
"commands.description.backup.list": "<gray>List available plot backups.</gray>",
"commands.description.backup.load": "<gray>Restore a plot backup</gray>",
"commands.description.biome": "<gray>Set the plot biome.</gray>",
"commands.description.buy": "<gray>Buy the plot you are standing on.</gray>",
"commands.description.caps": "<gray>Show plot entity caps.</gray>",
"commands.description.chat": "<gray>Toggles plot chat on or off.</gray>",
@ -699,7 +698,6 @@
"commands.description.debugsavetest": "<gray>This command will force the recreation of all plots in the database.</gray>",
"commands.description.delete": "<gray>Delete the plot you stand on.</gray>",
"commands.description.deny": "<gray>Deny a user from entering a plot.</gray>",
"commands.description.desc": "<gray>Set the plot description.</gray>",
"commands.description.dislike": "<gray>Dislike the plot.</gray>",
"commands.description.done": "<gray>Continue a plot that was previously marked as done.</gray>",
"commands.description.download": "<gray>Download your plot.</gray>",
@ -724,7 +722,6 @@
"commands.description.move": "<gray>Move a plot.</gray>",
"commands.description.music": "<gray>Play music in your plot.</gray>",
"commands.description.near": "<gray>Display nearby players.</gray>",
"commands.description.owner": "<gray>Set the plot owner.</gray>",
"commands.description.plugin": "<gray>Show plugin information.</gray>",
"commands.description.purge": "<gray>Purge all plots for a world.</gray>",
"commands.description.rate": "<gray>Rate a plot.</gray>",
@ -735,7 +732,10 @@
"commands.description.save": "<gray>Save your plot.</gray>",
"commands.description.schematic": "<gray>Manage schematics.</gray>",
"commands.description.set": "<gray>Set a plot value.</gray>",
"commands.description.setbiome": "<gray>Set the plot biome.</gray>",
"commands.description.setdescription": "<gray>Set the plot description.</gray>",
"commands.description.sethome": "<gray>Set the plot home.</gray>",
"commands.description.setowner": "<gray>Set the plot owner.</gray>",
"commands.description.setup": "<gray>Setup wizard for plot worlds.</gray>",
"commands.description.swap": "<gray>Swap two plots.</gray>",
"commands.description.target": "<gray>Target a plot with your compass.</gray>",