我一直试图制作一个枪支游戏插件,但我无法让玩家死亡事件发挥作用。插件加载得很好但是当我杀死另一个玩家时没有任何反应。
package me.GunGame;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
@
Override
public void onEnable() {
getLogger().info("Gun Game Enabled");
}@
Override
public void onDisable() {
getLogger().info("Gun Game Disabled");
}
@
EventHandler
public void OnPlayerDeath(PlayerDeathEvent e) {
Player p = e.getEntity();
p.sendMessage(ChatColor.RED + "You have died!");
Player k = p.getKiller();
k.sendMessage(ChatColor.RED + "You killed " + p.getDisplayName());
}
}
答案 0 :(得分:2)
您需要注册插件才能接收活动。使用* {
margin: 0;
padding: 0;
}
body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}
a {
text-decoration: none;
font-size: 11px;
font-weight: 100;
width: 100%;
box-sizing: border-box;
}
ul {
list-style: none;
}
/*
LEVEL ONE : MAIN MENU
*/
ul.dropdown {
position: relative;
}
ul.dropdown li.menuppal {
float: left;
zoom: 1;
background: #000 url(../images/menuLight.png) repeat-x top left;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-left: 1px solid #222;
}
ul.dropdown li.menuppal a {
display: block;
padding: 4px 8px;
color: #000000;
}
/* Doesn't work in IE */
ul.dropdown li.menuppal:hover {
background: #ccc url('../images/menuDark.png') repeat-x 50% 50%;
position: relative;
}
/*
FIN LEVEL ONE
*/
/*
LEVEL TWO
*/
ul.dropdown ul {
width: 220px;
visibility: hidden;
position: absolute;
top: 100%;
left: 0;
background-color: #40617C;
}
ul.dropdown ul li {
float: none;
position: relative;
}
/* IE 6 & 7 Needs Inline Block */
ul.dropdown li.menuppal ul li a {
border-right: none;
color: #FFF;
display: inline-block;
}
ul.dropdown li.menuppal ul li a:hover {
background: #07243a;
}
ul.dropdown li.menuppal ul li a:visited {
word-break: break-all;
}
/*
LEVEL THREE
*/
ul.dropdown ul ul {
left: 100%;
top:0!important;
}
/*
LEVEL FOUR
*/
ul.dropdown ul ul ul {
left: 100%;
top:0!important;
}
ul.dropdown li:hover > ul {
visibility: visible;
}
进行注册。有关详细信息,请参阅Event API Reference。
答案 1 :(得分:0)
您必须添加到onEnable()
您没有注册活动。
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
getLogger().info("Gun Game Enabled");
}
简单的错误,人们贬低了,因为如果你读过你的代码,你就会看到它。它也在维基上多次提到它。