1

Need coding help ;)

Rileys 1/29/15 2:00 am
849
1/30/2015 6:02 pm
when i start up my server this plugin doesn't load in?

http://gyazo.com/01429fa54f67c90f32fa6b30307f50c8


package me.Minecraft_GOLD.Nightv;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class Nightv extends JavaPlugin {


public void onEnable() {
}


public void onDisable() {}

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.DARK_RED + "Error: The console Can't run this command!.");
return true;
}

Player p = (Player) sender;

if (cmd.getName().equalsIgnoreCase("nv")) {
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 5000, 1));
p.sendMessage(ChatColor.GREEN + "Night Vision Enabled!.");
}
return false;
}
}
Posted by
Rileys
Level 3 : Apprentice Network
1

  Have something to say?

JoinSign in

11

MCGeeneus
01/29/2015 8:12 pm
Level 1 : New Explorer
A wise man once put it, "Get a job, get a cake, or get lost bub."
1
Ciberg
01/30/2015 6:02 pm
Level 18 : Journeyman Hunter
The cake was a lie, it's either get a job or get lost.
1
Ciberg
01/29/2015 6:26 pm
Level 18 : Journeyman Hunter
Make sure:

- Craftbukkit versions match
- No tabs or extra spaces in plugin.yml
- You exported it correctly, sometimes it messes up
- You post any errors you get. Try Bukkit.broadcastMessage("")'ing things to test what works and what doesn't.

Also, your main class path is not the same as what you have in your plugin.yml regarding capital letters. If you've fixed it, update your post so we don't have to try to help a non existant problem

Btw: There should be an error no matter what unless you completely left our your onEnable()
1
ArcaneGamer-
01/29/2015 6:20 pm
Level 29 : Expert Modder
Anyways, if your plugin simply isn't showing up in the console whatsoever (i.e. No errors, start-up messages, etc.), then it's a problem with your plugin.yml. Put this in your main section in your plugin.yml
Click to reveal
"me.Minecraft_GOLD.Nightv.Nightv" (without quotation marks).
For your command use two spaces (Yes some people say 3 or 4, but 2 has always worked for me).



This is my code for an op command I used on my server. It made things easier when I was testing plugins. I wouldn't have to switch back and forth between my console.
http://hastebin.com/jinasecuni.java
1
ArcaneGamer-
01/29/2015 6:13 pm
Level 29 : Expert Modder
From my experience, even if the command is in the same class you still need to implement CommandExecutor. I know for a fact you have to do that with listeners since it's one of the problems I ran into when I first started coding plugins.
1
ShadowCatEXE
01/29/2015 6:18 pm
Level 31 : Artisan Toast
Well, it's been a long time since I've put a command in the main class, so maybe you do need to implement CommandExecutor.. I can't remember. But I'm pretty sure he doesn't need to register the command.
1
ArcaneGamer-
01/29/2015 4:56 pm
Level 29 : Expert Modder
You didn't register the command nor implement CommandExecutor. Also, can you show the plugin.yml contents?
1
ShadowCatEXE
01/29/2015 6:01 pm
Level 31 : Artisan Toast
If his command is inside a class that extends JavaPlugin, then there's no need for implementing CommandExecutor, nor register the command.
1
Datac
01/29/2015 2:24 pm
Level 1 : New Crafter
You have a capital V at the end, your class has a lower case v. Your main needs to have a lower case v.
1
Rileys
01/29/2015 5:02 am
Level 3 : Apprentice Network
1
Datac
01/29/2015 2:03 am
Level 1 : New Crafter
Can you share the plugin.yml?
1

Welcome