mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Block plugin-specific commands for 1.7.2-R0.3
This commit is contained in:
parent
10443ff0d5
commit
4b671cc4c7
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Tue Jan 14 20:43:15 CET 2014
|
#Tue Mar 18 16:06:56 CET 2014
|
||||||
build.number=698
|
build.number=702
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class TFM_CommandBlocker
|
public class TFM_CommandBlocker
|
||||||
{
|
{
|
||||||
|
public static final Pattern COMMAND_PATTERN = Pattern.compile("^/?(\\S+)");
|
||||||
private Map<String, CommandBlockerEntry> blockedCommands = new HashMap<String, CommandBlockerEntry>();
|
private Map<String, CommandBlockerEntry> blockedCommands = new HashMap<String, CommandBlockerEntry>();
|
||||||
|
|
||||||
private TFM_CommandBlocker()
|
private TFM_CommandBlocker()
|
||||||
@ -35,19 +36,19 @@ public class TFM_CommandBlocker
|
|||||||
List<String> _blockedCommands = (List<String>) TFM_ConfigEntry.BLOCKED_COMMANDS.getList();
|
List<String> _blockedCommands = (List<String>) TFM_ConfigEntry.BLOCKED_COMMANDS.getList();
|
||||||
for (String rawEntry : _blockedCommands)
|
for (String rawEntry : _blockedCommands)
|
||||||
{
|
{
|
||||||
String[] parts = rawEntry.split(":");
|
final String[] parts = rawEntry.split(":");
|
||||||
if (parts.length < 3 || parts.length > 4)
|
if (parts.length < 3 || parts.length > 4)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
|
final CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
|
||||||
if (rank == null)
|
if (rank == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
|
final CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
|
||||||
if (action == null)
|
if (action == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -58,7 +59,7 @@ public class TFM_CommandBlocker
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
|
final Matcher matcher = COMMAND_PATTERN.matcher(command);
|
||||||
if (matcher.find())
|
if (matcher.find())
|
||||||
{
|
{
|
||||||
command = matcher.group(1);
|
command = matcher.group(1);
|
||||||
@ -82,9 +83,9 @@ public class TFM_CommandBlocker
|
|||||||
message = parts[3];
|
message = parts[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, command, message);
|
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, command, message);
|
||||||
|
|
||||||
Command bukkitCommand = commandMap.getCommand(command);
|
final Command bukkitCommand = commandMap.getCommand(command);
|
||||||
if (bukkitCommand == null)
|
if (bukkitCommand == null)
|
||||||
{
|
{
|
||||||
//TFM_Log.info("Blocking unknown command: " + blockedCommandEntry.getCommand());
|
//TFM_Log.info("Blocking unknown command: " + blockedCommandEntry.getCommand());
|
||||||
@ -118,7 +119,7 @@ public class TFM_CommandBlocker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
|
final Matcher matcher = COMMAND_PATTERN.matcher(command);
|
||||||
if (matcher.find())
|
if (matcher.find())
|
||||||
{
|
{
|
||||||
command = matcher.group(1);
|
command = matcher.group(1);
|
||||||
@ -136,15 +137,21 @@ public class TFM_CommandBlocker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CommandBlockerEntry blockedCommandEntry = blockedCommands.get(command);
|
if (command.contains(":"))
|
||||||
|
|
||||||
if (blockedCommandEntry != null)
|
|
||||||
{
|
{
|
||||||
if (!blockedCommandEntry.getRank().hasPermission(sender))
|
TFM_Util.playerMsg(sender, "Plugin-specific commands are disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CommandBlockerEntry entry = blockedCommands.get(command);
|
||||||
|
|
||||||
|
if (entry != null)
|
||||||
|
{
|
||||||
|
if (!entry.getRank().hasPermission(sender))
|
||||||
{
|
{
|
||||||
if (doAction)
|
if (doAction)
|
||||||
{
|
{
|
||||||
blockedCommandEntry.doActions(sender);
|
entry.doActions(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -121,7 +121,7 @@ public enum TFM_ConfigEntry
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getList()
|
public List<?> getList()
|
||||||
{
|
{
|
||||||
return TFM_Config.getInstance().getList(this);
|
return TFM_Config.getInstance().getList(this);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user