Added logic in CommandPreprocessListener to check if a guest has run the /rules command before doing /apply.

master
Joey Hines 2018-10-23 16:24:06 -05:00
parent 9f834011a2
commit 8997133923
1 changed files with 14 additions and 1 deletions

View File

@ -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.ArrayList;
import java.util.List;
import java.util.Map;
@ -22,6 +23,8 @@ public class CommandPreprocessListener implements Listener {
MinecraftManager plugin;
private ArrayList<String> hasReadRules = new ArrayList<>();
public CommandPreprocessListener(MinecraftManager plugin) {
this.plugin = plugin;
@ -71,6 +74,16 @@ 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.remove(sender.getUniqueId().toString())) {
sender.spigot().sendMessage(new TextComponent(ChatColor.RED + "Make sure to check /rules before applying!"));
}
}
}
}