Search in sources :

Example 51 with ICombatLogX

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

the class RegionHandler method preventEntry.

public final void preventEntry(Cancellable e, Player player, Location fromLocation, Location toLocation) {
    if (player == null) {
        return;
    }
    ICombatLogX plugin = this.expansion.getPlugin();
    JavaPlugin javaPlugin = plugin.getPlugin();
    ICombatManager combatManager = plugin.getCombatManager();
    if (!combatManager.isInCombat(player)) {
        return;
    }
    LivingEntity enemy = combatManager.getEnemy(player);
    sendEntryDeniedMessage(player, enemy);
    NoEntryMode noEntryMode = getNoEntryMode();
    switch(noEntryMode) {
        case KILL_PLAYER:
            player.setHealth(0.0D);
            break;
        case TELEPORT_TO_ENEMY:
            if (enemy != null) {
                player.teleport(enemy);
                break;
            }
        case CANCEL_EVENT:
            e.setCancelled(true);
            break;
        case KNOCKBACK_PLAYER:
            if (player.isInsideVehicle()) {
                if (!player.leaveVehicle()) {
                    e.setCancelled(true);
                    break;
                }
            }
            Runnable task = () -> knockbackPlayer(player, fromLocation, toLocation);
            BukkitScheduler scheduler = Bukkit.getScheduler();
            scheduler.runTaskLater(javaPlugin, task, 1L);
            break;
        case DISABLED:
        case VULNERABLE:
        default:
            break;
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) NoEntryMode(com.github.sirblobman.combatlogx.api.object.NoEntryMode) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) BukkitScheduler(org.bukkit.scheduler.BukkitScheduler) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 52 with ICombatLogX

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

the class CombatListener method register.

public void register() {
    ICombatLogX combatLogX = getCombatLogX();
    JavaPlugin plugin = combatLogX.getPlugin();
    PluginManager pluginManager = Bukkit.getPluginManager();
    pluginManager.registerEvents(this, plugin);
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 53 with ICombatLogX

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

the class CombatListener method getMessageWithPrefix.

protected final String getMessageWithPrefix(@Nullable CommandSender sender, @NotNull String key, @Nullable Replacer replacer, boolean color) {
    ICombatLogX plugin = getCombatLogX();
    LanguageManager languageManager = plugin.getLanguageManager();
    String message = languageManager.getMessage(sender, key, replacer, color);
    if (message.isEmpty())
        return "";
    String prefix = languageManager.getMessage(sender, "prefix", null, true);
    return (prefix.isEmpty() ? message : String.format(Locale.US, "%s %s", prefix, message));
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 54 with ICombatLogX

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

the class Expansion method registerListener.

protected final void registerListener(Listener listener) {
    ICombatLogX plugin = getPlugin();
    JavaPlugin javaPlugin = plugin.getPlugin();
    PluginManager pluginManager = Bukkit.getPluginManager();
    pluginManager.registerEvents(listener, javaPlugin);
    this.listenerList.add(listener);
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 55 with ICombatLogX

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

the class Expansion method selfDisable.

protected final void selfDisable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();
    expansionManager.disableExpansion(this);
}
Also used : ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

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