Code Cleanup Pt 2

This commit is contained in:
nossr50
2019-04-03 19:25:14 -07:00
parent 0e39656c88
commit 43037f8c13
118 changed files with 372 additions and 400 deletions

View File

@@ -54,7 +54,7 @@ public final class Alchemy {
public static double catalysisMinSpeed = AdvancedConfig.getInstance().getCatalysisMinSpeed();
public static double catalysisMaxSpeed = AdvancedConfig.getInstance().getCatalysisMaxSpeed();
public static Map<Location, AlchemyBrewTask> brewingStandMap = new HashMap<Location, AlchemyBrewTask>();
public static Map<Location, AlchemyBrewTask> brewingStandMap = new HashMap<>();
private Alchemy() {}
@@ -64,7 +64,7 @@ public final class Alchemy {
public static void finishAllBrews() {
mcMMO.p.debug("Completing " + brewingStandMap.size() + " unfinished Alchemy brews.");
List<AlchemyBrewTask> toFinish = new ArrayList<AlchemyBrewTask>();
List<AlchemyBrewTask> toFinish = new ArrayList<>();
toFinish.addAll(brewingStandMap.values());

View File

@@ -108,7 +108,7 @@ public final class AlchemyPotionBrewer {
return;
}
List<AlchemyPotion> inputList = new ArrayList<AlchemyPotion>();
List<AlchemyPotion> inputList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
ItemStack item = inventory.getItem(i);

View File

@@ -25,7 +25,7 @@ public class Archery {
public Archery()
{
List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
List<TrackedEntity> trackedEntities = new ArrayList<>();
skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax();

View File

@@ -21,7 +21,7 @@ public class Excavation {
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
if (ExcavationTreasureConfig.getInstance().excavationMap.containsKey(friendly))
return ExcavationTreasureConfig.getInstance().excavationMap.get(friendly);
return new ArrayList<ExcavationTreasure>();
return new ArrayList<>();
}
protected static int getBlockXP(BlockState blockState) {

View File

@@ -16,7 +16,7 @@ import java.util.Set;
public final class Fishing {
protected static final HashMap<Material, List<Enchantment>> ENCHANTABLE_CACHE = new HashMap<Material, List<Enchantment>>();
protected static final HashMap<Material, List<Enchantment>> ENCHANTABLE_CACHE = new HashMap<>();
/*public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;

View File

@@ -53,7 +53,6 @@ public class FishingManager extends SkillManager {
private long lastWarned = 0L;
private long lastWarnedExhaust = 0L;
private BoundingBox lastFishingBoundingBox;
private Item fishingCatch;
private Location hookLocation;
private int fishCaughtCounter = 1;
private final float boundingBoxSize;
@@ -87,7 +86,7 @@ public class FishingManager extends SkillManager {
getPlayer().getInventory().getItemInMainHand().setDurability((short) (getPlayer().getInventory().getItemInMainHand().getDurability() + 5));
getPlayer().updateInventory();
if(lastWarnedExhaust + (1000 * 1) < currentTime)
if(lastWarnedExhaust + (1000) < currentTime)
{
getPlayer().sendMessage(LocaleLoader.getString("Fishing.Exhausting"));
lastWarnedExhaust = currentTime;
@@ -114,7 +113,7 @@ public class FishingManager extends SkillManager {
long fishHookSpawnCD = fishHookSpawnTimestamp + 1000;
boolean hasFished = (currentTime < fishHookSpawnCD);
if(hasFished && (lastWarned + (1000 * 1) < currentTime))
if(hasFished && (lastWarned + (1000) < currentTime))
{
getPlayer().sendMessage(LocaleLoader.getString("Fishing.Scared"));
lastWarned = System.currentTimeMillis();
@@ -286,7 +285,6 @@ public class FishingManager extends SkillManager {
* @param fishingCatch The {@link Item} initially caught
*/
public void handleFishing(Item fishingCatch) {
this.fishingCatch = fishingCatch;
int fishXp = ExperienceConfig.getInstance().getXp(PrimarySkillType.FISHING, fishingCatch.getItemStack().getType());
int treasureXp = 0;
Player player = getPlayer();
@@ -294,12 +292,11 @@ public class FishingManager extends SkillManager {
if (MainConfig.getInstance().getFishingDropsEnabled() && Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) {
treasure = getFishingTreasure();
this.fishingCatch = null;
}
if (treasure != null) {
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
Map<Enchantment, Integer> enchants = new HashMap<>();
if (isMagicHunterEnabled()
&& ItemUtils.isEnchantable(treasureDrop)) {
@@ -517,7 +514,7 @@ public class FishingManager extends SkillManager {
* @return true if the item has been enchanted
*/
private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
Map<Enchantment, Integer> enchants = new HashMap<>();
List<EnchantmentTreasure> fishingEnchantments = null;
double diceRoll = Misc.getRandom().nextDouble() * 100;
@@ -547,7 +544,7 @@ public class FishingManager extends SkillManager {
}
List<Enchantment> validEnchantments = getPossibleEnchantments(treasureDrop);
List<EnchantmentTreasure> possibleEnchants = new ArrayList<EnchantmentTreasure>();
List<EnchantmentTreasure> possibleEnchants = new ArrayList<>();
for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) {
if (validEnchantments.contains(enchantmentTreasure.getEnchantment())) {
@@ -586,7 +583,7 @@ public class FishingManager extends SkillManager {
return Fishing.ENCHANTABLE_CACHE.get(dropType);
}
List<Enchantment> possibleEnchantments = new ArrayList<Enchantment>();
List<Enchantment> possibleEnchantments = new ArrayList<>();
for (Enchantment enchantment : Enchantment.values()) {
if (enchantment.canEnchantItem(treasureDrop)) {

View File

@@ -282,7 +282,7 @@ public class HerbalismManager extends SkillManager {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
Material seed = null;
Material seed;
switch (blockState.getType()) {
case CARROTS:

View File

@@ -130,8 +130,8 @@ public class MiningManager extends SkillManager {
* @param blockList The list of blocks to drop
*/
public void blastMiningDropProcessing(float yield, List<Block> blockList) {
List<BlockState> ores = new ArrayList<BlockState>();
List<BlockState> debris = new ArrayList<BlockState>();
List<BlockState> ores = new ArrayList<>();
List<BlockState> debris = new ArrayList<>();
int xp = 0;
float oreBonus = (float) (getOreBonus() / 100);
@@ -263,7 +263,7 @@ public class MiningManager extends SkillManager {
if (timeRemaining > 0) {
//getPlayer().sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf("timeRemaining"));
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining));
return false;
}

View File

@@ -6,6 +6,7 @@ import com.gmail.nossr50.util.ItemUtils;
import org.bukkit.Material;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -19,7 +20,7 @@ public class Repairable {
private final double xpMultiplier;
public Repairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) {
this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(Arrays.asList(repairMaterial)), minimumQuantity, minimumLevel, xpMultiplier);
this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(Collections.singletonList(repairMaterial)), minimumQuantity, minimumLevel, xpMultiplier);
}
public Repairable(Material itemMaterial, List<Material> repairMaterials, int minimumQuantity, int minimumLevel, double xpMultiplier) {

View File

@@ -16,7 +16,7 @@ public class RepairableManager implements Unload {
}
public RepairableManager(List<Repairable> repairablesCollection) {
this.repairables = new HashMap<Material, Repairable>(repairablesCollection.size());
this.repairables = new HashMap<>(repairablesCollection.size());
registerRepairables(repairablesCollection);
}

View File

@@ -143,7 +143,7 @@ public class SalvageManager extends SkillManager {
}*/
public int getSalvageableAmount() {
return (RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE) * 1);
return (RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE));
}
/**

View File

@@ -21,7 +21,7 @@ public class SalvageableManager implements Unload {
}
public SalvageableManager(List<Salvageable> salvageablesCollection) {
this.salvageables = new HashMap<Material, Salvageable>(salvageablesCollection.size());
this.salvageables = new HashMap<>(salvageablesCollection.size());
registerSalvageables(salvageablesCollection);
}

View File

@@ -37,7 +37,7 @@ public class TamingManager extends SkillManager {
super(mcMMOPlayer, PrimarySkillType.TAMING);
}
private static HashMap<EntityType, List<TrackedTamingEntity>> summonedEntities = new HashMap<EntityType, List<TrackedTamingEntity>>();
private static HashMap<EntityType, List<TrackedTamingEntity>> summonedEntities = new HashMap<>();
public boolean canUseThickFur() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_THICK_FUR)
@@ -384,7 +384,7 @@ public class TamingManager extends SkillManager {
TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity);
if (!summonedEntities.containsKey(livingEntity.getType())) {
summonedEntities.put(livingEntity.getType(), new ArrayList<TrackedTamingEntity>());
summonedEntities.put(livingEntity.getType(), new ArrayList<>());
}
summonedEntities.get(livingEntity.getType()).add(trackedEntity);

View File

@@ -99,7 +99,7 @@ public final class Woodcutting {
* before taking measurements).
*/
protected static void processTree(BlockState blockState, Set<BlockState> treeFellerBlocks) {
List<BlockState> futureCenterBlocks = new ArrayList<BlockState>();
List<BlockState> futureCenterBlocks = new ArrayList<>();
// Check the block up and take different behavior (smaller search) if it's a log
if (handleBlock(blockState.getBlock().getRelative(BlockFace.UP).getState(), futureCenterBlocks, treeFellerBlocks)) {

View File

@@ -75,7 +75,7 @@ public class WoodcuttingManager extends SkillManager {
*/
public void processTreeFeller(BlockState blockState) {
Player player = getPlayer();
Set<BlockState> treeFellerBlocks = new HashSet<BlockState>();
Set<BlockState> treeFellerBlocks = new HashSet<>();
Woodcutting.treeFellerReachedThreshold = false;