2013-03-01 06:52:01 +01:00
package com.gmail.nossr50.util ;
import java.text.DecimalFormat ;
2018-12-29 14:24:55 +01:00
import com.gmail.nossr50.datatypes.skills.PrimarySkill ;
2019-01-02 17:06:18 +01:00
import org.bukkit.ChatColor ;
2013-03-01 06:52:01 +01:00
import org.bukkit.entity.Player ;
import org.bukkit.plugin.PluginDescriptionFile ;
import com.gmail.nossr50.mcMMO ;
import com.gmail.nossr50.config.Config ;
import com.gmail.nossr50.locale.LocaleLoader ;
import com.gmail.nossr50.util.skills.PerksUtils ;
public final class Motd {
2014-01-20 22:58:40 +01:00
public static final String PERK_PREFIX = LocaleLoader . getString ( " MOTD.PerksPrefix " ) + " " ;
2013-03-01 06:52:01 +01:00
private static final PluginDescriptionFile pluginDescription = mcMMO . p . 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 .
*
2013-08-21 19:15:17 +02:00
* @param player Target player
2013-03-01 06:52:01 +01:00
* @param version Plugin version
* /
public static void displayVersion ( Player player , String version ) {
2014-02-17 16:31:59 +01:00
if ( Permissions . showversion ( player ) ) {
player . sendMessage ( LocaleLoader . getString ( " MOTD.Version " , version ) ) ;
2019-01-02 17:06:18 +01:00
//TODO: Remove this at release
player . sendMessage ( ChatColor . YELLOW + " You're playing an " + ChatColor . RED + " UNSTABLE " + ChatColor . YELLOW + " version of mcMMO! 2.1.0 is making many changes and if you are playing dev-snapshot you know the risks! " ) ;
2014-02-17 16:31:59 +01:00
}
2013-03-01 06:52:01 +01:00
}
/ * *
* Display Hardcore Mode settings .
*
* @param player Target player
* /
public static void displayHardcoreSettings ( Player player ) {
2013-09-10 14:38:06 +02:00
boolean deathStatLossEnabled = HardcoreManager . isStatLossEnabled ( ) ;
boolean vampirismEnabled = HardcoreManager . isVampirismEnabled ( ) ;
2013-08-23 20:07:59 +02:00
if ( ! deathStatLossEnabled & & ! vampirismEnabled ) {
2013-08-21 19:15:17 +02:00
return ;
}
2013-08-23 20:07:59 +02:00
String statLossInfo = " " ;
String vampirismInfo = " " ;
String seperator = " " ;
2013-08-21 19:15:17 +02:00
2013-08-23 20:07:59 +02:00
if ( deathStatLossEnabled ) {
statLossInfo = LocaleLoader . getString ( " Hardcore.DeathStatLoss.Name " ) ;
2013-08-21 19:15:17 +02:00
}
2013-08-23 20:07:59 +02:00
if ( vampirismEnabled ) {
vampirismInfo = LocaleLoader . getString ( " Hardcore.Vampirism.Name " ) ;
2013-08-21 19:15:17 +02:00
}
2013-08-23 20:07:59 +02:00
if ( deathStatLossEnabled & & vampirismEnabled ) {
seperator = " & " ;
2013-08-21 19:15:17 +02:00
}
2013-08-23 20:07:59 +02:00
player . sendMessage ( LocaleLoader . getString ( " MOTD.Hardcore.Enabled " , statLossInfo + seperator + vampirismInfo ) ) ;
2013-08-21 19:15:17 +02:00
if ( deathStatLossEnabled ) {
player . sendMessage ( LocaleLoader . getString ( " MOTD.Hardcore.DeathStatLoss.Stats " , Config . getInstance ( ) . getHardcoreDeathStatPenaltyPercentage ( ) ) ) ;
}
if ( vampirismEnabled ) {
player . sendMessage ( LocaleLoader . getString ( " MOTD.Hardcore.Vampirism.Stats " , Config . getInstance ( ) . getHardcoreVampirismStatLeechPercentage ( ) ) ) ;
2013-03-01 06:52:01 +01:00
}
}
/ * *
* Display XP perks .
*
* @param player Target player
* /
public static void displayXpPerks ( Player player ) {
2018-12-29 14:24:55 +01:00
for ( PrimarySkill skill : PrimarySkill . values ( ) ) {
2013-09-03 15:24:58 +02:00
if ( PerksUtils . handleXpPerks ( player , 1 , skill ) > 1 ) {
2014-01-20 23:53:31 +01:00
player . sendMessage ( PERK_PREFIX + LocaleLoader . getString ( " Effects.Template " , LocaleLoader . getString ( " Perks.XP.Name " ) , LocaleLoader . getString ( " Perks.XP.Desc " ) ) ) ;
2013-09-03 15:24:58 +02:00
return ;
}
2013-03-01 06:52:01 +01:00
}
}
/ * *
* 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% " ) ;
2014-01-20 22:58:40 +01:00
player . sendMessage ( PERK_PREFIX + LocaleLoader . getString ( " Effects.Template " , LocaleLoader . getString ( " Perks.Cooldowns.Name " ) , LocaleLoader . getString ( " Perks.Cooldowns.Desc " , percent . format ( cooldownReduction ) ) ) ) ;
2013-03-01 06:52:01 +01:00
}
}
/ * *
* Display activiation perks .
*
* @param player Target player
* /
public static void displayActivationPerks ( Player player ) {
int perkAmount = PerksUtils . handleActivationPerks ( player , 0 , 0 ) ;
if ( perkAmount > 0 ) {
2014-01-20 22:58:40 +01:00
player . sendMessage ( PERK_PREFIX + LocaleLoader . getString ( " Effects.Template " , LocaleLoader . getString ( " Perks.ActivationTime.Name " ) , LocaleLoader . getString ( " Perks.ActivationTime.Desc " , perkAmount ) ) ) ;
2013-03-01 06:52:01 +01:00
}
}
/ * *
* Display " lucky " perks .
*
* @param player Target player
* /
public static void displayLuckyPerks ( Player player ) {
2018-12-29 14:24:55 +01:00
for ( PrimarySkill skill : PrimarySkill . values ( ) ) {
2013-03-01 06:52:01 +01:00
if ( Permissions . lucky ( player , skill ) ) {
2014-01-20 22:58:40 +01:00
player . sendMessage ( PERK_PREFIX + LocaleLoader . getString ( " Effects.Template " , LocaleLoader . getString ( " Perks.Lucky.Name " ) , LocaleLoader . getString ( " Perks.Lucky.Desc.Login " ) ) ) ;
2013-03-01 06:52:01 +01:00
return ;
}
}
}
/ * *
* Display website info .
*
2013-08-21 19:15:17 +02:00
* @param player Target player
2013-03-01 06:52:01 +01:00
* @param website Plugin website
* /
public static void displayWebsite ( Player player , String website ) {
player . sendMessage ( LocaleLoader . getString ( " MOTD.Website " , website ) ) ;
}
}