banner



How To Register A Command Class Plugin

Thread Condition:
Non open for farther replies.
  1. I'm working on a kit plugin and I'm trying to organize it and add the commands dissever classes, but when I attempt and run the command, it doesn't piece of work and I get an error saying that its "Zippo".

    Main Class:

    packet com.ragecraft.pvpkit;   import java.io.IOException; import coffee.util.logging.Logger;   import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin;   import com.ragecraft.pvpkit.Kits; public grade Principal extends JavaPlugin implements Listener {         Logger logger = Logger.getLogger("Minecraft");         public void onEnable() {         logger.info("[PvpKits] Past Epicballzy!");         Bukkit.getServer().getPluginManager().registerEvents(new EventHandlers(), this);         getCommand("pvpkit").setExecutor(new Kits());         try {             saveConfig();             setupConfig(getConfig());             saveConfig();         } catch(Exception eastward) {             eastward.printStackTrace();         }     }       private void setupConfig(FileConfiguration config) throws IOException {     if(getDataFolder().exists()) {         config.gear up("kits.Mage.items" , "267 1, 364 32, 302 ane, 303 one, 304 1, 305 ane");         config.set("kits.Archer.items" , "261 1, 262 64, 364 32, 298 ane, 299 1, 300 1, 301 i");         config.set("kits.Poorman.items" , "272 i, 364 32, 298 1, 299 one, 300 i, 301 1");         config.prepare("kits.Axehead.items" , "279 i, 260 64, 298 ane, 299 1, 300 i, 301 1");         config.set("kits.Fisherman.items" , "346 1, 268 1, 298 one, 299 1, 300 i, 301 1");                 config.set("kits.names", "Mage,Archer,PoorMan,AxeHead,FisherMan");         }     } }
    Control Grade:
    package com.ragecraft.pvpkit;   import java.util.ArrayList;   import org.bukkit.ChatColor; import org.bukkit.Musical instrument; import org.bukkit.Note; import org.bukkit.Note.Tone; import org.bukkit.command.Command; import org.bukkit.control.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.effect.entity.PlayerDeathEvent; import org.bukkit.inventory.ItemStack;     public class Kits extends Master implements CommandExecutor {         /* Arrays */     public ArrayList<String> kit = new ArrayList<Cord>();       /* Command */     @SuppressWarnings("deprecation")     public boolean onCommand(CommandSender sender, Command cmd, Cord cord, String[] args) {         if(cord.equalsIgnoreCase("pvpkit")) {             Actor role player = (Thespian) sender;             if(!(sender instanceof Player)) {                 sender.sendMessage(ChatColor.RED + "You MUST exist a player to do this!");                 return true;             }                 if(histrion.hasPermission("pvpkit.kit")) {                 if(args.length == 0) {                     Cord[] classes = getConfig().getString("kits.names").split(",");                     Cord names = "";                     for (String southward : classes)                         if (s != cipher)                             names += due south + ", ";                     player.sendMessage(ChatColor.AQUA + "Kits" + ChatColor.DARK_GRAY + ": " + ChatColor.Light-green + names);             } else if(!(sender.hasPermission("pvpkit.kit") || (!(sender.isOp())))) {                   player.sendMessage(ChatColor.RED + "You Don't Have Permission!");                 } else {                     for (String s : getConfig().getConfigurationSection("kits")                             .getKeys(faux)) {                         if (args[0].equalsIgnoreCase(s)) {                             if(kit.contains(role player.getName())) {                                 role player.sendMessage(ChatColor.RED + "Y'all Already Accept A Kit!");                                 histrion.sendMessage(ChatColor.RED + "Become Fight!");                                 return fake;                             }                             kit.add(player.getName());                                 role player.getInventory().articulate();                             effort {                                 String items = getConfig().getString("kits." + s + ".items");                                 String[] indiItems = items.carve up(", ");                                 for (Cord s1 : indiItems) {                                     Cord[] itemAmounts = s1.dissever(" ");                                     ItemStack item = new ItemStack(Integer.valueOf(itemAmounts[0]),Integer.valueOf(itemAmounts[1]));                                     player.getInventory().addItem(particular);                                 }                                 player.updateInventory();                             } take hold of (Exception east) {                                 due east.printStackTrace();                             }                             actor.playNote(player.getLocation(), Instrument.BASS_GUITAR, Note.natural(1, Tone.E));                             player.sendMessage(ChatColor.AQUA + "You received the " + ChatColor.Gilded + ChatColor.Bold + south + ChatColor.AQUA + " kit!");                         }                     }                 }             }         }         render fake;     }       /* Remove From Array Handler */     @EventHandler     public void onPlayerDeathEvent(PlayerDeathEvent east) {         if(kit.contains(e.getEntity().getName())) {             kit.remove(e.getEntity().getName());         }     }   }                        
    Error Log:
    [xx:13:39] [Server thread/INFO]: Epicballzy issued server control: /pvpkit [20:13:39] [Server thread/Fault]: null org.bukkit.command.CommandException: Unhandled exception executing command 'pvpkit' in plugin PvpKits. v3.0     at org.bukkit.command.PluginCommand.execute(PluginCommand.coffee:46) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]     at org.bukkit.control.SimpleCommandMap.acceleration(SimpleCommandMap.coffee:196) ~[craftbukkit.jar:git-Bukkit-1.seven.2-R0.2-b2974jnks]     at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.coffee:542) ~[craftbukkit.jar:git-Bukkit-ane.7.ii-R0.two-b2974jnks]     at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.coffee:932) [craftbukkit.jar:git-Bukkit-i.vii.2-R0.2-b2974jnks]     at internet.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [craftbukkit.jar:git-Bukkit-1.seven.2-R0.2-b2974jnks]     at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]     at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.coffee:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]     at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-ane.seven.ii-R0.2-b2974jnks]     at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.seven.two-R0.ii-b2974jnks]     at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]     at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]     at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.seven.2-R0.ii-b2974jnks]     at cyberspace.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.two-R0.two-b2974jnks]     at internet.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] Caused by: java.lang.IllegalArgumentException: File cannot be goose egg     at org.apache.commons.lang.Validate.notNull(Validate.coffee:203) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.ii-b2974jnks]     at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:171) ~[craftbukkit.jar:git-Bukkit-one.7.ii-R0.2-b2974jnks]     at org.bukkit.plugin.coffee.JavaPlugin.reloadConfig(JavaPlugin.java:118) ~[craftbukkit.jar:git-Bukkit-1.vii.two-R0.ii-b2974jnks]     at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:112) ~[craftbukkit.jar:git-Bukkit-one.vii.2-R0.ii-b2974jnks]     at com.ragecraft.pvpkit.Kits.onCommand(Kits.java:37) ~[?:?]     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    I feel like I'one thousand making a simple mistake that I cannot figure out. Whatsoever help is appreciated! :)

  2. The plugin.yml should be correct.
    proper noun: PvpKits main: com.ragecraft.pvpkit.Principal version: 3.0 description: KitPvp! Author: Epicballzy   commands:   pvpkit:     clarification: List of Available Kits.
    It's the same as it was earlier I decided to motion the commands over to dissimilar classes.
  3. Also, umm, why does Kits extend Chief?

    Whoops, silly owl. ;P
    The fault is an IllegalArgumentException, apparently on line 37. What'south line 37?

  4. Epicballzy

    You're missing your brackets { } in some places buddy.

    EDIT:

    I believe this should work, if you register your commands in OnEnable

                              
    1. getCommand( "pvpkit" ).setExecutor ( new Kits( this ) ) ;

    Your plugin.yml

    proper noun: PvpKits main: com.ragecraft.pvpkit.Chief version: 3.0 commands:   pvpkit:       description: Put curt description here       usage: /<command>       permission: <plugin name>.permission_node       permission-message: Yous don't have <permission>
  5. I don't think I'm missing whatsoever brackets.. The command piece of work perfectly without information technology beingness in a separate class.
  6. Epicballzy
    Now Im not sure what youre asking then.
    Line 37 is missing a opening bracket for sure.
    You need { after for and if statement as far as I know.
  7. Adriani6 Not necessarily. If only a single statement is associated with an if/for/while statement, and so the braces do non have to be included.

    For example

    if(player.getName().equals("SnipsRevival"))     histrion.sendMessage("You are merely precious!")
    is valid despite not having opening braces.
Thread Condition:
Not open for further replies.

Share This Page

How To Register A Command Class Plugin,

Source: https://bukkit.org/threads/registering-commands-in-other-classes.256929/

Posted by: summerlinfrour1976.blogspot.com

0 Response to "How To Register A Command Class Plugin"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel