Possibly more useful tracking for chest protection.

False-negatives or false-positives?
This commit is contained in:
wizjany 2019-11-18 16:05:49 -05:00
parent 1fd94a3655
commit c431abde3c
3 changed files with 17 additions and 2 deletions

View File

@ -251,7 +251,7 @@ public class WorldGuardPlugin extends JavaPlugin {
return blacklistCounts;
}));
metrics.addCustomChart(new Metrics.SimplePie("chest_protection", () ->
"" + platform.getGlobalStateManager().getWorldConfigs().stream().anyMatch(cfg -> cfg.signChestProtection)));
"" + platform.getGlobalStateManager().getWorldConfigs().stream().anyMatch(cfg -> cfg.getChestProtection().hasBeenUsed())));
metrics.addCustomChart(new Metrics.SimplePie("build_permissions", () ->
"" + platform.getGlobalStateManager().getWorldConfigs().stream().anyMatch(cfg -> cfg.buildPermissions)));

View File

@ -28,9 +28,12 @@ import org.bukkit.block.Sign;
public class BukkitSignChestProtection extends SignChestProtection {
private boolean hasBeenUsed;
private Boolean isProtectedSign(Sign sign, LocalPlayer player) {
if (sign.getLine(0).equalsIgnoreCase("[Lock]")) {
if (player == null) { // No player, no access
hasBeenUsed = true;
return true;
}
@ -49,6 +52,15 @@ public class BukkitSignChestProtection extends SignChestProtection {
if (!(state instanceof Sign)) {
return null;
}
return isProtectedSign((Sign) state, player);
Boolean protectedSign = isProtectedSign((Sign) state, player);
if (protectedSign != null && protectedSign) {
hasBeenUsed = true;
}
return protectedSign;
}
@Override
public boolean hasBeenUsed() {
return hasBeenUsed;
}
}

View File

@ -71,4 +71,7 @@ public interface ChestProtection {
|| blockType == BlockTypes.DROPPER;
}
default boolean hasBeenUsed() {
return false;
}
}