Solved Blocking Commands?

Discussion in 'Plugin Development' started by Heirteir, Apr 12, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Heirteir

    Alright so my friend wants me to make it so when someone is muted through essentials that they can't do that /f command in factions how would I go about blocking them from doing the /f command in factions when there muted by essentials?
     
  2. Heirteir That's not possible unless you're the developer of essentials and can add that in the code I think.
     
  3. Offline

    Heirteir

    driver-e
    I can check if there muted with the essentials api
    I just want to set my plugin the executor of the /f command
     
  4. Heirteir
    Hmm, then you could maybe do something like, check if player is muted, then check if the player does /f command and disable it. Try using PlayerCommandPreProcessEvent.
     
  5. Offline

    Derpiee

  6. Derpiee
    Only way of doing it with the bukkit.yml is probably making it remove the factions permission when the /mute command is executed.
     
  7. Derpiee How would one go about blocking it with bukkit.yml?
     
  8. Offline

    Heirteir

    Derpiee
    Thanks Derpiee that worked out I forgot about that event lol I feel stupid

    For those of you that want to see the final code
    Code:java
    1. package me.heirteir.blockcreate;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerCommandPreprocessEvent;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. import com.earth2me.essentials.Essentials;
    11. import com.massivecraft.factions.Factions;
    12.  
    13. public class Main
    14. extends JavaPlugin
    15. implements Listener{
    16.  
    17. Essentials ess = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
    18. Factions factions = (Factions) Bukkit.getServer().getPluginManager().getPlugin("Factions");
    19.  
    20. public void onEnable(){
    21. Bukkit.getPluginManager().registerEvents(this, this);
    22. }
    23.  
    24. @EventHandler
    25. public void preprocess(PlayerCommandPreprocessEvent e){
    26. if (!ess.getUser(e.getPlayer()).isMuted()) return;
    27. if (e.getMessage().toLowerCase().startsWith("/f create") || e.getMessage().toLowerCase().startsWith("/f tag")){
    28. e.getPlayer().sendMessage(ChatColor.GOLD + "You can't do that while muted!");
    29. e.setCancelled(true);
    30. }
    31. }
    32. }
    33.  


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page