More annotation work

This commit is contained in:
Alexander Söderberg 2021-01-10 00:01:48 +01:00
parent 57fc51d013
commit 8292ed9e31
No known key found for this signature in database
GPG Key ID: FAB5B92197200E2C
35 changed files with 144 additions and 108 deletions

View File

@ -981,7 +981,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
@Override
public @Nullable final ChunkGenerator getDefaultWorldGenerator(final @NonNull String worldName, final String id) {
public @Nullable final ChunkGenerator getDefaultWorldGenerator(
final @NonNull String worldName,
final @Nullable String id)
{
final IndependentPlotGenerator result;
if (id != null && id.equalsIgnoreCase("single")) {
result = injector().getInstance(SingleWorldGenerator.class);
@ -995,7 +998,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
@Override
public @Nullable GeneratorWrapper<?> getGenerator(final @NonNull String world, final @Nullable String name) {
public @Nullable GeneratorWrapper<?> getGenerator(
final @NonNull String world,
final @Nullable String name
) {
if (name == null) {
return null;
}
@ -1108,7 +1114,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
@Override
public @NonNull GeneratorWrapper<?> wrapPlotGenerator(
final @Nullable String world,
final @NonNull String world,
final @NonNull IndependentPlotGenerator generator
) {
return new BukkitPlotGenerator(world, generator, this.plotAreaManager);
@ -1194,7 +1200,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
@NonNull
@Override
public String toLegacyPlatformString(Component component) {
public String toLegacyPlatformString(final @NonNull Component component) {
return LegacyComponentSerializer.legacyAmpersand().serialize(component);
}

View File

@ -125,7 +125,7 @@ public class BukkitUtil extends WorldUtil {
* @param player Bukkit player
* @return PlotSquared player
*/
public @NonNull static BukkitPlayer adapt(final @NonNull Player player) {
public static @NonNull BukkitPlayer adapt(final @NonNull Player player) {
final PlayerManager<?, ?> playerManager = PlotSquared.platform().playerManager();
return ((BukkitPlayerManager) playerManager).getPlayer(player);
}
@ -137,7 +137,7 @@ public class BukkitUtil extends WorldUtil {
* @param location Bukkit location
* @return PlotSquared location
*/
public @NonNull static Location adapt(final org.bukkit.@NonNull Location location) {
public static @NonNull Location adapt(final org.bukkit.@NonNull Location location) {
return Location
.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
MathMan.roundInt(location.getX()),
@ -153,7 +153,7 @@ public class BukkitUtil extends WorldUtil {
* @param location Bukkit location
* @return PlotSquared location
*/
public @NonNull static Location adaptComplete(final org.bukkit.@NonNull Location location) {
public static @NonNull Location adaptComplete(final org.bukkit.@NonNull Location location) {
return Location
.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
MathMan.roundInt(location.getX()),
@ -186,7 +186,7 @@ public class BukkitUtil extends WorldUtil {
* @param string World name
* @return World if it exists, or {@code null}
*/
public @Nullable static World getWorld(final @NonNull String string) {
public static @Nullable World getWorld(final @NonNull String string) {
return Bukkit.getWorld(string);
}

View File

@ -49,7 +49,7 @@ public class BukkitWorld implements World<org.bukkit.World> {
* @param worldName World name
* @return World instance
*/
public @NonNull static BukkitWorld of(final @NonNull String worldName) {
public static @NonNull BukkitWorld of(final @NonNull String worldName) {
final org.bukkit.World bukkitWorld = Bukkit.getWorld(worldName);
if (bukkitWorld == null) {
throw new IllegalArgumentException(String.format("There is no world with the name '%s'", worldName));
@ -63,7 +63,7 @@ public class BukkitWorld implements World<org.bukkit.World> {
* @param world Bukkit world
* @return World instance
*/
public @NonNull static BukkitWorld of(final org.bukkit.World world) {
public static @NonNull BukkitWorld of(final org.bukkit.World world) {
BukkitWorld bukkitWorld = worldMap.get(world.getName());
if (bukkitWorld != null && bukkitWorld.getPlatformWorld().equals(world)) {
return bukkitWorld;

View File

@ -154,8 +154,6 @@ public class PlotAPI {
final @NonNull String message,
final @NonNull Template @NonNull... replacements) {
ConsolePlayer.getConsole().sendMessage(StaticCaption.of(message), replacements);
// TODO: Re-implement
// PlotSquared.log(message);
}
/**

View File

@ -85,8 +85,7 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Plugin name
*/
@NonNull
default String pluginName() {
default @NonNull String pluginName() {
return "PlotSquared";
}
@ -316,6 +315,12 @@ public interface PlotPlatform<P> extends LocaleHolder {
return injector().getInstance(PlaceholderRegistry.class);
}
@NonNull String toLegacyPlatformString(Component component);
/**
* Convert a component to a legacy string
*
* @param component Component to convert
* @return Converted string
*/
@NonNull String toLegacyPlatformString(@NonNull Component component);
}

View File

@ -1583,10 +1583,25 @@ public class PlotSquared {
return this.plotListener;
}
/**
* Different ways of sorting {@link Plot plots}
*/
public enum SortType {
/**
* Sort plots by their creation, using their index in the database
*/
CREATION_DATE,
/**
* Sort plots by their creation timestamp
*/
CREATION_DATE_TIMESTAMP,
/**
* Sort plots by when they were last modified
*/
LAST_MODIFIED,
/**
* Sort plots based on their distance from the origin of the world
*/
DISTANCE_FROM_ORIGIN
}

View File

@ -36,7 +36,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class CmdConfirm {
public @Nullable static CmdInstance getPending(PlotPlayer<?> player) {
public static @Nullable CmdInstance getPending(PlotPlayer<?> player) {
try (final MetaDataAccess<CmdInstance> metaDataAccess = player.accessTemporaryMetaData(
PlayerMetaDataKeys.TEMPORARY_CONFIRM)) {
return metaDataAccess.get().orElse(null);

View File

@ -42,7 +42,7 @@ public final class StaticCaption implements Caption {
* @param text Text
* @return Created caption
*/
public @NonNull static StaticCaption of(final @NonNull String text) {
public static @NonNull StaticCaption of(final @NonNull String text) {
return new StaticCaption(Preconditions.checkNotNull(text, "Text may not be null"));
}

View File

@ -54,7 +54,7 @@ public final class Templates {
* @param replacements Replacements
* @return Generated template
*/
public @NonNull static Template of(
public static @NonNull Template of(
final @NonNull LocaleHolder localeHolder,
final @NonNull String key, final @NonNull Caption caption,
final @NonNull Template... replacements
@ -69,7 +69,7 @@ public final class Templates {
* @param uuid Player UUID
* @return Generated template
*/
public @NonNull static Template of(final @NonNull String key, final @NonNull UUID uuid) {
public static @NonNull Template of(final @NonNull String key, final @NonNull UUID uuid) {
final String username = PlayerManager.getName(uuid);
return Template.of(key, username);
}
@ -81,7 +81,7 @@ public final class Templates {
* @param value Template value
* @return Generated template
*/
public @NonNull static Template of(final @NonNull String key, final @NonNull String value) {
public static @NonNull Template of(final @NonNull String key, final @NonNull String value) {
return Template.of(key, value);
}
@ -92,7 +92,7 @@ public final class Templates {
* @param area Plot area
* @return Generated template
*/
public @NonNull static Template of(final @NonNull String key, final @NonNull PlotArea area) {
public static @NonNull Template of(final @NonNull String key, final @NonNull PlotArea area) {
return Template.of(key, area.toString());
}
@ -103,7 +103,7 @@ public final class Templates {
* @param number Number
* @return Generated template
*/
public @NonNull static Template of(final @NonNull String key, final @NonNull Number number) {
public static @NonNull Template of(final @NonNull String key, final @NonNull Number number) {
return Template.of(key, number.toString());
}

View File

@ -57,7 +57,7 @@ public final class TranslatableCaption implements NamespacedCaption {
* included, {@link #DEFAULT_NAMESPACE} will be used.
* @return Caption instance
*/
public @NonNull static TranslatableCaption of(final @NonNull String rawKey) {
public static @NonNull TranslatableCaption of(final @NonNull String rawKey) {
final String namespace;
final String key;
if (rawKey.contains(":")) {
@ -81,7 +81,7 @@ public final class TranslatableCaption implements NamespacedCaption {
* @param key Caption key
* @return Caption instance
*/
public @NonNull static TranslatableCaption of(
public static @NonNull TranslatableCaption of(
final @NonNull String namespace,
final @NonNull String key
) {

View File

@ -30,6 +30,7 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.queue.ScopedQueueCoordinator;
import com.plotsquared.core.setup.PlotAreaBuilder;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* This class allows for implementation independent world generation.
@ -94,7 +95,7 @@ public abstract class IndependentPlotGenerator {
* @param world ChunkGenerator Implementation
* @return Chunk generator
*/
public <T> GeneratorWrapper<T> specify(String world) {
public <T> GeneratorWrapper<T> specify(final @NonNull String world) {
return (GeneratorWrapper<T>) PlotSquared.platform().wrapPlotGenerator(world, this);
}

View File

@ -84,7 +84,7 @@ public final class Location extends BlockLoc implements Comparable<Location> {
* @param pitch pitch
* @return New location
*/
public @NonNull static Location at(
public static @NonNull Location at(
final @NonNull String world,
final @NonNull BlockVector3 blockVector3, final float yaw, final float pitch
) {
@ -98,7 +98,7 @@ public final class Location extends BlockLoc implements Comparable<Location> {
* @param blockVector3 (x,y,z) vector
* @return New location
*/
public @NonNull static Location at(
public static @NonNull Location at(
final @NonNull String world,
final @NonNull BlockVector3 blockVector3
) {
@ -116,7 +116,7 @@ public final class Location extends BlockLoc implements Comparable<Location> {
* @param pitch Pitch
* @return New location
*/
public @NonNull static Location at(
public static @NonNull Location at(
final @NonNull String world, final int x, final int y,
final int z, final float yaw, final float pitch
) {
@ -132,7 +132,7 @@ public final class Location extends BlockLoc implements Comparable<Location> {
* @param z Z coordinate
* @return New location
*/
public @NonNull static Location at(
public static @NonNull Location at(
final @NonNull String world, final int x, final int y,
final int z
) {
@ -148,7 +148,7 @@ public final class Location extends BlockLoc implements Comparable<Location> {
* @param pitch pitch
* @return New location
*/
public @NonNull static Location at(
public static @NonNull Location at(
final @NonNull World<?> world,
final @NonNull BlockVector3 blockVector3, final float yaw, final float pitch
) {
@ -162,7 +162,7 @@ public final class Location extends BlockLoc implements Comparable<Location> {
* @param blockVector3 (x,y,z) vector
* @return New location
*/
public @NonNull static Location at(
public static @NonNull Location at(
final @NonNull World<?> world,
final @NonNull BlockVector3 blockVector3
) {
@ -180,7 +180,7 @@ public final class Location extends BlockLoc implements Comparable<Location> {
* @param pitch Pitch
* @return New location
*/
public @NonNull static Location at(
public static @NonNull Location at(
final @NonNull World<?> world, final int x, final int y,
final int z, final float yaw, final float pitch
) {
@ -196,7 +196,7 @@ public final class Location extends BlockLoc implements Comparable<Location> {
* @param z Z coordinate
* @return New location
*/
public @NonNull static Location at(
public static @NonNull Location at(
final @NonNull World<?> world, final int x, final int y,
final int z
) {

View File

@ -53,7 +53,7 @@ public final class PlotLoc {
this.z = z;
}
public @Nullable static PlotLoc fromString(final String input) {
public static @Nullable PlotLoc fromString(final String input) {
if (input == null || "side".equalsIgnoreCase(input)) {
return null;
} else if (StringMan.isEqualIgnoreCaseToAny(input, "center", "middle")) {

View File

@ -62,7 +62,7 @@ public final class MetaDataKey<T> {
* @param <T> Type
* @return MetaData key instance
*/
public @NonNull static <T> MetaDataKey<T> of(final @NonNull String key, final @NonNull TypeLiteral<T> type) {
public static @NonNull <T> MetaDataKey<T> of(final @NonNull String key, final @NonNull TypeLiteral<T> type) {
synchronized (keyMetaData) {
return (MetaDataKey<T>)
keyMap.computeIfAbsent(key, missingKey -> new MetaDataKey<>(missingKey, type));

View File

@ -319,7 +319,7 @@ public class Plot {
* @param message If a message should be sent to the player if a plot cannot be found
* @return The plot if only 1 result is found, or null
*/
public @Nullable static Plot getPlotFromString(
public static @Nullable Plot getPlotFromString(
final @Nullable PlotPlayer<?> player,
final @Nullable String arg,
final boolean message
@ -386,7 +386,7 @@ public class Plot {
* @param string plot id/area + id
* @return New or existing plot object
*/
public @Nullable static Plot fromString(final @Nullable PlotArea defaultArea, final @NonNull String string) {
public static @Nullable Plot fromString(final @Nullable PlotArea defaultArea, final @NonNull String string) {
final String[] split = string.split("[;,]");
if (split.length == 2) {
if (defaultArea != null) {
@ -416,7 +416,7 @@ public class Plot {
* @return plot at location or null
* @see PlotPlayer#getCurrentPlot() if a player is expected here.
*/
public @Nullable static Plot getPlot(final @NonNull Location location) {
public static @Nullable Plot getPlot(final @NonNull Location location) {
final PlotArea pa = location.getPlotArea();
if (pa != null) {
return pa.getPlot(location);

View File

@ -61,7 +61,7 @@ public final class PlotId {
* @param y The plot y coordinate
* @return a new PlotId at x,y
*/
public @NonNull static PlotId of(final int x, final int y) {
public static @NonNull PlotId of(final int x, final int y) {
return new PlotId(x, y);
}
@ -72,7 +72,7 @@ public final class PlotId {
* @return the PlotId representation of the argument
* @throws IllegalArgumentException if the string does not contain a valid PlotId
*/
public @NonNull static PlotId fromString(final @NonNull String string) {
public static @NonNull PlotId fromString(final @NonNull String string) {
final PlotId plot = fromStringOrNull(string);
if (plot == null) {
throw new IllegalArgumentException("Cannot create PlotID. String invalid.");
@ -86,7 +86,7 @@ public final class PlotId {
* @param string ID string
* @return Plot ID, or {@code null} if none could be parsed
*/
public @Nullable static PlotId fromStringOrNull(final @NonNull String string) {
public static @Nullable PlotId fromStringOrNull(final @NonNull String string) {
final String[] parts = string.split("[;_,.]");
if (parts.length < 2) {
return null;
@ -109,7 +109,7 @@ public final class PlotId {
* @param hash ID hash
* @return Plot ID
*/
public @NonNull static PlotId unpair(final int hash) {
public static @NonNull PlotId unpair(final int hash) {
return PlotId.of(hash >> 16, hash & 0xFFFF);
}

View File

@ -131,7 +131,7 @@ public class DenyTeleportFlag extends PlotFlag<DenyTeleportFlag.DeniedGroup, Den
NONTRUSTED,
NONOWNERS;
public @Nullable static DeniedGroup fromString(final @NonNull String string) {
public static @Nullable DeniedGroup fromString(final @NonNull String string) {
for (final DeniedGroup group : values()) {
if (group.name().equalsIgnoreCase(string)) {
return group;

View File

@ -98,7 +98,7 @@ public class TitlesFlag extends PlotFlag<TitlesFlag.TitlesFlagValue, TitlesFlag>
TRUE,
FALSE;
public @Nullable static TitlesFlagValue fromString(final String value) {
public static @Nullable TitlesFlagValue fromString(final String value) {
if (value.equalsIgnoreCase("true")) {
return TRUE;
} else if (value.equalsIgnoreCase("false")) {

View File

@ -135,8 +135,7 @@ public interface PlotAreaManager {
* @param region Optional region
* @return All areas in the world (and region)
*/
@NonNull
default Set<PlotArea> getPlotAreasSet(
default @NonNull Set<@NonNull PlotArea> getPlotAreasSet(
final @NonNull String world,
final @Nullable CuboidRegion region
) {
@ -153,8 +152,7 @@ public interface PlotAreaManager {
* @param world World name
* @return Modifiable set containing all plot areas in the specified world
*/
@NonNull
default Set<PlotArea> getPlotAreasSet(final @NonNull String world) {
default @NonNull Set<@NonNull PlotArea> getPlotAreasSet(final @NonNull String world) {
final Set<PlotArea> set = new HashSet<>();
Collections.addAll(set, this.getPlotAreas(world, null));
return set;
@ -167,8 +165,7 @@ public interface PlotAreaManager {
* @param search Search string
* @return An area that matches the search string, or {@code null}
*/
@Nullable
default PlotArea getPlotAreaByString(final @NonNull String search) {
default @Nullable PlotArea getPlotAreaByString(final @NonNull String search) {
String[] split = search.split("[;,]");
PlotArea[] areas = this.getPlotAreas(split[0], null);
if (areas == null) {

View File

@ -60,7 +60,7 @@ public enum CommonSetupSteps implements SetupStep {
return CommonSetupSteps.CHOOSE_PLOT_AREA_TYPE; // proceed with next step
}
@NonNull
@Override
public Collection<String> getSuggestions() {
return Collections.unmodifiableSet(SetupUtils.generators.keySet());

View File

@ -55,7 +55,7 @@ public final class LockKey {
* @param key Key name
* @return Lock key instance
*/
public @NonNull static LockKey of(final @NonNull String key) {
public static @NonNull LockKey of(final @NonNull String key) {
synchronized (keyLock) {
return keyMap.computeIfAbsent(key, LockKey::new);
}

View File

@ -64,7 +64,7 @@ public final class BlockUtil {
* @param id Legacy ID
* @return Block state, or {@code null}
*/
public @Nullable static BlockState get(final int id) {
public static @Nullable BlockState get(final int id) {
return LegacyMapper.getInstance().getBlockFromLegacy(id);
}
@ -75,7 +75,7 @@ public final class BlockUtil {
* @param data Legacy data
* @return Block state, or {@code null}
*/
public @Nullable static BlockState get(final int id, final int data) {
public static @Nullable BlockState get(final int id, final int data) {
return LegacyMapper.getInstance().getBlockFromLegacy(id, data);
}
@ -83,20 +83,21 @@ public final class BlockUtil {
* Get a {@link BlockState} from its ID
*
* @param id String or integer ID
* @return Parsed block state, or {@code null} if none
* @return Parsed block state, or {@code null} if none
* could be parsed
*/
public @Nullable static BlockState get(@NonNull String id) {
public static @Nullable BlockState get(final @NonNull String id) {
if (id.length() == 1 && id.charAt(0) == '*') {
return FuzzyBlockState.builder().type(BlockTypes.AIR).build();
}
id = id.toLowerCase();
BlockType type = BlockTypes.get(id);
String mutableId = id;
mutableId = id.toLowerCase();
BlockType type = BlockTypes.get(mutableId );
if (type != null) {
return type.getDefaultState();
}
if (Character.isDigit(id.charAt(0))) {
String[] split = id.split(":");
if (Character.isDigit(mutableId .charAt(0))) {
String[] split = mutableId .split(":");
if (MathMan.isInteger(split[0])) {
if (split.length == 2) {
if (MathMan.isInteger(split[1])) {
@ -108,7 +109,7 @@ public final class BlockUtil {
}
}
try {
BaseBlock block = PARSER.parseFromInput(id, PARSER_CONTEXT);
BaseBlock block = PARSER.parseFromInput(mutableId, PARSER_CONTEXT);
return block.toImmutableState();
} catch (InputParseException e) {
return null;
@ -121,7 +122,7 @@ public final class BlockUtil {
* @param commaDelimited List of block states
* @return Parsed block states
*/
public @NonNull static BlockState[] parse(final @NonNull String commaDelimited) {
public static @NonNull BlockState[] parse(final @NonNull String commaDelimited) {
final String[] split = commaDelimited.split(",(?![^\\(\\[]*[\\]\\)])");
final BlockState[] result = new BlockState[split.length];
for (int i = 0; i < split.length; i++) {
@ -137,7 +138,7 @@ public final class BlockUtil {
* @return Deserialized block state, or {@code null} if the map is
* not a properly serialized block state
*/
public @Nullable static BlockState deserialize(final @NonNull Map<String, Object> map) {
public static @Nullable BlockState deserialize(final @NonNull Map<String, Object> map) {
if (map.containsKey("material")) {
final Object object = map.get("material");
return get(object.toString());

View File

@ -58,7 +58,7 @@ public final class FileUtils {
}
}
public @NonNull static File getFile(final @NonNull File base, final @NonNull String path) {
public static @NonNull File getFile(final @NonNull File base, final @NonNull String path) {
if (Paths.get(path).isAbsolute()) {
return new File(path);
}

View File

@ -117,7 +117,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
* @param localeHolder the localeHolder to localize the component for
* @return Component of name list
*/
public @NonNull static Component getPlayerList(final @NonNull Collection<UUID> uuids, LocaleHolder localeHolder) {
public static @NonNull Component getPlayerList(final @NonNull Collection<UUID> uuids, LocaleHolder localeHolder) {
if (uuids.isEmpty()) {
return MINI_MESSAGE.parse(TranslatableCaption.of("info.none").getComponent(localeHolder));
}
@ -163,7 +163,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
* @param owner Owner UUID
* @return The player's name, None, Everyone or Unknown
*/
public @NonNull static String getName(final @Nullable UUID owner) {
public static @NonNull String getName(final @Nullable UUID owner) {
return getName(owner, true);
}
@ -174,7 +174,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
* @param blocking Whether or not the operation can be blocking
* @return The player's name, None, Everyone or Unknown
*/
public @NonNull static String getName(final @Nullable UUID owner, final boolean blocking) {
public static @NonNull String getName(final @Nullable UUID owner, final boolean blocking) {
if (owner == null) {
TranslatableCaption.of("info.none");
}

View File

@ -38,7 +38,7 @@ import java.util.Iterator;
public class RegionUtil {
public @NonNull static Location[] getCorners(
public static @NonNull Location[] getCorners(
final @NonNull String world,
final @NonNull CuboidRegion region
) {
@ -47,7 +47,7 @@ public class RegionUtil {
return new Location[]{Location.at(world, min), Location.at(world, max)};
}
public @NonNull static Location[] getCorners(String world, Collection<CuboidRegion> regions) {
public static @NonNull Location[] getCorners(String world, Collection<CuboidRegion> regions) {
CuboidRegion aabb = getAxisAlignedBoundingBox(regions);
return getCorners(world, aabb);
}
@ -58,7 +58,7 @@ public class RegionUtil {
* @param regions The regions the bounding box should contain.
* @return a CuboidRegion that contains all given regions.
*/
public @NonNull static CuboidRegion getAxisAlignedBoundingBox(Iterable<CuboidRegion> regions) {
public static @NonNull CuboidRegion getAxisAlignedBoundingBox(Iterable<CuboidRegion> regions) {
Iterator<CuboidRegion> iterator = regions.iterator();
if (!iterator.hasNext()) {
throw new IllegalArgumentException("No regions given");
@ -102,7 +102,7 @@ public class RegionUtil {
.getY() && y <= max.getY();
}
public @NonNull static Rectangle2D toRectangle(final @NonNull CuboidRegion region) {
public static @NonNull Rectangle2D toRectangle(final @NonNull CuboidRegion region) {
final BlockVector2 min = region.getMinimumPoint().toBlockVector2();
final BlockVector2 max = region.getMaximumPoint().toBlockVector2();
return new Rectangle2D.Double(min.getX(), min.getZ(), max.getX(), max.getZ());

View File

@ -81,7 +81,7 @@ public final class TabCompletions {
* @param existing Players that should not be included in completions
* @return List of completions
*/
public @NonNull static List<Command> completePlayers(
public static @NonNull List<Command> completePlayers(
final @NonNull String input,
final @NonNull List<String> existing
) {
@ -96,7 +96,7 @@ public final class TabCompletions {
* @param existing Players that should not be included in completions
* @return List of completions
*/
public @NonNull static List<Command> completeAddedPlayers(
public static @NonNull List<Command> completeAddedPlayers(
final @NonNull Plot plot,
final @NonNull String input, final @NonNull List<String> existing
) {
@ -107,7 +107,7 @@ public final class TabCompletions {
);
}
public @NonNull static List<Command> completePlayersInPlot(
public static @NonNull List<Command> completePlayersInPlot(
final @NonNull Plot plot,
final @NonNull String input, final @NonNull List<String> existing
) {
@ -130,7 +130,7 @@ public final class TabCompletions {
* @param input Command input
* @return List of completions
*/
public @NonNull static List<Command> completePatterns(final @NonNull String input) {
public static @NonNull List<Command> completePatterns(final @NonNull String input) {
return PatternUtil.getSuggestions(input.trim()).stream()
.map(value -> value.toLowerCase(Locale.ENGLISH).replace("minecraft:", ""))
.filter(value -> value.startsWith(input.toLowerCase(Locale.ENGLISH)))
@ -138,7 +138,7 @@ public final class TabCompletions {
}).collect(Collectors.toList());
}
public @NonNull static List<Command> completeBoolean(final @NonNull String input) {
public static @NonNull List<Command> completeBoolean(final @NonNull String input) {
if (input.isEmpty()) {
return Arrays.asList(booleanTrueCompletion, booleanFalseCompletion);
}
@ -160,7 +160,7 @@ public final class TabCompletions {
* @param highestLimit Highest number to include
* @return Unmodifiable list of number completions
*/
public @NonNull static List<Command> completeNumbers(
public static @NonNull List<Command> completeNumbers(
final @NonNull String input,
final int amountLimit, final int highestLimit
) {
@ -187,7 +187,7 @@ public final class TabCompletions {
* @param input Input to filter with
* @return Unmodifiable list of area completions
*/
public @NonNull static List<Command> completeAreas(final @NonNull String input) {
public static @NonNull List<Command> completeAreas(final @NonNull String input) {
final List<Command> completions = new ArrayList<>();
for (final PlotArea area : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
String areaName = area.getWorldName();
@ -205,7 +205,7 @@ public final class TabCompletions {
return Collections.unmodifiableList(completions);
}
public @NonNull static List<Command> asCompletions(String... toFilter) {
public static @NonNull List<Command> asCompletions(String... toFilter) {
final List<Command> completions = new ArrayList<>();
for (String completion : toFilter) {
completions.add(new Command(null, false, completion, "",

View File

@ -40,7 +40,7 @@ public final class TimeUtil {
* @param time Time to format
* @return Formatted string
*/
public @NonNull static String secToTime(@NonNegative long time) {
public static @NonNull String secToTime(@NonNegative long time) {
StringBuilder toReturn = new StringBuilder();
if (time >= 33868800) {
int years = (int) (time / 33868800);

View File

@ -92,7 +92,7 @@ public abstract class TaskManager {
* @param id Task ID
* @return Task if stored, or {@code null}
*/
public @Nullable static PlotSquaredTask removeTask(final int id) {
public static @Nullable PlotSquaredTask removeTask(final int id) {
return tasks.remove(id);
}
@ -104,7 +104,7 @@ public abstract class TaskManager {
* @param taskTime Task interval
* @return Created task object, can be used to cancel the task
*/
public @NonNull static PlotSquaredTask runTaskRepeat(
public static @NonNull PlotSquaredTask runTaskRepeat(
final @Nullable Runnable runnable,
final @NonNull TaskTime taskTime
) {
@ -188,7 +188,7 @@ public abstract class TaskManager {
}
}
public @Nullable static TaskManager getPlatformImplementation() {
public static @Nullable TaskManager getPlatformImplementation() {
return platformImplementation;
}

View File

@ -48,7 +48,7 @@ public final class TaskTime {
* @param seconds Seconds
* @return Created task time instance
*/
public @NonNull static TaskTime seconds(@NonNegative final long seconds) {
public static @NonNull TaskTime seconds(@NonNegative final long seconds) {
return new TaskTime(seconds * 1000L, TaskUnit.MILLISECONDS);
}
@ -58,7 +58,7 @@ public final class TaskTime {
* @param ticks Server ticks
* @return Created task time instance
*/
public @NonNull static TaskTime ticks(@NonNegative final long ticks) {
public static @NonNull TaskTime ticks(@NonNegative final long ticks) {
return new TaskTime(ticks, TaskUnit.TICKS);
}
@ -68,7 +68,7 @@ public final class TaskTime {
* @param ms Milliseconds
* @return Created task time instance
*/
public @NonNull static TaskTime ms(@NonNegative final long ms) {
public static @NonNull TaskTime ms(@NonNegative final long ms) {
return new TaskTime(ms, TaskUnit.MILLISECONDS);
}

View File

@ -58,21 +58,21 @@ public class CacheUUIDService implements UUIDService, Consumer<List<UUIDMapping>
}
@Override
public @NonNull List<UUIDMapping> getNames(final @NonNull List<UUID> uuids) {
public @NonNull List<UUIDMapping> getNames(final @NonNull List<@NonNull UUID> uuids) {
final List<UUIDMapping> mappings = new ArrayList<>(uuids.size());
mappings.addAll(this.uuidCache.getAllPresent(uuids).values());
return mappings;
}
@Override
public @NonNull List<UUIDMapping> getUUIDs(final @NonNull List<String> usernames) {
public @NonNull List<UUIDMapping> getUUIDs(final @NonNull List<@NonNull String> usernames) {
final List<UUIDMapping> mappings = new ArrayList<>(usernames.size());
mappings.addAll(this.usernameCache.getAllPresent(usernames).values());
return mappings;
}
@Override
public void accept(final List<UUIDMapping> uuidMappings) {
public void accept(final @NonNull List<@NonNull UUIDMapping> uuidMappings) {
for (final UUIDMapping mapping : uuidMappings) {
this.uuidCache.put(mapping.getUuid(), mapping);
this.usernameCache.put(mapping.getUsername(), mapping);
@ -80,7 +80,7 @@ public class CacheUUIDService implements UUIDService, Consumer<List<UUIDMapping>
}
@Override
public @NonNull Collection<UUIDMapping> getImmediately() {
public @NonNull Collection<@NonNull UUIDMapping> getImmediately() {
return this.usernameCache.asMap().values();
}

View File

@ -36,7 +36,10 @@ public class ServiceError extends RuntimeException {
super(message);
}
public ServiceError(final @NonNull String message, final @NonNull Throwable cause) {
public ServiceError(
final @NonNull String message,
final @NonNull Throwable cause
) {
super(message, cause);
}

View File

@ -38,7 +38,7 @@ public class UUIDMapping {
private final UUID uuid;
private final String username;
public UUIDMapping(final @NonNull UUID uuid, final String username) {
public UUIDMapping(final @NonNull UUID uuid, final @NonNull String username) {
this.uuid = uuid;
this.username = username;
}

View File

@ -101,7 +101,7 @@ public class UUIDPipeline {
*
* @param mappingConsumer Consumer to register
*/
public void registerConsumer(final @NonNull Consumer<List<UUIDMapping>> mappingConsumer) {
public void registerConsumer(final @NonNull Consumer<@NonNull List<@NonNull UUIDMapping>> mappingConsumer) {
this.consumerList.add(mappingConsumer);
}
@ -110,7 +110,7 @@ public class UUIDPipeline {
*
* @return Copy of service list
*/
public List<UUIDService> getServiceListInstance() {
public @NonNull List<@NonNull UUIDService> getServiceListInstance() {
return Collections.unmodifiableList(this.serviceList);
}
@ -119,7 +119,7 @@ public class UUIDPipeline {
*
* @param mappings Mappings
*/
public void consume(final @NonNull List<UUIDMapping> mappings) {
public void consume(final @NonNull List<@NonNull UUIDMapping> mappings) {
final Runnable runnable = () -> {
for (final Consumer<List<UUIDMapping>> consumer : this.consumerList) {
consumer.accept(mappings);
@ -213,7 +213,7 @@ public class UUIDPipeline {
* @param username Username
* @param uuid UUID consumer
*/
public void getSingle(final @NonNull String username, final @NonNull BiConsumer<UUID, Throwable> uuid) {
public void getSingle(final @NonNull String username, final @NonNull BiConsumer<@Nullable UUID, @Nullable Throwable> uuid) {
this.getUUIDs(Collections.singletonList(username)).applyToEither(
timeoutAfter(Settings.UUID.NON_BLOCKING_TIMEOUT),
Function.identity()
@ -237,7 +237,7 @@ public class UUIDPipeline {
* @param uuid UUID
* @param username Username consumer
*/
public void getSingle(final @NonNull UUID uuid, final @NonNull BiConsumer<String, Throwable> username) {
public void getSingle(final @NonNull UUID uuid, final @NonNull BiConsumer<@Nullable String, @Nullable Throwable> username) {
this.getNames(Collections.singletonList(uuid)).applyToEither(
timeoutAfter(Settings.UUID.NON_BLOCKING_TIMEOUT),
Function.identity()
@ -265,7 +265,10 @@ public class UUIDPipeline {
* @param timeout Timeout in milliseconds
* @return Mappings
*/
public CompletableFuture<List<UUIDMapping>> getNames(final @NonNull Collection<UUID> requests, final long timeout) {
public @NonNull CompletableFuture<@NonNull List<@NonNull UUIDMapping>> getNames(
final @NonNull Collection<@NonNull UUID> requests,
final long timeout
) {
return this.getNames(requests).applyToEither(timeoutAfter(timeout), Function.identity());
}
@ -279,11 +282,14 @@ public class UUIDPipeline {
* @param timeout Timeout in milliseconds
* @return Mappings
*/
public CompletableFuture<List<UUIDMapping>> getUUIDs(final @NonNull Collection<String> requests, final long timeout) {
public @NonNull CompletableFuture<List<UUIDMapping>> getUUIDs(
final @NonNull Collection<String> requests,
final long timeout
) {
return this.getUUIDs(requests).applyToEither(timeoutAfter(timeout), Function.identity());
}
private CompletableFuture<List<UUIDMapping>> timeoutAfter(final long timeout) {
private @NonNull CompletableFuture<@NonNull List<@NonNull UUIDMapping>> timeoutAfter(final long timeout) {
final CompletableFuture<List<UUIDMapping>> result = new CompletableFuture<>();
this.timeoutExecutor.schedule(() -> result.completeExceptionally(new TimeoutException()), timeout, TimeUnit.MILLISECONDS);
return result;
@ -295,7 +301,9 @@ public class UUIDPipeline {
* @param requests UUIDs
* @return Mappings
*/
public CompletableFuture<List<UUIDMapping>> getNames(final @NonNull Collection<UUID> requests) {
public @NonNull CompletableFuture<@NonNull List<@NonNull UUIDMapping>> getNames(
final @NonNull Collection<@NonNull UUID> requests
) {
if (requests.isEmpty()) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
@ -362,7 +370,9 @@ public class UUIDPipeline {
* @param requests Names
* @return Mappings
*/
public CompletableFuture<List<UUIDMapping>> getUUIDs(final @NonNull Collection<String> requests) {
public @NonNull CompletableFuture<@NonNull List<@NonNull UUIDMapping>> getUUIDs(
final @NonNull Collection<@NonNull String> requests
) {
if (requests.isEmpty()) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
@ -417,7 +427,7 @@ public class UUIDPipeline {
*
* @return All mappings that could be provided immediately
*/
public @NonNull final Collection<UUIDMapping> getAllImmediately() {
public @NonNull final Collection<@NonNull UUIDMapping> getAllImmediately() {
final Set<UUIDMapping> mappings = new LinkedHashSet<>();
for (final UUIDService service : this.getServiceListInstance()) {
mappings.addAll(service.getImmediately());

View File

@ -45,7 +45,7 @@ public interface UUIDService {
* @param uuids Requests
* @return Completed requests
*/
@NonNull List<UUIDMapping> getNames(final @NonNull List<UUID> uuids);
@NonNull List<@NonNull UUIDMapping> getNames(final @NonNull List<@NonNull UUID> uuids);
/**
* Attempt to complete the given requests. Returns the mappings
@ -54,7 +54,7 @@ public interface UUIDService {
* @param usernames Requests
* @return Completed requests
*/
@NonNull List<UUIDMapping> getUUIDs(final @NonNull List<String> usernames);
@NonNull List<@NonNull UUIDMapping> getUUIDs(final @NonNull List<@NonNull String> usernames);
/**
* Get as many UUID mappings as possible under the condition
@ -62,7 +62,7 @@ public interface UUIDService {
*
* @return All mappings that could be provided immediately
*/
default @NonNull Collection<UUIDMapping> getImmediately() {
default @NonNull Collection<@NonNull UUIDMapping> getImmediately() {
return Collections.emptyList();
}

View File

@ -51,12 +51,12 @@ public class OfflineModeUUIDService implements UUIDService {
}
@Override
public @NonNull List<UUIDMapping> getNames(final @NonNull List<UUID> uuids) {
public @NonNull List<@NonNull UUIDMapping> getNames(final @NonNull List<@NonNull UUID> uuids) {
return Collections.emptyList();
}
@Override
public @NonNull List<UUIDMapping> getUUIDs(@NonNull List<String> usernames) {
public @NonNull List<@NonNull UUIDMapping> getUUIDs(@NonNull List<@NonNull String> usernames) {
final List<UUIDMapping> mappings = new ArrayList<>(usernames.size());
for (final String username : usernames) {
mappings.add(new UUIDMapping(getFromUsername(username), username));