mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-23 07:14:57 +00:00
Properly fixed commandblocker
Rest in peace, terrible, terrible mistake
This commit is contained in:
parent
b18aeb2d38
commit
80287433eb
2 changed files with 3 additions and 36 deletions
|
@ -1,3 +1,3 @@
|
||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Tue May 12 20:14:59 CEST 2015
|
#Tue May 12 20:32:19 CEST 2015
|
||||||
build.number=1022
|
build.number=1027
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package me.StevenLawson.TotalFreedomMod;
|
package me.StevenLawson.TotalFreedomMod;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||||
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
|
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -13,7 +10,6 @@ import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TFM_CommandBlocker
|
public class TFM_CommandBlocker
|
||||||
|
@ -94,35 +90,6 @@ public class TFM_CommandBlocker
|
||||||
|
|
||||||
if (command != null)
|
if (command != null)
|
||||||
{
|
{
|
||||||
// Temporarily workaround: Remove blocked command from the CommandMap
|
|
||||||
// In Spigot 1.8.3, cancelling PlayerCommandPreprocessEvent will have no effect
|
|
||||||
// This results in TFM failing to block player commands: The player will get a message,
|
|
||||||
// but the command will still execute. Removing the command from the CommandMap is a
|
|
||||||
// temporary workaround untill the related Spigot issue has been fixed.
|
|
||||||
// https://hub.spigotmc.org/jira/browse/SPIGOT-879
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Field field = SimpleCommandMap.class.getDeclaredField("knownCommands");
|
|
||||||
field.setAccessible(true);
|
|
||||||
Map<?, ?> knownCommands = (Map) field.get(commandMap);
|
|
||||||
|
|
||||||
Iterator<?> it = knownCommands.entrySet().iterator();
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
final Object e = it.next();
|
|
||||||
if (command.equals(((Entry) e).getValue()))
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TFM_Log.severe("Could not nullify command: " + command.getName());
|
|
||||||
TFM_Log.severe(ex);
|
|
||||||
}
|
|
||||||
// End Temporary workaround
|
|
||||||
|
|
||||||
for (String alias : command.getAliases())
|
for (String alias : command.getAliases())
|
||||||
{
|
{
|
||||||
BLOCKED_COMMANDS.put(alias.toLowerCase(), blockedCommandEntry);
|
BLOCKED_COMMANDS.put(alias.toLowerCase(), blockedCommandEntry);
|
||||||
|
@ -165,7 +132,7 @@ public class TFM_CommandBlocker
|
||||||
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).toLowerCase();
|
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
final CommandBlockerEntry entry = BLOCKED_COMMANDS.get(command);
|
final CommandBlockerEntry entry = BLOCKED_COMMANDS.get(commandParts[0]);
|
||||||
|
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue