Solved I need help

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

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

    TekxWolf

    Hey, I'm looking for a plugin veteran. I need someone who knows the ins and out of plugin development to review my code and show me how to fix it and make it better.
    As well i need to make it so that its customizable through the config.yml

    I'm relatively new to this so any help would be appreciated
     
  2. Offline

    nverdier

    @TekxWolf Just post the code and then people will help! What's the problem you are having?
     
  3. Offline

    TekxWolf

    well as of the moment i dont have a problem but more of a consumer request, i was asked by my server owner to make it so that the gods can be customizable via config.yml but i just did a test run on a home server and as far as i can tell everything works with a few bugs
    Java code (open)
    Code:
    package me.TekxWolf.McReligion;
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import static org.bukkit.ChatColor.*;
    
    public class McReligionmain extends JavaPlugin{
      
        public void onEnable(){
            getLogger().info("mcReligions has been Enabled!");
        }
      
        public void onDisable(){
            getLogger().info("mcReligions has been Disabled!");
        }
      
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            Player p = (Player) sender;
            if(sender.hasPermission("religion.religion.use")){
                if(label.equalsIgnoreCase("religion")){
                    if(args.length == 0){
                        p.sendMessage(RED + "Insufficient Arguments. "
                                + "Please type '/religion help' for help.");
                    }
                    if(args[0].equalsIgnoreCase("list")){
                        if(sender.hasPermission("religion.list.use")){
                            p.sendMessage(WHITE + "+---+ " + GOLD + "Gods List" + RESET + WHITE + " +---+");
                            p.sendMessage(GREEN + "Ilúvatar");
                            p.sendMessage(GOLD + "Zeus");
                            p.sendMessage(RED + "Hades");
                            p.sendMessage(GRAY + "Apollo");
                            p.sendMessage(WHITE + "+---+---+---+---+");
                        }
                    } else {
                        p.sendMessage(RED + "Sorry, " + p.getName() + " you do not have permission to use this command. "
                                + "If you believe you should please contact staff for further assistance");
                    }
                    if(args[0].equalsIgnoreCase("select")){
                        if(sender.hasPermission("religion.select.use")){
                            if(args.length == 0){
                                p.sendMessage(RED + "Please use "
                                        + "'/religion list' for a list of selectable gods");
                            }
                            if(args[1].equalsIgnoreCase("Ilúvatar")){
                                if(sender.hasPermission("religion.select.Iluvatar")){
                                    p.sendMessage(GREEN + "You have joined the religion of the mighty elven god, Ilúvatar!");
                                    Bukkit.broadcastMessage(" " + GRAY + BOLD + "[" + DARK_PURPLE + BOLD + "mcReligions" + BOLD + BLACK + "]"
                                            + RESET + GREEN + p.getName() + "Has joined the elven master Ilúvatar!");
                                }
                            } else {
                                p.sendMessage(RED + "Sorry but you lack the permission to use this command.");
                            }
                            if(args[1].equalsIgnoreCase("Zeus")){
                                if(sender.hasPermission("religion.select.Zeus")){
                                    p.sendMessage(GOLD + "You have joined the religion of the mighty god, ZEUS!");
                                    Bukkit.broadcastMessage(" " + GRAY + BOLD + "[" + DARK_PURPLE + BOLD + "mcReligions" + BOLD + BLACK + "]"
                                            + RESET + GOLD + p.getName() + "Has joined the greek god Zeus!");
                                }
                            } else {
                                p.sendMessage(RED + "Sorry but you lack the permission to use this command.");
                            }
                            if(args[1].equalsIgnoreCase("Hades")){
                                if(sender.hasPermission("religion.select.Hades")){
                                    p.sendMessage(RED + "You have joined the darkest of gods, behold the father of death: HADES!");
                                    Bukkit.broadcastMessage(" " + GRAY + BOLD + "[" + DARK_PURPLE + BOLD + "mcReligions" + BOLD + BLACK + "]"
                                            + RESET + RED + p.getName() + "Has joined the darkness with Hades");
                                }
                            } else {
                                p.sendMessage(RED + "Sorry but you lack the permission to use this command.");
                            }
                            if(args[1].equals("Apollo")){
                                if(sender.hasPermission("religion.selct.Apollo")){
                                    p.sendMessage(GRAY + "You have joined the nobelist of the gods, the heavenly master: APOLLO!");
                                    Bukkit.broadcastMessage(" " + GRAY + BOLD + "[" + DARK_PURPLE + BOLD + "mcReligions" + BOLD + BLACK + "]"
                                            + RESET + GRAY + "Has joined the Greek God APOLLO!");
                            } else {
                                    p.sendMessage(RED + "Sorry but you lack the permission to use this command.");
                            }
                            }
                        }
                    }
                }
            } else{
                p.sendMessage(RED + "Sorry, " + p.getName() + " you do not have permission to use this command. "
                    + "If you believe you should please contact staff for further assistance");
            }
            return true;
        }
    }
    

    Plugin.yml (open)
    Code:
    name: mcReligions
    main: me.TekxWolf.McReligion.McReligionmain
    version: 0.1
    description:  >
                  Religion plugin to worship gods and become HEROES.
    author: TekxWolf
    commands:
      religion:
        description: Brings up the help page.
        usage: /religion
        permission: religion.religion.use
        permission-message: You do not have permission to use this command. If you believe you should please contact staff for further assistance.
      list:
        description: Brings up a page listing all choosable gods.
        usage: /religion list
        permission: religion.list.use
        permission-message: You do not have permission to use this command. If you believe you should please contact staff for further assistance.
      select:
        description: Selects the god you want to choose
        usage: /religion select <god's name>
        permission: religion.select.use
        permission-message: Sorry but you lack the permission to use this command.
      
    permissions:
      religion.religion.use:
        description: Gives permission to bring up the help page
      religion.list.use:
        description: Gives permission to view the list of Gods
      religion.select.*:
        description: Gives permission to all select commands
        children:
          religion.select.use: true
          religion.select.Iluvatar: true
          religion.select.Zeus: true
          religion.select.Hades: true
          religion.select.Apollo: true
      religion.select.use:
        description: Allows the user to choose a god to follow.
      religion.select.Iluvatar:
        description: Allows the user follow the God Iluvatar
      religion.select.Zeus:
        description: Allows the user follow the God Zeus
      religion.select.Hades:
        description: Allows the user to follow the God Hades
      religion.select.Apollo:
        description: Allows the user to follow the God Hades


    as well heres a screenshot of it in action:
    Picture (open)
    [​IMG]


    I fixed all that messy red text and i added some more stuff :)

    New Code (open)

    Code:
    package me.TekxWolf.McReligion;
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import static org.bukkit.ChatColor.*;
    
    public class McReligionmain extends JavaPlugin{
      
        public void onEnable(){
            getLogger().info("mcReligions has been Enabled!");
        }
      
        public void onDisable(){
            getLogger().info("mcReligions has been Disabled!");
        }
      
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            Player p = (Player) sender;
                if(label.equalsIgnoreCase("religion")){
                    if(args.length == 0){
                        p.sendMessage("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
                        p.sendMessage(GRAY + "Plugin info");
                        p.sendMessage(GRAY + "Name: McReligions");
                        p.sendMessage(GRAY + "Version: 0.2 Beta");
                        p.sendMessage(GRAY + "Author: TekxWolf");
                        p.sendMessage(GRAY + "Website: http://dev.bukkit.org/bukkit-plugins/mcreligions/");
                        p.sendMessage(GRAY + "Donate to help fund this projact: ");
                    }
                if(sender.hasPermission("religion.help.use")){
                    if(args[0].equalsIgnoreCase("help")){
                        p.sendMessage(GRAY + "+-+-+-+-+-+-+-+ Commands +-+-+-+-+-+-+-+");
                        p.sendMessage(GRAY + "/Religion help - Displays this help screen");
                        p.sendMessage(GRAY + "/Religion list - displays a list of chooseable gods");
                        p.sendMessage(GRAY + "/Religion select <God> - selects a god");
                        p.sendMessage(GRAY + "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
                    }
                    if(args[0].equalsIgnoreCase("list")){
                        if(sender.hasPermission("religion.list.use")){
                            p.sendMessage(WHITE + "+---+ " + GOLD + "Gods List" + RESET + WHITE + " +---+");
                            p.sendMessage(GREEN + "Ilúvatar");
                            p.sendMessage(GOLD + "Zeus");
                            p.sendMessage(RED + "Hades");
                            p.sendMessage(GRAY + "Apollo");
                            p.sendMessage(WHITE + "+---+---+---+---+---+");
                        }
                    }
                    if(args[0].equalsIgnoreCase("select")){
                        if(args.length == 0){
                            p.sendMessage(GRAY + "Please use "
                                    + "'/religion list' for a list of selectable gods");
                        }
                        if(args[1].equalsIgnoreCase("Iluvatar")){
                            if(sender.hasPermission("religion.select.Iluvatar")){
                                p.sendMessage(GREEN + "You have joined the religion of the mighty elven god, Ilúvatar!");
                                Bukkit.broadcastMessage(" " + GRAY + BOLD + "[" + DARK_PURPLE + BOLD + "mcReligions" + BOLD + GRAY + "] "
                                        + RESET + GREEN + p.getName() +  "Has joined the elven master Ilúvatar!");
                            }
                        }
                        if(args[1].equalsIgnoreCase("Zeus")){
                            if(sender.hasPermission("religion.select.Zeus")){
                                p.sendMessage(GOLD + "You have joined the religion of the mighty god, ZEUS!");
                                Bukkit.broadcastMessage(" " + GRAY + BOLD + "[" + DARK_PURPLE + BOLD + "mcReligions" + BOLD + GRAY + "] "
                                        + RESET + GOLD + p.getName() + " Has joined the greek god Zeus!");
                            }
                        }
                        if(args[1].equalsIgnoreCase("Hades")){
                            if(sender.hasPermission("religion.select.Hades")){
                                p.sendMessage(RED + "You have joined the darkest of gods, behold the father of death: HADES!");
                                Bukkit.broadcastMessage(" " + GRAY + BOLD + "[" + DARK_PURPLE + BOLD + "mcReligions" + BOLD + GRAY+ "] "
                                        + RESET + RED + p.getName() + " Has joined the darkness with Hades");
                            }
                        }
                        if(args[1].equals("Apollo")){
                            if(sender.hasPermission("religion.selct.Apollo")){
                                p.sendMessage(GRAY + "You have joined the nobelist of the gods, the heavenly master: APOLLO!");
                                Bukkit.broadcastMessage(" " + GRAY + BOLD + "[" + DARK_PURPLE + BOLD + "mcReligions" + BOLD + GRAY + "] "
                                        + RESET + GRAY + " Has joined the Greek God APOLLO!");
                            }
                        }
                    }
                }
            }
            return true;
        }
    }
    

    New plugin.yml (open)

    Code:
    name: mcReligions
    main: me.TekxWolf.McReligion.McReligionmain
    version: 0.1
    description:  >
                  Religion plugin to worship gods and become HEROES.
    author: TekxWolf
    commands:
      Religion:
        description: shows plugin info
      Religion help:
        description: Brings up the help page.
        permission: religion.help.use
      Religion list:
        description: Shows choosable Gods
        permission: religion.list.use
        permission-message: You do not have permission to use this command. If you believe you should please contact staff for further assistance.
      Religion select <God>:
        description: Selects the god you want to choose
      
    permissions:
      religion.religion.use:
        description: Gives permission to bring up the help page
      religion.list.use:
        description: Gives permission to view the list of Gods
      religion.select.*:
        description: Gives permission to all select commands
        children:
          religion.select.use: true
          religion.select.Iluvatar: true
          religion.select.Zeus: true
          religion.select.Hades: true
          religion.select.Apollo: true
      religion.select.use:
        description: Allows the user to choose a god to follow.
      religion.select.Iluvatar:
        description: Allows the user follow the God Iluvatar
      religion.select.Zeus:
        description: Allows the user follow the God Zeus
      religion.select.Hades:
        description: Allows the user to follow the God Hades
      religion.select.Apollo:
        description: Allows the user to follow the God Hades


    as well here is the plugin in action in version 0.2 :)
    picture (open)
    [​IMG]



    although i came across a new bug when i used the command /religion
    picture (open)
    [​IMG]


    As you can see the /religion still executes but after it it says "An internal error has occurred..." and in the console it gets spammed with stuff that i don't know what it means

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

Share This Page