Search in sources :

Example 11 with LanguageManager

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);
}
Also used : List(java.util.List) Replacer(com.github.sirblobman.api.language.Replacer) DecimalFormat(java.text.DecimalFormat) LanguageManager(com.github.sirblobman.api.language.LanguageManager) Set(java.util.Set) CombatLogPlayerCommand(com.github.sirblobman.combatlogx.api.command.CombatLogPlayerCommand) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Collections(java.util.Collections) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) DecimalFormat(java.text.DecimalFormat) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Replacer(com.github.sirblobman.api.language.Replacer)

Example 12 with LanguageManager

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);
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) EventHandler(org.bukkit.event.EventHandler)

Example 13 with LanguageManager

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);
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager)

Example 14 with LanguageManager

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;
    }
}
Also used : Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager) IUser(net.ess3.api.IUser) CommandSource(com.earth2me.essentials.CommandSource) EventHandler(org.bukkit.event.EventHandler)

Example 15 with LanguageManager

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));
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Aggregations

LanguageManager (com.github.sirblobman.api.language.LanguageManager)36 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)12 Player (org.bukkit.entity.Player)12 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)9 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)9 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)7 Replacer (com.github.sirblobman.api.language.Replacer)6 NewbieHelperExpansion (combatlogx.expansion.newbie.helper.NewbieHelperExpansion)6 PVPManager (combatlogx.expansion.newbie.helper.manager.PVPManager)6 Collections (java.util.Collections)6 List (java.util.List)6 CommandSender (org.bukkit.command.CommandSender)6 Set (java.util.Set)5 MultiVersionHandler (com.github.sirblobman.api.nms.MultiVersionHandler)4 ProtectionManager (combatlogx.expansion.newbie.helper.manager.ProtectionManager)4 DecimalFormat (java.text.DecimalFormat)4 ArrayList (java.util.ArrayList)4 Arrays (java.util.Arrays)4 Locale (java.util.Locale)4 UUID (java.util.UUID)4