Update code style

This commit is contained in:
nossr50
2019-04-24 22:52:53 -07:00
parent dc758a6dfc
commit 02a69cbb05
334 changed files with 4660 additions and 5158 deletions

View File

@@ -36,8 +36,7 @@ public class PistonTrackerTask extends BukkitRunnable {
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
mcMMO.getPlaceStore().setTrue(nextBlock);
nextBlock.removeMetadata(mcMMO.blockMetadataKey, mcMMO.p);
}
else if (mcMMO.getPlaceStore().isTrue(nextBlock)) {
} else if (mcMMO.getPlaceStore().isTrue(nextBlock)) {
// Block doesn't have metadatakey but isTrue - set it to false
mcMMO.getPlaceStore().setFalse(nextBlock);
}

View File

@@ -31,7 +31,7 @@ public class CleanBackupsTask extends BukkitRunnable {
//if(BACKUP_DIR.listFiles().length < mcMMO.getConfigManager().getConfigAutomatedBackups().getMinimumBackupCount())
//Don't remove files unless there is at least 10 of them
if(BACKUP_DIR.listFiles().length < 10)
if (BACKUP_DIR.listFiles().length < 10)
return;
// Check files in backup folder from oldest to newest
@@ -54,8 +54,7 @@ public class CleanBackupsTask extends BukkitRunnable {
long currentTime = System.currentTimeMillis();
//File is not old enough so don't delete it
if((fileSaveTimeStamp + (oldFileAgeLimit * TimeUnit.MILLISECONDS.convert(24, TimeUnit.HOURS))) >= currentTime)
{
if ((fileSaveTimeStamp + (oldFileAgeLimit * TimeUnit.MILLISECONDS.convert(24, TimeUnit.HOURS))) >= currentTime) {
continue;
}
@@ -80,7 +79,6 @@ public class CleanBackupsTask extends BukkitRunnable {
* Check if date is within last 24 hours
*
* @param date date to check
*
* @return true is date is within last 24 hours, false if otherwise
*/
private boolean isPast24Hours(Date date) {
@@ -92,7 +90,6 @@ public class CleanBackupsTask extends BukkitRunnable {
* Check if date is within the last week
*
* @param date date to check
*
* @return true is date is within the last week, false if otherwise
*/
private boolean isLastWeek(Date date) {
@@ -106,8 +103,7 @@ public class CleanBackupsTask extends BukkitRunnable {
try {
date = dateFormat.parse(fileName);
}
catch (ParseException e) {
} catch (ParseException e) {
return null;
}

View File

@@ -62,8 +62,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
public void displayBoard() {
if (sender.getName().equalsIgnoreCase(playerName)) {
ScoreboardManager.showPlayerRankScoreboard((Player) sender, skills);
}
else {
} else {
ScoreboardManager.showPlayerRankScoreboardOthers((Player) sender, playerName, skills);
}
}

View File

@@ -44,25 +44,22 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
if (sender instanceof Player) {
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
}
if(sender instanceof Player)
if (sender instanceof Player)
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
}
private void displayChat() {
if (skill == null) {
if(sender instanceof Player) {
if (sender instanceof Player) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
} else {
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")));
}
}
else {
if(sender instanceof Player) {
} else {
if (sender instanceof Player) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
}
else {
} else {
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName())));
}
}
@@ -73,13 +70,12 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
// Format:
// 01. Playername - skill value
// 12. Playername - skill value
if(sender instanceof Player) {
if (sender instanceof Player) {
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, ChatColor.GREEN, stat.name, ChatColor.WHITE, stat.statVal));
}
else {
} else {
sender.sendMessage(String.format("%2d. %s - %s", place, stat.name, stat.statVal));
}
place++;
}
}
@@ -87,8 +83,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
private void displayBoard() {
if (skill == null) {
ScoreboardManager.showTopPowerScoreboard((Player) sender, page, userStats);
}
else {
} else {
ScoreboardManager.showTopScoreboard((Player) sender, skill, page, userStats);
}
}

View File

@@ -11,10 +11,8 @@ public class NotifySquelchReminderTask extends BukkitRunnable {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
if(UserManager.getPlayer(player) != null)
{
if(!UserManager.getPlayer(player).useChatNotifications())
{
if (UserManager.getPlayer(player) != null) {
if (!UserManager.getPlayer(player).useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Reminder.Squelched"));
}
}

View File

@@ -42,8 +42,7 @@ public class FormulaConversionTask extends BukkitRunnable {
editValues(profile);
// Since this is a temporary profile, we save it here.
profile.scheduleAsyncSave();
}
else {
} else {
profile = mcMMOPlayer.getProfile();
editValues(profile);
}

View File

@@ -7,10 +7,11 @@ import java.util.concurrent.locks.ReentrantLock;
public class UserPurgeTask extends BukkitRunnable {
private ReentrantLock lock = new ReentrantLock();
@Override
public void run() {
lock.lock();
if(mcMMO.getDatabaseCleaningSettings().isPurgePowerlessUsers())
if (mcMMO.getDatabaseCleaningSettings().isPurgePowerlessUsers())
mcMMO.getDatabaseManager().purgePowerlessUsers();
if (mcMMO.getDatabaseCleaningSettings().isPurgeOldUsers()) {

View File

@@ -44,8 +44,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
}
// Print errors to console/logs if we're failing at least 2 times in a row to load the profile
if (attempt >= 3)
{
if (attempt >= 3) {
//Log the error
mcMMO.p.getLogger().severe(LocaleLoader.getString("Profile.Loading.FailureNotice",
player.getName(), String.valueOf(attempt)));

View File

@@ -31,8 +31,7 @@ public class AlchemyBrewCheckTask extends BukkitRunnable {
if (oldInventory[Alchemy.INGREDIENT_SLOT] == null || newInventory[Alchemy.INGREDIENT_SLOT] == null || !oldInventory[Alchemy.INGREDIENT_SLOT].isSimilar(newInventory[Alchemy.INGREDIENT_SLOT]) || !validBrew) {
Alchemy.brewingStandMap.get(location).cancelBrew();
}
}
else if (validBrew) {
} else if (validBrew) {
Alchemy.brewingStandMap.put(location, new AlchemyBrewTask(brewingStand, player));
}
}

View File

@@ -86,8 +86,7 @@ public class AlchemyBrewTask extends BukkitRunnable {
if (brewTimer < Math.max(brewSpeed, 2)) {
this.cancel();
finish();
}
else {
} else {
((BrewingStand) brewingStand).setBrewingTime((int) brewTimer);
}
}

View File

@@ -9,12 +9,11 @@ public class BleedContainer {
public LivingEntity target;
public LivingEntity damageSource;
public BleedContainer(LivingEntity target, int bleedTicks, int bleedRank, int toolTier, LivingEntity damageSource)
{
this.target = target;
this.bleedTicks = bleedTicks;
this.bleedRank = bleedRank;
this.toolTier = toolTier;
this.damageSource = damageSource;
public BleedContainer(LivingEntity target, int bleedTicks, int bleedRank, int toolTier, LivingEntity damageSource) {
this.target = target;
this.bleedTicks = bleedTicks;
this.bleedRank = bleedRank;
this.toolTier = toolTier;
this.damageSource = damageSource;
}
}

View File

@@ -22,123 +22,7 @@ import java.util.Map.Entry;
public class BleedTimerTask extends BukkitRunnable {
private static Map<LivingEntity, BleedContainer> bleedList = new HashMap<>();
@Override
public void run() {
Iterator<Entry<LivingEntity, BleedContainer>> bleedIterator = bleedList.entrySet().iterator();
while (bleedIterator.hasNext()) {
Entry<LivingEntity, BleedContainer> containerEntry = bleedIterator.next();
LivingEntity target = containerEntry.getKey();
int toolTier = containerEntry.getValue().toolTier;
// String debugMessage = "";
// debugMessage += ChatColor.GOLD + "Target ["+target.getName()+"]: " + ChatColor.RESET;
// debugMessage+="RemainingTicks=["+containerEntry.getValue().bleedTicks+"], ";
if (containerEntry.getValue().bleedTicks <= 0 || !target.isValid()) {
if(target instanceof Player)
{
NotificationManager.sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Stopped");
}
bleedIterator.remove();
continue;
}
int armorCount = 0;
double damage;
if (target instanceof Player) {
damage = AdvancedConfig.getInstance().getRuptureDamagePlayer();
//Above Bleed Rank 3 deals 50% more damage
if (containerEntry.getValue().toolTier >= 4 && containerEntry.getValue().bleedRank >= 3)
damage = damage * 1.5;
Player player = (Player) target;
if (!player.isOnline()) {
continue;
}
//Count Armor
for(ItemStack armorPiece : ((Player) target).getInventory().getArmorContents())
{
if(armorPiece != null)
armorCount++;
}
} else {
damage = AdvancedConfig.getInstance().getRuptureDamageMobs();
// debugMessage+="BaseDMG=["+damage+"], ";
//Above Bleed Rank 3 deals 50% more damage
if (containerEntry.getValue().bleedRank >= 3)
{
damage = damage * 1.5;
}
// debugMessage+="Rank4Bonus=["+String.valueOf(containerEntry.getValue().bleedRank >= 3)+"], ";
MobHealthbarUtils.handleMobHealthbars(target, damage, mcMMO.p); //Update health bars
}
// debugMessage+="FullArmor=["+String.valueOf(armorCount > 3)+"], ";
if(armorCount > 3)
{
damage = damage * .75;
}
// debugMessage+="AfterRankAndArmorChecks["+damage+"], ";
//Weapons below Diamond get damage cut in half
if(toolTier < 4)
damage = damage / 2;
// debugMessage+="AfterDiamondCheck=["+String.valueOf(damage)+"], ";
//Wood weapons get damage cut in half again
if(toolTier < 2)
damage = damage / 2;
// debugMessage+="AfterWoodenCheck=["+String.valueOf(damage)+"], ";
double victimHealth = target.getHealth();
// debugMessage+="TargetHealthBeforeDMG=["+String.valueOf(target.getHealth())+"], ";
CombatUtils.dealNoInvulnerabilityTickDamageRupture(target, damage, containerEntry.getValue().damageSource, toolTier);
double victimHealthAftermath = target.getHealth();
// debugMessage+="TargetHealthAfterDMG=["+String.valueOf(target.getHealth())+"], ";
if(victimHealthAftermath <= 0 || victimHealth != victimHealthAftermath)
{
//Play Bleed Sound
SoundManager.worldSendSound(target.getWorld(), target.getLocation(), SoundType.BLEED);
ParticleEffectUtils.playBleedEffect(target);
}
//Lower Bleed Ticks
BleedContainer loweredBleedContainer = copyContainer(containerEntry.getValue());
loweredBleedContainer.bleedTicks -= 1;
// debugMessage+="RemainingTicks=["+loweredBleedContainer.bleedTicks+"]";
containerEntry.setValue(loweredBleedContainer);
// Bukkit.broadcastMessage(debugMessage);
}
}
public static BleedContainer copyContainer(BleedContainer container)
{
public static BleedContainer copyContainer(BleedContainer container) {
LivingEntity target = container.target;
LivingEntity source = container.damageSource;
int bleedTicks = container.bleedTicks;
@@ -168,10 +52,10 @@ public class BleedTimerTask extends BukkitRunnable {
* Add a LivingEntity to the bleedList if it is not in it.
*
* @param entity LivingEntity to add
* @param ticks Number of bleeding ticks
* @param ticks Number of bleeding ticks
*/
public static void add(LivingEntity entity, LivingEntity attacker, int ticks, int bleedRank, int toolTier) {
if(toolTier < 4)
if (toolTier < 4)
ticks = Math.max(1, (ticks / 3));
BleedContainer newBleedContainer = new BleedContainer(entity, ticks, bleedRank, toolTier, attacker);
@@ -181,4 +65,114 @@ public class BleedTimerTask extends BukkitRunnable {
public static boolean isBleeding(LivingEntity entity) {
return bleedList.containsKey(entity);
}
@Override
public void run() {
Iterator<Entry<LivingEntity, BleedContainer>> bleedIterator = bleedList.entrySet().iterator();
while (bleedIterator.hasNext()) {
Entry<LivingEntity, BleedContainer> containerEntry = bleedIterator.next();
LivingEntity target = containerEntry.getKey();
int toolTier = containerEntry.getValue().toolTier;
// String debugMessage = "";
// debugMessage += ChatColor.GOLD + "Target ["+target.getName()+"]: " + ChatColor.RESET;
// debugMessage+="RemainingTicks=["+containerEntry.getValue().bleedTicks+"], ";
if (containerEntry.getValue().bleedTicks <= 0 || !target.isValid()) {
if (target instanceof Player) {
NotificationManager.sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Stopped");
}
bleedIterator.remove();
continue;
}
int armorCount = 0;
double damage;
if (target instanceof Player) {
damage = AdvancedConfig.getInstance().getRuptureDamagePlayer();
//Above Bleed Rank 3 deals 50% more damage
if (containerEntry.getValue().toolTier >= 4 && containerEntry.getValue().bleedRank >= 3)
damage = damage * 1.5;
Player player = (Player) target;
if (!player.isOnline()) {
continue;
}
//Count Armor
for (ItemStack armorPiece : ((Player) target).getInventory().getArmorContents()) {
if (armorPiece != null)
armorCount++;
}
} else {
damage = AdvancedConfig.getInstance().getRuptureDamageMobs();
// debugMessage+="BaseDMG=["+damage+"], ";
//Above Bleed Rank 3 deals 50% more damage
if (containerEntry.getValue().bleedRank >= 3) {
damage = damage * 1.5;
}
// debugMessage+="Rank4Bonus=["+String.valueOf(containerEntry.getValue().bleedRank >= 3)+"], ";
MobHealthbarUtils.handleMobHealthbars(target, damage, mcMMO.p); //Update health bars
}
// debugMessage+="FullArmor=["+String.valueOf(armorCount > 3)+"], ";
if (armorCount > 3) {
damage = damage * .75;
}
// debugMessage+="AfterRankAndArmorChecks["+damage+"], ";
//Weapons below Diamond get damage cut in half
if (toolTier < 4)
damage = damage / 2;
// debugMessage+="AfterDiamondCheck=["+String.valueOf(damage)+"], ";
//Wood weapons get damage cut in half again
if (toolTier < 2)
damage = damage / 2;
// debugMessage+="AfterWoodenCheck=["+String.valueOf(damage)+"], ";
double victimHealth = target.getHealth();
// debugMessage+="TargetHealthBeforeDMG=["+String.valueOf(target.getHealth())+"], ";
CombatUtils.dealNoInvulnerabilityTickDamageRupture(target, damage, containerEntry.getValue().damageSource, toolTier);
double victimHealthAftermath = target.getHealth();
// debugMessage+="TargetHealthAfterDMG=["+String.valueOf(target.getHealth())+"], ";
if (victimHealthAftermath <= 0 || victimHealth != victimHealthAftermath) {
//Play Bleed Sound
SoundManager.worldSendSound(target.getWorld(), target.getLocation(), SoundType.BLEED);
ParticleEffectUtils.playBleedEffect(target);
}
//Lower Bleed Ticks
BleedContainer loweredBleedContainer = copyContainer(containerEntry.getValue());
loweredBleedContainer.bleedTicks -= 1;
// debugMessage+="RemainingTicks=["+loweredBleedContainer.bleedTicks+"]";
containerEntry.setValue(loweredBleedContainer);
// Bukkit.broadcastMessage(debugMessage);
}
}
}

View File

@@ -10,8 +10,7 @@ public class ExperienceBarHideTask extends BukkitRunnable {
public final PrimarySkillType primarySkillType;
public final ExperienceBarManager experienceBarManagerRef;
public ExperienceBarHideTask(ExperienceBarManager experienceBarManagerRef, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType)
{
public ExperienceBarHideTask(ExperienceBarManager experienceBarManagerRef, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType) {
this.experienceBarManagerRef = experienceBarManagerRef;
this.mcMMOPlayer = mcMMOPlayer;
this.primarySkillType = primarySkillType;
@@ -30,7 +29,7 @@ public class ExperienceBarHideTask extends BukkitRunnable {
*/
@Override
public void run() {
if(experienceBarManagerRef == null || mcMMOPlayer == null)
if (experienceBarManagerRef == null || mcMMOPlayer == null)
return;
experienceBarManagerRef.hideExperienceBar(primarySkillType);

View File

@@ -10,18 +10,20 @@ public class SkillUnlockNotificationTask extends BukkitRunnable {
private McMMOPlayer mcMMOPlayer;
private SubSkillType subSkillType;
private int rank;
/**
* Notify a player about a newly unlocked subskill
* @param mcMMOPlayer target player
*
* @param mcMMOPlayer target player
* @param subSkillType the subskill that they just unlocked
* @param rank the rank of the subskill
* @param rank the rank of the subskill
*/
public SkillUnlockNotificationTask(McMMOPlayer mcMMOPlayer, SubSkillType subSkillType, int rank)
{
public SkillUnlockNotificationTask(McMMOPlayer mcMMOPlayer, SubSkillType subSkillType, int rank) {
this.mcMMOPlayer = mcMMOPlayer;
this.subSkillType = subSkillType;
this.rank = rank;
}
/**
* When an object implementing interface <code>Runnable</code> is used
* to create a thread, starting the thread causes the object's