LibsDisguises/src/main/java/me/libraryaddict/disguise/commands/interactions/UndisguiseEntityInteraction.java

40 lines
1.4 KiB
Java
Raw Normal View History

package me.libraryaddict.disguise.commands.interactions;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
2020-06-27 11:01:58 +02:00
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsEntityInteract;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
/**
* Created by libraryaddict on 4/04/2020.
*/
public class UndisguiseEntityInteraction implements LibsEntityInteract {
@Override
public void onInteract(Player p, Entity entity) {
String entityName;
if (entity instanceof Player) {
entityName = entity.getName();
} else {
entityName = DisguiseType.getType(entity).toReadable();
}
if (DisguiseAPI.isDisguised(entity)) {
DisguiseAPI.undisguiseToAll(entity);
if (entity instanceof Player)
2020-06-27 11:01:58 +02:00
DisguiseUtilities.sendMessage(p, LibsMsg.LISTEN_UNDISG_PLAYER, entityName);
else
2020-06-27 11:01:58 +02:00
DisguiseUtilities.sendMessage(p, LibsMsg.LISTEN_UNDISG_ENT, entityName);
} else {
if (entity instanceof Player)
2020-06-27 11:01:58 +02:00
DisguiseUtilities.sendMessage(p, LibsMsg.LISTEN_UNDISG_PLAYER_FAIL, entityName);
else
2020-06-27 11:01:58 +02:00
DisguiseUtilities.sendMessage(p, LibsMsg.LISTEN_UNDISG_ENT_FAIL, entityName);
}
}
}