Q1: I make this autorespawn plugin but not working: PlayerListener: Code: package ro.MasT3r.EventListener; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand; import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand.EnumClientCommand; import ro.MasT3r.Auto.Main; public class PlayerListener implements Listener { public PlayerListener(Main plugin){ } @EventHandler public void onDeath(PlayerDeathEvent e) { final Player p =e.getEntity(); Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getInstace(), new Runnable() { @Override public void run() { @SuppressWarnings("unused") PacketPlayInClientCommand packet = new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN); ((CraftPlayer)p).getHandle().playerConnection.a(); } }, 1L); } } Main: Code: package ro.MasT3r.Auto; import org.bukkit.Bukkit; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin implements Listener{ public Main() { instance = this; } public static Main instance; public static Main getInstace() { return instance; } @Override public void onDisable(){ } @Override public void onEnable(){ Bukkit.getPluginManager().registerEvents(new Main(), this); } } plugin.yml: Code: main: ro.MasT3r.Auto.Main name: AutoRespawn version: 1.0.0 author: MasT3r Error: Code: [03:07:14 ERROR]: Error occurred while enabling AutoRespawn v1.0.0 (Is it up to date?) java.lang.IllegalArgumentException: Plugin already initialized! at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader .java:122) ~[spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[spigot .jar:git-Spigot-db6de12-18fbb24] at ro.MasT3r.Auto.Main.<init>(Main.java:9) ~[?:?] at ro.MasT3r.Auto.Main.onEnable(Main.java:22) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[s pigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader .java:340) [spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage r.java:405) [spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.jav a:357) [spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer. java:317) [spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:74 1) [spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot.jar:git-Spigot-db6d e12-18fbb24] at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java: 25) [spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:14 1) [spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServe r.java:641) [spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(Craf tServer.java:627) [spigot.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java: 412) [spigot.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:3 75) [spigot.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:6 54) [spigot.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java :557) [spigot.jar:git-Spigot-db6de12-18fbb24] at java.lang.Thread.run(Unknown Source) [?:1.8.0_66] Caused by: java.lang.IllegalStateException: Initial initialization at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader .java:125) ~[spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[spigot .jar:git-Spigot-db6de12-18fbb24] at ro.MasT3r.Auto.Main.<init>(Main.java:9) ~[?:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_66] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_66] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou rce) ~[?:1.8.0_66] at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_6 6] at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_66] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav a:76) ~[spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j ava:131) ~[spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager. java:329) ~[spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager .java:251) ~[spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.ja va:292) ~[spigot.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:73 9) ~[spigot.jar:git-Spigot-db6de12-18fbb24] ... 10 more Q2: How can i make this: When a player dies to show him a title who killed him,but it did not kill nobody show anything.Thanks.
Q1: Read this:https://bukkit.org/threads/how-to-r...ubleshoot-your-own-plugins-by-yourself.32457/ Q2 This make no sense. What did you mean?
I want to make like this: Not show this: http://imgur.com/rfHbfcJ Can you give me code pls? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Use EntityDamageByEntityEvent rather than PlayerDeathEvent. Check if the damage would cause the player to die, then teleport them/do something and set their health back to full.
I understand some things in java, but do not know where to put them, you say this: " Use EntityDamageByEntityEvent rather than PlayerDeathEvent. Check if the damage Would cause the player to die, the then teleport Them / Do Something and Their set back to full health. " But I do not know where to put them.Are tutorials useful?If so give me some tutorials that can help me.Help me please?
@masu7 It is recommended to fully learn java. But you replace your death even with the EntityDamageByEntity event.
There is (hopefully) nobody who will give you just code. You have to do your own research if you really want to learn java/Bukkit API. There are many useful tutorials out there, just use some google.
Ah unfortunately people give out code though without the slightest attempt to explain it. That is what lead to the creation of this thread. @masu7, please read it as well.
I make this: Code: package ro.MasT3r.Respawn; import org.bukkit.Sound; 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 { public void onEnable() { getServer().getPluginManager().registerEvents(this, this); } public void onDisable() { saveConfig(); } @EventHandler public void onDeath(PlayerDeathEvent e) { Player p = e.getEntity(); if ((p instanceof Player)) { p.setHealth(20.0D); p.setFoodLevel(20); p.playSound(p.getLocation(), Sound.BLAZE_DEATH, 1.0F, 0.0F); try { Utile.trimiteTitlu(p, Integer.valueOf(20), Integer.valueOf(100), Integer.valueOf(20), "§aAi fost ucis", "de §b " + p.getKiller().getName()); } catch (Exception e1) { Utile.trimiteTitlu(p, Integer.valueOf(20), Integer.valueOf(100), Integer.valueOf(20), "§aAi murit", ""); } } } } How can I do to send them to spawn after die?
Honestly just use EntityDamageEvent and check if: The damaged entity is the entity you would like to teleport (in your case Player) If Health - Damage >= 0 <--- After this set health to 20.0 food to 20 and teleport them
@webbhead That is a nice solution ut it wont trigger the PlayerDeathEvent for other plugins on the server, so that has to be handled as well. The PlayerDeathEvent has to be called manually.
@HoeMC No, However there is a problem with not calling it, because other plugins that expect it to fire will not know it occured. For example, lets asume that i have a server with a minigame and this auto-respawn plugin on. The minigame expects the player to die to reset their stats in the game. So before they die, they are teleported back in spawn because of the auto-respawn plugin. Now, the minigame plugin hasn't caught the PlayerDeathEvent it was expecting, so it hasnt reset the stats of the player. That is now broken :/
Oh. Yeah I know. I thought your answer implied there was a problem with calling the event. My bad, sorry.
ähhmm if you use spigot you can use the function in the PlayerDeathEvent Player player = e.getPlayer(); player.spigot.respawn;
@HoeMC Ah sorry i was quite unclear. -I should sleep more...- @InstanceofDeath εhhmm generally speaking, in bukkit plugin development forums, we dont really promote spigot.
@masu7 I asume you mean you want to drop the items of the player on death. Loop through the contents of their inventory and drop each of them at the location of death, don't forget armor contents.