More @Nullable annotations

This commit is contained in:
filoghost 2020-10-13 21:07:21 +02:00
parent 9989c9abb0
commit 6c097222a2
10 changed files with 29 additions and 18 deletions

View File

@ -233,7 +233,7 @@ public abstract class BaseConfigurableIcon implements Icon {
cachedRendering = null;
}
public String renderName(Player viewer) {
public @Nullable String renderName(Player viewer) {
if (name == null) {
return null;
}
@ -251,7 +251,7 @@ public abstract class BaseConfigurableIcon implements Icon {
}
}
public List<String> renderLore(Player viewer) {
public @Nullable List<String> renderLore(Player viewer) {
if (lore == null) {
return null;
}

View File

@ -23,6 +23,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@ -166,7 +167,7 @@ public class InternalConfigurableIcon extends BaseConfigurableIcon implements Re
}
@Override
public ItemStack updateRendering(Player viewer, ItemStack currentRendering) {
public @Nullable ItemStack updateRendering(Player viewer, @Nullable ItemStack currentRendering) {
if (currentRendering != null && shouldCacheRendering()) {
// Internal icons do not change, no need to update if the item is already rendered
return currentRendering;

View File

@ -7,9 +7,10 @@ package me.filoghost.chestcommands.icon;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
public interface RefreshableIcon {
ItemStack updateRendering(Player viewer, ItemStack currentRendering);
@Nullable ItemStack updateRendering(Player viewer, @Nullable ItemStack currentRendering);
}

View File

@ -20,6 +20,7 @@ import me.filoghost.fcommons.collection.CollectionUtils;
import me.filoghost.fcommons.config.ConfigLoader;
import me.filoghost.fcommons.config.exception.ConfigException;
import me.filoghost.fcommons.logging.Log;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.nio.file.Path;
@ -73,7 +74,7 @@ public class UpgradeList {
}
}
private static String readLegacyCommandSeparator(ConfigManager configManager) {
private static @Nullable String readLegacyCommandSeparator(ConfigManager configManager) {
ConfigLoader settingsConfigLoader = configManager.getConfigLoader("config.yml");
if (!settingsConfigLoader.fileExists()) {

View File

@ -11,6 +11,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.jetbrains.annotations.Nullable;
public class CommandListener implements Listener {
@ -30,7 +31,7 @@ public class CommandListener implements Listener {
menu.openCheckingPermission(event.getPlayer());
}
private static String getCommandName(String fullCommand) {
private static @Nullable String getCommandName(String fullCommand) {
if (!fullCommand.startsWith("/")) {
return null;
}

View File

@ -18,6 +18,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Collections;
@ -95,7 +96,7 @@ public class MenuManager {
}
}
public static DefaultMenuView getOpenMenuView(Player player) {
public static @Nullable DefaultMenuView getOpenMenuView(Player player) {
InventoryView inventoryView = player.getOpenInventory();
if (inventoryView == null) {
return null;
@ -110,7 +111,7 @@ public class MenuManager {
}
public static DefaultMenuView getOpenMenuView(Inventory inventory) {
public static @Nullable DefaultMenuView getOpenMenuView(Inventory inventory) {
MenuInventoryHolder inventoryHolder = getMenuInventoryHolder(inventory);
if (inventoryHolder != null) {
return inventoryHolder.getMenuView();
@ -119,7 +120,7 @@ public class MenuManager {
}
}
private static MenuInventoryHolder getMenuInventoryHolder(Inventory inventory) {
private static @Nullable MenuInventoryHolder getMenuInventoryHolder(Inventory inventory) {
if (inventory.getHolder() instanceof MenuInventoryHolder) {
return (MenuInventoryHolder) inventory.getHolder();
} else {

View File

@ -6,6 +6,7 @@
package me.filoghost.chestcommands.parsing.menu;
import org.bukkit.event.block.Action;
import org.jetbrains.annotations.Nullable;
public enum ClickType {
@ -13,7 +14,7 @@ public enum ClickType {
RIGHT,
BOTH;
public static ClickType fromOptions(boolean left, boolean right) {
public static @Nullable ClickType fromOptions(boolean left, boolean right) {
if (left && right) {
return BOTH;
} else if (left) {

View File

@ -5,8 +5,6 @@
*/
package me.filoghost.chestcommands.placeholder;
import java.util.ArrayList;
import java.util.List;
import me.filoghost.chestcommands.api.PlaceholderReplacer;
import me.filoghost.chestcommands.hook.PlaceholderAPIHook;
import me.filoghost.chestcommands.placeholder.scanner.PlaceholderMatch;
@ -14,6 +12,10 @@ import me.filoghost.chestcommands.placeholder.scanner.PlaceholderScanner;
import me.filoghost.fcommons.Preconditions;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class PlaceholderManager {
@ -62,7 +64,7 @@ public class PlaceholderManager {
return relativePlaceholderRegistry.getPlaceholderReplacer(placeholderMatch) != null;
}
private static String getReplacement(PlaceholderMatch placeholderMatch, Player player) {
private static @Nullable String getReplacement(PlaceholderMatch placeholderMatch, Player player) {
PlaceholderReplacer placeholderReplacer = relativePlaceholderRegistry.getPlaceholderReplacer(placeholderMatch);
if (placeholderReplacer == null) {

View File

@ -5,12 +5,14 @@
*/
package me.filoghost.chestcommands.placeholder;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import me.filoghost.chestcommands.api.PlaceholderReplacer;
import me.filoghost.chestcommands.placeholder.scanner.PlaceholderMatch;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class PlaceholderRegistry {
@ -27,7 +29,7 @@ public class PlaceholderRegistry {
.put(plugin.getName(), placeholderReplacer);
}
public PlaceholderReplacer getPlaceholderReplacer(PlaceholderMatch placeholderMatch) {
public @Nullable PlaceholderReplacer getPlaceholderReplacer(PlaceholderMatch placeholderMatch) {
if (placeholderMatch.getPluginNamespace() == null) {
PlaceholderReplacer internalReplacer = internalPlaceholders.get(placeholderMatch.getIdentifier());
if (internalReplacer != null) {

View File

@ -6,6 +6,7 @@
package me.filoghost.chestcommands.placeholder;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
public class PlaceholderString {
@ -13,7 +14,7 @@ public class PlaceholderString {
private final String stringWithStaticPlaceholders;
private final boolean hasDynamicPlaceholders;
public static PlaceholderString of(String string) {
public static @Nullable PlaceholderString of(String string) {
if (string != null) {
return new PlaceholderString(string);
} else {