Search in sources :

Example 6 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class CommandTogglePVP method commandCheck.

private boolean commandCheck(CommandSender sender, String[] args) {
    if (args.length < 1) {
        return false;
    }
    Player target = findTarget(sender, args[0]);
    if (target == null) {
        return true;
    }
    String targetName = target.getName();
    LanguageManager languageManager = getLanguageManager();
    NewbieHelperExpansion expansion = getExpansion();
    ProtectionManager protectionManager = expansion.getProtectionManager();
    PVPManager pvpManager = expansion.getPVPManager();
    boolean targetProtected = protectionManager.isProtected(target);
    boolean targetPvpStatus = !pvpManager.isDisabled(target);
    String placeholderPath0 = ("placeholder.toggle.");
    String placeholderPath1 = (placeholderPath0 + (targetProtected ? "enabled" : "disabled"));
    String placeholderPath2 = (placeholderPath0 + (targetPvpStatus ? "enabled" : "disabled"));
    String protectedString = languageManager.getMessage(sender, placeholderPath1, null, true);
    String pvpStatusString = languageManager.getMessage(sender, placeholderPath2, null, true);
    Replacer replacer = message -> message.replace("{target}", targetName).replace("{protected}", protectedString).replace("{pvp}", pvpStatusString);
    sendMessageWithPrefix(sender, "expansion.newbie-helper.check-format", replacer, true);
    return true;
}
Also used : Arrays(java.util.Arrays) CommandSender(org.bukkit.command.CommandSender) CombatLogCommand(com.github.sirblobman.combatlogx.api.command.CombatLogCommand) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) Set(java.util.Set) HashMap(java.util.HashMap) UUID(java.util.UUID) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) Replacer(com.github.sirblobman.api.language.Replacer) Locale(java.util.Locale) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Map(java.util.Map) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ProtectionManager(combatlogx.expansion.newbie.helper.manager.ProtectionManager) Collections(java.util.Collections) Player(org.bukkit.entity.Player) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) ProtectionManager(combatlogx.expansion.newbie.helper.manager.ProtectionManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager) Replacer(com.github.sirblobman.api.language.Replacer)

Example 7 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class CustomScoreboard method getLines.

private List<String> getLines() {
    Player player = getPlayer();
    LanguageManager languageManager = getLanguageManager();
    String lines = languageManager.getMessage(player, "expansion.scoreboard.lines", null, true);
    String[] split = lines.split("\n");
    List<String> lineList = new ArrayList<>();
    for (String line : split) {
        String replaced = replacePlaceholders(line);
        lineList.add(replaced);
    }
    return lineList;
}
Also used : Player(org.bukkit.entity.Player) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ArrayList(java.util.ArrayList)

Example 8 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class CustomScoreboard method createObjective.

private void createObjective() {
    Player player = getPlayer();
    LanguageManager languageManager = getLanguageManager();
    String title = languageManager.getMessage(player, "expansion.scoreboard.title", null, true);
    String titleReplaced = replacePlaceholders(title);
    ICombatLogX plugin = this.expansion.getPlugin();
    MultiVersionHandler multiVersionHandler = plugin.getMultiVersionHandler();
    ScoreboardHandler scoreboardHandler = multiVersionHandler.getScoreboardHandler();
    Scoreboard scoreboard = getScoreboard();
    this.objective = scoreboardHandler.createObjective(scoreboard, "combatlogx", "dummy", titleReplaced);
    this.objective.setDisplaySlot(DisplaySlot.SIDEBAR);
}
Also used : Player(org.bukkit.entity.Player) MultiVersionHandler(com.github.sirblobman.api.nms.MultiVersionHandler) ScoreboardHandler(com.github.sirblobman.api.nms.scoreboard.ScoreboardHandler) Scoreboard(org.bukkit.scoreboard.Scoreboard) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 9 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class CombatPlugin method broadcastEnableMessage.

private void broadcastEnableMessage() {
    ConfigurationManager configurationManager = getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    if (!configuration.getBoolean("broadcast.on-enable")) {
        return;
    }
    LanguageManager languageManager = getLanguageManager();
    languageManager.broadcastMessage("broadcast.on-enable", null, true);
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 10 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class CombatPlugin method onLoad.

@Override
public void onLoad() {
    ConfigurationChecker configurationChecker = new ConfigurationChecker(this);
    configurationChecker.checkVersion();
    ConfigurationManager configurationManager = getConfigurationManager();
    configurationManager.saveDefault("config.yml");
    configurationManager.saveDefault("commands.yml");
    configurationManager.saveDefault("punish.yml");
    LanguageManager languageManager = getLanguageManager();
    languageManager.saveDefaultLanguages();
    languageManager.reloadLanguages();
    ExpansionManager expansionManager = getExpansionManager();
    expansionManager.loadExpansions();
    broadcastLoadMessage();
}
Also used : ConfigurationChecker(com.github.sirblobman.combatlogx.configuration.ConfigurationChecker) ExpansionManager(com.github.sirblobman.combatlogx.api.expansion.ExpansionManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

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