Possibly more useful tracking for chest protection.
False-negatives or false-positives?
This commit is contained in:
parent
1fd94a3655
commit
c431abde3c
|
@ -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)));
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,4 +71,7 @@ public interface ChestProtection {
|
|||
|| blockType == BlockTypes.DROPPER;
|
||||
}
|
||||
|
||||
default boolean hasBeenUsed() {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue