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;
}
}
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);
}
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));
}
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);
}
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);
}
Aggregations