Plugin Disabling Not Work

Discussion in 'Plugin Development' started by ToPoEdiTs, Oct 4, 2014.

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

    ToPoEdiTs

    I State updating one of my plugin: Shotbow-Vanish and I wanted to add that a command will disable the plugin and not working and I get not error on console.

    CODE:

    Code:java
    1.  
    2. package com.topoedits;
    3.  
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.Plugin;
    10. import org.bukkit.plugin.PluginManager;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class Commands extends JavaPlugin {
    14. public void onEnable() {
    15. }
    16.  
    17. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    18. if (cmd.getName().equalsIgnoreCase("dspooped")) {
    19. Player player = (Player)sender;
    20. PluginManager plg = Bukkit.getPluginManager();
    21. Plugin plgname = plg.getPlugin("Pooped");
    22. plg.disablePlugin(plgname);
    23. player.sendMessage(ChatColor.GREEN + "[Shotbow Vanish]" + ChatColor.RED + "Plugin Disable!");
    24. }
    25. if ((cmd.getName().equalsIgnoreCase("ebpooped")) &&
    26. (args.length == 0)) {
    27. PluginManager plg = Bukkit.getPluginManager();
    28. Plugin plgname = plg.getPlugin("Pooped");
    29. plg.enablePlugin(plgname);
    30. player.sendMessage(ChatColor.GREEN + "[Shotbow Vanish]" + ChatColor.RED + "Plugin Enable!");
    31.  
    32. }
    33. return false;
    34. }
    35.  
    36. private static class player {
    37.  
    38. private static void sendMessage(String string) {
    39. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    40. }
    41.  
    42. public player() {
    43. }
    44. }
    45. }
     
  2. Well first off you need an onDisable() in your Commands Class
     
  3. Offline

    teej107

  4. Offline

    MajorSkillage

    Taking 1 big guess here :D
    this.setEnabled(false);
     
  5. Offline

    ToPoEdiTs

    that's what is public void onDisable(){ always put it at the end when the project is finished.
     
  6. Offline

    DJSkepter

    ToPoEdiTs Don't use enable/disable plugin. You could disable it, but you'd either have to reload the server or use a different plugin to re-enable it. Instead, have a boolean that can check if the boolean is enabled and if it is, then allow the plugin to function, otherwise, prevent the plugin from functioning.
     
    CubieX likes this.
  7. Offline

    MajorSkillage

    pretty much
    if(commandLabel.equalsIgnoreCase("disable command"){
    boolean disabled = true;
    } else if(commandLabel.equalsIgnoreCase("enable command"){
    boolean disabled = false;
    }
    then just add
    if(condition && disabled == true/false){then whatever will happen}
     
Thread Status:
Not open for further replies.

Share This Page