Motd.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package com.gmail.nossr50.util;
  2. import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
  3. import com.gmail.nossr50.util.skills.PerksUtils;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.plugin.PluginDescriptionFile;
  6. import java.text.DecimalFormat;
  7. public final class Motd {
  8. public static final String PERK_PREFIX = pluginRef.getLocaleManager().getString("MOTD.PerksPrefix") + " ";
  9. private static final PluginDescriptionFile pluginDescription = pluginRef.getDescription();
  10. private Motd() {
  11. }
  12. public static void displayAll(Player player) {
  13. displayVersion(player, pluginDescription.getVersion());
  14. displayHardcoreSettings(player);
  15. displayXpPerks(player);
  16. displayCooldownPerks(player);
  17. displayActivationPerks(player);
  18. displayLuckyPerks(player);
  19. displayWebsite(player, pluginDescription.getWebsite());
  20. }
  21. /**
  22. * Display version info.
  23. *
  24. * @param player Target player
  25. * @param version Plugin version
  26. */
  27. public static void displayVersion(Player player, String version) {
  28. if (pluginRef.getPermissionTools().showversion(player)) {
  29. player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version.Overhaul", version));
  30. }
  31. }
  32. /**
  33. * Display Hardcore Mode settings.
  34. *
  35. * @param player Target player
  36. */
  37. public static void displayHardcoreSettings(Player player) {
  38. boolean deathStatLossEnabled = HardcoreManager.isStatLossEnabled();
  39. boolean vampirismEnabled = HardcoreManager.isVampirismEnabled();
  40. if (!deathStatLossEnabled && !vampirismEnabled) {
  41. return;
  42. }
  43. String statLossInfo = "";
  44. String vampirismInfo = "";
  45. String seperator = "";
  46. if (deathStatLossEnabled) {
  47. statLossInfo = pluginRef.getLocaleManager().getString("Hardcore.DeathStatLoss.Name");
  48. }
  49. if (vampirismEnabled) {
  50. vampirismInfo = pluginRef.getLocaleManager().getString("Hardcore.Vampirism.Name");
  51. }
  52. if (deathStatLossEnabled && vampirismEnabled) {
  53. seperator = " & ";
  54. }
  55. player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Hardcore.Enabled", statLossInfo + seperator + vampirismInfo));
  56. if (deathStatLossEnabled) {
  57. player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Hardcore.DeathStatLoss.Stats", pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getPenaltyPercentage()));
  58. }
  59. if (vampirismEnabled) {
  60. player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Hardcore.Vampirism.Stats", pluginRef.getConfigManager().getConfigHardcore().getVampirism().getPenaltyPercentage()));
  61. }
  62. }
  63. /**
  64. * Display XP perks.
  65. *
  66. * @param player Target player
  67. */
  68. public static void displayXpPerks(Player player) {
  69. for (PrimarySkillType skill : PrimarySkillType.values()) {
  70. // if (PerksUtils.handleXpPerks(player, 1, skill) > 1) {
  71. // player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.XP.Name"), pluginRef.getLocaleManager().getString("Perks.XP.Desc")));
  72. // return;
  73. // }
  74. }
  75. }
  76. /**
  77. * Display cooldown perks.
  78. *
  79. * @param player Target player
  80. */
  81. public static void displayCooldownPerks(Player player) {
  82. double cooldownReduction = 1 - (PerksUtils.handleCooldownPerks(player, 12) / 12.0);
  83. if (cooldownReduction > 0.0) {
  84. DecimalFormat percent = new DecimalFormat("##0.00%");
  85. player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Cooldowns.Name"), pluginRef.getLocaleManager().getString("Perks.Cooldowns.Desc", percent.format(cooldownReduction))));
  86. }
  87. }
  88. /**
  89. * Display activiation perks.
  90. *
  91. * @param player Target player
  92. */
  93. public static void displayActivationPerks(Player player) {
  94. int perkAmount = pluginRef.getSkillTools().getEnduranceLength(player);
  95. if (perkAmount > 0) {
  96. player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.ActivationTime.Name"), pluginRef.getLocaleManager().getString("Perks.ActivationTime.Desc", perkAmount)));
  97. }
  98. }
  99. /**
  100. * Display "lucky" perks.
  101. *
  102. * @param player Target player
  103. */
  104. public static void displayLuckyPerks(Player player) {
  105. for (PrimarySkillType skill : PrimarySkillType.values()) {
  106. if (pluginRef.getPermissionTools().lucky(player, skill)) {
  107. player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Lucky.Name"), pluginRef.getLocaleManager().getString("Perks.Lucky.Desc.Login")));
  108. return;
  109. }
  110. }
  111. }
  112. /**
  113. * Display website info.
  114. *
  115. * @param player Target player
  116. * @param website Plugin website
  117. */
  118. public static void displayWebsite(Player player, String website) {
  119. player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Website", website));
  120. }
  121. }