Added `minealert.ignore` permission (#13)

Added `minealert.ignore` perm

+ `minealert.ignore.ore` ignores ore alerts generated by the user
+ `minealert.ignore.grief` ignores grief alerts generated by the user
+ `minealert.ignore` ignores all alerts generated by the user

Co-authored-by: Joey Hines <joey@ahines.net>
Reviewed-on: https://git.etztech.xyz/Minecraft/MineAlert/pulls/13
Reviewed-by: Etzelia <etzelia@noreply.example.org>
Co-Authored-By: ZeroHD <joey@ahines.net>
Co-Committed-By: ZeroHD <joey@ahines.net>
master
Joey Hines 2020-12-07 00:08:53 +01:00 committed by Etzelia
parent d9e916e7b2
commit 78791c6ee2
6 changed files with 29 additions and 6 deletions

View File

@ -3,7 +3,7 @@
<groupId>xyz.etztech</groupId>
<artifactId>MineAlert</artifactId>
<!-- Version is used in plugin.yml -->
<version>0.0.4</version>
<version>0.0.5</version>
<packaging>jar</packaging>
<!-- Plugin Information -->
@ -31,13 +31,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>xyz.etztech</groupId>
<artifactId>javacord</artifactId>
<version>0.2.0</version>
<version>0.2.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
@ -58,7 +58,7 @@
</repository>
<repository>
<id>etztech-repo</id>
<url>http://repo.etztech.xyz/</url>
<url>https://repo.etztech.xyz/</url>
</repository>
<repository>
<id>mvn-repo</id>

View File

@ -1,6 +1,7 @@
package xyz.etztech.minealert;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import xyz.etztech.minealert.commands.AlertMute;
import xyz.etztech.minealert.commands.MainCommand;
@ -66,5 +67,9 @@ public class MineAlert extends JavaPlugin {
}
return def;
}
static public Boolean hasIgnoreAlertPerm(Player player, MuteType muteType) {
return player.hasPermission("minealert.ignore") || player.hasPermission(muteType.getMetadataValue());
}
}

View File

@ -4,8 +4,8 @@ import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
public enum MuteType {
OREALERT_MUTE("MineAlert.OreAlert"),
GRIEFALERT_MUTE("MineAlert.GriefAlert");
OREALERT_MUTE("minealert.ignore.ore"),
GRIEFALERT_MUTE("minealert.ignore.grief");
private final String metadataValue;

View File

@ -46,6 +46,10 @@ public class GriefAlertListener implements Listener {
}
public void addAlert(Player player, Location eventLocation, Lang lang) {
if (MineAlert.hasIgnoreAlertPerm(player, MuteType.GRIEFALERT_MUTE)) {
return;
}
String playerName = player.getName();
String alert = lang.getMessage(playerName);
purge();

View File

@ -45,6 +45,7 @@ public class OreAlertListener implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if (MineAlert.hasIgnoreAlertPerm(event.getPlayer(), MuteType.OREALERT_MUTE)) return;
if (cache.contains(event.getBlock().getLocation())) return;
if (!isMaterialTracked(event.getBlock().getType())) return;

View File

@ -22,3 +22,16 @@ permissions:
minealert.alert_mute:
description: Ability to mute alerts
default: op
minealert.ignore:
description: Ignore all alerts for this player
default: op
children:
minealert.ignore.grief: true
minealert.ignore.ore: true
minealert.ignore.grief:
description: Ignore grief alerts for this player
default: op
minealert.ignore.ore:
description: Ignore ore alerts for this player
default: op