Code smell reduction

This commit is contained in:
tastybento 2021-09-18 08:15:15 -07:00
parent 4f22df069b
commit 8eb45e817c
77 changed files with 152 additions and 107 deletions

View File

@ -158,7 +158,7 @@ public final class AddonDescription {
* @return the permissions * @return the permissions
* @since 1.13.0 * @since 1.13.0
*/ */
public ConfigurationSection getPermissions() { public @Nullable ConfigurationSection getPermissions() {
return permissions; return permissions;
} }

View File

@ -218,7 +218,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
* subcommands until it finds the right object and then runs execute on it. * subcommands until it finds the right object and then runs execute on it.
*/ */
@Override @Override
public boolean execute(CommandSender sender, String label, String[] args) { public boolean execute(@NonNull CommandSender sender, @NonNull String label, String[] args) {
// Get the User instance for this sender // Get the User instance for this sender
User user = User.getInstance(sender); User user = User.getInstance(sender);
// Fire an event to see if this command should be cancelled // Fire an event to see if this command should be cancelled
@ -352,7 +352,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
} }
@Override @Override
public BentoBox getPlugin() { public @NonNull BentoBox getPlugin() {
return plugin; return plugin;
} }
@ -422,7 +422,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
} }
@Override @Override
public String getUsage() { public @NonNull String getUsage() {
return "/" + usage; return "/" + usage;
} }
@ -521,7 +521,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
* @return The instance of this {@link Command}. * @return The instance of this {@link Command}.
*/ */
@Override @Override
public Command setDescription(String description) { public @NonNull Command setDescription(@NonNull String description) {
super.setDescription(description); super.setDescription(description);
return this; return this;
} }
@ -575,7 +575,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
* This creates the full linking chain of commands * This creates the full linking chain of commands
*/ */
@Override @Override
public Command setUsage(String usage) { public @NonNull Command setUsage(@NonNull String usage) {
// Go up the chain // Go up the chain
CompositeCommand parentCommand = getParent(); CompositeCommand parentCommand = getParent();
StringBuilder u = new StringBuilder().append(getLabel()).append(" ").append(usage); StringBuilder u = new StringBuilder().append(getLabel()).append(" ").append(usage);
@ -590,7 +590,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
@Override @Override
@NonNull @NonNull
public List<String> tabComplete(final CommandSender sender, final String alias, final String[] args) { public List<String> tabComplete(final @NonNull CommandSender sender, final @NonNull String alias, final String[] args) {
List<String> options = new ArrayList<>(); List<String> options = new ArrayList<>();
// Get command object based on args entered so far // Get command object based on args entered so far
CompositeCommand command = getCommandFromArgs(args); CompositeCommand command = getCommandFromArgs(args);

View File

@ -22,7 +22,7 @@ public class NamePrompt extends StringPrompt {
private final String oldName; private final String oldName;
private final BentoBox plugin; private final BentoBox plugin;
public NamePrompt(BentoBox plugin, @NonNull Island island, User user, String oldName) { public NamePrompt(BentoBox plugin, @NonNull Island island, @NonNull User user, String oldName) {
this.plugin = plugin; this.plugin = plugin;
this.island = island; this.island = island;
this.user = user; this.user = user;
@ -30,12 +30,12 @@ public class NamePrompt extends StringPrompt {
} }
@Override @Override
public String getPromptText(ConversationContext context) { public @NonNull String getPromptText(@NonNull ConversationContext context) {
return user.getTranslation("commands.island.renamehome.enter-new-name"); return user.getTranslation("commands.island.renamehome.enter-new-name");
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(@NonNull ConversationContext context, String input) {
if (island.renameHome(oldName, input)) { if (island.renameHome(oldName, input)) {
plugin.getIslands().save(island); plugin.getIslands().save(island);
Bukkit.getScheduler().runTask(plugin, () -> user.sendMessage("general.success")); Bukkit.getScheduler().runTask(plugin, () -> user.sendMessage("general.success"));

View File

@ -12,6 +12,7 @@ import java.util.Objects;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
/** /**
@ -55,7 +56,7 @@ public abstract class BentoBoxEvent extends Event {
*/ */
@Override @Override
@Deprecated @Deprecated
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -1,6 +1,7 @@
package world.bentobox.bentobox.api.events; package world.bentobox.bentobox.api.events;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
/** /**
* Fired when plugin is ready to play and all files are loaded * Fired when plugin is ready to play and all files are loaded
@ -12,7 +13,7 @@ public class BentoBoxReadyEvent extends BentoBoxEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -3,6 +3,7 @@ package world.bentobox.bentobox.api.events;
import java.util.UUID; import java.util.UUID;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
/** /**
* Fired when a message is going to an offline player * Fired when a message is going to an offline player
@ -16,7 +17,7 @@ public class OfflineMessageEvent extends BentoBoxEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -4,6 +4,7 @@ import java.util.Map;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Addon;
/** /**
@ -16,7 +17,7 @@ public class AddonDisableEvent extends AddonBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -4,6 +4,7 @@ import java.util.Map;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Addon;
/** /**
@ -16,7 +17,7 @@ public class AddonEnableEvent extends AddonBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -4,6 +4,7 @@ import java.util.Map;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Addon;
/** /**
@ -16,7 +17,7 @@ public class AddonGeneralEvent extends AddonBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -4,6 +4,7 @@ import java.util.Map;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Addon;
/** /**
@ -16,7 +17,7 @@ public class AddonLoadEvent extends AddonBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.BentoBoxEvent; import world.bentobox.bentobox.api.events.BentoBoxEvent;
/** /**
@ -24,7 +25,7 @@ public class CommandEvent extends BentoBoxEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -4,6 +4,7 @@ import java.util.UUID;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -18,7 +19,7 @@ public class FlagProtectionChangeEvent extends FlagChangeEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -4,6 +4,7 @@ import java.util.UUID;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -18,7 +19,7 @@ public class FlagSettingChangeEvent extends FlagChangeEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.api.flags.Flag;
/** /**
@ -18,7 +19,7 @@ public class FlagWorldSettingChangeEvent extends FlagChangeEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -19,7 +20,7 @@ public class IslandBanEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -20,7 +20,7 @@ public class IslandCreateEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -16,7 +17,7 @@ public class IslandCreatedEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.database.objects.IslandDeletion; import world.bentobox.bentobox.database.objects.IslandDeletion;
@ -19,7 +20,7 @@ public class IslandDeleteChunksEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class IslandDeleteEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.database.objects.IslandDeletion; import world.bentobox.bentobox.database.objects.IslandDeletion;
@ -21,7 +22,7 @@ public class IslandDeletedEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
@ -20,7 +21,7 @@ public class IslandEnterEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }
@ -28,7 +29,7 @@ public class IslandEnterEvent extends IslandBaseEvent {
return handlers; return handlers;
} }
IslandEnterEvent(Island island, UUID player, boolean admin, Location location, Island fromIsland, Event rawEvent) { IslandEnterEvent(Island island, UUID player, boolean admin, Location location, @Nullable Island fromIsland, Event rawEvent) {
// Final variables have to be declared in the constructor // Final variables have to be declared in the constructor
super(island, player, admin, location, rawEvent); super(island, player, admin, location, rawEvent);
this.fromIsland = fromIsland; this.fromIsland = fromIsland;

View File

@ -26,7 +26,7 @@ public class IslandEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }
@ -425,7 +425,7 @@ public class IslandEvent extends IslandBaseEvent {
private final @Nullable Island fromIsland; private final @Nullable Island fromIsland;
private IslandEnterEvent(Island island, UUID player, boolean admin, Location location, Island fromIsland, Event rawEvent) { private IslandEnterEvent(Island island, UUID player, boolean admin, Location location, @Nullable Island fromIsland, Event rawEvent) {
// Final variables have to be declared in the constructor // Final variables have to be declared in the constructor
super(island, player, admin, location, rawEvent); super(island, player, admin, location, rawEvent);
this.fromIsland = fromIsland; this.fromIsland = fromIsland;
@ -448,7 +448,7 @@ public class IslandEvent extends IslandBaseEvent {
private final @Nullable Island toIsland; private final @Nullable Island toIsland;
private IslandExitEvent(Island island, UUID player, boolean admin, Location location, Island toIsland, Event rawEvent) { private IslandExitEvent(Island island, UUID player, boolean admin, Location location, @Nullable Island toIsland, Event rawEvent) {
// Final variables have to be declared in the constructor // Final variables have to be declared in the constructor
super(island, player, admin, location, rawEvent); super(island, player, admin, location, rawEvent);
this.toIsland = toIsland; this.toIsland = toIsland;

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
@ -20,7 +21,7 @@ public class IslandExitEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }
@ -28,7 +29,7 @@ public class IslandExitEvent extends IslandBaseEvent {
return handlers; return handlers;
} }
IslandExitEvent(Island island, UUID player, boolean admin, Location location, Island toIsland, Event rawEvent) { IslandExitEvent(Island island, UUID player, boolean admin, Location location, @Nullable Island toIsland, Event rawEvent) {
// Final variables have to be declared in the constructor // Final variables have to be declared in the constructor
super(island, player, admin, location, rawEvent); super(island, player, admin, location, rawEvent);
this.toIsland = toIsland; this.toIsland = toIsland;

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -20,7 +21,7 @@ public class IslandExpelEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class IslandGeneralEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class IslandLockEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class IslandNewIslandEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -4,6 +4,7 @@ import java.util.UUID;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
/** /**
@ -16,7 +17,7 @@ public class IslandPreCreateEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -19,7 +19,7 @@ public class IslandPreclearEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class IslandProtectionRangeChangeEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -20,7 +21,7 @@ public class IslandRankChangeEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class IslandRegisteredEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class IslandReservedEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -21,7 +21,7 @@ public class IslandResetEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -19,7 +19,7 @@ public class IslandResettedEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -20,7 +21,7 @@ public class IslandUnbanEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class IslandUnlockEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class IslandUnregisteredEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -13,7 +14,7 @@ public class TeamDeleteEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -13,7 +14,7 @@ public class TeamGeneralEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -13,7 +14,7 @@ public class TeamInfoEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -13,7 +14,7 @@ public class TeamInviteEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -13,7 +14,7 @@ public class TeamJoinEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -17,7 +18,7 @@ public class TeamJoinedEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -13,7 +14,7 @@ public class TeamKickEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -18,7 +19,7 @@ public class TeamLeaveEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -13,7 +14,7 @@ public class TeamRejectEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -19,7 +20,7 @@ public class TeamSetownerEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
@ -13,7 +14,7 @@ public class TeamUninviteEvent extends IslandBaseEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public @NonNull HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();
} }

View File

@ -24,7 +24,7 @@ import world.bentobox.bentobox.util.Util;
*/ */
public class CycleClick implements PanelItem.ClickHandler { public class CycleClick implements PanelItem.ClickHandler {
protected BentoBox plugin = BentoBox.getInstance(); protected final BentoBox plugin = BentoBox.getInstance();
protected Island island; protected Island island;
protected User user; protected User user;
protected boolean changeOccurred; protected boolean changeOccurred;

View File

@ -137,7 +137,7 @@ public class PanelItemBuilder {
/** /**
* @return the name * @return the name
*/ */
public String getName() { public @Nullable String getName() {
return name; return name;
} }

View File

@ -1,5 +1,6 @@
package world.bentobox.bentobox.api.placeholders.placeholderapi; package world.bentobox.bentobox.api.placeholders.placeholderapi;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Addon;
public class AddonPlaceholderExpansion extends BasicPlaceholderExpansion { public class AddonPlaceholderExpansion extends BasicPlaceholderExpansion {
@ -10,17 +11,17 @@ public class AddonPlaceholderExpansion extends BasicPlaceholderExpansion {
} }
@Override @Override
public String getName() { public @NonNull String getName() {
return addon.getDescription().getName(); return addon.getDescription().getName();
} }
@Override @Override
public String getAuthor() { public @NonNull String getAuthor() {
return addon.getDescription().getAuthors().get(0); return addon.getDescription().getAuthors().get(0);
} }
@Override @Override
public String getVersion() { public @NonNull String getVersion() {
return addon.getDescription().getVersion(); return addon.getDescription().getVersion();
} }
} }

View File

@ -24,7 +24,7 @@ abstract class BasicPlaceholderExpansion extends PlaceholderExpansion {
} }
@Override @Override
public String getIdentifier() { public @NonNull String getIdentifier() {
return getName().toLowerCase(Locale.ENGLISH); return getName().toLowerCase(Locale.ENGLISH);
} }
@ -42,7 +42,7 @@ abstract class BasicPlaceholderExpansion extends PlaceholderExpansion {
} }
@Override @Override
public String onPlaceholderRequest(Player p, String placeholder) { public String onPlaceholderRequest(Player p, @NonNull String placeholder) {
if (placeholders.containsKey(placeholder)) { if (placeholders.containsKey(placeholder)) {
return placeholders.get(placeholder).onReplace(User.getInstance(p)); return placeholders.get(placeholder).onReplace(User.getInstance(p));
} }

View File

@ -1,5 +1,6 @@
package world.bentobox.bentobox.api.placeholders.placeholderapi; package world.bentobox.bentobox.api.placeholders.placeholderapi;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
public class BentoBoxPlaceholderExpansion extends BasicPlaceholderExpansion { public class BentoBoxPlaceholderExpansion extends BasicPlaceholderExpansion {
@ -11,17 +12,17 @@ public class BentoBoxPlaceholderExpansion extends BasicPlaceholderExpansion {
} }
@Override @Override
public String getName() { public @NonNull String getName() {
return plugin.getName(); return plugin.getName();
} }
@Override @Override
public String getAuthor() { public @NonNull String getAuthor() {
return "Tastybento and Poslovitch"; return "Tastybento and Poslovitch";
} }
@Override @Override
public String getVersion() { public @NonNull String getVersion() {
return plugin.getDescription().getVersion(); return plugin.getDescription().getVersion();
} }
} }

View File

@ -6,6 +6,7 @@ import java.util.concurrent.TimeUnit;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import org.eclipse.jdt.annotation.NonNull;
/** /**
* Utilities class that helps to avoid spamming the User with potential repeated messages * Utilities class that helps to avoid spamming the User with potential repeated messages
@ -26,7 +27,7 @@ public class Notifier {
.build( .build(
new CacheLoader<>() { new CacheLoader<>() {
@Override @Override
public Notification load(User user) { public Notification load(@NonNull User user) {
return new Notification(null, 0); return new Notification(null, 0);
} }
} }

View File

@ -135,7 +135,7 @@ public class User implements MetaDataAble {
private Addon addon; private Addon addon;
private User(CommandSender sender) { private User(@Nullable CommandSender sender) {
player = null; player = null;
playerUUID = null; playerUUID = null;
this.sender = sender; this.sender = sender;

View File

@ -79,7 +79,7 @@ public class Blueprint {
/** /**
* @return the icon * @return the icon
*/ */
public Material getIcon() { public @NonNull Material getIcon() {
return icon; return icon;
} }
/** /**

View File

@ -398,7 +398,7 @@ public class BlueprintClipboard {
/** /**
* @return the blueprint * @return the blueprint
*/ */
public Blueprint getBlueprint() { public @Nullable Blueprint getBlueprint() {
return blueprint; return blueprint;
} }

View File

@ -8,6 +8,7 @@ import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt; import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
@ -33,7 +34,7 @@ public class DescriptionPrompt extends StringPrompt {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public String getPromptText(ConversationContext context) { public @NonNull String getPromptText(ConversationContext context) {
User user = User.getInstance((Player)context.getForWhom()); User user = User.getInstance((Player)context.getForWhom());
if (context.getSessionData(DESCRIPTION) != null) { if (context.getSessionData(DESCRIPTION) != null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View File

@ -7,6 +7,7 @@ import org.bukkit.conversations.MessagePrompt;
import org.bukkit.conversations.Prompt; import org.bukkit.conversations.Prompt;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
@ -28,7 +29,7 @@ public class DescriptionSuccessPrompt extends MessagePrompt {
} }
@Override @Override
public String getPromptText(ConversationContext context) { public @NonNull String getPromptText(ConversationContext context) {
User user = User.getInstance((Player)context.getForWhom()); User user = User.getInstance((Player)context.getForWhom());
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<String> description = (List<String>)context.getSessionData("description"); List<String> description = (List<String>)context.getSessionData("description");
@ -46,7 +47,7 @@ public class DescriptionSuccessPrompt extends MessagePrompt {
} }
@Override @Override
protected Prompt getNextPrompt(ConversationContext context) { protected Prompt getNextPrompt(@NonNull ConversationContext context) {
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} }

View File

@ -4,12 +4,13 @@ import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.ConversationPrefix; import org.bukkit.conversations.ConversationPrefix;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
public class NameConversationPrefix implements ConversationPrefix { public class NameConversationPrefix implements ConversationPrefix {
@Override @Override
public String getPrefix(ConversationContext context) { public @NonNull String getPrefix(ConversationContext context) {
User user = User.getInstance((Player)context.getForWhom()); User user = User.getInstance((Player)context.getForWhom());
return user.getTranslation("commands.admin.blueprint.management.name.conversation-prefix"); return user.getTranslation("commands.admin.blueprint.management.name.conversation-prefix");
} }

View File

@ -38,7 +38,7 @@ public class NamePrompt extends StringPrompt {
} }
@Override @Override
public String getPromptText(ConversationContext context) { public @NonNull String getPromptText(ConversationContext context) {
User user = User.getInstance((Player)context.getForWhom()); User user = User.getInstance((Player)context.getForWhom());
return user.getTranslation("commands.admin.blueprint.management.name.prompt"); return user.getTranslation("commands.admin.blueprint.management.name.prompt");
} }

View File

@ -34,7 +34,7 @@ public class NameSuccessPrompt extends MessagePrompt {
} }
@Override @Override
public String getPromptText(ConversationContext context) { public @NonNull String getPromptText(ConversationContext context) {
String name = (String) context.getSessionData("name"); String name = (String) context.getSessionData("name");
String uniqueId = (String) context.getSessionData("uniqueId"); String uniqueId = (String) context.getSessionData("uniqueId");
User user = User.getInstance((Player)context.getForWhom()); User user = User.getInstance((Player)context.getForWhom());
@ -65,7 +65,7 @@ public class NameSuccessPrompt extends MessagePrompt {
} }
@Override @Override
protected Prompt getNextPrompt(ConversationContext context) { protected Prompt getNextPrompt(@NonNull ConversationContext context) {
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} }

View File

@ -33,7 +33,7 @@ import world.bentobox.bentobox.database.json.adapters.WorldTypeAdapter;
*/ */
public class BentoboxTypeAdapterFactory implements TypeAdapterFactory { public class BentoboxTypeAdapterFactory implements TypeAdapterFactory {
BentoBox plugin; final BentoBox plugin;
/** /**
* @param plugin plugin * @param plugin plugin

View File

@ -19,6 +19,7 @@ import com.mongodb.client.model.IndexOptions;
import com.mongodb.client.model.Indexes; import com.mongodb.client.model.Indexes;
import com.mongodb.util.JSON; import com.mongodb.util.JSON;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.database.DatabaseConnector; import world.bentobox.bentobox.database.DatabaseConnector;
import world.bentobox.bentobox.database.json.AbstractJSONDatabaseHandler; import world.bentobox.bentobox.database.json.AbstractJSONDatabaseHandler;
@ -125,7 +126,7 @@ public class MongoDBDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
} }
@Override @Override
public T loadObject(String uniqueId) { public T loadObject(@NonNull String uniqueId) {
Document doc = collection.find(new Document(MONGO_ID, uniqueId)).limit(1).first(); Document doc = collection.find(new Document(MONGO_ID, uniqueId)).limit(1).first();
Gson gson = getGson(); Gson gson = getGson();
String json = JSON.serialize(doc).replaceFirst(MONGO_ID, UNIQUEID); String json = JSON.serialize(doc).replaceFirst(MONGO_ID, UNIQUEID);

View File

@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.database.AbstractDatabaseHandler; import world.bentobox.bentobox.database.AbstractDatabaseHandler;
@ -55,7 +56,7 @@ public class TransitionDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
* @see world.bentobox.bentobox.database.AbstractDatabaseHandler#loadObject(java.lang.String) * @see world.bentobox.bentobox.database.AbstractDatabaseHandler#loadObject(java.lang.String)
*/ */
@Override @Override
public T loadObject(String uniqueId) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException, NoSuchMethodException { public T loadObject(@NonNull String uniqueId) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException, NoSuchMethodException {
// Try destination database // Try destination database
@Nullable @Nullable
T object = toHandler.loadObject(uniqueId); T object = toHandler.loadObject(uniqueId);

View File

@ -144,7 +144,7 @@ public class YamlDatabaseConnector implements DatabaseConnector {
// Run through the file and add in the comments // Run through the file and add in the comments
File commentedFile = new File(file.getPath() + ".tmp"); File commentedFile = new File(file.getPath() + ".tmp");
List<String> newFile = new ArrayList<>(); List<String> newFile = new ArrayList<>();
try (Scanner scanner = new Scanner(file, "UTF-8")) { try (Scanner scanner = new Scanner(file, StandardCharsets.UTF_8)) {
while (scanner.hasNextLine()) { while (scanner.hasNextLine()) {
String nextLine = scanner.nextLine(); String nextLine = scanner.nextLine();
// See if there are any comments in this line // See if there are any comments in this line

View File

@ -80,7 +80,7 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
* @see world.bentobox.bentobox.database.AbstractDatabaseHandler#loadObject(java.lang.String) * @see world.bentobox.bentobox.database.AbstractDatabaseHandler#loadObject(java.lang.String)
*/ */
@Override @Override
public T loadObject(String key) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException, NoSuchMethodException { public T loadObject(@NonNull String key) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException, NoSuchMethodException {
// Objects are loaded from a folder named after the simple name of the class being stored // Objects are loaded from a folder named after the simple name of the class being stored
String path = DATABASE_FOLDER_NAME + File.separator + dataObject.getSimpleName(); String path = DATABASE_FOLDER_NAME + File.separator + dataObject.getSimpleName();
// This path and key can be overridden by the StoreAt annotation in the code // This path and key can be overridden by the StoreAt annotation in the code

View File

@ -32,7 +32,7 @@ public class PlaceholderAPIHook extends PlaceholderHook {
public PlaceholderAPIHook() { public PlaceholderAPIHook() {
super("PlaceholderAPI"); super();
this.addonsExpansions = new HashMap<>(); this.addonsExpansions = new HashMap<>();
this.bentoBoxPlaceholders = new HashSet<>(); this.bentoBoxPlaceholders = new HashSet<>();
this.addonPlaceholders = new HashMap<>(); this.addonPlaceholders = new HashMap<>();

View File

@ -14,8 +14,8 @@ import world.bentobox.bentobox.api.placeholders.PlaceholderReplacer;
*/ */
public abstract class PlaceholderHook extends Hook { public abstract class PlaceholderHook extends Hook {
protected PlaceholderHook(@NonNull String pluginName) { protected PlaceholderHook() {
super(pluginName, Material.NAME_TAG); super("PlaceholderAPI", Material.NAME_TAG);
} }
/** /**

View File

@ -40,15 +40,9 @@ public class BucketListener extends FlagListener {
public void onBucketFill(final PlayerBucketFillEvent e) { public void onBucketFill(final PlayerBucketFillEvent e) {
// Check filling of various liquids // Check filling of various liquids
switch (e.getItemStack().getType()) { switch (e.getItemStack().getType()) {
case LAVA_BUCKET -> { case LAVA_BUCKET -> checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.COLLECT_LAVA);
checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.COLLECT_LAVA); case WATER_BUCKET -> checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.COLLECT_WATER);
} case MILK_BUCKET -> checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.MILKING);
case WATER_BUCKET -> {
checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.COLLECT_WATER);
}
case MILK_BUCKET -> {
checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.MILKING);
}
default -> default ->
// Check general bucket use // Check general bucket use
checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.BUCKET); checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.BUCKET);

View File

@ -678,7 +678,7 @@ public class IslandWorldManager {
* @return data folder file object or the plugin's data folder if none found * @return data folder file object or the plugin's data folder if none found
*/ */
public File getDataFolder(@NonNull World world) { public File getDataFolder(@NonNull World world) {
return getAddon(world).map(GameModeAddon::getDataFolder).orElseGet(() -> plugin.getDataFolder()); return getAddon(world).map(GameModeAddon::getDataFolder).orElseGet(plugin::getDataFolder);
} }
/** /**

View File

@ -129,7 +129,7 @@ public class IslandsManager {
* Used only for testing. Sets the database to a mock database. * Used only for testing. Sets the database to a mock database.
* @param handler - handler * @param handler - handler
*/ */
public void setHandler(Database<Island> handler) { public void setHandler(@NonNull Database<Island> handler) {
this.handler = handler; this.handler = handler;
} }

View File

@ -32,7 +32,7 @@ public class DefaultNewIslandLocationStrategy implements NewIslandLocationStrate
ISLAND_FOUND, BLOCKS_IN_AREA, FREE ISLAND_FOUND, BLOCKS_IN_AREA, FREE
} }
protected BentoBox plugin = BentoBox.getInstance(); protected final BentoBox plugin = BentoBox.getInstance();
@Override @Override
public Location getNextLocation(World world) { public Location getNextLocation(World world) {

View File

@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.flags.Flag.Type; import world.bentobox.bentobox.api.flags.Flag.Type;
import world.bentobox.bentobox.api.flags.clicklisteners.WorldToggleClick; import world.bentobox.bentobox.api.flags.clicklisteners.WorldToggleClick;
import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.localization.TextVariables;
@ -68,7 +69,7 @@ public class WorldDefaultSettingsTab extends SettingsTab implements Tab {
* @return list of all the panel items for this flag type * @return list of all the panel items for this flag type
*/ */
@Override @Override
public List<PanelItem> getPanelItems() { public @NonNull List<PanelItem> getPanelItems() {
// Different description and click handlers // Different description and click handlers
return getFlags().stream().map(f -> { return getFlags().stream().map(f -> {
PanelItem i = f.toPanelItem(plugin, user, null, false); PanelItem i = f.toPanelItem(plugin, user, null, false);

View File

@ -28,7 +28,7 @@ public class IslandInfo {
/** /**
* @param plugin * Get island Info
* @param island Island to show info * @param island Island to show info
*/ */
public IslandInfo(Island island) { public IslandInfo(Island island) {

View File

@ -7,6 +7,7 @@ import org.bukkit.World.Environment;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.NonNull;
/** /**
* A biome grid for generators * A biome grid for generators
@ -37,19 +38,19 @@ public class MyBiomeGrid implements BiomeGrid {
} }
@Override @Override
public Biome getBiome(int x, int z) { public @NonNull Biome getBiome(int x, int z) {
return map.getOrDefault(new Vector(x,0,z), defaultBiome); return map.getOrDefault(new Vector(x,0,z), defaultBiome);
} }
@Override @Override
public void setBiome(int x, int z, Biome bio) { public void setBiome(int x, int z, @NonNull Biome bio) {
map.put(new Vector(x,0,z), bio); map.put(new Vector(x,0,z), bio);
} }
@Override @Override
public Biome getBiome(int x, int y, int z) { public @NonNull Biome getBiome(int x, int y, int z) {
return map.getOrDefault(new Vector(x,y,z), defaultBiome); return map.getOrDefault(new Vector(x,y,z), defaultBiome);
} }
@Override @Override
public void setBiome(int x, int y, int z, Biome bio) { public void setBiome(int x, int y, int z, @NonNull Biome bio) {
map.put(new Vector(x, y, z), bio); map.put(new Vector(x, y, z), bio);
} }