Search in sources :

Example 61 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class CommandCombatLogXUntag method execute.

@Override
protected boolean execute(CommandSender sender, String[] args) {
    if (!checkPermission(sender, "combatlogx.command.combatlogx.untag", true)) {
        return true;
    }
    if (args.length < 1) {
        return false;
    }
    Player target = findTarget(sender, args[0]);
    if (target == null) {
        return true;
    }
    String targetName = target.getName();
    Replacer replacer = message -> message.replace("{target}", targetName);
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = plugin.getCombatManager();
    if (!combatManager.isInCombat(target)) {
        sendMessageWithPrefix(sender, "error.target-not-in-combat", replacer, true);
        return true;
    }
    combatManager.untag(target, UntagReason.EXPIRE);
    sendMessageWithPrefix(sender, "command.combatlogx.untag-player", replacer, true);
    return true;
}
Also used : UntagReason(com.github.sirblobman.combatlogx.api.object.UntagReason) List(java.util.List) CommandSender(org.bukkit.command.CommandSender) CombatLogCommand(com.github.sirblobman.combatlogx.api.command.CombatLogCommand) Replacer(com.github.sirblobman.api.language.Replacer) Set(java.util.Set) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Collections(java.util.Collections) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Replacer(com.github.sirblobman.api.language.Replacer) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 62 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class CommandCombatLogXVersion method getPluginVersion.

private String getPluginVersion() {
    ICombatLogX combatLogX = getCombatLogX();
    JavaPlugin plugin = combatLogX.getPlugin();
    PluginDescriptionFile information = plugin.getDescription();
    return information.getVersion();
}
Also used : JavaPlugin(org.bukkit.plugin.java.JavaPlugin) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 63 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class CommandCombatLogXVersion method addDependencyInformation.

private void addDependencyInformation(List<String> messageList) {
    ICombatLogX combatLogX = getCombatLogX();
    JavaPlugin plugin = combatLogX.getPlugin();
    PluginDescriptionFile information = plugin.getDescription();
    messageList.add("&f&lDependency Information:");
    List<String> loadBeforeList = information.getLoadBefore();
    List<String> dependList = information.getDepend();
    List<String> softDependList = information.getSoftDepend();
    List<String> fullDependencyList = new ArrayList<>(loadBeforeList);
    fullDependencyList.addAll(dependList);
    fullDependencyList.addAll(softDependList);
    PluginManager pluginManager = Bukkit.getPluginManager();
    for (String dependencyName : fullDependencyList) {
        Plugin dependency = pluginManager.getPlugin(dependencyName);
        if (dependency == null) {
            continue;
        }
        PluginDescriptionFile dependencyInformation = dependency.getDescription();
        String dependencyFullName = dependencyInformation.getFullName();
        messageList.add("&f&l - &7" + dependencyFullName);
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) ArrayList(java.util.ArrayList) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Plugin(org.bukkit.plugin.Plugin) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) CorePlugin(com.github.sirblobman.api.core.CorePlugin)

Example 64 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class CommandCombatLogXVersion method getSpigotVersion.

private String getSpigotVersion() {
    ICombatLogX combatLogX = getCombatLogX();
    JavaPlugin plugin = combatLogX.getPlugin();
    CorePlugin corePlugin = JavaPlugin.getPlugin(CorePlugin.class);
    UpdateManager updateManager = corePlugin.getUpdateManager();
    String spigotVersion = updateManager.getSpigotVersion(plugin);
    if (spigotVersion == null) {
        return "Not Available";
    }
    return spigotVersion;
}
Also used : JavaPlugin(org.bukkit.plugin.java.JavaPlugin) UpdateManager(com.github.sirblobman.api.update.UpdateManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) CorePlugin(com.github.sirblobman.api.core.CorePlugin)

Example 65 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class ListenerConfiguration method runTagCommands.

private void runTagCommands(Player player, LivingEntity enemy) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("commands.yml");
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = getCombatManager();
    List<String> tagCommandList = configuration.getStringList("tag-command-list");
    if (tagCommandList.isEmpty())
        return;
    for (String tagCommand : tagCommandList) {
        String replacedCommand = combatManager.replaceVariables(player, enemy, tagCommand);
        if (replacedCommand.startsWith("[PLAYER]")) {
            String command = replacedCommand.substring("[PLAYER]".length());
            CommandHelper.runAsPlayer(plugin, player, command);
            continue;
        }
        if (replacedCommand.startsWith("[OP]")) {
            String command = replacedCommand.substring("[OP]".length());
            CommandHelper.runAsOperator(plugin, player, command);
            continue;
        }
        CommandHelper.runAsConsole(plugin, replacedCommand);
    }
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Aggregations

ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)96 ExpansionManager (com.github.sirblobman.combatlogx.api.expansion.ExpansionManager)24 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)19 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)19 Player (org.bukkit.entity.Player)18 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)14 LivingEntity (org.bukkit.entity.LivingEntity)13 LanguageManager (com.github.sirblobman.api.language.LanguageManager)12 Logger (java.util.logging.Logger)11 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)10 MultiVersionHandler (com.github.sirblobman.api.nms.MultiVersionHandler)9 PlayerDataManager (com.github.sirblobman.api.configuration.PlayerDataManager)8 Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)8 List (java.util.List)8 Replacer (com.github.sirblobman.api.language.Replacer)6 EntityHandler (com.github.sirblobman.api.nms.EntityHandler)5 State (com.github.sirblobman.combatlogx.api.expansion.Expansion.State)5 Collections (java.util.Collections)5 EventHandler (org.bukkit.event.EventHandler)5 NewbieHelperExpansion (combatlogx.expansion.newbie.helper.NewbieHelperExpansion)4