Static Abuse Removal - Motd ( now MessageOfTheDayUtils )

This commit is contained in:
nossr50 2019-09-24 14:01:26 -07:00
parent 2735cb1666
commit ec4fbe678e
3 changed files with 28 additions and 14 deletions

View File

@ -19,7 +19,6 @@ import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.HardcoreManager; import com.gmail.nossr50.util.HardcoreManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Motd;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -517,7 +516,7 @@ public class PlayerListener implements Listener {
new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 60); new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 60);
if (pluginRef.getConfigManager().getConfigMOTD().isEnableMOTD()) { if (pluginRef.getConfigManager().getConfigMOTD().isEnableMOTD()) {
Motd.displayAll(player); pluginRef.getMessageOfTheDayUtils().displayAll(player);
} }
if (pluginRef.isXPEventEnabled()) { if (pluginRef.isXPEventEnabled()) {

View File

@ -99,6 +99,7 @@ public class mcMMO extends JavaPlugin {
private ItemTools itemTools; private ItemTools itemTools;
private PermissionTools permissionTools; private PermissionTools permissionTools;
private WorldGuardUtils worldGuardUtils; private WorldGuardUtils worldGuardUtils;
private MessageOfTheDayUtils messageOfTheDayUtils;
private ZipLibrary zipLibrary; private ZipLibrary zipLibrary;
/* Never-Ending tasks */ /* Never-Ending tasks */
@ -277,6 +278,9 @@ public class mcMMO extends JavaPlugin {
//Init World Guard Utils (Not sure about the order of this one, might need to be loaded earlier) //Init World Guard Utils (Not sure about the order of this one, might need to be loaded earlier)
worldGuardUtils = new WorldGuardUtils(this); worldGuardUtils = new WorldGuardUtils(this);
//Init MOTD Utils
messageOfTheDayUtils = new MessageOfTheDayUtils(this);
} }
@Override @Override
@ -809,4 +813,10 @@ public class mcMMO extends JavaPlugin {
public WorldGuardUtils getWorldGuardUtils() { public WorldGuardUtils getWorldGuardUtils() {
return worldGuardUtils; return worldGuardUtils;
} }
public MessageOfTheDayUtils getMessageOfTheDayUtils() {
return messageOfTheDayUtils;
}
} }

View File

@ -1,20 +1,25 @@
package com.gmail.nossr50.util; package com.gmail.nossr50.util;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import java.text.DecimalFormat; import java.text.DecimalFormat;
public final class Motd { public final class MessageOfTheDayUtils {
public static final String PERK_PREFIX = pluginRef.getLocaleManager().getString("MOTD.PerksPrefix") + " "; private final mcMMO pluginRef;
private static final PluginDescriptionFile pluginDescription = pluginRef.getDescription(); public final String PERK_PREFIX;
private final PluginDescriptionFile pluginDescription;
private Motd() { public MessageOfTheDayUtils(mcMMO pluginRef) {
this.pluginRef = pluginRef;
PERK_PREFIX = pluginRef.getLocaleManager().getString("MOTD.PerksPrefix") + " ";
pluginDescription = pluginRef.getDescription();
} }
public static void displayAll(Player player) { public void displayAll(Player player) {
displayVersion(player, pluginDescription.getVersion()); displayVersion(player, pluginDescription.getVersion());
displayHardcoreSettings(player); displayHardcoreSettings(player);
displayXpPerks(player); displayXpPerks(player);
@ -30,7 +35,7 @@ public final class Motd {
* @param player Target player * @param player Target player
* @param version Plugin version * @param version Plugin version
*/ */
public static void displayVersion(Player player, String version) { public void displayVersion(Player player, String version) {
if (pluginRef.getPermissionTools().showversion(player)) { if (pluginRef.getPermissionTools().showversion(player)) {
player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version.Overhaul", version)); player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version.Overhaul", version));
} }
@ -41,7 +46,7 @@ public final class Motd {
* *
* @param player Target player * @param player Target player
*/ */
public static void displayHardcoreSettings(Player player) { public void displayHardcoreSettings(Player player) {
boolean deathStatLossEnabled = HardcoreManager.isStatLossEnabled(); boolean deathStatLossEnabled = HardcoreManager.isStatLossEnabled();
boolean vampirismEnabled = HardcoreManager.isVampirismEnabled(); boolean vampirismEnabled = HardcoreManager.isVampirismEnabled();
@ -81,7 +86,7 @@ public final class Motd {
* *
* @param player Target player * @param player Target player
*/ */
public static void displayXpPerks(Player player) { public void displayXpPerks(Player player) {
for (PrimarySkillType skill : PrimarySkillType.values()) { for (PrimarySkillType skill : PrimarySkillType.values()) {
// if (PerksUtils.handleXpPerks(player, 1, skill) > 1) { // 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"))); // player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.XP.Name"), pluginRef.getLocaleManager().getString("Perks.XP.Desc")));
@ -95,7 +100,7 @@ public final class Motd {
* *
* @param player Target player * @param player Target player
*/ */
public static void displayCooldownPerks(Player player) { public void displayCooldownPerks(Player player) {
double cooldownReduction = 1 - (PerksUtils.handleCooldownPerks(player, 12) / 12.0); double cooldownReduction = 1 - (PerksUtils.handleCooldownPerks(player, 12) / 12.0);
if (cooldownReduction > 0.0) { if (cooldownReduction > 0.0) {
@ -109,7 +114,7 @@ public final class Motd {
* *
* @param player Target player * @param player Target player
*/ */
public static void displayActivationPerks(Player player) { public void displayActivationPerks(Player player) {
int perkAmount = pluginRef.getSkillTools().getEnduranceLength(player); int perkAmount = pluginRef.getSkillTools().getEnduranceLength(player);
if (perkAmount > 0) { if (perkAmount > 0) {
@ -122,7 +127,7 @@ public final class Motd {
* *
* @param player Target player * @param player Target player
*/ */
public static void displayLuckyPerks(Player player) { public void displayLuckyPerks(Player player) {
for (PrimarySkillType skill : PrimarySkillType.values()) { for (PrimarySkillType skill : PrimarySkillType.values()) {
if (pluginRef.getPermissionTools().lucky(player, skill)) { 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"))); player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Lucky.Name"), pluginRef.getLocaleManager().getString("Perks.Lucky.Desc.Login")));
@ -137,7 +142,7 @@ public final class Motd {
* @param player Target player * @param player Target player
* @param website Plugin website * @param website Plugin website
*/ */
public static void displayWebsite(Player player, String website) { public void displayWebsite(Player player, String website) {
player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Website", website)); player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Website", website));
} }
} }