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

@@ -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);
}
}
}