首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >开发“我的世界”插件有困难

开发“我的世界”插件有困难
EN

Stack Overflow用户
提问于 2020-04-26 06:11:47
回答 3查看 98关注 0票数 0

遵循YouTube教程,但当我运行插件时,我根本不注册它。插件的意思是返回“嗨!”当剧本开始的时候,/hello或/hi。当我把插件放在我的服务器上什么都没有,甚至没有注册在/plugins

代码: Main.java:

代码语言:javascript
复制
package me.Cheese_Echidna.helloworld;

import me.Cheese_Echidna.helloworld.commands.HelloCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin {

    @Override
    public void onEnable() {
        new HelloCommand(this);

    }
}

HelloCommand.java:

代码语言:javascript
复制
package me.Cheese_Echidna.helloworld.commands;

import me.Cheese_Echidna.helloworld.Main;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;


public class HelloCommand implements CommandExecutor {

    @SuppressWarnings("unused")
    private Main plugin;

    public HelloCommand(Main plugin) {
        this.plugin = plugin;
        plugin.getCommand("hello").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
         if (!(sender instanceof Player)) {
             sender.sendMessage("Only players may execute this command!");
             return true;
         }
         Player p = (Player) sender;

         if (p.hasPermission("hello.use")) {
             p.sendMessage("Hi!");

             return true;
         } else {
             p.sendMessage("You do not have permission to execute this command!");
         }

        return false;
    }

}

plugin.yml:

代码语言:javascript
复制
name: HelloWorld
version: 1.0
author: Cheese_Echidna
main: me.Cheese_Echidna.helloworld.main
description: My first Bukkit plugin

commands:
  hello:
   aliases: [hi]
   description: This is the hello command!

YT教程:https://www.youtube.com/watch?v=XaU8JKQW0Ao

我在这里附上了一张文件结构的照片:

任何帮助都会很感激的。

EN

回答 3

Stack Overflow用户

发布于 2020-06-22 19:21:57

我有个基本问题。您是否在您的“我的世界”服务器上安装了Vanilla Min克拉夫特版本?要使用Bukkit或Spigot插件,您必须使用,它们的扩展

票数 0
EN

Stack Overflow用户

发布于 2021-05-06 23:13:58

我不是舒尔。但问题可能在plugin.yml!

首先,在plugin.yml中为制表符使用一个空格是很重要的

另一个问题是,在main后面有一条路径:必须导致一个类--在本例中,它将是main: me.Cheese_Echidna.helloworld.main.Main

更正后的plugin.yml应该如下所示:

代码语言:javascript
复制
name: HelloWorld
version: 1.0
author: Cheese_Echidna
main: me.Cheese_Echidna.helloworld.main.Main
description: My first Bukkit plugin

commands:
 hello:
  aliases: [hi]
  description: This is the hello command!
票数 0
EN

Stack Overflow用户

发布于 2021-05-16 03:07:35

您忘了在plugin.yml中添加API版本。很常见的错误,别担心,很多人都这么做。以下是plugin.yml wiki以获取更多信息:Plugin.yml维基

也应该是这样的。你好像把文件放在文件夹里,而不是包里。

我的plugin.yml供参考

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61436530

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档