diff --git a/src/main/java/xyz/etztech/minecraftmanager/listeners/CommandPreprocessListener.java b/src/main/java/xyz/etztech/minecraftmanager/listeners/CommandPreprocessListener.java index fe148b9..e74a388 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/listeners/CommandPreprocessListener.java +++ b/src/main/java/xyz/etztech/minecraftmanager/listeners/CommandPreprocessListener.java @@ -1,6 +1,7 @@ package xyz.etztech.minecraftmanager.listeners; import org.apache.commons.lang.StringUtils; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -14,7 +15,7 @@ import xyz.etztech.minecraftmanager.MCMUtil; import xyz.etztech.minecraftmanager.MinecraftManager; import java.util.Arrays; -import java.util.HashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -22,6 +23,8 @@ public class CommandPreprocessListener implements Listener { MinecraftManager plugin; + private LinkedHashSet hasReadRules = new LinkedHashSet<>(); + public CommandPreprocessListener(MinecraftManager plugin) { this.plugin = plugin; @@ -71,6 +74,17 @@ public class CommandPreprocessListener implements Listener { } } } + else if (sender.hasPermission("minecraftmanager.guest")) { + if ("rules".equalsIgnoreCase(base)) { + hasReadRules.add(sender.getUniqueId().toString()); + } + else if ("apply".equalsIgnoreCase(base)) { + if(!hasReadRules.contains(sender.getUniqueId().toString())) { + event.setCancelled(true); + sender.spigot().sendMessage(new TextComponent(ChatColor.RED + "Make sure to check /rules before applying!")); + } + } + } }