use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class PlaceholderHelper method getInCombat.
public static String getInCombat(ICombatLogX plugin, Player player) {
ICombatManager combatManager = plugin.getCombatManager();
LanguageManager languageManager = plugin.getLanguageManager();
boolean inCombat = combatManager.isInCombat(player);
String key = ("placeholder.status." + (inCombat ? "in-combat" : "not-in-combat"));
return languageManager.getMessage(player, key, null, true);
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class PlaceholderHelper method getEnemyName.
public static String getEnemyName(ICombatLogX plugin, Player player) {
ICombatManager combatManager = plugin.getCombatManager();
LivingEntity enemy = combatManager.getEnemy(player);
if (enemy == null)
return getUnknownEnemy(plugin, player);
MultiVersionHandler multiVersionHandler = plugin.getMultiVersionHandler();
EntityHandler entityHandler = multiVersionHandler.getEntityHandler();
return entityHandler.getName(enemy);
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ActionBarUpdater method getBars.
private String getBars(Player player, long timeLeftMillis) {
ConfigurationManager configurationManager = this.expansion.getConfigurationManager();
YamlConfiguration configuration = configurationManager.get("config.yml");
int scale = configuration.getInt("scale");
String leftColorString = configuration.getString("left-color", "GREEN");
String leftSymbol = configuration.getString("left-symbol", "|");
String rightColorString = configuration.getString("right-color", "RED");
String rightSymbol = configuration.getString("right-symbol", "|");
ChatColor leftColor = getChatColor(leftColorString);
ChatColor rightColor = getChatColor(rightColorString);
ICombatLogX plugin = getCombatLogX();
ICombatManager combatManager = plugin.getCombatManager();
double timerMaxMillis = (combatManager.getMaxTimerSeconds(player) * 1_000L);
double progressPercent = ((double) timeLeftMillis / timerMaxMillis);
long leftBarsCount = Math.round(scale * progressPercent);
long rightBarsCount = (scale - leftBarsCount);
StringBuilder builder = new StringBuilder();
builder.append(leftColor);
for (long i = 0; i < leftBarsCount; i++) {
builder.append(leftSymbol);
}
builder.append(rightColor);
for (long i = 0; i < rightBarsCount; i++) {
builder.append(rightSymbol);
}
String barsString = builder.toString();
return MessageUtility.color(barsString);
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager 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.manager.ICombatManager in project CombatLogX by SirBlobman.
the class CommandCombatLogXTag method execute.
@Override
protected boolean execute(CommandSender sender, String[] args) {
if (!checkPermission(sender, "combatlogx.command.combatlogx.tag", 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();
boolean successfulTag;
if (args.length < 2) {
successfulTag = combatManager.tag(target, null, TagType.UNKNOWN, TagReason.UNKNOWN);
} else {
BigInteger bigSeconds = parseInteger(sender, args[0]);
if (bigSeconds == null) {
return true;
}
long seconds = bigSeconds.longValue();
long milliseconds = TimeUnit.SECONDS.toMillis(seconds);
long systemMillis = System.currentTimeMillis();
long combatEndTime = (systemMillis + milliseconds);
successfulTag = combatManager.tag(target, null, TagType.UNKNOWN, TagReason.UNKNOWN, combatEndTime);
}
String messagePath = ("command.combatlogx." + (successfulTag ? "tag-player" : "tag-failure"));
sendMessageWithPrefix(sender, messagePath, replacer, true);
return true;
}
Aggregations