所以我做了一个插件,可以在执行/ pvpeventon之后注册事件,并在执行/ pvpeventoff之后取消所有注册。 它是一个PVPeventplugin。 我想在玩家重生后传送他们,但它不起作用。他们不会被传送。顺便说一句:我很久不编码Spigot了。这是我的代码:
package me.leopa.R1.FFA;
import org.bukkit.Location;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.md_5.bungee.api.ChatColor;
public class MainFFA extends JavaPlugin implements Listener{
@Override
public void onEnable() {
System.out.println("[INFO Leopa] Start");
super.onEnable();
}
@Override
public void onDisable() {
System.out.println("[INFO Leopa] Stop");
super.onDisable();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(command.getName().equalsIgnoreCase("PVPEVENTon")) {
if(sender instanceof Player) {
getServer().getPluginManager().registerEvents(this, this);
}
}
if(command.getName().equalsIgnoreCase("PVPEVENToff")) {
HandlerList.unregisterAll();
}
return true;
}
@EventHandler
public void onRespawnPVPEVENT(PlayerRespawnEvent pvpevent) {
Player p = pvpevent.getPlayer();
double x = 22;
double y = 82;
double z = 22;
Location loc = new Location(Bukkit.getWorld("world"), x, y, z);
p.teleport(loc);
}
@EventHandler
public void sed(PlayerDeathEvent totevent) {
Player p1 = totevent.getEntity();
p1.sendMessage(ChatColor.GOLD + "[PvP Event] " + ChatColor.AQUA + "Du Bist Gestorben und somit raus");
}
}
答案 0 :(得分:1)
PlayerRespawnEvent
具有setRespawnLocation()
方法,该方法可让您更改播放器重生的位置。 PlayerRespawnEvent
的处理程序应如下所示:
@EventHandler
public void onRespawnPVPEVENT(PlayerRespawnEvent pvpevent) {
Player p = pvpevent.getPlayer();
double x = 22;
double y = 82;
double z = 22;
Location loc = new Location(Bukkit.getWorld("world"), x, y, z);
pvpevent.setRespawnLocation(loc);
}