Code health pass for Java 16
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2011-2021 lishid. All rights reserved.
 | 
			
		||||
 * Copyright (C) 2011-2022 lishid. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -44,7 +44,7 @@ public class SearchContainerCommand implements TabExecutor {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
 | 
			
		||||
        if (!(sender instanceof Player)) {
 | 
			
		||||
        if (!(sender instanceof Player senderPlayer)) {
 | 
			
		||||
            plugin.sendMessage(sender, "messages.error.consoleUnsupported");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
@@ -72,7 +72,6 @@ public class SearchContainerCommand implements TabExecutor {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Player senderPlayer = (Player) sender;
 | 
			
		||||
        World world = senderPlayer.getWorld();
 | 
			
		||||
        Chunk centerChunk = senderPlayer.getLocation().getChunk();
 | 
			
		||||
        StringBuilder locations = new StringBuilder();
 | 
			
		||||
@@ -84,10 +83,9 @@ public class SearchContainerCommand implements TabExecutor {
 | 
			
		||||
                }
 | 
			
		||||
                Chunk chunk = world.getChunkAt(centerChunk.getX() + dX, centerChunk.getZ() + dZ);
 | 
			
		||||
                for (BlockState tileEntity : chunk.getTileEntities()) {
 | 
			
		||||
                    if (!(tileEntity instanceof InventoryHolder)) {
 | 
			
		||||
                    if (!(tileEntity instanceof InventoryHolder holder)) {
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
                    InventoryHolder holder = (InventoryHolder) tileEntity;
 | 
			
		||||
                    if (!holder.getInventory().contains(material)) {
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2011-2021 lishid. All rights reserved.
 | 
			
		||||
 * Copyright (C) 2011-2022 lishid. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -127,7 +127,6 @@ public class SearchEnchantCommand implements TabExecutor {
 | 
			
		||||
 | 
			
		||||
    private boolean containsEnchantment(Inventory inventory, @Nullable Enchantment enchant, int minLevel) {
 | 
			
		||||
        for (ItemStack item : inventory.getContents()) {
 | 
			
		||||
            //noinspection ConstantConditions // Spigot improperly annotated, should be ItemStack @NotNull []
 | 
			
		||||
            if (item == null || item.getType() == Material.AIR) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2011-2021 lishid. All rights reserved.
 | 
			
		||||
 * Copyright (C) 2011-2022 lishid. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -17,6 +17,7 @@
 | 
			
		||||
package com.lishid.openinv.internal;
 | 
			
		||||
 | 
			
		||||
import com.lishid.openinv.OpenInv;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
import org.bukkit.entity.HumanEntity;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.event.inventory.InventoryType;
 | 
			
		||||
@@ -70,11 +71,7 @@ public class OpenInventoryView extends InventoryView {
 | 
			
		||||
                            titleKey,
 | 
			
		||||
                            "%player%",
 | 
			
		||||
                            owner.getName());
 | 
			
		||||
            if (localTitle != null) {
 | 
			
		||||
                title = localTitle;
 | 
			
		||||
            } else  {
 | 
			
		||||
                title = owner.getName() + titleDefaultSuffix;
 | 
			
		||||
            }
 | 
			
		||||
            title = Objects.requireNonNullElseGet(localTitle, () -> owner.getName() + titleDefaultSuffix);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return title;
 | 
			
		||||
 
 | 
			
		||||
@@ -50,7 +50,7 @@ public class LanguageManager {
 | 
			
		||||
        getOrLoadLocale(defaultLocale);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private YamlConfiguration getOrLoadLocale(@NotNull String locale) {
 | 
			
		||||
    private @NotNull YamlConfiguration getOrLoadLocale(@NotNull String locale) {
 | 
			
		||||
        YamlConfiguration loaded = locales.get(locale);
 | 
			
		||||
        if (loaded != null) {
 | 
			
		||||
            return loaded;
 | 
			
		||||
@@ -136,8 +136,7 @@ public class LanguageManager {
 | 
			
		||||
        return localeConfig;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public String getValue(@NotNull String key, @Nullable String locale) {
 | 
			
		||||
    public @Nullable String getValue(@NotNull String key, @Nullable String locale) {
 | 
			
		||||
        String value = getOrLoadLocale(locale == null ? defaultLocale : locale.toLowerCase()).getString(key);
 | 
			
		||||
        if (value == null || value.isEmpty()) {
 | 
			
		||||
            return null;
 | 
			
		||||
@@ -148,8 +147,7 @@ public class LanguageManager {
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public String getValue(@NotNull String key, @Nullable String locale, @NotNull String... replacements) {
 | 
			
		||||
    public @Nullable String getValue(@NotNull String key, @Nullable String locale, String @NotNull ... replacements) {
 | 
			
		||||
        if (replacements.length % 2 != 0) {
 | 
			
		||||
            plugin.getLogger().log(Level.WARNING, "[LanguageManager] Replacement data is uneven", new Exception());
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user