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

@@ -27,7 +27,8 @@ public abstract class SkillManager {
/**
* Applies XP to a player, provides SELF as an XpGainSource source
* @param xp amount of XP to apply
*
* @param xp amount of XP to apply
* @param xpGainReason the reason for the XP gain
* @deprecated use applyXpGain(float, XPGainReason, XPGainSource)
*/
@@ -38,7 +39,8 @@ public abstract class SkillManager {
/**
* Applies XP to a player
* @param xp amount of XP to apply
*
* @param xp amount of XP to apply
* @param xpGainReason the reason for the XP gain
* @param xpGainSource the source of the XP
*/

View File

@@ -22,37 +22,32 @@ import org.bukkit.entity.Player;
public class AcrobaticsManager extends SkillManager {
private long rollXPCooldown = 0;
private long rollXPInterval;
private long rollXPIntervalLengthen = (1000 * 10); //10 Seconds
private LimitedSizeList fallLocationMap;
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, PrimarySkillType.ACROBATICS);
rollXPInterval = (1000 * mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().getRollXPGainCooldownSeconds());
//Save some memory if exploit prevention is off
if(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
fallLocationMap = new LimitedSizeList(mcMMO.getConfigManager().getConfigExploitPrevention().getAcrobaticLocationLimit());
}
private long rollXPCooldown = 0;
private long rollXPInterval;
private long rollXPIntervalLengthen = (1000 * 10); //10 Seconds
private LimitedSizeList fallLocationMap;
public boolean hasFallenInLocationBefore(Location location)
{
public boolean hasFallenInLocationBefore(Location location) {
return fallLocationMap.contains(location);
}
public void addLocationToFallMap(Location location)
{
public void addLocationToFallMap(Location location) {
fallLocationMap.add(location);
}
public boolean canGainRollXP()
{
if(!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
public boolean canGainRollXP() {
if (!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
return true;
if(System.currentTimeMillis() >= rollXPCooldown)
{
if (System.currentTimeMillis() >= rollXPCooldown) {
rollXPCooldown = System.currentTimeMillis() + rollXPInterval;
rollXPIntervalLengthen = (1000 * 10); //5 Seconds
return true;
@@ -64,7 +59,7 @@ public class AcrobaticsManager extends SkillManager {
}
public boolean canDodge(Entity damager) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE))
return false;
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ACROBATICS_DODGE)) {
@@ -96,7 +91,7 @@ public class AcrobaticsManager extends SkillManager {
}
//Check respawn to prevent abuse
if(!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
if (!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVP);
else if (SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)
&& mcMMOPlayer.getTeleportATS() < System.currentTimeMillis()) {

View File

@@ -49,14 +49,15 @@ public final class Alchemy {
public static final int INGREDIENT_SLOT = 3;
public static int catalysisUnlockLevel = RankUtils.getUnlockLevel(SubSkillType.ALCHEMY_CATALYSIS);
public static int catalysisMaxBonusLevel = AdvancedConfig.getInstance().getCatalysisMaxBonusLevel();
public static double catalysisMinSpeed = AdvancedConfig.getInstance().getCatalysisMinSpeed();
public static double catalysisMaxSpeed = AdvancedConfig.getInstance().getCatalysisMaxSpeed();
public static int catalysisUnlockLevel = RankUtils.getUnlockLevel(SubSkillType.ALCHEMY_CATALYSIS);
public static int catalysisMaxBonusLevel = AdvancedConfig.getInstance().getCatalysisMaxBonusLevel();
public static double catalysisMinSpeed = AdvancedConfig.getInstance().getCatalysisMinSpeed();
public static double catalysisMaxSpeed = AdvancedConfig.getInstance().getCatalysisMaxSpeed();
public static Map<Location, AlchemyBrewTask> brewingStandMap = new HashMap<>();
private Alchemy() {}
private Alchemy() {
}
/**
* Finish all active brews. Used upon Disable to prevent vanilla potions from being brewed upon next Enable.

View File

@@ -59,11 +59,9 @@ public final class AlchemyPotionBrewer {
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
}
else if (ingredient.getAmount() <= 1) {
} else if (ingredient.getAmount() <= 1) {
inventory.setIngredient(null);
}
else {
} else {
ingredient.setAmount(ingredient.getAmount() - 1);
inventory.setIngredient(ingredient);
}
@@ -90,8 +88,7 @@ public final class AlchemyPotionBrewer {
}
private static List<ItemStack> getValidIngredients(Player player) {
if(player == null || UserManager.getPlayer(player) == null)
{
if (player == null || UserManager.getPlayer(player) == null) {
return PotionConfig.getInstance().getIngredients(1);
}
@@ -161,8 +158,7 @@ public final class AlchemyPotionBrewer {
if (click.isLeftClick()) {
success = transferItems(view, fromSlot);
}
else if (click.isRightClick()) {
} else if (click.isRightClick()) {
success = transferOneItem(view, fromSlot);
}
@@ -182,13 +178,11 @@ public final class AlchemyPotionBrewer {
if (!emptyTo && fromAmount >= from.getType().getMaxStackSize()) {
return false;
}
else if (emptyTo || from.isSimilar(to)) {
} else if (emptyTo || from.isSimilar(to)) {
if (emptyTo) {
to = from.clone();
to.setAmount(1);
}
else {
} else {
to.setAmount(to.getAmount() + 1);
}
@@ -211,14 +205,12 @@ public final class AlchemyPotionBrewer {
if (isEmpty(from)) {
return false;
}
else if (isEmpty(to)) {
} else if (isEmpty(to)) {
view.setItem(Alchemy.INGREDIENT_SLOT, from);
view.setItem(fromSlot, null);
return true;
}
else if (from.isSimilar(to)) {
} else if (from.isSimilar(to)) {
int fromAmount = from.getAmount();
int toAmount = to.getAmount();
int maxSize = to.getType().getMaxStackSize();

View File

@@ -14,114 +14,6 @@ import java.util.Map.Entry;
public class PotionGenerator {
public static class Ingredient {
public Material mat;
public int data;
public String name;
public Ingredient(Material mat) {
this.mat = mat;
this.data = 0;
name = mat.name();
}
}
public static class WriteablePotion {
public String name;
public Material mat;
public PotionData data;
public PotionEffect effect;
public String baseName;
public WriteablePotion(PotionData data) {
this(Material.POTION, data);
}
public WriteablePotion(Material type, PotionData data) {
this(type, data, null, getMCName(data.getType()));
}
public WriteablePotion(Material mat, PotionType type, PotionEffect effect, String baseName) {
this(mat, new PotionData(type, false, false), effect, baseName);
}
public WriteablePotion(Material type, PotionData data, PotionEffect effect, String baseName) {
this.data = data;
this.effect = effect;
this.mat = type;
this.baseName = baseName;
this.name = "POTION_OF_" + baseName;
if (mat == Material.SPLASH_POTION) {
this.name = "SPLASH_" + this.name;
}
if (mat == Material.LINGERING_POTION) {
this.name = "LINGERING_" + this.name;
}
if (data.isExtended()) {
this.name += "_EXTENDED";
}
if (data.isUpgraded()) {
this.name += "_II";
}
}
public WriteablePotion(PotionType type) {
this(new PotionData(type, false, false));
}
public WriteablePotion(Material mat, PotionType type) {
this(mat, new PotionData(type, false, false));
}
private static String getMCName(PotionType type) {
switch (type) {
case INSTANT_DAMAGE :
return "HARMING";
case INSTANT_HEAL :
return "HEALING";
case JUMP :
return "LEAPING";
case REGEN :
return "REGENERATION";
case SPEED :
return "SWIFTNESS";
case UNCRAFTABLE :
return "EMPTY";
case LUCK :
case MUNDANE :
case NIGHT_VISION :
case POISON :
case INVISIBILITY :
case SLOWNESS :
case AWKWARD :
case STRENGTH :
case THICK :
case FIRE_RESISTANCE :
case WATER :
case WATER_BREATHING :
case WEAKNESS :
case TURTLE_MASTER:
case SLOW_FALLING:
return type.name();
default :
return "";
}
}
public int hashCode() {
return name.hashCode();
}
public boolean equals(Object obj) {
if (!(obj instanceof WriteablePotion)) {
return false;
}
return name.equals(((WriteablePotion) obj).name);
}
}
public static void main(String[] args) {
Map<WriteablePotion, Map<Ingredient, WriteablePotion>> vanillaPotions = new HashMap<>();
populateVanillaPotions(vanillaPotions);
@@ -250,59 +142,59 @@ public class PotionGenerator {
private static String getName(PotionEffectType type) {
switch (type.getId()) {
case 1 :
case 1:
return "SPEED";
case 2 :
case 2:
return "SLOW";
case 3 :
case 3:
return "FAST_DIGGING";
case 4 :
case 4:
return "SLOW_DIGGING";
case 5 :
case 5:
return "INCREASE_DAMAGE";
case 6 :
case 6:
return "HEAL";
case 7 :
case 7:
return "HARM";
case 8 :
case 8:
return "JUMP";
case 9 :
case 9:
return "CONFUSION";
case 10 :
case 10:
return "REGENERATION";
case 11 :
case 11:
return "DAMAGE_RESISTANCE";
case 12 :
case 12:
return "FIRE_RESISTANCE";
case 13 :
case 13:
return "WATER_BREATHING";
case 14 :
case 14:
return "INVISIBILITY";
case 15 :
case 15:
return "BLINDNESS";
case 16 :
case 16:
return "NIGHT_VISION";
case 17 :
case 17:
return "HUNGER";
case 18 :
case 18:
return "WEAKNESS";
case 19 :
case 19:
return "POISON";
case 20 :
case 20:
return "WITHER";
case 21 :
case 21:
return "HEALTH_BOOST";
case 22 :
case 22:
return "ABSORPTION";
case 23 :
case 23:
return "SATURATION";
case 24 :
case 24:
return "GLOWING";
case 25 :
case 25:
return "LEVITATION";
case 26 :
case 26:
return "LUCK";
case 27 :
case 27:
return "UNLUCK";
case 28:
return "SLOW_FALLING";
@@ -310,7 +202,7 @@ public class PotionGenerator {
return "CONDUIT_POWER";
case 30:
return "DOLPHINS_GRACE";
default :
default:
return "UNKNOWN_EFFECT_TYPE_" + type.getId();
}
}
@@ -348,9 +240,9 @@ public class PotionGenerator {
private static void getChildren(WriteablePotion current, HashMap<Ingredient, WriteablePotion> children) {
switch (current.data.getType()) {
case WATER :
assert(!current.data.isExtended());
assert(!current.data.isUpgraded());
case WATER:
assert (!current.data.isExtended());
assert (!current.data.isUpgraded());
children.put(new Ingredient(Material.NETHER_WART), new WriteablePotion(current.mat, PotionType.AWKWARD));
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.WEAKNESS));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, PotionType.MUNDANE));
@@ -363,9 +255,9 @@ public class PotionGenerator {
children.put(new Ingredient(Material.GLISTERING_MELON_SLICE), new WriteablePotion(current.mat, PotionType.MUNDANE));
children.put(new Ingredient(Material.GHAST_TEAR), new WriteablePotion(current.mat, PotionType.MUNDANE));
return;
case AWKWARD :
assert(!current.data.isExtended());
assert(!current.data.isUpgraded());
case AWKWARD:
assert (!current.data.isExtended());
assert (!current.data.isUpgraded());
children.put(new Ingredient(Material.GOLDEN_CARROT), new WriteablePotion(current.mat, PotionType.NIGHT_VISION));
children.put(new Ingredient(Material.RABBIT_FOOT), new WriteablePotion(current.mat, PotionType.JUMP));
children.put(new Ingredient(Material.MAGMA_CREAM), new WriteablePotion(current.mat, PotionType.FIRE_RESISTANCE));
@@ -396,8 +288,8 @@ public class PotionGenerator {
children.put(new Ingredient(Material.FERN), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SATURATION, (int) (8 * mod), 0), "SATURATION"));
children.put(new Ingredient(Material.APPLE), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HEALTH_BOOST, (int) (1800 * mod), 0), "HEALTH_BOOST"));
return;
case FIRE_RESISTANCE :
assert(!current.data.isUpgraded());
case FIRE_RESISTANCE:
assert (!current.data.isUpgraded());
if (current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.SLOWNESS, true, false)));
} else {
@@ -405,14 +297,14 @@ public class PotionGenerator {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case INSTANT_DAMAGE :
assert(!current.data.isExtended());
case INSTANT_DAMAGE:
assert (!current.data.isExtended());
if (!current.data.isUpgraded()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
}
return;
case INSTANT_HEAL :
assert(!current.data.isExtended());
case INSTANT_HEAL:
assert (!current.data.isExtended());
if (!current.data.isUpgraded()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
@@ -420,21 +312,21 @@ public class PotionGenerator {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true)));
}
return;
case INVISIBILITY :
assert(!current.data.isUpgraded());
case INVISIBILITY:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case JUMP :
case JUMP:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.SLOWNESS));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case NIGHT_VISION :
assert(!current.data.isUpgraded());
case NIGHT_VISION:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INVISIBILITY));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
@@ -442,7 +334,7 @@ public class PotionGenerator {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INVISIBILITY, true, false)));
}
return;
case POISON :
case POISON:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
@@ -451,25 +343,25 @@ public class PotionGenerator {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true)));
}
return;
case REGEN :
case REGEN:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case SLOWNESS :
assert(!current.data.isUpgraded());
case SLOWNESS:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case SLOW_FALLING :
assert(!current.data.isUpgraded());
case SLOW_FALLING:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case SPEED :
case SPEED:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.SLOWNESS));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
@@ -478,7 +370,7 @@ public class PotionGenerator {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.SLOWNESS, true, false)));
}
return;
case STRENGTH :
case STRENGTH:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
@@ -490,28 +382,28 @@ public class PotionGenerator {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case WATER_BREATHING :
assert(!current.data.isUpgraded());
case WATER_BREATHING:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case WEAKNESS :
assert(!current.data.isUpgraded());
case WEAKNESS:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case LUCK :
case MUNDANE :
case THICK :
case UNCRAFTABLE :
assert(!current.data.isExtended());
assert(!current.data.isUpgraded());
case LUCK:
case MUNDANE:
case THICK:
case UNCRAFTABLE:
assert (!current.data.isExtended());
assert (!current.data.isUpgraded());
return;
default :
assert(false);
default:
assert (false);
break;
}
}
@@ -608,7 +500,7 @@ public class PotionGenerator {
}
mcMMOPotions.put(data, children);
}
// Add all material state changes
for (Entry<WriteablePotion, Map<Ingredient, WriteablePotion>> entry : mcMMOPotions.entrySet()) {
if (entry.getKey().mat == Material.POTION) {
@@ -620,4 +512,113 @@ public class PotionGenerator {
}
}
}
public static class Ingredient {
public Material mat;
public int data;
public String name;
public Ingredient(Material mat) {
this.mat = mat;
this.data = 0;
name = mat.name();
}
}
public static class WriteablePotion {
public String name;
public Material mat;
public PotionData data;
public PotionEffect effect;
public String baseName;
public WriteablePotion(PotionData data) {
this(Material.POTION, data);
}
public WriteablePotion(Material type, PotionData data) {
this(type, data, null, getMCName(data.getType()));
}
public WriteablePotion(Material mat, PotionType type, PotionEffect effect, String baseName) {
this(mat, new PotionData(type, false, false), effect, baseName);
}
public WriteablePotion(Material type, PotionData data, PotionEffect effect, String baseName) {
this.data = data;
this.effect = effect;
this.mat = type;
this.baseName = baseName;
this.name = "POTION_OF_" + baseName;
if (mat == Material.SPLASH_POTION) {
this.name = "SPLASH_" + this.name;
}
if (mat == Material.LINGERING_POTION) {
this.name = "LINGERING_" + this.name;
}
if (data.isExtended()) {
this.name += "_EXTENDED";
}
if (data.isUpgraded()) {
this.name += "_II";
}
}
public WriteablePotion(PotionType type) {
this(new PotionData(type, false, false));
}
public WriteablePotion(Material mat, PotionType type) {
this(mat, new PotionData(type, false, false));
}
private static String getMCName(PotionType type) {
switch (type) {
case INSTANT_DAMAGE:
return "HARMING";
case INSTANT_HEAL:
return "HEALING";
case JUMP:
return "LEAPING";
case REGEN:
return "REGENERATION";
case SPEED:
return "SWIFTNESS";
case UNCRAFTABLE:
return "EMPTY";
case LUCK:
case MUNDANE:
case NIGHT_VISION:
case POISON:
case INVISIBILITY:
case SLOWNESS:
case AWKWARD:
case STRENGTH:
case THICK:
case FIRE_RESISTANCE:
case WATER:
case WATER_BREATHING:
case WEAKNESS:
case TURTLE_MASTER:
case SLOW_FALLING:
return type.name();
default:
return "";
}
}
public int hashCode() {
return name.hashCode();
}
public boolean equals(Object obj) {
if (!(obj instanceof WriteablePotion)) {
return false;
}
return name.equals(((WriteablePotion) obj).name);
}
}
}

View File

@@ -25,15 +25,7 @@ public class Archery {
private static Archery archery;
public static Archery getInstance() {
if(archery == null)
archery = new Archery();
return archery;
}
public Archery()
{
public Archery() {
List<TrackedEntity> trackedEntities = new ArrayList<>();
skillShotDamageCap = AdvancedConfig.getInstance().getSkillShotDamageMax();
@@ -43,6 +35,13 @@ public class Archery {
distanceXpMultiplier = mcMMO.getConfigManager().getConfigExperience().getDistanceMultiplier();
}
public static Archery getInstance() {
if (archery == null)
archery = new Archery();
return archery;
}
protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
@@ -71,7 +70,7 @@ public class Archery {
* @param livingEntity The entity hit by the arrows
*/
public static void arrowRetrievalCheck(LivingEntity livingEntity) {
for (Iterator<TrackedEntity> entityIterator = trackedEntities.iterator(); entityIterator.hasNext();) {
for (Iterator<TrackedEntity> entityIterator = trackedEntities.iterator(); entityIterator.hasNext(); ) {
TrackedEntity trackedEntity = entityIterator.next();
if (trackedEntity.getID() == livingEntity.getUniqueId()) {
@@ -82,8 +81,7 @@ public class Archery {
}
}
public static double getSkillShotBonusDamage(Player player, double oldDamage)
{
public static double getSkillShotBonusDamage(Player player, double oldDamage) {
double damageBonusPercent = getDamageBonusPercent(player);
double newDamage = oldDamage + (oldDamage * damageBonusPercent);
return Math.min(newDamage, Archery.skillShotDamageCap);

View File

@@ -25,21 +25,21 @@ public class ArcheryManager extends SkillManager {
}
public boolean canDaze(LivingEntity target) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_DAZE))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_DAZE))
return false;
return target instanceof Player && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_DAZE);
}
public boolean canSkillShot() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT))
return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT);
}
public boolean canRetrieveArrows() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL))
return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL);
@@ -48,7 +48,7 @@ public class ArcheryManager extends SkillManager {
/**
* Calculate bonus XP awarded for Archery when hitting a far-away target.
*
* @param target The {@link LivingEntity} damaged by the arrow
* @param target The {@link LivingEntity} damaged by the arrow
* @param damager The {@link Entity} who shot the arrow
*/
public double distanceXpBonusMultiplier(LivingEntity target, Entity damager) {

View File

@@ -11,14 +11,14 @@ import org.bukkit.inventory.ItemStack;
public class Axes {
public static double axeMasteryRankDamageMultiplier = AdvancedConfig.getInstance().getAxeMasteryRankDamageMultiplier();
public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getCriticalStrikesPVPModifier();
public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getCriticalStrikesPVEModifier();
public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getCriticalStrikesPVPModifier();
public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getCriticalStrikesPVEModifier();
public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel();
public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel();
//public static double impactChance = AdvancedConfig.getInstance().getImpactChance();
public static double impactMaxDurabilityModifier = AdvancedConfig.getInstance().getArmorImpactMaxDurabilityDamage() / 100D;
public static double greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage();
public static double greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage();
//public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance();
public static double greaterImpactKnockbackMultiplier = AdvancedConfig.getInstance().getGreaterImpactModifier();
@@ -36,11 +36,11 @@ public class Axes {
/**
* For every rank in Axe Mastery we add RankDamageMultiplier to get the total bonus damage from Axe Mastery
*
* @param player The target player
* @return The axe mastery bonus damage which will be added to their attack
*/
public static double getAxeMasteryBonusDamage(Player player)
{
public static double getAxeMasteryBonusDamage(Player player) {
return RankUtils.getRank(player, SubSkillType.AXES_AXE_MASTERY) * Axes.axeMasteryRankDamageMultiplier;
}
}

View File

@@ -25,35 +25,35 @@ public class AxesManager extends SkillManager {
}
public boolean canUseAxeMastery() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_AXE_MASTERY))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_AXE_MASTERY))
return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_AXE_MASTERY);
}
public boolean canCriticalHit(LivingEntity target) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES))
return false;
return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES);
}
public boolean canImpact(LivingEntity target) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT))
return false;
return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT) && Axes.hasArmor(target);
}
public boolean canGreaterImpact(LivingEntity target) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_GREATER_IMPACT))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_GREATER_IMPACT))
return false;
return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_GREATER_IMPACT) && !Axes.hasArmor(target);
}
public boolean canUseSkullSplitter(LivingEntity target) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_SKULL_SPLITTER))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_SKULL_SPLITTER))
return false;
return target.isValid() && mcMMOPlayer.getAbilityMode(SuperAbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
@@ -99,8 +99,7 @@ public class AxesManager extends SkillManager {
}
damage = (damage * Axes.criticalHitPVPModifier) - damage;
}
else {
} else {
damage = (damage * Axes.criticalHitPVEModifier) - damage;
}

View File

@@ -25,7 +25,7 @@ public class FamilyTree {
}
public static Set<PrimarySkillType> getParents(PrimarySkillType childSkill) {
if(childSkill == PrimarySkillType.SALVAGE)
if (childSkill == PrimarySkillType.SALVAGE)
return salvageTree;
else
return smeltingTree;

View File

@@ -50,18 +50,17 @@ public class ExcavationManager extends SkillManager {
applyXpGain(xp, XPGainReason.PVE);
}
public void printExcavationDebug(Player player, BlockState blockState)
{
public void printExcavationDebug(Player player, BlockState blockState) {
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
List<ExcavationTreasure> treasures = Excavation.getTreasures(blockState);
if (!treasures.isEmpty()) {
for (ExcavationTreasure treasure : treasures) {
player.sendMessage("|||||||||||||||||||||||||||||||||");
player.sendMessage("[mcMMO DEBUG] Treasure found: ("+treasure.getDrop().getType().toString()+")");
player.sendMessage("[mcMMO DEBUG] Drop Chance for Treasure: "+treasure.getDropChance());
player.sendMessage("[mcMMO DEBUG] Skill Level Required: "+treasure.getDropLevel());
player.sendMessage("[mcMMO DEBUG] XP for Treasure: "+treasure.getXp());
player.sendMessage("[mcMMO DEBUG] Treasure found: (" + treasure.getDrop().getType().toString() + ")");
player.sendMessage("[mcMMO DEBUG] Drop Chance for Treasure: " + treasure.getDropChance());
player.sendMessage("[mcMMO DEBUG] Skill Level Required: " + treasure.getDropLevel());
player.sendMessage("[mcMMO DEBUG] XP for Treasure: " + treasure.getXp());
}
} else {
player.sendMessage("[mcMMO DEBUG] No treasures found for this block.");

View File

@@ -17,22 +17,14 @@ import java.util.Set;
public final class Fishing {
private HashMap<Material, List<Enchantment>> enchantableCache = new HashMap<>();
private HashMap<Material, Integer> fishingXpRewardMap;
private Set<Biome> masterAnglerBiomes = BiomeAdapter.WATER_BIOMES;
private Set<Biome> iceFishingBiomes = BiomeAdapter.ICE_BIOMES;
public static Fishing instance;
private final long fishingRodCastCdMilliseconds;
private final int overfishLimit;
private final float boundingBoxSize;
public static Fishing instance;
public static Fishing getInstance() {
if(instance == null)
instance = new Fishing();
return instance;
}
private HashMap<Material, List<Enchantment>> enchantableCache = new HashMap<>();
private HashMap<Material, Integer> fishingXpRewardMap;
private Set<Biome> masterAnglerBiomes = BiomeAdapter.WATER_BIOMES;
private Set<Biome> iceFishingBiomes = BiomeAdapter.ICE_BIOMES;
public Fishing() {
overfishLimit = mcMMO.getConfigManager().getConfigExploitPrevention().getOverfishingLimit() + 1;
@@ -41,21 +33,25 @@ public final class Fishing {
initFishingXPRewardMap();
}
public static Fishing getInstance() {
if (instance == null)
instance = new Fishing();
return instance;
}
/**
* Inits the Fishing Catch -> XP Reward map
*/
private void initFishingXPRewardMap()
{
private void initFishingXPRewardMap() {
fishingXpRewardMap = new HashMap<>();
HashMap<String, Integer> nameRegisterMap = mcMMO.getConfigManager().getConfigExperience().getFishingXPMap();
for(String qualifiedName : nameRegisterMap.keySet())
{
for (String qualifiedName : nameRegisterMap.keySet()) {
Material material = Material.matchMaterial(qualifiedName);
if(material == null)
{
mcMMO.p.getLogger().info("Unable to match qualified name to item for fishing xp map: "+qualifiedName);
if (material == null) {
mcMMO.p.getLogger().info("Unable to match qualified name to item for fishing xp map: " + qualifiedName);
continue;
}
@@ -66,8 +62,7 @@ public final class Fishing {
/**
* Finds the possible drops of an entity
*
* @param target
* Targeted entity
* @param target Targeted entity
* @return possibleDrops List of ItemStack that can be dropped
*/
public List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
@@ -80,8 +75,7 @@ public final class Fishing {
/**
* Randomly chooses a drop among the list
*
* @param possibleDrops
* List of ItemStack that can be dropped
* @param possibleDrops List of ItemStack that can be dropped
* @return Chosen ItemStack
*/
public ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
@@ -115,8 +109,7 @@ public final class Fishing {
return iceFishingBiomes;
}
public int getFishXPValue(Material material)
{
public int getFishXPValue(Material material) {
return fishingXpRewardMap.get(material);
}

View File

@@ -66,21 +66,18 @@ public class FishingManager extends SkillManager {
return getSkillLevel() >= RankUtils.getUnlockLevel(SubSkillType.FISHING_MASTER_ANGLER) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_MASTER_ANGLER);
}
public void setFishingRodCastTimestamp()
{
public void setFishingRodCastTimestamp() {
long currentTime = System.currentTimeMillis();
//Only track spam casting if the fishing hook is fresh
if(currentTime > fishHookSpawnTimestamp + 1000)
if (currentTime > fishHookSpawnTimestamp + 1000)
return;
if(currentTime < fishingRodCastTimestamp + Fishing.getInstance().getFishingRodCastCdMilliseconds())
{
if (currentTime < fishingRodCastTimestamp + Fishing.getInstance().getFishingRodCastCdMilliseconds()) {
getPlayer().setFoodLevel(Math.max(getPlayer().getFoodLevel() - 1, 0));
getPlayer().getInventory().getItemInMainHand().setDurability((short) (getPlayer().getInventory().getItemInMainHand().getDurability() + 5));
getPlayer().updateInventory();
if(lastWarnedExhaust + (1000) < currentTime)
{
if (lastWarnedExhaust + (1000) < currentTime) {
getPlayer().sendMessage(LocaleLoader.getString("Fishing.Exhausting"));
lastWarnedExhaust = currentTime;
SoundManager.sendSound(getPlayer(), getPlayer().getLocation(), SoundType.TIRED);
@@ -90,9 +87,8 @@ public class FishingManager extends SkillManager {
fishingRodCastTimestamp = System.currentTimeMillis();
}
public void setFishHookReference(FishHook fishHook)
{
if(fishHook.getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() > 0)
public void setFishHookReference(FishHook fishHook) {
if (fishHook.getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() > 0)
return;
fishHook.setMetadata(mcMMO.FISH_HOOK_REF_METAKEY, mcMMO.metadataValue);
@@ -100,14 +96,12 @@ public class FishingManager extends SkillManager {
fishingRodCastTimestamp = System.currentTimeMillis();
}
public boolean isFishingTooOften()
{
public boolean isFishingTooOften() {
long currentTime = System.currentTimeMillis();
long fishHookSpawnCD = fishHookSpawnTimestamp + 1000;
boolean hasFished = (currentTime < fishHookSpawnCD);
if(hasFished && (lastWarned + (1000) < currentTime))
{
if (hasFished && (lastWarned + (1000) < currentTime)) {
getPlayer().sendMessage(LocaleLoader.getString("Fishing.Scared"));
lastWarned = System.currentTimeMillis();
}
@@ -129,32 +123,27 @@ public class FishingManager extends SkillManager {
boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
if(sameTarget)
if (sameTarget)
fishCaughtCounter++;
else
fishCaughtCounter = 1;
if(fishCaughtCounter + 1 == overfishLimit)
{
if (fishCaughtCounter + 1 == overfishLimit) {
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResources"));
}
//If the new bounding box does not intersect with the old one, then update our bounding box reference
if(!sameTarget)
if (!sameTarget)
lastFishingBoundingBox = newCastBoundingBox;
if(sameTarget && fishCaughtCounter >= overfishLimit)
{
if (sameTarget && fishCaughtCounter >= overfishLimit) {
overFishCount++;
} else
overFishCount=0;
overFishCount = 0;
if(overFishCount == 2)
{
for(Player player : Bukkit.getOnlinePlayers())
{
if(player.isOp() || Permissions.adminChat(player))
{
if (overFishCount == 2) {
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.isOp() || Permissions.adminChat(player)) {
player.sendMessage(LocaleLoader.getString("Fishing.OverFishingDetected", getPlayer().getDisplayName()));
}
}
@@ -225,7 +214,6 @@ public class FishingManager extends SkillManager {
* Handle the Fisherman's Diet ability
*
* @param eventFoodLevel The initial change in hunger from the event
*
* @return the modified change in hunger for the event
*/
public int handleFishermanDiet(int eventFoodLevel) {
@@ -268,8 +256,7 @@ public class FishingManager extends SkillManager {
hook.setBiteChance(Math.min(biteChance, 1.0));
}
public boolean isMagicHunterEnabled()
{
public boolean isMagicHunterEnabled() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_MAGIC_HUNTER)
&& RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER);
@@ -305,8 +292,7 @@ public class FishingManager extends SkillManager {
if (!event.isCancelled()) {
treasureDrop = event.getTreasure();
treasureXp = event.getXp();
}
else {
} else {
treasureDrop = null;
treasureXp = 0;
}
@@ -340,7 +326,6 @@ public class FishingManager extends SkillManager {
* Handle the vanilla XP boost for Fishing
*
* @param experience The amount of experience initially awarded by the event
*
* @return the modified event damage
*/
public int addInnerPeaceVanillaXPBoost(int experience) {
@@ -397,8 +382,7 @@ public class FishingManager extends SkillManager {
if (FishingTreasureConfig.getInstance().getInventoryStealStacks()) {
inventory.setItem(slot, null);
}
else {
} else {
inventory.setItem(slot, (drop.getAmount() > 1) ? new ItemStack(drop.getType(), drop.getAmount() - 1) : null);
drop.setAmount(1);
}
@@ -451,8 +435,7 @@ public class FishingManager extends SkillManager {
if (getPlayer().getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {
luck = getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK);
}
else {
} else {
// We know something was caught, so if the rod wasn't in the main hand it must be in the offhand
luck = getPlayer().getInventory().getItemInOffHand().getEnchantmentLevel(Enchantment.LUCK);
}
@@ -508,7 +491,6 @@ public class FishingManager extends SkillManager {
* Process the Magic Hunter ability
*
* @param treasureDrop The {@link ItemStack} to enchant
*
* @return true if the item has been enchanted
*/
private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {

View File

@@ -15,8 +15,7 @@ public class Herbalism {
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState
* The {@link BlockState} to check ability activation for
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
@@ -29,16 +28,16 @@ public class Herbalism {
blockState.setType(Material.MOSSY_STONE_BRICKS);
return true;
case DIRT :
case GRASS_PATH :
case DIRT:
case GRASS_PATH:
blockState.setType(Material.GRASS_BLOCK);
return true;
case COBBLESTONE :
case COBBLESTONE:
blockState.setType(Material.MOSSY_COBBLESTONE);
return true;
default :
default:
return false;
}
}
@@ -62,15 +61,14 @@ public class Herbalism {
if (mcMMO.getPlaceStore().isTrue(target))
mcMMO.getPlaceStore().setFalse(target);
else
{
else {
dropAmount++;
if(herbalismManager.checkDoubleDrop(target.getState()))
if (herbalismManager.checkDoubleDrop(target.getState()))
BlockUtils.markDropsAsBonus(target.getState(), triple);
}
for (BlockFace blockFace : new BlockFace[] { BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST ,BlockFace.WEST})
for (BlockFace blockFace : new BlockFace[]{BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST})
dropAmount += calculateChorusPlantDropsRecursive(target.getRelative(blockFace, 1), traversed, triple, herbalismManager);
return dropAmount;
@@ -80,8 +78,7 @@ public class Herbalism {
* Calculate the drop amounts for multi block plants based on the blocks
* relative to them.
*
* @param blockState
* The {@link BlockState} of the bottom block of the plant
* @param blockState The {@link BlockState} of the bottom block of the plant
* @return the number of bonus drops to award from the blocks in this plant
*/
protected static int countAndMarkDoubleDropsMultiBlockPlant(BlockState blockState, boolean triple, HerbalismManager herbalismManager) {
@@ -109,7 +106,7 @@ public class Herbalism {
} else {
dropAmount++;
if(herbalismManager.checkDoubleDrop(relativeBlock.getState()))
if (herbalismManager.checkDoubleDrop(relativeBlock.getState()))
BlockUtils.markDropsAsBonus(relativeBlock.getState(), triple);
}
}
@@ -122,8 +119,7 @@ public class Herbalism {
* Calculate the drop amounts for kelp plants based on the blocks
* relative to them.
*
* @param blockState
* The {@link BlockState} of the bottom block of the plant
* @param blockState The {@link BlockState} of the bottom block of the plant
* @return the number of bonus drops to award from the blocks in this plant
*/
protected static int countAndMarkDoubleDropsKelp(BlockState blockState, boolean triple, HerbalismManager herbalismManager) {
@@ -136,12 +132,12 @@ public class Herbalism {
for (int y = 1; y < kelpMaxHeight; y++) {
Block relativeUpBlock = block.getRelative(BlockFace.UP, y);
if(!isKelp(relativeUpBlock))
if (!isKelp(relativeUpBlock))
break;
amount += 1;
if(herbalismManager.checkDoubleDrop(relativeUpBlock.getState()))
if (herbalismManager.checkDoubleDrop(relativeUpBlock.getState()))
BlockUtils.markDropsAsBonus(relativeUpBlock.getState(), triple);
}
@@ -169,19 +165,18 @@ public class Herbalism {
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState
* The {@link BlockState} to check ability activation for
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertShroomThumb(BlockState blockState) {
switch (blockState.getType()) {
case DIRT :
case DIRT:
case GRASS_BLOCK:
case GRASS_PATH :
case GRASS_PATH:
blockState.setType(Material.MYCELIUM);
return true;
default :
default:
return false;
}
}
@@ -189,8 +184,7 @@ public class Herbalism {
/**
* Check if the block has a recently grown crop from Green Thumb
*
* @param blockState
* The {@link BlockState} to check green thumb regrown for
* @param blockState The {@link BlockState} to check green thumb regrown for
* @return true if the block is recently regrown, false otherwise
*/
public static boolean isRecentlyRegrown(BlockState blockState) {

View File

@@ -42,7 +42,7 @@ public class HerbalismManager extends SkillManager {
}
public boolean canGreenThumbBlock(BlockState blockState) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_GREEN_THUMB))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_GREEN_THUMB))
return false;
Player player = getPlayer();
@@ -52,7 +52,7 @@ public class HerbalismManager extends SkillManager {
}
public boolean canUseShroomThumb(BlockState blockState) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_SHROOM_THUMB))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_SHROOM_THUMB))
return false;
Player player = getPlayer();
@@ -63,7 +63,7 @@ public class HerbalismManager extends SkillManager {
}
public boolean canUseHylianLuck() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))
return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK);
@@ -148,26 +148,26 @@ public class HerbalismManager extends SkillManager {
// }
// }
// else {
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getType());
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getType());
if (!oneBlockPlant) {
//Kelp is actually two blocks mixed together
if(material == Material.KELP_PLANT || material == Material.KELP) {
amount = Herbalism.countAndMarkDoubleDropsKelp(blockState, greenTerra,this);
} else {
amount = Herbalism.countAndMarkDoubleDropsMultiBlockPlant(blockState, greenTerra, this);
}
xp *= amount;
if (!oneBlockPlant) {
//Kelp is actually two blocks mixed together
if (material == Material.KELP_PLANT || material == Material.KELP) {
amount = Herbalism.countAndMarkDoubleDropsKelp(blockState, greenTerra, this);
} else {
/* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */
if(checkDoubleDrop(blockState))
BlockUtils.markDropsAsBonus(blockState, greenTerra);
amount = Herbalism.countAndMarkDoubleDropsMultiBlockPlant(blockState, greenTerra, this);
}
if (Permissions.greenThumbPlant(player, material)) {
processGreenThumbPlants(blockState, greenTerra);
}
xp *= amount;
} else {
/* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */
if (checkDoubleDrop(blockState))
BlockUtils.markDropsAsBonus(blockState, greenTerra);
}
if (Permissions.greenThumbPlant(player, material)) {
processGreenThumbPlants(blockState, greenTerra);
}
//} mod config close
applyXpGain(xp, XPGainReason.PVE);
@@ -181,11 +181,11 @@ public class HerbalismManager extends SkillManager {
/**
* Check for success on herbalism double drops
*
* @param blockState target block state
* @return true if double drop succeeds
*/
public boolean checkDoubleDrop(BlockState blockState)
{
public boolean checkDoubleDrop(BlockState blockState) {
return BlockUtils.checkDoubleDrops(getPlayer(), blockState, SubSkillType.HERBALISM_DOUBLE_DROPS);
}
@@ -252,7 +252,7 @@ public class HerbalismManager extends SkillManager {
public boolean processShroomThumb(BlockState blockState) {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
if (!playerInventory.contains(Material.BROWN_MUSHROOM, 1)) {
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM));
return false;
@@ -328,8 +328,7 @@ public class HerbalismManager extends SkillManager {
return;
}
if(!ItemUtils.isHoe(getPlayer().getInventory().getItemInMainHand()))
{
if (!ItemUtils.isHoe(getPlayer().getInventory().getItemInMainHand())) {
if (!playerInventory.containsAtLeast(seedStack, 1)) {
return;
}
@@ -355,8 +354,7 @@ public class HerbalismManager extends SkillManager {
if (greenTerra) {
crops.setAge(3);
}
else {
} else {
crops.setAge(greenThumbStage);
}
break;
@@ -366,21 +364,18 @@ public class HerbalismManager extends SkillManager {
if (greenTerra || greenThumbStage > 2) {
crops.setAge(2);
}
else if (greenThumbStage == 2) {
} else if (greenThumbStage == 2) {
crops.setAge(1);
}
else {
} else {
crops.setAge(0);
}
break;
break;
case COCOA:
if (greenTerra || getGreenThumbStage() > 1) {
crops.setAge(1);
}
else {
} else {
crops.setAge(0);
}
break;

View File

@@ -46,13 +46,11 @@ public class BlastMining {
}
public static double getBlastDamageDecrease(int rank) {
return AdvancedConfig.getInstance().getBlastDamageDecrease(rank);
}
public static int getDemolitionExpertUnlockLevel() {
/*List<Tier> tierList = Arrays.asList(Tier.values());
for (Tier tier : tierList) {
@@ -63,10 +61,9 @@ public class BlastMining {
return tier == Tier.EIGHT ? tier.getLevel() : tierList.get(tierList.indexOf(tier) - 1).getLevel();
}*/
for(int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks()-1; i++)
{
if(getBlastDamageDecrease(i+1) > 0)
return RankUtils.getRankUnlockLevel(SubSkillType.MINING_BLAST_MINING, i+1);
for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) {
if (getBlastDamageDecrease(i + 1) > 0)
return RankUtils.getRankUnlockLevel(SubSkillType.MINING_BLAST_MINING, i + 1);
}
return 0;
@@ -82,10 +79,9 @@ public class BlastMining {
return tier == Tier.EIGHT ? tier.getLevel() : tierList.get(tierList.indexOf(tier) - 1).getLevel();
}*/
for(int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks()-1; i++)
{
if(getBlastRadiusModifier(i+1) > 0)
return RankUtils.getRankUnlockLevel(SubSkillType.MINING_BLAST_MINING, i+1);
for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) {
if (getBlastRadiusModifier(i + 1) > 0)
return RankUtils.getRankUnlockLevel(SubSkillType.MINING_BLAST_MINING, i + 1);
}
return 0;
@@ -103,12 +99,11 @@ public class BlastMining {
return false;
}
if(UserManager.getPlayer(defender) == null)
{
if (UserManager.getPlayer(defender) == null) {
return false;
}
MiningManager miningManager = UserManager.getPlayer(defender).getMiningManager();
MiningManager miningManager = UserManager.getPlayer(defender).getMiningManager();
if (!miningManager.canUseDemolitionsExpertise()) {
return false;

View File

@@ -13,37 +13,19 @@ import java.util.List;
public class Mining {
private List<Material> detonators;
private static Mining instance;
public static Mining getInstance() {
if(instance == null)
instance = new Mining();
return instance;
}
private List<Material> detonators;
public Mining() {
//Init detonators
this.detonators = ItemUtils.matchMaterials(mcMMO.getConfigManager().getConfigMining().getDetonators());
}
/**
* Retrieve a list of Blast Mining detonator types
* @return blast mining detonator materials
*/
public List<Material> getDetonators() {
return detonators;
}
public static Mining getInstance() {
if (instance == null)
instance = new Mining();
/**
* Check if an itemStack is a valid blast mining detonator
* @param itemStack target itemstack
* @return true if valid blast mining detonator
*/
public Boolean isDetonator(ItemStack itemStack)
{
return getDetonators().contains(itemStack.getType());
return instance;
}
/**
@@ -201,4 +183,23 @@ public class Mining {
}*/
}
}
/**
* Retrieve a list of Blast Mining detonator types
*
* @return blast mining detonator materials
*/
public List<Material> getDetonators() {
return detonators;
}
/**
* Check if an itemStack is a valid blast mining detonator
*
* @param itemStack target itemstack
* @return true if valid blast mining detonator
*/
public Boolean isDetonator(ItemStack itemStack) {
return getDetonators().contains(itemStack.getType());
}
}

View File

@@ -35,8 +35,20 @@ public class MiningManager extends SkillManager {
super(mcMMOPlayer, PrimarySkillType.MINING);
}
public static double getOreBonus(int rank) {
return AdvancedConfig.getInstance().getOreBonus(rank);
}
public static double getDebrisReduction(int rank) {
return AdvancedConfig.getInstance().getDebrisReduction(rank);
}
public static int getDropMultiplier(int rank) {
return AdvancedConfig.getInstance().getDropMultiplier(rank);
}
public boolean canUseDemolitionsExpertise() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DEMOLITIONS_EXPERTISE))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DEMOLITIONS_EXPERTISE))
return false;
return getSkillLevel() >= BlastMining.getDemolitionExpertUnlockLevel() && Permissions.demolitionsExpertise(getPlayer());
@@ -56,7 +68,7 @@ public class MiningManager extends SkillManager {
}
public boolean canUseBiggerBombs() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_BIGGER_BOMBS))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_BIGGER_BOMBS))
return false;
return getSkillLevel() >= BlastMining.getBiggerBombsUnlockLevel() && Permissions.biggerBombs(getPlayer());
@@ -83,13 +95,13 @@ public class MiningManager extends SkillManager {
}
//if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || !MainConfig.getInstance().getDoubleDropsEnabled(skill, material)) {
if(!MainConfig.getInstance().getDoubleDropsEnabled(skill, material)) {
if (!MainConfig.getInstance().getDoubleDropsEnabled(skill, material)) {
return;
}
boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH);
if(silkTouch && !AdvancedConfig.getInstance().getDoubleDropSilkTouchEnabled())
if (silkTouch && !AdvancedConfig.getInstance().getDoubleDropSilkTouchEnabled())
return;
//TODO: Make this readable
@@ -128,7 +140,7 @@ public class MiningManager extends SkillManager {
/**
* Handler for explosion drops and XP gain.
*
* @param yield The % of blocks to drop
* @param yield The % of blocks to drop
* @param blockList The list of blocks to drop
*/
public void blastMiningDropProcessing(float yield, List<Block> blockList) {
@@ -147,8 +159,7 @@ public class MiningManager extends SkillManager {
if (BlockUtils.isOre(blockState)) {
ores.add(blockState);
}
else {
} else {
debris.add(blockState);
}
}
@@ -212,14 +223,6 @@ public class MiningManager extends SkillManager {
return getOreBonus(getBlastMiningTier());
}
public static double getOreBonus(int rank) {
return AdvancedConfig.getInstance().getOreBonus(rank);
}
public static double getDebrisReduction(int rank) {
return AdvancedConfig.getInstance().getDebrisReduction(rank);
}
/**
* Gets the Blast Mining tier
*
@@ -229,10 +232,6 @@ public class MiningManager extends SkillManager {
return getDebrisReduction(getBlastMiningTier());
}
public static int getDropMultiplier(int rank) {
return AdvancedConfig.getInstance().getDropMultiplier(rank);
}
/**
* Gets the Blast Mining tier
*

View File

@@ -13,8 +13,7 @@ public class Repair {
anvilMaterial = mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().getRepairAnvilMaterial();
//TODO: Replace this horrid shit
if(mcMMO.isRetroModeEnabled())
{
if (mcMMO.isRetroModeEnabled()) {
repairMasteryMaxBonus = mcMMO.getConfigManager().getConfigRepair().getRepairSubSkills().getRepairMastery().getSettings().getRetro().getMaxBonusPercentage();
repairMasteryMaxBonusLevel = mcMMO.getConfigManager().getConfigRepair().getRepairSubSkills().getRepairMastery().getSettings().getRetro().getMaxBonusLevel();
} else {
@@ -23,9 +22,8 @@ public class Repair {
}
}
public static Repair getInstance()
{
if(instance == null)
public static Repair getInstance() {
if (instance == null)
instance = new Repair();
return instance;

View File

@@ -34,7 +34,7 @@ import java.util.Map.Entry;
public class RepairManager extends SkillManager {
private boolean placedAnvil;
private int lastClick;
private int lastClick;
public RepairManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, PrimarySkillType.REPAIR);
@@ -62,7 +62,6 @@ public class RepairManager extends SkillManager {
}
public void handleRepair(ItemStack item) {
Player player = getPlayer();
Repairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType());
@@ -97,14 +96,10 @@ public class RepairManager extends SkillManager {
boolean foundNonBasicMaterial = false;
//Find the first compatible repair material
for(Material repairMaterialCandidate : repairable.getRepairMaterials())
{
for(ItemStack is : player.getInventory().getContents())
{
if(is.getType() == repairMaterialCandidate)
{
if(is.getItemMeta().getLore().isEmpty())
{
for (Material repairMaterialCandidate : repairable.getRepairMaterials()) {
for (ItemStack is : player.getInventory().getContents()) {
if (is.getType() == repairMaterialCandidate) {
if (is.getItemMeta().getLore().isEmpty()) {
repairMaterial = repairMaterialCandidate;
break;
} else {
@@ -115,8 +110,7 @@ public class RepairManager extends SkillManager {
}
/* Abort the repair if no compatible basic repairing item found */
if(repairMaterial == null && foundNonBasicMaterial == true)
{
if (repairMaterial == null && foundNonBasicMaterial == true) {
player.sendMessage(LocaleLoader.getString("Repair.NoBasicRepairMatsFound"));
return;
}
@@ -286,7 +280,7 @@ public class RepairManager extends SkillManager {
/**
* Computes repair bonuses.
*
* @param durability The durability of the item being repaired
* @param durability The durability of the item being repaired
* @param repairAmount The base amount of durability repaired to the item
* @return The final amount of durability repaired to the item
*/
@@ -320,7 +314,7 @@ public class RepairManager extends SkillManager {
* @return true if bonus granted, false otherwise
*/
private boolean checkPlayerProcRepair() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_SUPER_REPAIR))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_SUPER_REPAIR))
return false;
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.REPAIR_SUPER_REPAIR, getPlayer())) {
@@ -372,8 +366,7 @@ public class RepairManager extends SkillManager {
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
downgraded = true;
}
}
else {
} else {
item.removeEnchantment(enchantment);
}
}
@@ -382,11 +375,9 @@ public class RepairManager extends SkillManager {
if (newEnchants.isEmpty()) {
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE_FAILED, "Repair.Arcane.Fail");
}
else if (downgraded || newEnchants.size() < enchants.size()) {
} else if (downgraded || newEnchants.size() < enchants.size()) {
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE_FAILED, "Repair.Arcane.Downgrade");
}
else {
} else {
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Repair.Arcane.Perfect");
}
}

View File

@@ -10,16 +10,16 @@ import java.util.List;
public class RepairableManager implements Unload {
private HashMap<Material, Repairable> repairables;
@Override
public void unload() {
repairables.clear();
}
public RepairableManager(List<Repairable> repairablesCollection) {
this.repairables = new HashMap<>(repairablesCollection.size());
registerRepairables(repairablesCollection);
}
@Override
public void unload() {
repairables.clear();
}
public void registerRepairable(Repairable repairable) {
Material item = repairable.getItemMaterial();
repairables.put(item, repairable);

View File

@@ -32,7 +32,7 @@ import java.util.Map.Entry;
public class SalvageManager extends SkillManager {
private boolean placedAnvil;
private int lastClick;
private int lastClick;
public SalvageManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, PrimarySkillType.SALVAGE);
@@ -179,7 +179,7 @@ public class SalvageManager extends SkillManager {
}*/
public double getExtractFullEnchantChance() {
if(Permissions.hasSalvageEnchantBypassPerk(getPlayer()))
if (Permissions.hasSalvageEnchantBypassPerk(getPlayer()))
return 100.0D;
return AdvancedConfig.getInstance().getArcaneSalvageExtractFullEnchantsChance(getArcaneSalvageRank());
@@ -208,8 +208,7 @@ public class SalvageManager extends SkillManager {
|| Permissions.hasSalvageEnchantBypassPerk(player)
|| RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue(), true);
}
else if (enchant.getValue() > 1
} else if (enchant.getValue() > 1
&& Salvage.arcaneSalvageDowngrades
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractPartialEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue() - 1, true);
@@ -219,12 +218,10 @@ public class SalvageManager extends SkillManager {
}
}
if(failedAllEnchants(arcaneFailureCount, enchants.entrySet().size()))
{
if (failedAllEnchants(arcaneFailureCount, enchants.entrySet().size())) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcaneFailed");
return null;
} else if(downgraded)
{
} else if (downgraded) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcanePartial");
}
@@ -238,8 +235,8 @@ public class SalvageManager extends SkillManager {
/**
* Check if the player has tried to use an Anvil before.
* @param actualize
*
* @param actualize
* @return true if the player has confirmed using an Anvil
*/
public boolean checkConfirmation(boolean actualize) {

View File

@@ -17,18 +17,15 @@ public class Salvageable {
private final ItemMaterialCategory salvageItemMaterialCategory;
private final double xpMultiplier;
public Salvageable(String itemRegisterKey, String salvagedMaterialRegisterKey)
{
public Salvageable(String itemRegisterKey, String salvagedMaterialRegisterKey) {
this(Material.matchMaterial(itemRegisterKey), Material.matchMaterial(salvagedMaterialRegisterKey), 0, 1);
}
public Salvageable(String itemRegisterKey, String salvagedMaterialRegisterKey, int minimumLevel, int maximumQuantity)
{
public Salvageable(String itemRegisterKey, String salvagedMaterialRegisterKey, int minimumLevel, int maximumQuantity) {
this(Material.matchMaterial(itemRegisterKey), Material.matchMaterial(salvagedMaterialRegisterKey), minimumLevel, maximumQuantity);
}
public Salvageable(Material itemMaterial, Material salvagedItemMaterial, int minimumLevel, int maximumQuantity)
{
public Salvageable(Material itemMaterial, Material salvagedItemMaterial, int minimumLevel, int maximumQuantity) {
this.itemMaterial = itemMaterial;
this.salvagedItemMaterial = salvagedItemMaterial;
this.salvageItemType = ItemUtils.determineItemType(itemMaterial);

View File

@@ -15,16 +15,16 @@ public class SalvageableManager implements Unload {
this(55);
}*/
@Override
public void unload() {
salvageables.clear();
}
public SalvageableManager(List<Salvageable> salvageablesCollection) {
this.salvageables = new HashMap<>(salvageablesCollection.size());
registerSalvageables(salvageablesCollection);
}
@Override
public void unload() {
salvageables.clear();
}
public void registerSalvageable(Salvageable salvageable) {
Material item = salvageable.getItemMaterial();
salvageables.put(item, salvageable);

View File

@@ -9,8 +9,7 @@ import org.bukkit.inventory.ItemStack;
public class Smelting {
public static int getRank(Player player)
{
public static int getRank(Player player) {
return RankUtils.getRank(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
}

View File

@@ -93,10 +93,8 @@ public class SmeltingManager extends SkillManager {
return burnTime * getFuelEfficiencyMultiplier();
}
public int getFuelEfficiencyMultiplier()
{
switch(RankUtils.getRank(getPlayer(), SubSkillType.SMELTING_FUEL_EFFICIENCY))
{
public int getFuelEfficiencyMultiplier() {
switch (RankUtils.getRank(getPlayer(), SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
case 1:
return 2;
case 2:

View File

@@ -42,14 +42,14 @@ public class SwordsManager extends SkillManager {
}
public boolean canUseCounterAttack(Entity target) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK))
return false;
return target instanceof LivingEntity && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK);
}
public boolean canUseSerratedStrike() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_SERRATED_STRIKES))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_SERRATED_STRIKES))
return false;
return mcMMOPlayer.getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
@@ -67,11 +67,11 @@ public class SwordsManager extends SkillManager {
Player defender = (Player) target;
//Don't start or add to a bleed if they are blocking
if(defender.isBlocking())
if (defender.isBlocking())
return;
if (NotificationManager.doesPlayerUseNotifications(defender)) {
if(!BleedTimerTask.isBleeding(defender))
if (!BleedTimerTask.isBleeding(defender))
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Started");
}
}
@@ -84,12 +84,10 @@ public class SwordsManager extends SkillManager {
}
}
public double getStabDamage()
{
public double getStabDamage() {
int rank = RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_STAB);
if(rank > 0)
{
if (rank > 0) {
double stabDamage = 1.0D + (rank * 1.5);
return stabDamage;
}
@@ -97,23 +95,21 @@ public class SwordsManager extends SkillManager {
return 0;
}
public int getToolTier(ItemStack itemStack)
{
if(ItemUtils.isDiamondTool(itemStack))
public int getToolTier(ItemStack itemStack) {
if (ItemUtils.isDiamondTool(itemStack))
return 4;
else if(ItemUtils.isIronTool(itemStack) || ItemUtils.isGoldTool(itemStack))
else if (ItemUtils.isIronTool(itemStack) || ItemUtils.isGoldTool(itemStack))
return 3;
else if(ItemUtils.isStoneTool(itemStack))
else if (ItemUtils.isStoneTool(itemStack))
return 2;
else
return 1;
}
public int getRuptureBleedTicks()
{
public int getRuptureBleedTicks() {
int bleedTicks = 2 * RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE);
if(bleedTicks > AdvancedConfig.getInstance().getRuptureMaxTicks())
if (bleedTicks > AdvancedConfig.getInstance().getRuptureMaxTicks())
bleedTicks = AdvancedConfig.getInstance().getRuptureMaxTicks();
return bleedTicks;
@@ -123,7 +119,7 @@ public class SwordsManager extends SkillManager {
* Handle the effects of the Counter Attack ability
*
* @param attacker The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @param damage The amount of damage initially dealt by the event
*/
public void counterAttackChecks(LivingEntity attacker, double damage) {
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_COUNTER_ATTACK, getPlayer())) {
@@ -132,7 +128,7 @@ public class SwordsManager extends SkillManager {
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Countered");
if (attacker instanceof Player) {
NotificationManager.sendPlayerInformation((Player)attacker, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Counter.Hit");
NotificationManager.sendPlayerInformation((Player) attacker, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Counter.Hit");
}
}
}

View File

@@ -32,11 +32,29 @@ import java.util.HashMap;
import java.util.List;
public class TamingManager extends SkillManager {
private static HashMap<EntityType, List<TrackedTamingEntity>> summonedEntities = new HashMap<>();
public TamingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, PrimarySkillType.TAMING);
}
private static HashMap<EntityType, List<TrackedTamingEntity>> summonedEntities = new HashMap<>();
protected static void addToTracker(LivingEntity livingEntity) {
TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity);
if (!summonedEntities.containsKey(livingEntity.getType())) {
summonedEntities.put(livingEntity.getType(), new ArrayList<>());
}
summonedEntities.get(livingEntity.getType()).add(trackedEntity);
}
protected static List<TrackedTamingEntity> getTrackedEntities(EntityType entityType) {
return summonedEntities.get(entityType);
}
protected static void removeFromTracker(TrackedTamingEntity trackedEntity) {
summonedEntities.get(trackedEntity.getLivingEntity().getType()).remove(trackedEntity);
}
public boolean canUseThickFur() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_THICK_FUR)
@@ -69,14 +87,14 @@ public class TamingManager extends SkillManager {
}
public boolean canUseGore() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_GORE))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_GORE))
return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_GORE);
}
public boolean canUseBeastLore() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_BEAST_LORE))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_BEAST_LORE))
return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_BEAST_LORE);
@@ -94,7 +112,7 @@ public class TamingManager extends SkillManager {
/**
* Apply the Fast Food Service ability.
*
* @param wolf The wolf using the ability
* @param wolf The wolf using the ability
* @param damage The damage being absorbed by the wolf
*/
public void fastFoodService(Wolf wolf, double damage) {
@@ -126,7 +144,7 @@ public class TamingManager extends SkillManager {
BleedTimerTask.add(target, getPlayer(), Taming.getInstance().getGoreBleedTicks(), 1, 2);
if (target instanceof Player) {
NotificationManager.sendPlayerInformation((Player)target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore");
NotificationManager.sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore");
}
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.Gore");
@@ -143,7 +161,7 @@ public class TamingManager extends SkillManager {
* Summon an ocelot to your side.
*/
public void summonOcelot() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.OCELOT)) {
@@ -157,7 +175,7 @@ public class TamingManager extends SkillManager {
* Summon a wolf to your side.
*/
public void summonWolf() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.WOLF)) {
@@ -171,7 +189,7 @@ public class TamingManager extends SkillManager {
* Summon a horse to your side.
*/
public void summonHorse() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.HORSE)) {
@@ -212,10 +230,10 @@ public class TamingManager extends SkillManager {
}
public void pummel(LivingEntity target, Wolf wolf) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
return;
if(!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))
if (!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))
return;
ParticleEffectUtils.playGreaterImpactEffect(target);
@@ -252,7 +270,7 @@ public class TamingManager extends SkillManager {
/**
* Handle the Call of the Wild ability.
*
* @param type The type of entity to summon.
* @param type The type of entity to summon.
* @param summonAmount The amount of material needed to summon the entity
*/
private void callOfTheWild(EntityType type, int summonAmount) {
@@ -378,22 +396,4 @@ public class TamingManager extends SkillManager {
return true;
}
protected static void addToTracker(LivingEntity livingEntity) {
TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity);
if (!summonedEntities.containsKey(livingEntity.getType())) {
summonedEntities.put(livingEntity.getType(), new ArrayList<>());
}
summonedEntities.get(livingEntity.getType()).add(trackedEntity);
}
protected static List<TrackedTamingEntity> getTrackedEntities(EntityType entityType) {
return summonedEntities.get(entityType);
}
protected static void removeFromTracker(TrackedTamingEntity trackedEntity) {
summonedEntities.get(trackedEntity.getLivingEntity().getType()).remove(trackedEntity);
}
}

View File

@@ -21,27 +21,22 @@ public class Unarmed {
int amount = itemDrop.getAmount();
boolean grabbedItem = false;
for(int i = 0; i <= storageContents.length-1; i++)
{
if(amount <= 0)
for (int i = 0; i <= storageContents.length - 1; i++) {
if (amount <= 0)
break;
if(i == heldItemSlotID)
if (i == heldItemSlotID)
continue;
//EMPTY SLOT!
if(storageContents[i] == null)
{
if (storageContents[i] == null) {
player.getInventory().setItem(i, itemDrop);
amount = 0;
grabbedItem = true;
break;
}
else if(itemDrop.isSimilar(storageContents[i]) && storageContents[i].getAmount() < storageContents[i].getMaxStackSize())
{
} else if (itemDrop.isSimilar(storageContents[i]) && storageContents[i].getAmount() < storageContents[i].getMaxStackSize()) {
//If we can fit this whole itemstack into this item
if(amount + storageContents[i].getAmount() <= storageContents[i].getMaxStackSize())
{
if (amount + storageContents[i].getAmount() <= storageContents[i].getMaxStackSize()) {
ItemStack modifiedAmount = storageContents[i];
modifiedAmount.setAmount(amount + storageContents[i].getAmount());
@@ -63,15 +58,14 @@ public class Unarmed {
}
}
if(amount <= 0)
if (amount <= 0)
event.getItem().remove(); //Cleanup Item
else
event.getItem().getItemStack().setAmount(amount);
event.setCancelled(true);
if(grabbedItem)
{
if (grabbedItem) {
SoundManager.sendSound(player, player.getLocation(), SoundType.POP);
player.updateInventory();
}

View File

@@ -36,7 +36,7 @@ public class UnarmedManager extends SkillManager {
}
public boolean canUseIronArm() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE))
return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE);
@@ -47,14 +47,14 @@ public class UnarmedManager extends SkillManager {
}
public boolean canDisarm(LivingEntity target) {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_DISARM))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_DISARM))
return false;
return target instanceof Player && ((Player) target).getInventory().getItemInMainHand().getType() != Material.AIR && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_DISARM);
}
public boolean canDeflect() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_ARROW_DEFLECT))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_ARROW_DEFLECT))
return false;
Player player = getPlayer();
@@ -63,7 +63,7 @@ public class UnarmedManager extends SkillManager {
}
public boolean canUseBlockCracker() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER))
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER))
return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER);
@@ -101,7 +101,7 @@ public class UnarmedManager extends SkillManager {
return;
}
if(UserManager.getPlayer(defender) == null)
if (UserManager.getPlayer(defender) == null)
return;
Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand());
@@ -156,8 +156,7 @@ public class UnarmedManager extends SkillManager {
public double getIronArmDamage() {
int rank = RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE);
if(rank == 1)
{
if (rank == 1) {
return 4;
} else {
return 3 + (rank * 2);

View File

@@ -17,19 +17,26 @@ import java.util.List;
import java.util.Set;
public final class Woodcutting {
/**
* The x/y differences to the blocks in a flat cylinder around the center
* block, which is excluded.
*/
private static final int[][] directions = {
new int[]{-2, -1}, new int[]{-2, 0}, new int[]{-2, 1},
new int[]{-1, -2}, new int[]{-1, -1}, new int[]{-1, 0}, new int[]{-1, 1}, new int[]{-1, 2},
new int[]{0, -2}, new int[]{0, -1}, new int[]{0, 1}, new int[]{0, 2},
new int[]{1, -2}, new int[]{1, -1}, new int[]{1, 0}, new int[]{1, 1}, new int[]{1, 2},
new int[]{2, -1}, new int[]{2, 0}, new int[]{2, 1},
};
protected static boolean treeFellerReachedThreshold = false;
protected enum ExperienceGainMethod {
DEFAULT,
TREE_FELLER,
private Woodcutting() {
}
private Woodcutting() {}
/**
* Retrieves the experience reward from a log
*
* @param blockState Log being broken
* @param blockState Log being broken
* @param experienceGainMethod How the log is being broken
* @return Amount of experience
*/
@@ -51,28 +58,16 @@ public final class Woodcutting {
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
}
else {*/
if (MainConfig.getInstance().getWoodcuttingDoubleDropsEnabled(blockState.getBlockData())) {
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
}
if (MainConfig.getInstance().getWoodcuttingDoubleDropsEnabled(blockState.getBlockData())) {
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
}
//}
}
/**
* The x/y differences to the blocks in a flat cylinder around the center
* block, which is excluded.
*/
private static final int[][] directions = {
new int[] {-2, -1}, new int[] {-2, 0}, new int[] {-2, 1},
new int[] {-1, -2}, new int[] {-1, -1}, new int[] {-1, 0}, new int[] {-1, 1}, new int[] {-1, 2},
new int[] { 0, -2}, new int[] { 0, -1}, new int[] { 0, 1}, new int[] { 0, 2},
new int[] { 1, -2}, new int[] { 1, -1}, new int[] { 1, 0}, new int[] { 1, 1}, new int[] { 1, 2},
new int[] { 2, -1}, new int[] { 2, 0}, new int[] { 2, 1},
};
/**
* Processes Tree Feller in a recursive manner
*
* @param blockState Block being checked
* @param blockState Block being checked
* @param treeFellerBlocks List of blocks to be removed
*/
/*
@@ -110,8 +105,7 @@ public final class Woodcutting {
return;
}
}
}
else {
} else {
// Cover DOWN
handleBlock(blockState.getBlock().getRelative(BlockFace.DOWN).getState(), futureCenterBlocks, treeFellerBlocks);
// Search in a cube
@@ -140,7 +134,7 @@ public final class Woodcutting {
* Handles the durability loss
*
* @param treeFellerBlocks List of blocks to be removed
* @param inHand tool being used
* @param inHand tool being used
* @return True if the tool can sustain the durability loss
*/
protected static boolean handleDurabilityLoss(Set<BlockState> treeFellerBlocks, ItemStack inHand) {
@@ -162,12 +156,12 @@ public final class Woodcutting {
* list of blocks used for future recursive calls of
* 'processTree()'
*
* @param blockState Block to be added
* @param blockState Block to be added
* @param futureCenterBlocks List of blocks that will be used to call
* 'processTree()'
* @param treeFellerBlocks List of blocks to be removed
* 'processTree()'
* @param treeFellerBlocks List of blocks to be removed
* @return true if and only if the given blockState was a Log not already
* in treeFellerBlocks.
* in treeFellerBlocks.
*/
private static boolean handleBlock(BlockState blockState, List<BlockState> futureCenterBlocks, Set<BlockState> treeFellerBlocks) {
if (treeFellerBlocks.contains(blockState) || mcMMO.getPlaceStore().isTrue(blockState)) {
@@ -183,11 +177,15 @@ public final class Woodcutting {
treeFellerBlocks.add(blockState);
futureCenterBlocks.add(blockState);
return true;
}
else if (BlockUtils.isLeaves(blockState)) {
} else if (BlockUtils.isLeaves(blockState)) {
treeFellerBlocks.add(blockState);
return false;
}
return false;
}
protected enum ExperienceGainMethod {
DEFAULT,
TREE_FELLER,
}
}