Solved Bug with my plugin

Discussion in 'Plugin Help/Development/Requests' started by TekxWolf, Mar 28, 2015.

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

    TekxWolf

  2. Invisible

    nverdier

  3. Offline

    TekxWolf

    I have been trying to fix it so ive been tinkering with the code
    Heres whats new:
    New Java Code (open)

    Code:
    package me.TekxWolf.McReligion;
    
    import java.util.List;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    
    import static org.bukkit.ChatColor.*;
    @SuppressWarnings("unused")
    public class McReligionmain extends JavaPlugin{
        public void onEnable(){
            getLogger().info("mcReligions has been Enabled!");
            Bukkit.broadcastMessage("" + GRAY + BOLD + "[" + RESET + DARK_PURPLE + "mcReligions" + RESET + GRAY + BOLD + "]"
                    + RED + BOLD + UNDERLINE + "I AM ALIVE!");
            this.saveDefaultConfig();
        }
        public void onDisable(){
            getLogger().info("mcReligions has been Disabled!");
        }
      
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            boolean Message = this.getConfig().getBoolean("Chat.Message");
            boolean Broadcast = this.getConfig().getBoolean("Chat.Broadcast");
          
          
            /*********************************************************************************************************************/
            if(sender.hasPermission("mcReligion.religion")){
              
              
                /*********************************************************************************************************************/
                if(label.equalsIgnoreCase("religion") && args.length == 0){
                    sender.sendMessage(WHITE + "+---+---+" + GOLD +  " mcReligion Plugin Info " + WHITE + "+---+---+");
                    sender.sendMessage("" + AQUA + BOLD + "Name: McReligions");
                    sender.sendMessage("" + AQUA + BOLD + "Version: 0.7 Beta");
                    sender.sendMessage("" + AQUA + BOLD + "Author: TekxWolf");
                    sender.sendMessage("" + AQUA + BOLD + "Website: http://dev.bukkit.org/bukkit-plugins/mcreligions/");
                    sender.sendMessage("" + AQUA + BOLD + "Donate to help fund this project: ");
                    sender.sendMessage(WHITE + "+---+---+---+---+---+---+---+---+---+---+");
                }
              
              
                /*********************************************************************************************************************/
                if(args[0].equalsIgnoreCase("help")){
                    if(sender.hasPermission("mcReligion.help")){
                        sender.sendMessage(WHITE + "+---+---+" + GOLD +  " Religion Help Page 1 of 1: " + WHITE + "+---+---+");
                        sender.sendMessage("" + AQUA + BOLD + "/Religion plugininfo - displays plugin info");
                        sender.sendMessage("" + AQUA + BOLD + "/Religion help - Displays this help screen");
                        sender.sendMessage("" + AQUA + BOLD + "/Religion list - displays a list of chooseable gods");
                        sender.sendMessage(WHITE + "+---+---+---+---+---+---+---+---+---+---+");
                    } else {sender.sendMessage(RED + "Sorry, " + sender.getName() + ", but you do not have permission to use this command.");}
                }
              
              
                /*********************************************************************************************************************/
                if(args[0].equalsIgnoreCase("list")){
                    if(sender.hasPermission("mcReligion.list")){
                        sender.sendMessage(GRAY + "+---+---+" + GOLD + " Religions List " + GRAY + "+---+---+");
                        if(!(this.getConfig().getString("Religion1.Name") == "null"))
                        { Listcmd(sender, "Religion1"); }
                        else { sender.sendMessage(RED + "Sorry, You currently have no Religions on this Server"); }
                        if(!(this.getConfig().getString("Religion2.Name") == "null"))
                        { Listcmd(sender, "Religion2"); }
                        if(!(this.getConfig().getString("Religion3.Name") == "null"))
                        { Listcmd(sender, "Religion3"); }
                        if(!(this.getConfig().getString("Religion4.Name") == "null"))
                        { Listcmd(sender, "Religion4"); }
                        if(!(this.getConfig().getString("Religion5.Name") == "null"))
                        { Listcmd(sender, "Religion5"); }
                        if(!(this.getConfig().getString("Religion6.Name") == "null"))
                        { Listcmd(sender, "Religion6"); }
                        if(!(this.getConfig().getString("Religion7.Name") == "null"))
                        { Listcmd(sender, "Religion7"); }
                        if(!(this.getConfig().getString("Religion8.Name") == "null"))
                        { Listcmd(sender, "Religion8"); }
                        if(!(this.getConfig().getString("Religion9.Name") == "null"))
                        { Listcmd(sender, "Religion9"); }
                        if(!(this.getConfig().getString("Religion10.Name") == "null"))
                        { Listcmd(sender, "Religion10"); }
                        if(!(this.getConfig().getString("Religion11.Name") == "null"))
                        { Listcmd(sender, "Religion11"); }
                        if(!(this.getConfig().getString("Religion12.Name") == "null"))
                        { Listcmd(sender, "Religion12"); }
                        if(!(this.getConfig().getString("Religion13.Name") == "null"))
                        { Listcmd(sender, "Religion13"); }
                        if(!(this.getConfig().getString("Religion14.Name") == "null"))
                        { Listcmd(sender, "Religion14"); }
                        if(!(this.getConfig().getString("Religion15.Name") == "null"))
                        { Listcmd(sender, "Religion15"); }
                        if(!(this.getConfig().getString("Religion16.Name") == "null"))
                        { Listcmd(sender, "Religion16"); }
                        if(!(this.getConfig().getString("Religion17.Name") == "null"))
                        { Listcmd(sender, "Religion17"); }
                        if(!(this.getConfig().getString("Religion18.Name") == "null"))
                        { Listcmd(sender, "Religion18"); }
                        if(!(this.getConfig().getString("Religion19.Name") == "null"))
                        { Listcmd(sender, "Religion19"); }
                        if(!(this.getConfig().getString("Religion20.Name") == "null"))
                        { Listcmd(sender, "Religion20"); }
                        sender.sendMessage(GRAY + "+---+---+---+---+---+---+---+---+");
                    }
                }
            }
              
              
            /*********************************************************************************************************************/
         
            return true;
        }
    
        @SuppressWarnings("unchecked")
        private void Listcmd(CommandSender sender, String a) {
            String b = String.format("%s.Name", a);
            String c = String.format("%s.Color", a);
            String d = String.format("%s.God.Color.Red", a);
            String e = String.format("%s.God.Color.Blue", a);
            String f = String.format("%s.God.Color.Gold", a);
            String g = String.format("%s.God.Color.Green", a);
            String h = String.format("%s.God.Color.White", a);
            /*  What the above does, is defines all the different config paths to read from config.yml  */
          
            String name = this.getConfig().getString(b);
            String color = this.getConfig().getString(c);
            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', String.format("&7Religion: &r %s %s", color, name)));
            /*  Defines String name to the name of the religion and String color to the color value of the religion  */
          
            List<String> A = (List<String>) this.getConfig().getList(d);
            List<String> B = (List<String>) this.getConfig().getList(e);
            List<String> C = (List<String>) this.getConfig().getList(f);
            List<String> D = (List<String>) this.getConfig().getList(g);
            List<String> E = (List<String>) this.getConfig().getList(h);
            /*  Gets the list values from the paths defined in Strings d-h  */
          
            for (String s : A){
                sender.sendMessage(GRAY + "  - " + RED + s);
            }
            for (String s : B){
                sender.sendMessage(GRAY + "  - " + BLUE + s);
            }
            for (String s : C){
                sender.sendMessage(GRAY + "  - " + GOLD + s);
            }
            for (String s : D){
                sender.sendMessage(GRAY + "  - " + GREEN + s);
            }
            for (String s : E){
                sender.sendMessage(GRAY + "  - " + WHITE + s);
            }
            /*  Sends out the list of Gods followed by The list of Gods under that religion
             * Example:
             * +---+---+ Religions List +---+---+
             * Default Religion
             *   - Default God Red
             *   - Default God Blue
             *   - Default God Gold
             *   - Default God Green
             *   - Default God White
             * +---+---+---+---+---+---+---+---+
             */
        }
    }
    
    
    
    
    

    New(er) config.yml - Was trying to trest if 2 religions would work (open)

    Code:
    # default config.yml
    
    #/////////////////////////////////////////////////////////////////////
    #//                ~ McReligions ~                                  //
    #//  - Author: ~TekxWolf                                            //
    #//  - Version: v0.7 ALPHA                                          //
    #//  - Web site: http://dev.bukkit.org/bukkit-plugins/mcreligions/   //
    #//  - Donate:                                                      //
    #/////////////////////////////////////////////////////////////////////
    
    #//////////////////////////////////////////////////////////
    #// More options to follow in the releases to come:      //
    #// -------------------------------------------------    //
    #// - Cults (Internal groups inside religions)           //
    #// - Crusades (religious war)                           //
    #// - Marriages                                          //
    #// - Enhancements from joining a certain god            //
    #// - Religion chat [RC]                                 //
    #// - cult chat [CC] (subsection of RC chat)             //
    #//////////////////////////////////////////////////////////
    
    #-----------------------------------------------------------------------------------------
    # Case Sensitive! please keep it in lower cased 'true' or 'false'
    # Broadcast is the announcement when a user selects a god to follow
    # Message is the private message to the player informing them they have chosen a god
    #-----------------------------------------------------------------------------------------
    
    Chat:
      Broadcast: true
      Message: true
    
    #-----------------------------------------------------------------------------------------
    # Here is how the below works:
    #   Player does command
    #   > Assigns name to religion
    #   > Assigns designated color for the religion
    #   > at subsection God.Color.<Color> :
    #     > Assigns a god to a color group to designate what it will be colored in the chat
    #-----------------------------------------------------------------------------------------
    
    Religion1:
      Name: Default
      Color: &6
      God:
        Color:
          Red:
            - Default Red
          Blue:
            - Default Blue
          Gold:
            - Default Gold
          Green:
            - Default Green
          White:
            - Default White
    Religion2:
      Name: Default2
      Color: &6
      God:
        Color:
          Red:
            - Default2 Red
          Blue:
            - Default2 Blue
          Gold:
            - Default2 Gold
          Green:
            - Default2 Green
          White:
            - Default2 White
    Religion3:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion4:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion5:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion6:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion7:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion8:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion9:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion10:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion11:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion12:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion13:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion14:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion15:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion16:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion17:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion18:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion19:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:
    Religion20:
      Name: null
      Color:
      God:
        Color:
          Red:
          Blue:
          Gold:
          Green:
          White:

    My log data (newest) : http://pastebin.com/sF5f2B2M
    Visual representation (open)
    [​IMG]
     
    Last edited: Mar 28, 2015
  4. Offline

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
     
  5. Invisible

    nverdier

  6. Offline

    TekxWolf

    Okay so i read my stack trace and it says the errors were at:
    Line 72 : if(!(this.getConfig().getString("Religion4.Name") == "null"))
    and line 141: sender.sendMessage(GRAY + " - " + RED + s);

    I understand why it might catch an error but on line 72 it says if section Religion4.Name does not == "null" it will call the method Listcmd but Religion4.name does equal "null"
    Religion4:
    Name: null

    So im confused at why its catching this
     
Thread Status:
Not open for further replies.

Share This Page