mirror of
https://github.com/LordBoos/boosCooldowns.git
synced 2024-11-22 10:35:15 +01:00
Add option to disable command confirmations
This commit is contained in:
parent
020b3ca234
commit
6779923320
6
pom.xml
6
pom.xml
@ -3,16 +3,16 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cz.boosik</groupId>
|
||||
<artifactId>boosCooldowns</artifactId>
|
||||
<version>3.9.8c-GIT</version>
|
||||
<version>3.10.0-GIT</version>
|
||||
<name>boosCooldowns</name>
|
||||
<packaging>jar</packaging>
|
||||
<url>http://maven.apache.org</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<minecraft.version>1.8</minecraft.version>
|
||||
<minecraft.version>1.9</minecraft.version>
|
||||
<bukkit.version>R0.1</bukkit.version>
|
||||
<bukkit.packet>v1_8_R1</bukkit.packet>
|
||||
<bukkit.packet>v1_9_R1</bukkit.packet>
|
||||
</properties>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
|
@ -1,7 +1,6 @@
|
||||
package cz.boosik.boosCooldown;
|
||||
|
||||
import cz.boosik.boosCooldown.Managers.*;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -10,8 +9,8 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import util.boosChat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -25,7 +24,7 @@ public class BoosCoolDownListener implements Listener {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
public static ConcurrentHashMap<String,Boolean> commandQueue = new ConcurrentHashMap();
|
||||
public static Map<String,Boolean> commandQueue = new ConcurrentHashMap();
|
||||
|
||||
private void checkRestrictions(PlayerCommandPreprocessEvent event,
|
||||
Player player, String regexCommad, String originalCommand,
|
||||
@ -162,6 +161,7 @@ public class BoosCoolDownListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (BoosConfigManager.getConfirmCommandEnabled()) {
|
||||
for (String key : commandQueue.keySet()) {
|
||||
String[] keyList = key.split("@");
|
||||
if (keyList[0].equals(String.valueOf(uuid))) {
|
||||
@ -175,6 +175,7 @@ public class BoosCoolDownListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String originalCommand = event.getMessage().replace("\\", "\\\\");
|
||||
originalCommand = originalCommand.replace("$", "SdollarS");
|
||||
@ -198,7 +199,7 @@ public class BoosCoolDownListener implements Listener {
|
||||
}
|
||||
if (on && commands != null) {
|
||||
for (String group : commands) {
|
||||
String group2 = group.replace("*", ".+");
|
||||
String group2 = group.replace("*", ".*");
|
||||
if (originalCommand.matches("(?i)" + group2)) {
|
||||
regexCommad = group;
|
||||
if (BoosConfigManager.getWarmupEnabled()) {
|
||||
@ -228,16 +229,18 @@ public class BoosCoolDownListener implements Listener {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (commandQueue.keySet().contains(uuid + "@" + originalCommand) && commandQueue.get(uuid + "@" + originalCommand)) {
|
||||
if (!BoosConfigManager.getConfirmCommandEnabled() || (commandQueue.keySet().contains(uuid + "@" + originalCommand) && commandQueue.get(uuid + "@" + originalCommand))) {
|
||||
this.checkRestrictions(event, player, regexCommad, originalCommand,
|
||||
warmupTime, cooldownTime, price, item, count, limit,
|
||||
xpPrice);
|
||||
} else {
|
||||
if ((price > 0 || xpPrice > 0 || count > 0 || limit > 0) && !BoosWarmUpManager.isWarmUpProcess(player, regexCommad) && !BoosCoolDownManager.isCoolingdown(player,regexCommad,cooldownTime)) {
|
||||
if (BoosConfigManager.getConfirmCommandEnabled()) {
|
||||
commandQueue.put(uuid + "@" + originalCommand, false);
|
||||
String questionMessage = BoosConfigManager.getQuestionMessage();
|
||||
questionMessage = questionMessage.replace("&command&", originalCommand);
|
||||
boosChat.sendMessageToPlayer(player, questionMessage);
|
||||
}
|
||||
if (BoosCoolDown.getEconomy() != null) {
|
||||
if (BoosConfigManager.getPriceEnabled()) {
|
||||
if (price > 0) {
|
||||
@ -284,6 +287,7 @@ public class BoosCoolDownListener implements Listener {
|
||||
private void onPlayerChatEvent(AsyncPlayerChatEvent event){
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (BoosConfigManager.getConfirmCommandEnabled()) {
|
||||
for (String key : commandQueue.keySet()) {
|
||||
String[] keyList = key.split("@");
|
||||
if (keyList[0].equals(String.valueOf(uuid))) {
|
||||
@ -301,6 +305,7 @@ public class BoosCoolDownListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void start(PlayerCommandPreprocessEvent event, Player player,
|
||||
String regexCommad, String originalCommand, int warmupTime,
|
||||
int cooldownTime) {
|
||||
|
@ -711,4 +711,9 @@ public class BoosConfigManager {
|
||||
return conf.getBoolean("options.options.syntax_blocker_enabled",
|
||||
true);
|
||||
}
|
||||
|
||||
public static boolean getConfirmCommandEnabled() {
|
||||
return conf.getBoolean("options.options.command_confirmation",
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ public class BoosItemCostManager {
|
||||
private static boolean payItemForCommand(Player player,
|
||||
String originalCommand, String item, int count) {
|
||||
Material material = Material.getMaterial(item);
|
||||
|
||||
Inventory inventory = player.getInventory();
|
||||
Boolean trans = false;
|
||||
if (inventory.contains(material, count)) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
package util;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class boosChat {
|
||||
|
||||
@ -25,7 +25,7 @@ public class boosChat {
|
||||
|
||||
private static String replaceColorCodes(String line) {
|
||||
line = replaceTags(line);
|
||||
line = line.replaceAll("(&([a-f0-9]))", "\u00A7$2");
|
||||
line = line.replaceAll("&", "§");
|
||||
return line;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user