use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.
the class CommandCombatTimer method checkSelf.
private void checkSelf(Player player) {
ICombatLogX plugin = getCombatLogX();
ICombatManager combatManager = plugin.getCombatManager();
LanguageManager languageManager = getLanguageManager();
if (combatManager.isInCombat(player)) {
double timeLeftMillis = combatManager.getTimerLeftMillis(player);
double timeLeftSeconds = (timeLeftMillis / 1_000.0D);
String decimalFormatString = languageManager.getMessage(player, "decimal-format", null, false);
DecimalFormat decimalFormat = new DecimalFormat(decimalFormatString);
String timeLeftString = decimalFormat.format(timeLeftSeconds);
Replacer replacer = message -> message.replace("{time_left}", timeLeftString);
sendMessageWithPrefix(player, "command.combat-timer.time-left-self", replacer, true);
return;
}
sendMessageWithPrefix(player, "error.self-not-in-combat", null, true);
}
use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.
the class ListenerJoin method beforeLogin.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void beforeLogin(AsyncPlayerPreLoginEvent e) {
printDebug("Detected AsyncPlayerPreLoginEvent...");
UUID uuid = e.getUniqueId();
printDebug("Checking if player with uuid=" + uuid + " can login...");
if (shouldAllowLogin(uuid)) {
printDebug("Login allowed, ignoring event.");
return;
}
CommandSender console = Bukkit.getConsoleSender();
LanguageManager languageManager = getLanguageManager();
String npcMessage = languageManager.getMessage(console, "expansion.citizens-compatibility.prevent-join", null, true);
e.disallow(Result.KICK_OTHER, npcMessage);
}
use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.
the class PlaceholderHelper method getStatus.
public static String getStatus(ICombatLogX plugin, Player player) {
ICombatManager combatManager = plugin.getCombatManager();
LanguageManager languageManager = plugin.getLanguageManager();
boolean inCombat = combatManager.isInCombat(player);
String key = ("placeholder.status." + (inCombat ? "fighting" : "idle"));
return languageManager.getMessage(player, key, null, true);
}
use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.
the class ListenerEssentials method onTeleportRequest.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onTeleportRequest(TPARequestEvent e) {
if (isTeleportRequestEnabled())
return;
ICombatManager combatManager = getCombatManager();
LanguageManager languageManager = getLanguageManager();
CommandSource requester = e.getRequester();
Player player = requester.getPlayer();
if (player == null)
return;
if (combatManager.isInCombat(player)) {
sendMessageWithPrefix(player, "expansion.essentials-compatibility.prevent-teleport-request-self", null, true);
e.setCancelled(true);
return;
}
IUser targetUser = e.getTarget();
Player target = targetUser.getBase();
if (target == null)
return;
if (combatManager.isInCombat(target)) {
sendMessageWithPrefix(player, "expansion.essentials-compatibility.prevent-teleport-request-other", null, true);
e.setCancelled(true);
// return;
}
}
use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.
the class CombatLogPlayerCommand 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));
}
Aggregations