I Need Help On A Plugin Im Developing

Discussion in 'Plugin Development' started by Kharte321, Mar 26, 2016.

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


    Hi does Anybody Now How To Fix This

    The Main Code:

    package me.kharte321;
    import org.bukkit.plugin.java.JavaPlugin;
    import me.kharte321.commands.regeneration;
    import me.kharte321.commands.speed;
    public class PotionAndDamage extends JavaPlugin {
        public void onEnable(){
            getLogger().info("Potion And Damage Has Been Enabled,Made By Kharte321");
            getCommand("regeneration").setExecutor(new regeneration());
            getCommand("speed").setExecutor(new speed());
        private void registerConfig() {
        public void onDisable(){
            getLogger().info("Potion And Damage Has Been Disabled");
    Regen Code:

    package me.kharte321.commands;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    import me.kharte321.PotionAndDamage;
    public class regeneration implements CommandExecutor   {
        private PotionAndDamage plugin;
        public regeneration(PotionAndDamage pl){
            plugin = pl;
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("regeneration") && sender instanceof Player  ){
                Player player = (Player) sender;
                player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20*20,20));
                player.sendMessage("U Have Been Giving Regen 20 For 0.20 Minute In Return for 12 Half Hearts");
                String  Damage;
                Damage = plugin.getConfig().getString("Amount_Of_Hearts");
            return true;
    Config Code:

    # PotionAndDamage
    Amount_Of_Hearts: '12'

    Damage Is Red On Code
  2. Offline

    timtower Administrator Administrator Moderator

    @Kharte321 Why is Damage a string? And you are getting it AFTER you are using it.
  3. Offline


    Because I Want To be Able To Edit The Amount Of Hearts It takes Away In The Config

    And Damage Is Underlined
    In Red

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Mar 26, 2016
  4. Offline

    timtower Administrator Administrator Moderator

    @Kharte321 Couple things:
    1. Your capitalization is very annoying, please don't capitalize every single word.
    2. You are using a variable before you set it.
    3. Try getDouble instead of getString, then you at least have the right variable type.
  5. Offline


    Sorry But Im Confused
  6. Offline

    timtower Administrator Administrator Moderator

    1. Stop hitting shift at the beginning of every word.
    2. You are eating the pie before you are baking it. Bad example, but it is what you are doing in your code.
    3. You are eating apple pie while you are needing cherry pie.
    I suggest some basic java lessons.
    teej107 likes this.
  7. Offline


    First I will point out to you what tim means when he is saying you are trying to use a variable before you even set it.
                String  Damage;
    Notice how you are calling player.damage(Damage) before the code has even found out what Damage means. That would give you an error.

    After going through some basic lessons like @timtower suggested,

    You cannot use a string to deal damage. If you want to store a configurable amount of damage in the config, you will need to stop setting it as a string and instead use
    int dmg = getConfig().getInt("damage");
    After correctly defining it, and defining it BEFORE you call it, you can damage the player.
Thread Status:
Not open for further replies.

Share This Page