.

Discussion in 'Plugin Development' started by elementalgodz11, Nov 30, 2013.

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

    elementalgodz11

  2. Offline

    adam753

    So you're enabling it if the command is /drops, and disabling if it isn't? I don't think that's what you meant to do.
     
  3. Offline

    jimuskin

    Something like this?

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] arg) {
    2.  
    3. if (sender.hasPermission("kits.dropstoggle")) {
    4.  
    5. if (cmd.getName().equalsIgnoreCase("drops")) {
    6. if(this.Drops1 == true){
    7. this.Drops1 = false;
    8. sender.sendMessage(ChatColor.WHITE + "Drops are now "
    9. + ChatColor.RED + "Disabled.");
    10. }else {
    11. this.Drops1 = true;
    12. sender.sendMessage(ChatColor.WHITE + "Drops are now "
    13. + ChatColor.RED + "Enabled.");
    14. }
    15. }
    16. return true;
    17. }
     
  4. Offline

    PolarCraft

    elementalgodz11 If you do not mind me asking what is the purpose of this plugin. And also did you import the event into your main class?
     
  5. Offline

    jimuskin

    elementalgodz11 Check to see if drops is enabled, if it isn't then enable it
     
  6. Offline

    boysnnoco

    elementalgodz11 instead of a boolean, use a hashmap/arraylist and just store the player's name if they want drops on then if they try to drop something check if their name is within the arraylist / hashmap.
     
  7. Offline

    Erigitic

    elementalgodz11 Your if statements are nested to where the drops will not be set to true unless Drops1 is equal to true and Drops2 is false. Try setting Drops1 and 2 to true if Drops1 is false. For example,
    Code:java
    1. if (this.Drops1 == true) {
    2. this.Drops1 = false;
    3. if (this.Drops2 == true) {
    4. this.Drops2 = false;
    5. sender.sendMessage(ChatColor.WHITE + "Drops are now " + ChatColor.RED + "Disabled.");
    6. }
    7. } else { //If Drops1 != true run this code
    8. this.Drops1 = true;
    9. this.Drops2 = true;
    10. sender.sendMessage(ChatColor.WHITE + "Drops are now "+ ChatColor.RED + "Enabled.");
    11. }
     
  8. Offline

    PolarCraft

    If you want them to be disabled first do this.
    Code:java
    1. boolean Drops1 = false;
    2. boolean Drops2 = false;


    Instead of:
    Code:java
    1. private boolean Drops1 = true;
    2. private boolean Drops2 = true;
     
Thread Status:
Not open for further replies.

Share This Page