Misc code fixes

This commit is contained in:
nossr50
2020-07-13 11:39:03 -07:00
parent 428c093ae4
commit 7eae59a0b3
153 changed files with 1139 additions and 1474 deletions

View File

@ -5,7 +5,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
private LivingEntity target;
private final LivingEntity target;
public MobHealthDisplayUpdaterTask(LivingEntity target) {
this.target = target;

View File

@ -9,9 +9,9 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
public class PistonTrackerTask extends BukkitRunnable {
private List<Block> blocks;
private BlockFace direction;
private Block futureEmptyBlock;
private final List<Block> blocks;
private final BlockFace direction;
private final Block futureEmptyBlock;
public PistonTrackerTask(List<Block> blocks, BlockFace direction, Block futureEmptyBlock) {
this.blocks = blocks;

View File

@ -7,9 +7,9 @@ import org.bukkit.block.BlockFace;
import org.bukkit.scheduler.BukkitRunnable;
public class StickyPistonTrackerTask extends BukkitRunnable {
private BlockFace direction;
private Block block;
private Block movedBlock;
private final BlockFace direction;
private final Block block;
private final Block movedBlock;
public StickyPistonTrackerTask(BlockFace direction, Block block, Block movedBlock) {
this.direction = direction;

View File

@ -58,11 +58,7 @@ public class CleanBackupsTask extends BukkitRunnable {
continue;
}
else {
List<Integer> savedWeeks = savedYearsWeeks.get(year);
if (savedWeeks == null) {
savedWeeks = new ArrayList<Integer>();
savedYearsWeeks.put(year, savedWeeks);
}
List<Integer> savedWeeks = savedYearsWeeks.computeIfAbsent(year, k -> new ArrayList<Integer>());
if (!savedWeeks.contains(weekOfYear) && Config.getInstance().getKeepWeeklyPastMonth()) {
// Keep one backup of each week

View File

@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class McScoreboardKeepTask extends BukkitRunnable {
private Player player;
private final Player player;
public McScoreboardKeepTask(Player player) {
this.player = player;

View File

@ -21,11 +21,6 @@ public class DatabaseConversionTask extends BukkitRunnable {
public void run() {
sourceDatabase.convertUsers(mcMMO.getDatabaseManager());
mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, new Runnable() {
@Override
public void run() {
sender.sendMessage(message);
}
});
mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, () -> sender.sendMessage(message));
}
}

View File

@ -14,8 +14,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
public class FormulaConversionTask extends BukkitRunnable {
private CommandSender sender;
private FormulaType formulaType;
private final CommandSender sender;
private final FormulaType formulaType;
public FormulaConversionTask(CommandSender sender, FormulaType formulaType) {
this.sender = sender;

View File

@ -7,7 +7,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.concurrent.locks.ReentrantLock;
public class UserPurgeTask extends BukkitRunnable {
private ReentrantLock lock = new ReentrantLock();
private final ReentrantLock lock = new ReentrantLock();
@Override
public void run() {
lock.lock();

View File

@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
public class ChimaeraWingWarmup extends BukkitRunnable {
private McMMOPlayer mcMMOPlayer;
private final McMMOPlayer mcMMOPlayer;
public ChimaeraWingWarmup(McMMOPlayer mcMMOPlayer) {
this.mcMMOPlayer = mcMMOPlayer;

View File

@ -14,8 +14,8 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class TeleportationWarmup extends BukkitRunnable {
private McMMOPlayer mcMMOPlayer;
private McMMOPlayer mcMMOTarget;
private final McMMOPlayer mcMMOPlayer;
private final McMMOPlayer mcMMOTarget;
public TeleportationWarmup(McMMOPlayer mcMMOPlayer, McMMOPlayer mcMMOTarget) {
this.mcMMOPlayer = mcMMOPlayer;

View File

@ -12,11 +12,11 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PartyChatTask extends BukkitRunnable {
private Plugin plugin;
private final Plugin plugin;
private Party party;
private String senderName;
private String displayName;
private final Party party;
private final String senderName;
private final String displayName;
private String message;
public PartyChatTask(Plugin plugin, Party party, String senderName, String displayName, String message) {

View File

@ -4,8 +4,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import org.bukkit.scheduler.BukkitRunnable;
public class PlayerProfileSaveTask extends BukkitRunnable {
private PlayerProfile playerProfile;
private boolean isSync;
private final PlayerProfile playerProfile;
private final boolean isSync;
public PlayerProfileSaveTask(PlayerProfile playerProfile, boolean isSync) {
this.playerProfile = playerProfile;

View File

@ -5,7 +5,7 @@ import org.bukkit.scheduler.BukkitRunnable;
@SuppressWarnings("deprecation")
public class PlayerUpdateInventoryTask extends BukkitRunnable {
private Player player;
private final Player player;
public PlayerUpdateInventoryTask(Player player) {
this.player = player;

View File

@ -7,8 +7,8 @@ import com.gmail.nossr50.util.player.NotificationManager;
import org.bukkit.scheduler.BukkitRunnable;
public class AbilityCooldownTask extends BukkitRunnable {
private McMMOPlayer mcMMOPlayer;
private SuperAbilityType ability;
private final McMMOPlayer mcMMOPlayer;
private final SuperAbilityType ability;
public AbilityCooldownTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) {
this.mcMMOPlayer = mcMMOPlayer;

View File

@ -17,8 +17,8 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class AbilityDisableTask extends BukkitRunnable {
private McMMOPlayer mcMMOPlayer;
private SuperAbilityType ability;
private final McMMOPlayer mcMMOPlayer;
private final SuperAbilityType ability;
public AbilityDisableTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) {
this.mcMMOPlayer = mcMMOPlayer;
@ -41,7 +41,7 @@ public class AbilityDisableTask extends BukkitRunnable {
case BERSERK:
if (Config.getInstance().getRefreshChunksEnabled()) {
resendChunkRadiusAt(player, 1);
resendChunkRadiusAt(player);
}
// Fallthrough
@ -66,13 +66,15 @@ public class AbilityDisableTask extends BukkitRunnable {
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
}
private void resendChunkRadiusAt(Player player, int radius) {
private void resendChunkRadiusAt(Player player) {
Chunk chunk = player.getLocation().getChunk();
World world = player.getWorld();
int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
int radius = 1;
for (int x = chunkX - radius; x <= chunkX + radius; x++) {
for (int z = chunkZ - radius; z <= chunkZ + radius; z++) {
world.refreshChunk(x, z);

View File

@ -11,9 +11,9 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.Arrays;
public class AlchemyBrewCheckTask extends BukkitRunnable {
private Player player;
private BrewingStand brewingStand;
private ItemStack[] oldInventory;
private final Player player;
private final BrewingStand brewingStand;
private final ItemStack[] oldInventory;
public AlchemyBrewCheckTask(Player player, BrewingStand brewingStand) {
this.player = player;

View File

@ -18,14 +18,14 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class AlchemyBrewTask extends BukkitRunnable {
private static double DEFAULT_BREW_SPEED = 1.0;
private static int DEFAULT_BREW_TICKS = 400;
private static final double DEFAULT_BREW_SPEED = 1.0;
private static final int DEFAULT_BREW_TICKS = 400;
private BlockState brewingStand;
private Location location;
private final BlockState brewingStand;
private final Location location;
private double brewSpeed;
private double brewTimer;
private Player player;
private final Player player;
private int fuel;
private boolean firstRun = true;

View File

@ -8,12 +8,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
public class AwardCombatXpTask extends BukkitRunnable {
private McMMOPlayer mcMMOPlayer;
private double baseXp;
private PrimarySkillType primarySkillType;
private LivingEntity target;
private XPGainReason xpGainReason;
private double baseHealth;
private final McMMOPlayer mcMMOPlayer;
private final double baseXp;
private final PrimarySkillType primarySkillType;
private final LivingEntity target;
private final XPGainReason xpGainReason;
private final double baseHealth;
public AwardCombatXpTask(McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, double baseXp, LivingEntity target, XPGainReason xpGainReason) {
this.mcMMOPlayer = mcMMOPlayer;

View File

@ -23,7 +23,7 @@ import java.util.Map;
import java.util.Map.Entry;
public class BleedTimerTask extends BukkitRunnable {
private static Map<LivingEntity, BleedContainer> bleedList = new HashMap<LivingEntity, BleedContainer>();
private static final Map<LivingEntity, BleedContainer> bleedList = new HashMap<LivingEntity, BleedContainer>();
private static boolean isIterating = false;
@Override
@ -155,8 +155,7 @@ public class BleedTimerTask extends BukkitRunnable {
int bleedRank = container.bleedRank;
int toolTier = container.toolTier;
BleedContainer newContainer = new BleedContainer(target, bleedTicks, bleedRank, toolTier, source);
return newContainer;
return new BleedContainer(target, bleedTicks, bleedRank, toolTier, source);
}
/**

View File

@ -4,7 +4,7 @@ import org.bukkit.block.BlockState;
import org.bukkit.scheduler.BukkitRunnable;
public class HerbalismBlockUpdaterTask extends BukkitRunnable {
private BlockState blockState;
private final BlockState blockState;
public HerbalismBlockUpdaterTask(BlockState blockState) {
this.blockState = blockState;

View File

@ -7,9 +7,9 @@ import org.bukkit.scheduler.BukkitRunnable;
public class SkillUnlockNotificationTask extends BukkitRunnable {
private McMMOPlayer mcMMOPlayer;
private SubSkillType subSkillType;
private int rank;
private final McMMOPlayer mcMMOPlayer;
private final SubSkillType subSkillType;
private final int rank;
/**
* Notify a player about a newly unlocked subskill
* @param mcMMOPlayer target player

View File

@ -8,8 +8,8 @@ import com.gmail.nossr50.util.player.NotificationManager;
import org.bukkit.scheduler.BukkitRunnable;
public class ToolLowerTask extends BukkitRunnable {
private McMMOPlayer mcMMOPlayer;
private ToolType tool;
private final McMMOPlayer mcMMOPlayer;
private final ToolType tool;
public ToolLowerTask(McMMOPlayer mcMMOPlayer, ToolType tool) {
this.mcMMOPlayer = mcMMOPlayer;