Adds some missing annotations
This commit is contained in:
parent
37a773511d
commit
d3a1ed2145
@ -6,6 +6,9 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin main class
|
||||||
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class ClearOnWorldGuard extends JavaPlugin {
|
public final class ClearOnWorldGuard extends JavaPlugin {
|
||||||
|
|
||||||
|
@ -60,31 +60,42 @@ public class WorldGuardListener implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a region manager for the world
|
loadRegions(world, worldsSection, worldId);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<ProtectedRegion> regions = new HashSet<>();
|
|
||||||
List<String> regionNames = worldsSection.getStringList(worldId);
|
|
||||||
for (String regionName : regionNames) {
|
|
||||||
// Register the region if it's valid
|
|
||||||
ProtectedRegion region = regionManager.getRegion(regionName);
|
|
||||||
if (region == null) {
|
|
||||||
ClearOnWorldGuard.logger().log(Level.WARNING, "Region name " + regionName + " is invalid");
|
|
||||||
} else {
|
|
||||||
regions.add(region);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protectedRegions.put(world, regions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<ProtectedRegion> regions = new HashSet<>();
|
||||||
|
List<String> regionNames = worldsSection.getStringList(worldId);
|
||||||
|
for (String regionName : regionNames) {
|
||||||
|
// Register the region if it's valid
|
||||||
|
ProtectedRegion region = regionManager.getRegion(regionName);
|
||||||
|
if (region == null) {
|
||||||
|
ClearOnWorldGuard.logger().log(Level.WARNING, "Region name " + regionName + " is invalid");
|
||||||
|
} else {
|
||||||
|
regions.add(region);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protectedRegions.put(world, regions);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@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) {
|
if (event.getTo() == null || event.getFrom().getWorld() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,7 +120,8 @@ public class WorldGuardListener implements Listener {
|
|||||||
* @param playerRegions <p>The regions the player is in or will be in</p>
|
* @param playerRegions <p>The regions the player is in or will be in</p>
|
||||||
* @return <p>All clear regions found in playerRegions</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> possibleRegions = protectedRegions.get(playerWorld);
|
||||||
Set<ProtectedRegion> result = new HashSet<>();
|
Set<ProtectedRegion> result = new HashSet<>();
|
||||||
for (ProtectedRegion region : playerRegions) {
|
for (ProtectedRegion region : playerRegions) {
|
||||||
|
Loading…
Reference in New Issue
Block a user