Added logic in CommandPreprocessListener to check if a guest has run the /rules command before doing /apply.
parent
9f834011a2
commit
8997133923
|
@ -1,6 +1,7 @@
|
||||||
package xyz.etztech.minecraftmanager.listeners;
|
package xyz.etztech.minecraftmanager.listeners;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -14,7 +15,7 @@ import xyz.etztech.minecraftmanager.MCMUtil;
|
||||||
import xyz.etztech.minecraftmanager.MinecraftManager;
|
import xyz.etztech.minecraftmanager.MinecraftManager;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -22,6 +23,8 @@ public class CommandPreprocessListener implements Listener {
|
||||||
|
|
||||||
|
|
||||||
MinecraftManager plugin;
|
MinecraftManager plugin;
|
||||||
|
private ArrayList<String> hasReadRules = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
public CommandPreprocessListener(MinecraftManager plugin) {
|
public CommandPreprocessListener(MinecraftManager plugin) {
|
||||||
this.plugin = 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!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue