gpt4 book ai didi

java - Minecraft Bukkit Activity

转载 作者:行者123 更新时间:2023-11-30 08:04:21 25 4
gpt4 key购买 nike

我正在尝试为 Minecraft 进行 bukkit 编程,但出于某种原因我被事件困住了。这是我的代码:

主类文件:

package com.plugin1;

import java.util.logging.Logger;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginDescriptionFile;
//import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import net.md_5.bungee.api.ChatColor;

public class Plugin extends JavaPlugin {

public int songStage;
public static Plugin plugin;

public void OnEnable () {
PluginDescriptionFile pluginDesc = getDescription();
Logger logger = getLogger();

plugin = this;
registerEvents(this, new BlockBreak());

logger.info(pluginDesc.getName() + " is enabled! (V. " + pluginDesc.getVersion() + ")");
}

public void OnDisable () {
PluginDescriptionFile pluginDesc = getDescription();
Logger logger = Logger.getLogger("Plugin");

plugin = null;
logger.info(pluginDesc.getName() + " is disabled! (V. " + pluginDesc.getVersion() + ")");
}

public static void registerEvents(org.bukkit.plugin.Plugin plugin, Listener... listeners) {
for (Listener listener : listeners) {
Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
}
}

public static Plugin getPlugin() {
return plugin;
}
}

事件类文件:

package com.plugin1;

import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;

public class BlockBreak implements Listener {

@EventHandler(priority = EventPriority.HIGH)
public void OnBlockBreak (BlockBreakEvent e) {
Player p = e.getPlayer();

p.sendMessage("Block broken.");
}
}

基本上,这不会返回任何错误。我已经通过控制台,什么也没有。当我打破一个 block 时,几乎什么都没有发生!

我已经尝试了一些事情:我经历了它,尝试了多个视频教程并尝试了 minecraft 论坛上的文本教程,但仍然没有。我还联系了一位编写 bukkit 插件的服务器所有者,但他无法解决这个问题......

如果有人可以帮助我,请告诉我!!!!

提前致谢!

最佳答案

这是一个在进程中启动服务器的代码示例:

package me.Nightfighter001.GlobalSystem.Listener;

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

import me.Nightfighter001.GlobalSystem.Main.main;

public class Join implements Listener {

public Join(main main) {
plugin = main;
plugin.getServer().getPluginManager().registerEvents(this, main);
}

@EventHandler
public void onPlayerJoin(PlayerJoinEvent ev) {
ev.setJoinMessage("");
}

main plugin = main.getPlugin();
}

关于java - Minecraft Bukkit Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35687552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com