2012-05-17 12:25:02 +02:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 21:59:39 +02:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2012-05-17 12:25:02 +02:00
|
|
|
import com.earth2me.essentials.User;
|
2024-02-03 21:38:14 +01:00
|
|
|
import com.earth2me.essentials.utils.CommonPlaceholders;
|
2020-08-11 20:09:22 +02:00
|
|
|
import net.ess3.api.events.VanishStatusChangeEvent;
|
2012-05-17 12:25:02 +02:00
|
|
|
import org.bukkit.Server;
|
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
public class Commandvanish extends EssentialsToggleCommand {
|
|
|
|
public Commandvanish() {
|
|
|
|
super("vanish", "essentials.vanish.others");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
toggleOtherPlayers(server, sender, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
2016-03-03 20:54:18 +01:00
|
|
|
handleToggleWithArgs(server, user, args);
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-20 17:37:16 +01:00
|
|
|
protected void togglePlayer(final CommandSource sender, final User user, Boolean enabled) {
|
2015-04-15 06:06:16 +02:00
|
|
|
if (enabled == null) {
|
|
|
|
enabled = !user.isVanished();
|
|
|
|
}
|
2020-10-03 19:46:05 +02:00
|
|
|
|
|
|
|
final VanishStatusChangeEvent vanishEvent = new VanishStatusChangeEvent(sender.isPlayer() ? ess.getUser(sender.getPlayer()) : null, user, enabled);
|
2016-07-10 17:09:53 +02:00
|
|
|
ess.getServer().getPluginManager().callEvent(vanishEvent);
|
|
|
|
if (vanishEvent.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
user.setVanished(enabled);
|
2024-02-10 05:01:20 +01:00
|
|
|
user.sendTl("vanish", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
2015-04-15 06:06:16 +02:00
|
|
|
|
2015-06-03 22:11:56 +02:00
|
|
|
if (enabled) {
|
2024-02-03 21:38:14 +01:00
|
|
|
user.sendTl("vanished");
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {
|
2024-02-10 05:01:20 +01:00
|
|
|
sender.sendTl("vanish", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-10 17:09:53 +02:00
|
|
|
}
|