Fixed another bunch of code smells

This commit is contained in:
Florian CUNY 2019-03-24 15:51:45 +01:00
parent 5073d9cf5c
commit 70749b0d16
2 changed files with 9 additions and 10 deletions

View File

@ -1,8 +1,5 @@
package world.bentobox.bentobox.hooks; package world.bentobox.bentobox.hooks;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Addon;
@ -11,6 +8,9 @@ import world.bentobox.bentobox.api.placeholders.PlaceholderReplacer;
import world.bentobox.bentobox.api.placeholders.placeholderapi.AddonPlaceholderExpansion; import world.bentobox.bentobox.api.placeholders.placeholderapi.AddonPlaceholderExpansion;
import world.bentobox.bentobox.api.placeholders.placeholderapi.BentoBoxPlaceholderExpansion; import world.bentobox.bentobox.api.placeholders.placeholderapi.BentoBoxPlaceholderExpansion;
import java.util.HashMap;
import java.util.Map;
/** /**
* Provides implementations and interfacing needed to register and get placeholders from PlaceholderAPI. * Provides implementations and interfacing needed to register and get placeholders from PlaceholderAPI.
* *
@ -112,10 +112,10 @@ public class PlaceholderAPIHook extends Hook {
* Checks if a placeholder with this name is already registered * Checks if a placeholder with this name is already registered
* @param addon the addon, not null * @param addon the addon, not null
* @param placeholder - name of placeholder * @param placeholder - name of placeholder
* @return <tt>true</tt> if a placeholder with this name is already registered * @return {@code true} if a placeholder with this name is already registered
* @since 1.4.0 * @since 1.4.0
*/ */
public boolean isPlaceholder(@NonNull Addon addon, @NonNull String placeholder) { public boolean isPlaceholder(@NonNull Addon addon, @NonNull String placeholder) {
return addonsExpansions.containsKey(addon) ? addonsExpansions.get(addon).isPlaceholder(placeholder) : false; return addonsExpansions.containsKey(addon) && addonsExpansions.get(addon).isPlaceholder(placeholder);
} }
} }

View File

@ -1,5 +1,7 @@
package world.bentobox.bentobox.managers; package world.bentobox.bentobox.managers;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.placeholders.PlaceholderReplacer; import world.bentobox.bentobox.api.placeholders.PlaceholderReplacer;
@ -7,9 +9,6 @@ import world.bentobox.bentobox.hooks.PlaceholderAPIHook;
import java.util.Optional; import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
/** /**
* Manages placeholder integration. * Manages placeholder integration.
* *
@ -91,10 +90,10 @@ public class PlaceholdersManager {
* Checks if a placeholder with this name is already registered * Checks if a placeholder with this name is already registered
* @param addon the addon, not null * @param addon the addon, not null
* @param placeholder - name of placeholder * @param placeholder - name of placeholder
* @return <tt>true</tt> if a placeholder with this name is already registered * @return {@code true} if a placeholder with this name is already registered
* @since 1.4.0 * @since 1.4.0
*/ */
public boolean isPlaceholder(@NonNull Addon addon, @NonNull String placeholder) { public boolean isPlaceholder(@NonNull Addon addon, @NonNull String placeholder) {
return addon == null ? false : getPlaceholderAPIHook().map(h -> h.isPlaceholder(addon, placeholder)).orElse(false); return getPlaceholderAPIHook().map(h -> h.isPlaceholder(addon, placeholder)).orElse(false);
} }
} }