1. Этот сайт использует файлы cookie. Продолжая пользоваться данным сайтом, Вы соглашаетесь на использование нами Ваших файлов cookie. Узнать больше.
  2. Вы находитесь в сообществе Rubukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на различные языки плагины наших коллег из других стран.
    Скрыть объявление
Скрыть объявление
В преддверии глобального обновления, мы проводим исследования, которые помогут нам сделать опыт пользования форумом ещё удобнее. Помогите нам, примите участие!

Не могу создать команду

Тема в разделе "Разработка плагинов для новичков", создана пользователем erioxis, 27 май 2020.

Метки:
  1. Автор темы
    erioxis

    erioxis Активный участник

    Баллы:
    61
    Имя в Minecraft:
    erioxis
    Сделал команду, но не работает
    Вот ошибка:
    Код:
    java.lang.NullPointerException: null
        at erioxis.main.ErioxisPlugin.onEnable(ErioxisPlugin.java:21) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:352) [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:462) [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:376) [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.reload(CraftServer.java:811) [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.Bukkit.reload(Bukkit.java:576) [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:711) [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchServerCommand(CraftServer.java:696) [spigot.jar:git-Spigot-800b93f-8160e29]
        at net.minecraft.server.v1_15_R1.DedicatedServer.handleCommandQueue(DedicatedServer.java:436) [spigot.jar:git-Spigot-800b93f-8160e29]
        at net.minecraft.server.v1_15_R1.DedicatedServer.b(DedicatedServer.java:400) [spigot.jar:git-Spigot-800b93f-8160e29]
        at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:984) [spigot.jar:git-Spigot-800b93f-8160e29]
        at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:824) [spigot.jar:git-Spigot-800b93f-8160e29]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
    Вот код:
    Main:
    Код:
    public void onEnable(){
            Bukkit.getPluginManager().registerEvents(new Handler(), this);
            /*Bukkit.addRecipe(getRecipe());*/
            getCommand("erioxis").setExecutor(new Commands(this));
            logger.info("[ErioxisPlugin] has started");
        }
    Commands:
    Код:
    package erioxis.main;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    
    import net.md_5.bungee.api.ChatColor;
    
    public class Commands implements CommandExecutor {
        
        private ErioxisPlugin plugin;
    
        public Commands(ErioxisPlugin plugin) {
            this.plugin = plugin;
        }
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(!sender.hasPermission("erioxisplugin.erioxis")) {
                sender.sendMessage(ChatColor.RED + "You don't have permission!");
                return true;
            }
            
            sender.sendMessage("Test command");
            
            return true;
        }
    
    }
     
  2. keepitslice

    keepitslice Активный участник Пользователь

    Баллы:
    66
    Помимо getCommand ещё нужно в plugin.yml прописать
     
  3. alexandrage

    alexandrage Старожил Пользователь

    Баллы:
    173
  4. keepitslice

    keepitslice Активный участник Пользователь

    Баллы:
    66
    Кстати, вместо прописывания всего самому можешь заюзать аннотации: https://www.spigotmc.org/wiki/spigot-plugin-yml-annotations/
     
  5. Автор темы
    erioxis

    erioxis Активный участник

    Баллы:
    61
    Имя в Minecraft:
    erioxis
    Ок, позже попробую
     
  6. Автор темы
    erioxis

    erioxis Активный участник

    Баллы:
    61
    Имя в Minecraft:
    erioxis
    Сделал, но не работает.
    upload_2020-5-27_16-43-54.png
     
  7. Sigvegutt

    Sigvegutt Активный участник Пользователь

    Баллы:
    96
  8. Автор темы
    erioxis

    erioxis Активный участник

    Баллы:
    61
    Имя в Minecraft:
    erioxis
    Ща попробую
     
  9. Автор темы
    erioxis

    erioxis Активный участник

    Баллы:
    61
    Имя в Minecraft:
    erioxis
    Также ошибка
     
  10. Sigvegutt

    Sigvegutt Активный участник Пользователь

    Баллы:
    96
    Код:
    # This determines the command prefix when there are conflicts (/name:home, /name:help, etc.)
    name: Essentials
    main: com.earth2me.essentials.Essentials
    # Note to developers: This next line cannot change, or the automatic versioning system will break.
    version: 2.17.1.0
    website: http://tiny.cc/EssentialsCommands
    description: Provides an essential, core set of commands for Bukkit.
    softdepend: [Vault]
    authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Iaccidentally, drtshock, vemacs, SupaHam, md678685]
    api-version: 1.13
    commands:
      afk:
        description: Marks you as away-from-keyboard.
        usage: /<command> [player/message...]
        aliases: [eafk,away,eaway]
      antioch:
        description: 'A little surprise for operators.'
        usage: /<command> [message]
        aliases: [eantioch,grenade,egrenade,tnt,etnt]
      back:
        description: Teleports you to your location prior to tp/spawn/warp.
        usage: /<command> [player]
        aliases: [eback,return,ereturn]
      backup:
        description: Runs the backup if configured.
        usage: /<command>
        aliases: [ebackup]
      gamemode:
        description: Change player gamemode.
        usage: /<command> <survival|creative|adventure|spectator> [player]
        aliases: [adventure,eadventure,adventuremode,eadventuremode,creative,eecreative,creativemode,ecreativemode,egamemode,gm,egm,gma,egma,gmc,egmc,gms,egms,gmt,egmt,survival,esurvival,survivalmode,esurvivalmode,gmsp,sp,egmsp,spec,spectator]
      gc:
        description: Reports memory, uptime and tick info.
        usage: /<command> [all]
        aliases: [lag,elag,egc,mem,emem,memory,ememory,uptime,euptime,tps,etps,entities,eentities]
      getpos:
        description: Get your current coordinates or those of a player.
        usage: /<command> [player]
        aliases: [coords,egetpos,position,eposition,whereami,ewhereami,getlocation,egetlocation,getloc,egetloc]
      give:
        description: Give a player an item.
        usage: /<command> <player> <item|numeric> [amount [itemmeta...]]
        aliases: [egive]
      god:
        description: Enables your godly powers.
        usage: /<command> [player] [on|off]
        aliases: [egod,godmode,egodmode,tgm,etgm]
      hat:
        description: Get some cool new headgear.
        usage: /<command> [remove]
        aliases: [ehat,head,ehead]
      heal:
        description: Heals you or the given player.
        usage: /<command> [player]
        aliases: [eheal]
      help:
        description: Views a list of available commands.
        usage: /<command> [search term] [page]
        aliases: [ehelp]
      helpop:
        description: Message online admins.
        usage: /<command> <message>
        aliases: [ac,eac,amsg,eamsg,ehelpop]
      home:
        description: Teleport to your home.
        usage: /<command> [player:][name]
        aliases: [ehome,homes,ehomes]
      ignore:
        description: Ignore or unignore other players.
        usage: /<command> <player>
        aliases: [eignore,unignore,eunignore,delignore,edelignore,remignore,eremignore,rmignore,ermignore]
      info:
        description: Shows information set by the server owner.
        usage: /<command> [chapter] [page]
        aliases: [about,eabout,ifo,eifo,einfo,inform,einform,news,enews]
      invsee:
        description: See the inventory of other players.
        usage: /<command> <player>
        aliases: [einvsee]
      item:
        description: Spawn an item.
        usage: /<command> <item|numeric> [amount [itemmeta...]]
        aliases: [i,eitem,ei]
      itemdb:
        description: Searches for an item.
        usage: /<command> <item>
        aliases: [dura,edura,durability,edurability,eitemdb,itemno,eitemno]
      itemname:
        description: Names an item.
        usage: /<command> [name]
        aliases: [iname, einame, eitemname, itemrename, irename, eitemrename, eirename]
      jails:
        description: List all jails.
        usage: /<command>
        aliases: [ejails]
      jump:
        description: Jumps to the nearest block in the line of sight.
        usage: /<command>
        aliases: [j,ej,ejump,jumpto,ejumpto]
      kick:
        description: Kicks a specified player with a reason.
        usage: /<command> <player> [reason]
        aliases: [ekick]
      kickall:
        description: Kicks all players off the server except the issuer.
        usage: /<command> [reason]
        aliases: [ekickall]
      kill:
        description: Kills specified player.
        usage: /<command> <player>
        aliases: [ekill]
      kit:
        description: Obtains the specified kit or views all available kits.
        usage: /<command> [kit] [player]
        aliases: [ekit,kits,ekits]
      kittycannon:
        description: Throw an exploding kitten at your opponent.
        usage: /<command>
        aliases: [ekittycannon]
      lightning:
        description: The power of Thor. Strike at cursor or player.
        usage: /<command> [player] [power]
        aliases: [elightning,shock,eshock,smite,esmite,strike,estrike,thor,ethor]
      list:
        description: List all online players.
        usage: /<command> [group]
        aliases: [elist,online,eonline,playerlist,eplayerlist,plist,eplist,who,ewho]
      mail:
        description: Manages inter-player, intra-server mail.
        usage: /<command> [read|clear|send [to] [message]|sendall [message]]
        aliases: [email,eemail,memo,ememo]
      me:
        description: Describes an action in the context of the player.
        usage: /<command> <description>
        aliases: [action,eaction,describe,edescribe,eme]
      more:
        description: Fills the item stack in hand to maximum size.
        usage: /<command>
        aliases: [emore]
      motd:
        description: Views the Message Of The Day.
        usage: /<command> [chapter] [page]
        aliases: [emotd]
      msg:
        description: Sends a private message to the specified player.
        usage: /<command> <to> <message>
        aliases: [w,m,t,pm,emsg,epm,tell,etell,whisper,ewhisper]
      msgtoggle:
        description: Blocks receiving all private messages.
        usage: /<command> [player] [on|off]
        aliases: [emsgtoggle]
      mute:
        description: Mutes or unmutes a player.
        usage: /<command> <player> [datediff] [reason]
        aliases: [emute,silence,esilence]
      near:
        description: Lists the players near by or around a player.
        usage: /<command> [playername] [radius]
        aliases: [enear,nearby,enearby]
      nick:
        description: Change your nickname or that of another player.
        usage: /<command> [player] <nickname|off>
        aliases: [enick,nickname,enickname]
      nuke:
        description: May death rain upon them.
        usage: /<command> [player]
        aliases: [enuke]
      pay:
        description: Pays another player from your balance.
        usage: /<command> <player> <amount>
        aliases: [epay]
      paytoggle:
        description: Toggles whether you are accepting payments.
        usage: /<command>
        aliases: [epaytoggle, payoff, epayoff, payon, epayon]
      payconfirmtoggle:
        description: Toggles whether you are prompted to confirm payments.
        usage: /<command>
        aliases: [epayconfirmtoggle, payconfirmoff, epayconfirmoff, payconfirmon, epayconfirmon, payconfirm, epayconfirm]
      ping:
        description: Pong!
        usage: /<command>
        aliases: [echo,eecho,eping,pong,epong]
      potion:
        description: Adds custom potion effects to a potion.
        usage: /<command> <clear|apply|effect:<effect> power:<power> duration:<duration>>
        aliases: [epotion,elixer,eelixer]
      powertool:
        description: Assigns a command to the item in hand.
        usage: /<command> [l:|a:|r:|c:|d:][command] [arguments] - {player} can be replaced by name of a clicked player.
        aliases: [epowertool,pt,ept]
      powertooltoggle:
        description: Enables or disables all current powertools.
        usage: /<command>
        aliases: [epowertooltoggle,ptt,eptt,pttoggle,epttoggle]
      ptime:
        description: Adjust player's client time. Add @ prefix to fix.
        usage: /<command> [list|reset|day|night|dawn|17:30|4pm|4000ticks] [player|*]
        aliases: [playertime,eplayertime,eptime]
      pweather:
        description: Adjust a player's weather
        usage: /<command> [list|reset|storm|sun|clear] [player|*]
        aliases: [playerweather,eplayerweather,epweather]
      r:
        description: Quickly reply to the last player to message you.
        usage: /<command> <message>
        aliases: [er,reply,ereply]
    
    permissions:
      essentials.*:
        default: op
        description: Give players with op everything by default
        children:
          essentials.gamemode.*: true
      # These permissions can't be assigned from player-commands for compatibility reasons
      essentials.teleport.cooldown.bypass.tpa:
        default: true
        description: If the player does not have this permission, /tpa will have cooldown even with the parent bypass perm
      essentials.teleport.cooldown.bypass.back:
        default: true
        description: If the player does not have this permission, /back will have cooldown even with the parent bypass perm
      essentials.gamemode.*:
        default: op
        children:
          essentials.gamemode: true
          essentials.gamemode.others: true
          essentials.gamemode.all: true
      essentials.seen.extra:
        default: op
        children:
          essentials.seen.ip: true
          essentials.seen.location: true
      essentials.keepinv:
        default: false
        description: Controls whether players keep their inventory on death.
     
  11. FoxyMan228822

    FoxyMan228822 Активный участник

    Баллы:
    61
    Имя в Minecraft:
    FoxyMan228822
    Что у тебя ещё в главном классе?
     
  12. JustMelon_

    JustMelon_ Активный участник Пользователь

    Баллы:
    66
    Имя в Minecraft:
    JustMelon_
    А то, что он скинул, разве недостаточно?

    Я вообще команды регистрирую без plugin.yml, вот сам туториал.
     
  13. alexandrage

    alexandrage Старожил Пользователь

    Баллы:
    173
    Полезная штука для динамических сундук гуищ ага, и не только.
     

Поделиться этой страницей