123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- package com.gmail.nossr50.util;
- import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
- import com.gmail.nossr50.util.skills.PerksUtils;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.PluginDescriptionFile;
- import java.text.DecimalFormat;
- public final class Motd {
- public static final String PERK_PREFIX = pluginRef.getLocaleManager().getString("MOTD.PerksPrefix") + " ";
- private static final PluginDescriptionFile pluginDescription = pluginRef.getDescription();
- private Motd() {
- }
- public static void displayAll(Player player) {
- displayVersion(player, pluginDescription.getVersion());
- displayHardcoreSettings(player);
- displayXpPerks(player);
- displayCooldownPerks(player);
- displayActivationPerks(player);
- displayLuckyPerks(player);
- displayWebsite(player, pluginDescription.getWebsite());
- }
- /**
- * Display version info.
- *
- * @param player Target player
- * @param version Plugin version
- */
- public static void displayVersion(Player player, String version) {
- if (pluginRef.getPermissionTools().showversion(player)) {
- player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version.Overhaul", version));
- }
- }
- /**
- * Display Hardcore Mode settings.
- *
- * @param player Target player
- */
- public static void displayHardcoreSettings(Player player) {
- boolean deathStatLossEnabled = HardcoreManager.isStatLossEnabled();
- boolean vampirismEnabled = HardcoreManager.isVampirismEnabled();
- if (!deathStatLossEnabled && !vampirismEnabled) {
- return;
- }
- String statLossInfo = "";
- String vampirismInfo = "";
- String seperator = "";
- if (deathStatLossEnabled) {
- statLossInfo = pluginRef.getLocaleManager().getString("Hardcore.DeathStatLoss.Name");
- }
- if (vampirismEnabled) {
- vampirismInfo = pluginRef.getLocaleManager().getString("Hardcore.Vampirism.Name");
- }
- if (deathStatLossEnabled && vampirismEnabled) {
- seperator = " & ";
- }
- player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Hardcore.Enabled", statLossInfo + seperator + vampirismInfo));
- if (deathStatLossEnabled) {
- player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Hardcore.DeathStatLoss.Stats", pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getPenaltyPercentage()));
- }
- if (vampirismEnabled) {
- player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Hardcore.Vampirism.Stats", pluginRef.getConfigManager().getConfigHardcore().getVampirism().getPenaltyPercentage()));
- }
- }
- /**
- * Display XP perks.
- *
- * @param player Target player
- */
- public static void displayXpPerks(Player player) {
- for (PrimarySkillType skill : PrimarySkillType.values()) {
- // if (PerksUtils.handleXpPerks(player, 1, skill) > 1) {
- // player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.XP.Name"), pluginRef.getLocaleManager().getString("Perks.XP.Desc")));
- // return;
- // }
- }
- }
- /**
- * Display cooldown perks.
- *
- * @param player Target player
- */
- public static void displayCooldownPerks(Player player) {
- double cooldownReduction = 1 - (PerksUtils.handleCooldownPerks(player, 12) / 12.0);
- if (cooldownReduction > 0.0) {
- DecimalFormat percent = new DecimalFormat("##0.00%");
- player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Cooldowns.Name"), pluginRef.getLocaleManager().getString("Perks.Cooldowns.Desc", percent.format(cooldownReduction))));
- }
- }
- /**
- * Display activiation perks.
- *
- * @param player Target player
- */
- public static void displayActivationPerks(Player player) {
- int perkAmount = pluginRef.getSkillTools().getEnduranceLength(player);
- if (perkAmount > 0) {
- player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.ActivationTime.Name"), pluginRef.getLocaleManager().getString("Perks.ActivationTime.Desc", perkAmount)));
- }
- }
- /**
- * Display "lucky" perks.
- *
- * @param player Target player
- */
- public static void displayLuckyPerks(Player player) {
- for (PrimarySkillType skill : PrimarySkillType.values()) {
- if (pluginRef.getPermissionTools().lucky(player, skill)) {
- player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Lucky.Name"), pluginRef.getLocaleManager().getString("Perks.Lucky.Desc.Login")));
- return;
- }
- }
- }
- /**
- * Display website info.
- *
- * @param player Target player
- * @param website Plugin website
- */
- public static void displayWebsite(Player player, String website) {
- player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Website", website));
- }
- }
|