我做的自定义插件在eclipse中没有错误,当我导出它时,它不会在spigot中显示?
主文件
package me.intelligamez.damageone;
import org.bukkit.plugin.java.JavaPlugin;
import me.intelligamez.damageone.listeners.DamageListener;
import me.intelligamez.damageone.listeners.HealthListener;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
new DamageListener(this);
new HealthListener(this);
}
}
侦听器1
package me.intelligamez.damageone.listeners;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import me.intelligamez.damageone.Main;
public class DamageListener implements Listener {
private Main plugin;
public DamageListener(Main plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this,plugin);
}
@EventHandler
public void onDamage(EntityDamageEvent dmg) {
Entity e = dmg.getEntity();
if(e instanceof Player) {
Player p = (Player) e;
double initialh = p.getHealth();
double taken = dmg.getFinalDamage();
double pop = taken*1.25;
p.setHealth(pop+initialh);
}
}
}
监听器2(基本相同)
package me.intelligamez.damageone.listeners;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import me.intelligamez.damageone.Main;
public class HealthListener implements Listener {
private Main plugin;
public HealthListener(Main plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this,plugin);
}
@EventHandler
public void onDamage(EntityRegainHealthEvent hlth) {
Entity e = hlth.getEntity();
if(e instanceof Player) {
Player p = (Player) e;
double afterh = p.getHealth();
double gain = hlth.getAmount();
double pop = gain*1.25;
p.setHealth(afterh-pop);
}
}
}
插件.yml
main: me.intelligamez.damageone.Main
name: damageone
version: 1.0
author: intelligamez
description: Srsly who reads this you already know !
我什么都做对了?很多人说plugin.yml不需要空格,但它没有修复问题版本:minecraft 1.16.3server:spigot ide:日 eclipse
1条答案
按热度按时间x7yiwoj41#
您需要在plugin.yml中添加spigotapi的版本
另外,api版本不能是特定的(使用1.13,1.16,。。。不要使用1.13.1或1.16.2)