Adds some missing annotations

This commit is contained in:
Kristian Knarvik 2023-12-17 14:54:00 +01:00
parent 37a773511d
commit d3a1ed2145
2 changed files with 37 additions and 22 deletions

View File

@ -6,6 +6,9 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Logger;
/**
* The plugin main class
*/
@SuppressWarnings("unused")
public final class ClearOnWorldGuard extends JavaPlugin {

View File

@ -60,12 +60,24 @@ public class WorldGuardListener implements Listener {
continue;
}
loadRegions(world, worldsSection, worldId);
}
}
/**
* Loads clear regions for a world
*
* @param world <p>The world to load regions for</p>
* @param worldsSection <p>The configuration section listing all worlds and regions</p>
* @param worldId <p>The user-specified identifier for the currently processed world</p>
*/
private void loadRegions(@NotNull World world, @NotNull ConfigurationSection worldsSection, @NotNull String worldId) {
// Get a region manager for the world
RegionManager regionManager = regionContainer.get(BukkitAdapter.adapt(world));
if (regionManager == null) {
ClearOnWorldGuard.logger().log(Level.WARNING, "Unable to get region manager for world: " +
world.getName());
continue;
return;
}
Set<ProtectedRegion> regions = new HashSet<>();
@ -81,10 +93,9 @@ public class WorldGuardListener implements Listener {
}
protectedRegions.put(world, regions);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) {
public void onMove(@NotNull PlayerMoveEvent event) {
if (event.getTo() == null || event.getFrom().getWorld() == null) {
return;
}
@ -109,7 +120,8 @@ public class WorldGuardListener implements Listener {
* @param playerRegions <p>The regions the player is in or will be in</p>
* @return <p>All clear regions found in playerRegions</p>
*/
private Set<ProtectedRegion> getOccupiedClearRegions(World playerWorld, Set<ProtectedRegion> playerRegions) {
private Set<ProtectedRegion> getOccupiedClearRegions(@NotNull World playerWorld,
@NotNull Set<ProtectedRegion> playerRegions) {
Set<ProtectedRegion> possibleRegions = protectedRegions.get(playerWorld);
Set<ProtectedRegion> result = new HashSet<>();
for (ProtectedRegion region : playerRegions) {