2011-03-19 23:39:51 +01:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
|
|
|
import com.earth2me.essentials.User;
|
2011-11-18 18:42:26 +01:00
|
|
|
import org.bukkit.Server;
|
2012-05-06 17:09:47 +02:00
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
2011-03-19 23:39:51 +01:00
|
|
|
|
2020-07-01 23:04:46 +02:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
public class Commandsuicide extends EssentialsCommand {
|
|
|
|
public Commandsuicide() {
|
|
|
|
super("suicide");
|
|
|
|
}
|
2011-03-19 23:39:51 +01:00
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
@Override
|
|
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
2020-10-03 19:46:05 +02:00
|
|
|
final EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, Float.MAX_VALUE);
|
2015-04-15 06:06:16 +02:00
|
|
|
server.getPluginManager().callEvent(ede);
|
2015-09-28 03:45:25 +02:00
|
|
|
ede.getEntity().setLastDamageCause(ede);
|
2020-07-01 23:04:46 +02:00
|
|
|
user.getBase().setHealth(0);
|
2024-02-03 21:38:14 +01:00
|
|
|
user.sendTl("suicideMessage");
|
2015-04-15 06:06:16 +02:00
|
|
|
user.setDisplayNick();
|
2024-02-10 05:01:20 +01:00
|
|
|
ess.broadcastTl(user, "suicideSuccess", user.getDisplayName());
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
2020-07-01 23:04:46 +02:00
|
|
|
|
|
|
|
@Override
|
2020-10-03 19:46:05 +02:00
|
|
|
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
2020-07-01 23:04:46 +02:00
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2011-03-19 23:39:51 +01:00
|
|
|
}
|