Replace annotations with JetBrains annotations

This commit is contained in:
MattBDev 2019-08-13 23:43:11 -04:00
parent 705d0294b5
commit a910b542a0
24 changed files with 173 additions and 187 deletions

View file

@ -55,7 +55,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;

View file

@ -30,8 +30,8 @@ public final class PlotAutoMergeEvent extends PlotEvent implements Cancellable {
* @param plot Plot that was merged
* @param plots A list of plots involved in the event
*/
public PlotAutoMergeEvent(@Nonnull final World world, @Nonnull final Plot plot,
@Nonnull final List<PlotId> plots) {
public PlotAutoMergeEvent(@NotNull final World world, @NotNull final Plot plot,
@NotNull final List<PlotId> plots) {
super(plot);
this.world = world;
this.plots = plots;

View file

@ -31,8 +31,8 @@ public final class PlotUnlinkEvent extends Event implements Cancellable {
* @param world World in which the event occurred
* @param plots Plots that are involved in the event
*/
public PlotUnlinkEvent(@Nonnull final World world, @Nonnull final PlotArea area,
@Nonnull final List<PlotId> plots) {
public PlotUnlinkEvent(@NotNull final World world, @NotNull final PlotArea area,
@NotNull final List<PlotId> plots) {
this.plots = plots;
this.world = world;
this.area = area;

View file

@ -184,7 +184,7 @@ public class BukkitPlayer extends PlotPlayer {
}
}
@Override public void teleport(@Nonnull final Location location) {
@Override public void teleport(@NotNull final Location location) {
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
return;
}
@ -229,7 +229,7 @@ public class BukkitPlayer extends PlotPlayer {
}
}
@Nonnull @Override public PlotGameMode getGameMode() {
@NotNull @Override public PlotGameMode getGameMode() {
switch (this.player.getGameMode()) {
case ADVENTURE:
return PlotGameMode.ADVENTURE;

View file

@ -1,22 +1,6 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerClaimPlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotDeniedEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotHelperEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotTrustedEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerTeleportToPlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotAutoMergeEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotChangeOwnerEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotClearEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotComponentSetEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotDeleteEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotFlagAddEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotFlagRemoveEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotMergeEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotRateEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotUnlinkEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.*;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.object.Location;
@ -30,9 +14,9 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.UUID;
@ -41,91 +25,93 @@ import java.util.UUID;
*/
public final class BukkitEventUtil extends EventUtil {
@Nullable public Player getPlayer(final PlotPlayer player) {
if (player instanceof BukkitPlayer) {
return ((BukkitPlayer) player).player;
@Nullable public Player getPlayer(final PlotPlayer player) {
if (player instanceof BukkitPlayer) {
return ((BukkitPlayer) player).player;
}
return null;
}
return null;
}
private boolean callEvent(@Nonnull final Event event) {
Bukkit.getServer().getPluginManager().callEvent(event);
return !(event instanceof Cancellable) || !((Cancellable) event).isCancelled();
}
@Override public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
return callEvent(new PlayerClaimPlotEvent(getPlayer(player), plot, auto));
}
@Override public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
return callEvent(new PlayerTeleportToPlotEvent(getPlayer(player), from, plot));
}
@Override public boolean callComponentSet(Plot plot, String component) {
return callEvent(new PlotComponentSetEvent(plot, component));
}
@Override public boolean callClear(Plot plot) {
return callEvent(new PlotClearEvent(plot));
}
@Override public boolean callDelete(Plot plot) {
return callEvent(new PlotDeleteEvent(plot));
}
@Override public boolean callFlagAdd(Flag flag, Plot plot) {
return callEvent(new PlotFlagAddEvent(flag, plot));
}
@Override public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) {
return callEvent(new PlotFlagRemoveEvent(flag, plot));
}
@Override public boolean callMerge(Plot plot, int dir, int max) {
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, dir, max));
}
@Override public boolean callAutoMerge(Plot plot, List<PlotId> plots) {
return callEvent(new PlotAutoMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
}
@Override public boolean callUnlink(PlotArea area, List<PlotId> plots) {
return callEvent(new PlotUnlinkEvent(BukkitUtil.getWorld(area.worldname), area, plots));
}
@Override public void callEntry(PlotPlayer player, Plot plot) {
callEvent(new PlayerEnterPlotEvent(getPlayer(player), plot));
}
@Override public void callLeave(PlotPlayer player, Plot plot) {
callEvent(new PlayerLeavePlotEvent(getPlayer(player), plot));
}
@Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotDeniedEvent(getPlayer(initiator), plot, player, added));
}
@Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added));
}
@Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added));
}
@Override
public boolean callOwnerChange(PlotPlayer initiator, Plot plot, UUID oldOwner, UUID newOwner,
boolean hasOldOwner) {
return callEvent(
new PlotChangeOwnerEvent(getPlayer(initiator), plot, oldOwner, newOwner, hasOldOwner));
}
@Override @Nullable public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;
private boolean callEvent(@NotNull final Event event) {
Bukkit.getServer().getPluginManager().callEvent(event);
return !(event instanceof Cancellable) || !((Cancellable) event).isCancelled();
}
@Override public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
return callEvent(new PlayerClaimPlotEvent(getPlayer(player), plot, auto));
}
@Override public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
return callEvent(new PlayerTeleportToPlotEvent(getPlayer(player), from, plot));
}
@Override public boolean callComponentSet(Plot plot, String component) {
return callEvent(new PlotComponentSetEvent(plot, component));
}
@Override public boolean callClear(Plot plot) {
return callEvent(new PlotClearEvent(plot));
}
@Override public boolean callDelete(Plot plot) {
return callEvent(new PlotDeleteEvent(plot));
}
@Override public boolean callFlagAdd(Flag flag, Plot plot) {
return callEvent(new PlotFlagAddEvent(flag, plot));
}
@Override public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) {
return callEvent(new PlotFlagRemoveEvent(flag, plot));
}
@Override public boolean callMerge(Plot plot, int dir, int max) {
return callEvent(
new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, dir, max));
}
@Override public boolean callAutoMerge(Plot plot, List<PlotId> plots) {
return callEvent(
new PlotAutoMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
}
@Override public boolean callUnlink(PlotArea area, List<PlotId> plots) {
return callEvent(new PlotUnlinkEvent(BukkitUtil.getWorld(area.worldname), area, plots));
}
@Override public void callEntry(PlotPlayer player, Plot plot) {
callEvent(new PlayerEnterPlotEvent(getPlayer(player), plot));
}
@Override public void callLeave(PlotPlayer player, Plot plot) {
callEvent(new PlayerLeavePlotEvent(getPlayer(player), plot));
}
@Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotDeniedEvent(getPlayer(initiator), plot, player, added));
}
@Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added));
}
@Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added));
}
@Override
public boolean callOwnerChange(PlotPlayer initiator, Plot plot, UUID oldOwner, UUID newOwner,
boolean hasOldOwner) {
return callEvent(
new PlotChangeOwnerEvent(getPlayer(initiator), plot, oldOwner, newOwner, hasOldOwner));
}
@Override @Nullable public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;
}
return event.getRating();
}
return event.getRating();
}
}

View file

@ -29,7 +29,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;

View file

@ -34,7 +34,7 @@ import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URISyntaxException;

View file

@ -12,7 +12,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
@CommandDeclaration(command = "auto", permission = "plots.auto",

View file

@ -17,7 +17,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import lombok.*;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.Map.Entry;

View file

@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.database;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.*;
@ -301,7 +302,7 @@ public interface AbstractDB {
*
* @param plot The Plot to get comments from
*/
void getComments(@Nonnull Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone);
void getComments(@NotNull Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone);
void createPlotAndSettings(Plot plot, Runnable whenDone);

View file

@ -2170,7 +2170,7 @@ import java.util.concurrent.atomic.AtomicInteger;
});
}
@Override public void getComments(@Nonnull Plot plot, final String inbox,
@Override public void getComments(@NotNull Plot plot, final String inbox,
final RunnableVal<List<PlotComment>> whenDone) {
addPlotTask(plot, new UniqueStatement("getComments_" + plot) {
@Override public void set(PreparedStatement statement) throws SQLException {

View file

@ -46,7 +46,7 @@ import java.util.Locale;
* command - this may be useful if a config value can be changed at a later date, and has no impact on the actual
* world generation</p>
*/
@Nonnull @Override public ConfigurationNode[] getSettingNodes() {
@NotNull @Override public ConfigurationNode[] getSettingNodes() {
return new ConfigurationNode[] {
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height",
Configuration.INTEGER),

View file

@ -7,7 +7,6 @@ import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.UUID;
public class ConsolePlayer extends PlotPlayer {
@ -101,14 +100,14 @@ public class ConsolePlayer extends PlotPlayer {
return RequiredType.CONSOLE;
}
@Override public void setWeather(@Nonnull PlotWeather weather) {
@Override public void setWeather(@NotNull PlotWeather weather) {
}
@Nonnull @Override public PlotGameMode getGameMode() {
@NotNull @Override public PlotGameMode getGameMode() {
return PlotGameMode.NOT_SET;
}
@Override public void setGameMode(@Nonnull PlotGameMode gameMode) {
@Override public void setGameMode(@NotNull PlotGameMode gameMode) {
}
@Override public void setTime(long time) {
@ -121,7 +120,7 @@ public class ConsolePlayer extends PlotPlayer {
@Override public void setFlight(boolean fly) {
}
@Override public void playMusic(@Nonnull Location location, @Nonnull PlotBlock id) {
@Override public void playMusic(@NotNull Location location, @NotNull PlotBlock id) {
}
@Override public void kick(String message) {

View file

@ -24,7 +24,7 @@ import com.sk89q.jnbt.CompoundTag;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.awt.geom.Area;
import java.awt.geom.PathIterator;
import java.awt.geom.Rectangle2D;
@ -337,7 +337,7 @@ public class Plot {
* @param uuid the player uuid
* @return if the provided uuid is the owner of the plot
*/
public boolean isOwner(@Nonnull UUID uuid) {
public boolean isOwner(@NotNull UUID uuid) {
if (uuid.equals(this.getOwner())) {
return true;
}
@ -993,7 +993,7 @@ public class Plot {
*
* @param name name
*/
public void setSign(@Nonnull String name) {
public void setSign(@NotNull String name) {
if (!isLoaded()) {
return;
}
@ -1524,7 +1524,7 @@ public class Plot {
* @param notify notify
* @return true if plot was created successfully
*/
public boolean create(@Nonnull UUID uuid, final boolean notify) {
public boolean create(@NotNull UUID uuid, final boolean notify) {
this.owner = uuid;
Plot existing = this.area.getOwnedPlotAbs(this.id);
if (existing != null) {
@ -2569,7 +2569,7 @@ public class Plot {
*
* @return
*/
@Nonnull public HashSet<RegionWrapper> getRegions() {
@NotNull public HashSet<RegionWrapper> getRegions() {
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
return regions_cache;
}

View file

@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableSet;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
@ -76,7 +76,7 @@ public abstract class PlotArea {
private ConcurrentHashMap<String, Object> meta;
private QuadMap<PlotCluster> clusters;
public PlotArea(@Nonnull final String worldName, @Nullable final String id,
public PlotArea(@NotNull final String worldName, @Nullable final String id,
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
@Nullable final PlotId max) {
this.worldname = worldName;
@ -394,7 +394,7 @@ public abstract class PlotArea {
}
}
@Nonnull @Override public String toString() {
@NotNull @Override public String toString() {
if (this.id == null) {
return this.worldname;
} else {
@ -422,7 +422,7 @@ public abstract class PlotArea {
* @param location the location
* @return the {@code Plot} or null if none exists
*/
@Nullable public Plot getPlotAbs(@Nonnull final Location location) {
@Nullable public Plot getPlotAbs(@NotNull final Location location) {
final PlotId pid =
this.manager.getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
@ -437,7 +437,7 @@ public abstract class PlotArea {
* @param location the location
* @return base Plot
*/
@Nullable public Plot getPlot(@Nonnull final Location location) {
@Nullable public Plot getPlot(@NotNull final Location location) {
final PlotId pid =
this.manager.getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
@ -452,7 +452,7 @@ public abstract class PlotArea {
* @param location the location
* @return the base plot or null
*/
@Nullable public Plot getOwnedPlot(@Nonnull final Location location) {
@Nullable public Plot getOwnedPlot(@NotNull final Location location) {
final PlotId pid =
this.manager.getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
@ -468,7 +468,7 @@ public abstract class PlotArea {
* @param location the location
* @return Plot or null
*/
@Nullable public Plot getOwnedPlotAbs(@Nonnull final Location location) {
@Nullable public Plot getOwnedPlotAbs(@NotNull final Location location) {
final PlotId pid =
this.manager.getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
@ -483,11 +483,11 @@ public abstract class PlotArea {
* @param id the {@code PlotId}
* @return the plot or null
*/
@Nullable public Plot getOwnedPlotAbs(@Nonnull final PlotId id) {
@Nullable public Plot getOwnedPlotAbs(@NotNull final PlotId id) {
return this.plots.get(id);
}
@Nullable public Plot getOwnedPlot(@Nonnull final PlotId id) {
@Nullable public Plot getOwnedPlot(@NotNull final PlotId id) {
Plot plot = this.plots.get(id);
return plot == null ? null : plot.getBasePlot(false);
}
@ -496,17 +496,17 @@ public abstract class PlotArea {
return this.TYPE != 2 || getRegionAbs().isIn(x, z);
}
public boolean contains(@Nonnull final PlotId id) {
public boolean contains(@NotNull final PlotId id) {
return this.min == null || (id.x >= this.min.x && id.x <= this.max.x && id.y >= this.min.y
&& id.y <= this.max.y);
}
public boolean contains(@Nonnull final Location location) {
public boolean contains(@NotNull final Location location) {
return StringMan.isEqual(location.getWorld(), this.worldname) && (getRegionAbs() == null
|| this.region.isIn(location.getX(), location.getZ()));
}
@Nonnull Set<Plot> getPlotsAbs(final UUID uuid) {
@NotNull Set<Plot> getPlotsAbs(final UUID uuid) {
if (uuid == null) {
return Collections.emptySet();
}
@ -519,7 +519,7 @@ public abstract class PlotArea {
return myPlots;
}
@Nonnull public Set<Plot> getPlots(@Nonnull final UUID uuid) {
@NotNull public Set<Plot> getPlots(@NotNull final UUID uuid) {
return getPlots().stream().filter(plot -> plot.isBasePlot() && plot.isOwner(uuid))
.collect(ImmutableSet.toImmutableSet());
}
@ -533,7 +533,7 @@ public abstract class PlotArea {
return this.plots.values();
}
public int getPlotCount(@Nonnull final UUID uuid) {
public int getPlotCount(@NotNull final UUID uuid) {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
return (int) getPlotsAbs(uuid).stream().filter(plot -> !plot.hasFlag(Flags.DONE))
.count();
@ -546,11 +546,11 @@ public abstract class PlotArea {
*
* @deprecated Use {@link #getPlots(UUID)}
*/
@Deprecated public Set<Plot> getPlots(@Nonnull final PlotPlayer player) {
@Deprecated public Set<Plot> getPlots(@NotNull final PlotPlayer player) {
return getPlots(player.getUUID());
}
public boolean hasPlot(@Nonnull final UUID uuid) {
public boolean hasPlot(@NotNull final UUID uuid) {
return this.plots.entrySet().stream().anyMatch(entry -> entry.getValue().isOwner(uuid));
}
@ -559,7 +559,7 @@ public abstract class PlotArea {
return player != null ? getPlotCount(player.getUUID()) : 0;
}
@Nullable public Plot getPlotAbs(@Nonnull final PlotId id) {
@Nullable public Plot getPlotAbs(@NotNull final PlotId id) {
Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
if (this.min != null && (id.x < this.min.x || id.x > this.max.x || id.y < this.min.y
@ -571,7 +571,7 @@ public abstract class PlotArea {
return plot;
}
@Nullable public Plot getPlot(@Nonnull final PlotId id) {
@Nullable public Plot getPlot(@NotNull final PlotId id) {
final Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
if (this.min != null && (id.x < this.min.x || id.x > this.max.x || id.y < this.min.y
@ -592,7 +592,7 @@ public abstract class PlotArea {
return this.plots.size();
}
@Nullable public PlotCluster getCluster(@Nonnull final Location location) {
@Nullable public PlotCluster getCluster(@NotNull final Location location) {
final Plot plot = getPlot(location);
if (plot == null) {
return null;
@ -600,8 +600,8 @@ public abstract class PlotArea {
return this.clusters != null ? this.clusters.get(plot.getId().x, plot.getId().y) : null;
}
@Nullable public PlotCluster getFirstIntersectingCluster(@Nonnull final PlotId pos1,
@Nonnull final PlotId pos2) {
@Nullable public PlotCluster getFirstIntersectingCluster(@NotNull final PlotId pos1,
@NotNull final PlotId pos2) {
if (this.clusters == null) {
return null;
}
@ -613,7 +613,7 @@ public abstract class PlotArea {
return null;
}
@Nullable PlotCluster getCluster(@Nonnull final PlotId id) {
@Nullable PlotCluster getCluster(@NotNull final PlotId id) {
return this.clusters != null ? this.clusters.get(id.x, id.y) : null;
}
@ -628,7 +628,7 @@ public abstract class PlotArea {
*
* @see FlagManager
*/
public void setMeta(@Nonnull final String key, @Nullable final Object value) {
public void setMeta(@NotNull final String key, @Nullable final Object value) {
if (this.meta == null) {
this.meta = new ConcurrentHashMap<>();
}
@ -645,14 +645,14 @@ public abstract class PlotArea {
* <br>
* For persistent metadata use the flag system
*/
@Nullable public Object getMeta(@Nonnull final String key) {
@Nullable public Object getMeta(@NotNull final String key) {
if (this.meta != null) {
return this.meta.get(key);
}
return null;
}
@SuppressWarnings("unused") @Nonnull public Set<Plot> getBasePlots() {
@SuppressWarnings("unused") @NotNull public Set<Plot> getBasePlots() {
final HashSet<Plot> myPlots = new HashSet<>(getPlots());
myPlots.removeIf(plot -> !plot.isBasePlot());
return myPlots;
@ -685,15 +685,15 @@ public abstract class PlotArea {
* @deprecated Use {@link #getPlotsMap()}
*/
//todo eventually remove
@Deprecated @Nonnull public Map<PlotId, Plot> getPlotsRaw() {
@Deprecated @NotNull public Map<PlotId, Plot> getPlotsRaw() {
return ImmutableMap.copyOf(plots);
}
@Nonnull public Set<Entry<PlotId, Plot>> getPlotEntries() {
@NotNull public Set<Entry<PlotId, Plot>> getPlotEntries() {
return this.plots.entrySet();
}
public boolean addPlot(@Nonnull final Plot plot) {
public boolean addPlot(@NotNull final Plot plot) {
for (PlotPlayer pp : plot.getPlayersInPlot()) {
pp.setMeta(PlotPlayer.META_LAST_PLOT, plot);
}
@ -731,7 +731,7 @@ public abstract class PlotArea {
return null;
}
public boolean addPlotIfAbsent(@Nonnull final Plot plot) {
public boolean addPlotIfAbsent(@NotNull final Plot plot) {
if (this.plots.putIfAbsent(plot.getId(), plot) == null) {
for (PlotPlayer pp : plot.getPlayersInPlot()) {
pp.setMeta(PlotPlayer.META_LAST_PLOT, plot);
@ -741,7 +741,7 @@ public abstract class PlotArea {
return false;
}
public boolean addPlotAbs(@Nonnull final Plot plot) {
public boolean addPlotAbs(@NotNull final Plot plot) {
return this.plots.put(plot.getId(), plot) == null;
}
@ -786,14 +786,14 @@ public abstract class PlotArea {
*
* @param key Meta data key
*/
public void deleteMeta(@Nonnull final String key) {
public void deleteMeta(@NotNull final String key) {
if (this.meta != null) {
this.meta.remove(key);
}
}
public boolean canClaim(@Nullable final PlotPlayer player, @Nonnull final PlotId pos1,
@Nonnull final PlotId pos2) {
public boolean canClaim(@Nullable final PlotPlayer player, @NotNull final PlotId pos1,
@NotNull final PlotId pos2) {
if (pos1.x == pos2.x && pos1.y == pos2.y) {
if (getOwnedPlot(pos1) != null) {
return false;
@ -819,11 +819,11 @@ public abstract class PlotArea {
return true;
}
public boolean removePlot(@Nonnull final PlotId id) {
public boolean removePlot(@NotNull final PlotId id) {
return this.plots.remove(id) != null;
}
public boolean mergePlots(@Nonnull final List<PlotId> plotIds, final boolean removeRoads) {
public boolean mergePlots(@NotNull final List<PlotId> plotIds, final boolean removeRoads) {
if (plotIds.size() < 2) {
return false;
}
@ -901,7 +901,7 @@ public abstract class PlotArea {
* @param pos2 second corner of selection
* @return the plots in the selection which are owned
*/
public Set<Plot> getPlotSelectionOwned(@Nonnull final PlotId pos1, @Nonnull final PlotId pos2) {
public Set<Plot> getPlotSelectionOwned(@NotNull final PlotId pos1, @NotNull final PlotId pos2) {
final int size = (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
final Set<Plot> result = new HashSet<>();
if (size < 16 || size < getPlotCount()) {

View file

@ -1,7 +1,7 @@
package com.github.intellectualsites.plotsquared.plot.object;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
public class PlotId {
/**
@ -32,14 +32,14 @@ public class PlotId {
* @return the PlotId representation of the arguement
* @throws IllegalArgumentException if the string does not contain a valid PlotId
*/
@Nonnull public static PlotId fromString(@Nonnull String string) {
@NotNull public static PlotId fromString(@NotNull String string) {
PlotId plot = fromStringOrNull(string);
if (plot == null)
throw new IllegalArgumentException("Cannot create PlotID. String invalid.");
return plot;
}
@Nullable public static PlotId fromStringOrNull(@Nonnull String string) {
@Nullable public static PlotId fromStringOrNull(@NotNull String string) {
String[] parts = string.split("[;|,]");
if (parts.length < 2) {
return null;

View file

@ -422,21 +422,21 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*
* @param weather the weather visible to the player
*/
public abstract void setWeather(@Nonnull PlotWeather weather);
public abstract void setWeather(@NotNull PlotWeather weather);
/**
* Get this player's gamemode.
*
* @return the gamemode of the player.
*/
@Nonnull public abstract PlotGameMode getGameMode();
@NotNull public abstract PlotGameMode getGameMode();
/**
* Set this player's gameMode.
*
* @param gameMode the gamemode to set
*/
public abstract void setGameMode(@Nonnull PlotGameMode gameMode);
public abstract void setGameMode(@NotNull PlotGameMode gameMode);
/**
* Set this player's local time (ticks).
@ -465,7 +465,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
* @param location where to play the music
* @param id the record item id
*/
public abstract void playMusic(@Nonnull Location location, @Nonnull PlotBlock id);
public abstract void playMusic(@NotNull Location location, @NotNull PlotBlock id);
/**
* Check if this player is banned.

View file

@ -60,7 +60,7 @@ public class SinglePlot extends Plot {
return super.isLoaded();
}
@Nonnull @Override public HashSet<RegionWrapper> getRegions() {
@NotNull @Override public HashSet<RegionWrapper> getRegions() {
return regions;
}

View file

@ -11,7 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@ -113,38 +113,38 @@ public class SinglePlotArea extends GridPlotWorld {
new ConfigurationNode("void", this.VOID, "Void world", Configuration.BOOLEAN)};
}
@Nullable @Override public Plot getOwnedPlot(@Nonnull final Location location) {
@Nullable @Override public Plot getOwnedPlot(@NotNull final Location location) {
PlotId pid = PlotId.fromStringOrNull(location.getWorld());
Plot plot = pid == null ? null : this.plots.get(pid);
return plot == null ? null : plot.getBasePlot(false);
}
@Nullable @Override public Plot getOwnedPlotAbs(@Nonnull Location location) {
@Nullable @Override public Plot getOwnedPlotAbs(@NotNull Location location) {
PlotId pid = PlotId.fromStringOrNull(location.getWorld());
return pid == null ? null : plots.get(pid);
}
@Nullable @Override public Plot getPlot(@Nonnull final Location location) {
@Nullable @Override public Plot getPlot(@NotNull final Location location) {
PlotId pid = PlotId.fromStringOrNull(location.getWorld());
return pid == null ? null : getPlot(pid);
}
@Nullable @Override public Plot getPlotAbs(@Nonnull final Location location) {
@Nullable @Override public Plot getPlotAbs(@NotNull final Location location) {
final PlotId pid = PlotId.fromStringOrNull(location.getWorld());
return pid == null ? null : getPlotAbs(pid);
}
public boolean addPlot(@Nonnull Plot plot) {
public boolean addPlot(@NotNull Plot plot) {
plot = adapt(plot);
return super.addPlot(plot);
}
@Override public boolean addPlotAbs(@Nonnull Plot plot) {
@Override public boolean addPlotAbs(@NotNull Plot plot) {
plot = adapt(plot);
return super.addPlotAbs(plot);
}
@Override public boolean addPlotIfAbsent(@Nonnull Plot plot) {
@Override public boolean addPlotIfAbsent(@NotNull Plot plot) {
plot = adapt(plot);
return super.addPlotIfAbsent(plot);
}
@ -160,7 +160,7 @@ public class SinglePlotArea extends GridPlotWorld {
return p;
}
@Nullable public Plot getPlotAbs(@Nonnull final PlotId id) {
@Nullable public Plot getPlotAbs(@NotNull final PlotId id) {
Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
return new SinglePlot(this, id);
@ -168,7 +168,7 @@ public class SinglePlotArea extends GridPlotWorld {
return plot;
}
@Nullable public Plot getPlot(@Nonnull PlotId id) {
@Nullable public Plot getPlot(@NotNull PlotId id) {
// TODO
Plot plot = getOwnedPlotAbs(id);
if (plot == null) {

View file

@ -10,7 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;

View file

@ -329,7 +329,7 @@ public class MainUtil {
* @param owner
* @return The player's name, None, Everyone or Unknown
*/
@Nonnull public static String getName(UUID owner) {
@NotNull public static String getName(UUID owner) {
if (owner == null) {
return Captions.NONE.getTranslated();
}
@ -358,7 +358,7 @@ public class MainUtil {
* @return
* @see Plot#getCorners()
*/
@Nonnull public static Location[] getCorners(String world, Collection<RegionWrapper> regions) {
@NotNull public static Location[] getCorners(String world, Collection<RegionWrapper> regions) {
Location min = null;
Location max = null;
for (RegionWrapper region : regions) {

View file

@ -11,7 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.google.common.collect.BiMap;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

View file

@ -15,7 +15,7 @@ import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

View file

@ -149,7 +149,7 @@ public class AbstractDBTest implements AbstractDB {
@Override public void setComment(Plot plot, PlotComment comment) {
}
@Override public void getComments(@Nonnull Plot plot, String inbox,
@Override public void getComments(@NotNull Plot plot, String inbox,
RunnableVal<List<PlotComment>> whenDone) {
}