fix for factions-specific commands not being prevented properly if they were in "territoryNeutralDenyCommands" or "territoryEnemyDenyCommands"
also got rid of a command preprocess listener which is now unnecessary
This commit is contained in:
parent
2d83f6f764
commit
90d91180af
@ -9,6 +9,7 @@ import java.util.Set;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
@ -107,7 +108,6 @@ public class P extends MPlugin
|
|||||||
// Player Events
|
// Player Events
|
||||||
this.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Event.Priority.Highest);
|
this.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Event.Priority.Highest);
|
||||||
this.registerEvent(Event.Type.PLAYER_CHAT, this.chatEarlyListener, Event.Priority.Lowest);
|
this.registerEvent(Event.Type.PLAYER_CHAT, this.chatEarlyListener, Event.Priority.Lowest);
|
||||||
this.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, this.playerListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Event.Priority.Normal);
|
this.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Event.Priority.Normal);
|
||||||
this.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.Normal);
|
this.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.Normal);
|
||||||
this.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal);
|
this.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal);
|
||||||
@ -172,6 +172,14 @@ public class P extends MPlugin
|
|||||||
Conf.save();
|
Conf.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly)
|
||||||
|
{
|
||||||
|
if (sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player)sender)) return true;
|
||||||
|
|
||||||
|
return super.handleCommand(sender, commandString, testOnly);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Integration with other plugins
|
// Integration with other plugins
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -29,17 +29,10 @@ public class FactionsChatEarlyListener extends PlayerListener
|
|||||||
public void onPlayerChat(PlayerChatEvent event)
|
public void onPlayerChat(PlayerChatEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
if (p.handleCommand(event.getPlayer(), event.getMessage()))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player talkingPlayer = event.getPlayer();
|
Player talkingPlayer = event.getPlayer();
|
||||||
String msg = event.getMessage();
|
String msg = event.getMessage();
|
||||||
|
|
||||||
// ... it was not a command. This means that it is a chat message!
|
|
||||||
FPlayer me = FPlayers.i.get(talkingPlayer);
|
FPlayer me = FPlayers.i.get(talkingPlayer);
|
||||||
|
|
||||||
// Is it a faction chat message?
|
// Is it a faction chat message?
|
||||||
|
@ -513,17 +513,6 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
|
|
||||||
if (preventCommand(event.getMessage().toLowerCase(), event.getPlayer()))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean preventCommand(String fullCmd, Player player)
|
public static boolean preventCommand(String fullCmd, Player player)
|
||||||
{
|
{
|
||||||
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty()))
|
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty()))
|
||||||
@ -544,7 +533,14 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String shortCmd = fullCmd.substring(1); // Get rid of the slash at the beginning
|
String shortCmd; // command without the slash at the beginning
|
||||||
|
if (fullCmd.startsWith("/"))
|
||||||
|
shortCmd = fullCmd.substring(1);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shortCmd = fullCmd;
|
||||||
|
fullCmd = "/" + fullCmd;
|
||||||
|
}
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user