UltimateModeration/src/main/java/com/craftaro/ultimatemoderation/moderate/moderations/ReviveModeration.java

67 lines
2.1 KiB
Java
Raw Normal View History

2023-08-02 18:57:10 +02:00
package com.craftaro.ultimatemoderation.moderate.moderations;
2020-08-05 00:20:25 +02:00
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.core.utils.PlayerUtils;
2023-08-02 18:57:10 +02:00
import com.craftaro.ultimatemoderation.UltimateModeration;
import com.craftaro.ultimatemoderation.listeners.DeathListener;
import com.craftaro.ultimatemoderation.moderate.AbstractModeration;
import com.craftaro.ultimatemoderation.moderate.ModerationType;
2020-08-05 00:20:25 +02:00
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class ReviveModeration extends AbstractModeration {
private final UltimateModeration plugin;
2020-08-05 00:20:25 +02:00
public ReviveModeration(UltimateModeration plugin) {
super(plugin, true, true);
this.plugin = plugin;
2020-08-05 00:20:25 +02:00
registerCommand(plugin);
}
@Override
public ModerationType getType() {
return ModerationType.REVIVE;
}
@Override
public XMaterial getIcon() {
return XMaterial.POTION;
2020-08-05 00:20:25 +02:00
}
@Override
public String getProper() {
return "Revive";
}
@Override
public String getDescription() {
return "Allows you to revive a player.";
}
@Override
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
Player toModeratePlayer = (Player) toModerate;
List<ItemStack> drops = DeathListener.getLastDrop(toModeratePlayer);
if (drops == null) {
this.plugin.getLocale().getMessage("command.revive.noloot").sendPrefixedMessage(runner);
2020-08-05 00:20:25 +02:00
return false;
}
ItemStack[] dropArr = new ItemStack[drops.size()];
dropArr = drops.toArray(dropArr);
PlayerUtils.giveItem(toModeratePlayer, dropArr);
this.plugin.getLocale().getMessage("command.revive.revived").sendPrefixedMessage(toModeratePlayer);
this.plugin.getLocale().getMessage("command.revive.success")
2020-08-05 00:20:25 +02:00
.processPlaceholder("player", toModerate.getName()).sendPrefixedMessage(runner);
return true;
}
}