Adds info about how to configure the plugin

This commit is contained in:
2023-12-17 04:07:51 +01:00
parent e233e5d918
commit 37a773511d
4 changed files with 41 additions and 19 deletions

View File

@ -8,7 +8,7 @@ import java.util.logging.Logger;
@SuppressWarnings("unused")
public final class ClearOnWorldGuard extends JavaPlugin {
private static ClearOnWorldGuard instance;
@Override
@ -17,18 +17,18 @@ public final class ClearOnWorldGuard extends JavaPlugin {
this.saveDefaultConfig();
this.reloadConfig();
FileConfiguration configuration = this.getConfig();
// Register the WorldGuard listener
Bukkit.getPluginManager().registerEvents(new WorldGuardListener(configuration), this);
}
/**
* Gets the logger used by this plugin
*
*
* @return <p>The logger used by this plugin</p>
*/
public static Logger logger() {
return instance.getLogger();
}
}

View File

@ -45,7 +45,7 @@ public class WorldGuardListener implements Listener {
return;
}
Set<String> worlds = worldsSection.getKeys(false);
for (String worldId : worlds) {
// Parse every world identifier
World world;
@ -59,15 +59,15 @@ public class WorldGuardListener implements Listener {
ClearOnWorldGuard.logger().log(Level.WARNING, "The specified world: \"" + worldId + "\" is invalid.");
continue;
}
// 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: " +
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) {
@ -95,7 +95,7 @@ public class WorldGuardListener implements Listener {
Set<ProtectedRegion> fromRegions = getOccupiedClearRegions(playerWorld, setFrom.getRegions());
Set<ProtectedRegion> toRegions = getOccupiedClearRegions(playerWorld, setTo.getRegions());
// If the player is in one or more clear regions, clear unless the clear regions are the same
if ((!fromRegions.isEmpty() || !toRegions.isEmpty()) && !fromRegions.equals(toRegions)) {
event.getPlayer().getInventory().clear();
@ -104,8 +104,8 @@ public class WorldGuardListener implements Listener {
/**
* Gets all regions set as clear regions the player currently occupies
*
* @param playerWorld <p>The world the player is currently in</p>
*
* @param playerWorld <p>The world the player is currently 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>
*/
@ -117,7 +117,7 @@ public class WorldGuardListener implements Listener {
result.add(region);
}
}
return result;
}

View File

@ -2,6 +2,6 @@
clearRegions:
# The name or UUID of a world. Add any regions that should force inventory clearing as a comma-separated list inside
# the square parentheses.
world: []
world_nether: []
world_the_end: []
world: [ ]
world_nether: [ ]
world_the_end: [ ]